umem.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. /*
  2. * mm.c - Micro Memory(tm) PCI memory board block device driver - v2.3
  3. *
  4. * (C) 2001 San Mehat <nettwerk@valinux.com>
  5. * (C) 2001 Johannes Erdfelt <jerdfelt@valinux.com>
  6. * (C) 2001 NeilBrown <neilb@cse.unsw.edu.au>
  7. *
  8. * This driver for the Micro Memory PCI Memory Module with Battery Backup
  9. * is Copyright Micro Memory Inc 2001-2002. All rights reserved.
  10. *
  11. * This driver is released to the public under the terms of the
  12. * GNU GENERAL PUBLIC LICENSE version 2
  13. * See the file COPYING for details.
  14. *
  15. * This driver provides a standard block device interface for Micro Memory(tm)
  16. * PCI based RAM boards.
  17. * 10/05/01: Phap Nguyen - Rebuilt the driver
  18. * 10/22/01: Phap Nguyen - v2.1 Added disk partitioning
  19. * 29oct2001:NeilBrown - Use make_request_fn instead of request_fn
  20. * - use stand disk partitioning (so fdisk works).
  21. * 08nov2001:NeilBrown - change driver name from "mm" to "umem"
  22. * - incorporate into main kernel
  23. * 08apr2002:NeilBrown - Move some of interrupt handle to tasklet
  24. * - use spin_lock_bh instead of _irq
  25. * - Never block on make_request. queue
  26. * bh's instead.
  27. * - unregister umem from devfs at mod unload
  28. * - Change version to 2.3
  29. * 07Nov2001:Phap Nguyen - Select pci read command: 06, 12, 15 (Decimal)
  30. * 07Jan2002: P. Nguyen - Used PCI Memory Write & Invalidate for DMA
  31. * 15May2002:NeilBrown - convert to bio for 2.5
  32. * 17May2002:NeilBrown - remove init_mem initialisation. Instead detect
  33. * - a sequence of writes that cover the card, and
  34. * - set initialised bit then.
  35. */
  36. //#define DEBUG /* uncomment if you want debugging info (pr_debug) */
  37. #include <linux/fs.h>
  38. #include <linux/bio.h>
  39. #include <linux/kernel.h>
  40. #include <linux/mm.h>
  41. #include <linux/mman.h>
  42. #include <linux/ioctl.h>
  43. #include <linux/module.h>
  44. #include <linux/init.h>
  45. #include <linux/interrupt.h>
  46. #include <linux/timer.h>
  47. #include <linux/pci.h>
  48. #include <linux/slab.h>
  49. #include <linux/dma-mapping.h>
  50. #include <linux/fcntl.h> /* O_ACCMODE */
  51. #include <linux/hdreg.h> /* HDIO_GETGEO */
  52. #include "umem.h"
  53. #include <asm/uaccess.h>
  54. #include <asm/io.h>
  55. #define MM_MAXCARDS 4
  56. #define MM_RAHEAD 2 /* two sectors */
  57. #define MM_BLKSIZE 1024 /* 1k blocks */
  58. #define MM_HARDSECT 512 /* 512-byte hardware sectors */
  59. #define MM_SHIFT 6 /* max 64 partitions on 4 cards */
  60. /*
  61. * Version Information
  62. */
  63. #define DRIVER_NAME "umem"
  64. #define DRIVER_VERSION "v2.3"
  65. #define DRIVER_AUTHOR "San Mehat, Johannes Erdfelt, NeilBrown"
  66. #define DRIVER_DESC "Micro Memory(tm) PCI memory board block driver"
  67. static int debug;
  68. /* #define HW_TRACE(x) writeb(x,cards[0].csr_remap + MEMCTRLSTATUS_MAGIC) */
  69. #define HW_TRACE(x)
  70. #define DEBUG_LED_ON_TRANSFER 0x01
  71. #define DEBUG_BATTERY_POLLING 0x02
  72. module_param(debug, int, 0644);
  73. MODULE_PARM_DESC(debug, "Debug bitmask");
  74. static int pci_read_cmd = 0x0C; /* Read Multiple */
  75. module_param(pci_read_cmd, int, 0);
  76. MODULE_PARM_DESC(pci_read_cmd, "PCI read command");
  77. static int pci_write_cmd = 0x0F; /* Write and Invalidate */
  78. module_param(pci_write_cmd, int, 0);
  79. MODULE_PARM_DESC(pci_write_cmd, "PCI write command");
  80. static int pci_cmds;
  81. static int major_nr;
  82. #include <linux/blkdev.h>
  83. #include <linux/blkpg.h>
  84. struct cardinfo {
  85. struct pci_dev *dev;
  86. unsigned char __iomem *csr_remap;
  87. unsigned int mm_size; /* size in kbytes */
  88. unsigned int init_size; /* initial segment, in sectors,
  89. * that we know to
  90. * have been written
  91. */
  92. struct bio *bio, *currentbio, **biotail;
  93. int current_idx;
  94. sector_t current_sector;
  95. struct request_queue *queue;
  96. struct mm_page {
  97. dma_addr_t page_dma;
  98. struct mm_dma_desc *desc;
  99. int cnt, headcnt;
  100. struct bio *bio, **biotail;
  101. int idx;
  102. } mm_pages[2];
  103. #define DESC_PER_PAGE ((PAGE_SIZE*2)/sizeof(struct mm_dma_desc))
  104. int Active, Ready;
  105. struct tasklet_struct tasklet;
  106. unsigned int dma_status;
  107. struct {
  108. int good;
  109. int warned;
  110. unsigned long last_change;
  111. } battery[2];
  112. spinlock_t lock;
  113. int check_batteries;
  114. int flags;
  115. };
  116. static struct cardinfo cards[MM_MAXCARDS];
  117. static struct block_device_operations mm_fops;
  118. static struct timer_list battery_timer;
  119. static int num_cards = 0;
  120. static struct gendisk *mm_gendisk[MM_MAXCARDS];
  121. static void check_batteries(struct cardinfo *card);
  122. /*
  123. -----------------------------------------------------------------------------------
  124. -- get_userbit
  125. -----------------------------------------------------------------------------------
  126. */
  127. static int get_userbit(struct cardinfo *card, int bit)
  128. {
  129. unsigned char led;
  130. led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL);
  131. return led & bit;
  132. }
  133. /*
  134. -----------------------------------------------------------------------------------
  135. -- set_userbit
  136. -----------------------------------------------------------------------------------
  137. */
  138. static int set_userbit(struct cardinfo *card, int bit, unsigned char state)
  139. {
  140. unsigned char led;
  141. led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL);
  142. if (state)
  143. led |= bit;
  144. else
  145. led &= ~bit;
  146. writeb(led, card->csr_remap + MEMCTRLCMD_LEDCTRL);
  147. return 0;
  148. }
  149. /*
  150. -----------------------------------------------------------------------------------
  151. -- set_led
  152. -----------------------------------------------------------------------------------
  153. */
  154. /*
  155. * NOTE: For the power LED, use the LED_POWER_* macros since they differ
  156. */
  157. static void set_led(struct cardinfo *card, int shift, unsigned char state)
  158. {
  159. unsigned char led;
  160. led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL);
  161. if (state == LED_FLIP)
  162. led ^= (1<<shift);
  163. else {
  164. led &= ~(0x03 << shift);
  165. led |= (state << shift);
  166. }
  167. writeb(led, card->csr_remap + MEMCTRLCMD_LEDCTRL);
  168. }
  169. #ifdef MM_DIAG
  170. /*
  171. -----------------------------------------------------------------------------------
  172. -- dump_regs
  173. -----------------------------------------------------------------------------------
  174. */
  175. static void dump_regs(struct cardinfo *card)
  176. {
  177. unsigned char *p;
  178. int i, i1;
  179. p = card->csr_remap;
  180. for (i = 0; i < 8; i++) {
  181. printk(KERN_DEBUG "%p ", p);
  182. for (i1 = 0; i1 < 16; i1++)
  183. printk("%02x ", *p++);
  184. printk("\n");
  185. }
  186. }
  187. #endif
  188. /*
  189. -----------------------------------------------------------------------------------
  190. -- dump_dmastat
  191. -----------------------------------------------------------------------------------
  192. */
  193. static void dump_dmastat(struct cardinfo *card, unsigned int dmastat)
  194. {
  195. dev_printk(KERN_DEBUG, &card->dev->dev, "DMAstat - ");
  196. if (dmastat & DMASCR_ANY_ERR)
  197. printk("ANY_ERR ");
  198. if (dmastat & DMASCR_MBE_ERR)
  199. printk("MBE_ERR ");
  200. if (dmastat & DMASCR_PARITY_ERR_REP)
  201. printk("PARITY_ERR_REP ");
  202. if (dmastat & DMASCR_PARITY_ERR_DET)
  203. printk("PARITY_ERR_DET ");
  204. if (dmastat & DMASCR_SYSTEM_ERR_SIG)
  205. printk("SYSTEM_ERR_SIG ");
  206. if (dmastat & DMASCR_TARGET_ABT)
  207. printk("TARGET_ABT ");
  208. if (dmastat & DMASCR_MASTER_ABT)
  209. printk("MASTER_ABT ");
  210. if (dmastat & DMASCR_CHAIN_COMPLETE)
  211. printk("CHAIN_COMPLETE ");
  212. if (dmastat & DMASCR_DMA_COMPLETE)
  213. printk("DMA_COMPLETE ");
  214. printk("\n");
  215. }
  216. /*
  217. * Theory of request handling
  218. *
  219. * Each bio is assigned to one mm_dma_desc - which may not be enough FIXME
  220. * We have two pages of mm_dma_desc, holding about 64 descriptors
  221. * each. These are allocated at init time.
  222. * One page is "Ready" and is either full, or can have request added.
  223. * The other page might be "Active", which DMA is happening on it.
  224. *
  225. * Whenever IO on the active page completes, the Ready page is activated
  226. * and the ex-Active page is clean out and made Ready.
  227. * Otherwise the Ready page is only activated when it becomes full, or
  228. * when mm_unplug_device is called via the unplug_io_fn.
  229. *
  230. * If a request arrives while both pages a full, it is queued, and b_rdev is
  231. * overloaded to record whether it was a read or a write.
  232. *
  233. * The interrupt handler only polls the device to clear the interrupt.
  234. * The processing of the result is done in a tasklet.
  235. */
  236. static void mm_start_io(struct cardinfo *card)
  237. {
  238. /* we have the lock, we know there is
  239. * no IO active, and we know that card->Active
  240. * is set
  241. */
  242. struct mm_dma_desc *desc;
  243. struct mm_page *page;
  244. int offset;
  245. /* make the last descriptor end the chain */
  246. page = &card->mm_pages[card->Active];
  247. pr_debug("start_io: %d %d->%d\n", card->Active, page->headcnt, page->cnt-1);
  248. desc = &page->desc[page->cnt-1];
  249. desc->control_bits |= cpu_to_le32(DMASCR_CHAIN_COMP_EN);
  250. desc->control_bits &= ~cpu_to_le32(DMASCR_CHAIN_EN);
  251. desc->sem_control_bits = desc->control_bits;
  252. if (debug & DEBUG_LED_ON_TRANSFER)
  253. set_led(card, LED_REMOVE, LED_ON);
  254. desc = &page->desc[page->headcnt];
  255. writel(0, card->csr_remap + DMA_PCI_ADDR);
  256. writel(0, card->csr_remap + DMA_PCI_ADDR + 4);
  257. writel(0, card->csr_remap + DMA_LOCAL_ADDR);
  258. writel(0, card->csr_remap + DMA_LOCAL_ADDR + 4);
  259. writel(0, card->csr_remap + DMA_TRANSFER_SIZE);
  260. writel(0, card->csr_remap + DMA_TRANSFER_SIZE + 4);
  261. writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR);
  262. writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR + 4);
  263. offset = ((char*)desc) - ((char*)page->desc);
  264. writel(cpu_to_le32((page->page_dma+offset)&0xffffffff),
  265. card->csr_remap + DMA_DESCRIPTOR_ADDR);
  266. /* Force the value to u64 before shifting otherwise >> 32 is undefined C
  267. * and on some ports will do nothing ! */
  268. writel(cpu_to_le32(((u64)page->page_dma)>>32),
  269. card->csr_remap + DMA_DESCRIPTOR_ADDR + 4);
  270. /* Go, go, go */
  271. writel(cpu_to_le32(DMASCR_GO | DMASCR_CHAIN_EN | pci_cmds),
  272. card->csr_remap + DMA_STATUS_CTRL);
  273. }
  274. static int add_bio(struct cardinfo *card);
  275. static void activate(struct cardinfo *card)
  276. {
  277. /* if No page is Active, and Ready is
  278. * not empty, then switch Ready page
  279. * to active and start IO.
  280. * Then add any bh's that are available to Ready
  281. */
  282. do {
  283. while (add_bio(card))
  284. ;
  285. if (card->Active == -1 &&
  286. card->mm_pages[card->Ready].cnt > 0) {
  287. card->Active = card->Ready;
  288. card->Ready = 1-card->Ready;
  289. mm_start_io(card);
  290. }
  291. } while (card->Active == -1 && add_bio(card));
  292. }
  293. static inline void reset_page(struct mm_page *page)
  294. {
  295. page->cnt = 0;
  296. page->headcnt = 0;
  297. page->bio = NULL;
  298. page->biotail = & page->bio;
  299. }
  300. static void mm_unplug_device(struct request_queue *q)
  301. {
  302. struct cardinfo *card = q->queuedata;
  303. unsigned long flags;
  304. spin_lock_irqsave(&card->lock, flags);
  305. if (blk_remove_plug(q))
  306. activate(card);
  307. spin_unlock_irqrestore(&card->lock, flags);
  308. }
  309. /*
  310. * If there is room on Ready page, take
  311. * one bh off list and add it.
  312. * return 1 if there was room, else 0.
  313. */
  314. static int add_bio(struct cardinfo *card)
  315. {
  316. struct mm_page *p;
  317. struct mm_dma_desc *desc;
  318. dma_addr_t dma_handle;
  319. int offset;
  320. struct bio *bio;
  321. struct bio_vec *vec;
  322. int idx;
  323. int rw;
  324. int len;
  325. bio = card->currentbio;
  326. if (!bio && card->bio) {
  327. card->currentbio = card->bio;
  328. card->current_idx = card->bio->bi_idx;
  329. card->current_sector = card->bio->bi_sector;
  330. card->bio = card->bio->bi_next;
  331. if (card->bio == NULL)
  332. card->biotail = &card->bio;
  333. card->currentbio->bi_next = NULL;
  334. return 1;
  335. }
  336. if (!bio)
  337. return 0;
  338. idx = card->current_idx;
  339. rw = bio_rw(bio);
  340. if (card->mm_pages[card->Ready].cnt >= DESC_PER_PAGE)
  341. return 0;
  342. vec = bio_iovec_idx(bio, idx);
  343. len = vec->bv_len;
  344. dma_handle = pci_map_page(card->dev,
  345. vec->bv_page,
  346. vec->bv_offset,
  347. len,
  348. (rw==READ) ?
  349. PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE);
  350. p = &card->mm_pages[card->Ready];
  351. desc = &p->desc[p->cnt];
  352. p->cnt++;
  353. if (p->bio == NULL)
  354. p->idx = idx;
  355. if ((p->biotail) != &bio->bi_next) {
  356. *(p->biotail) = bio;
  357. p->biotail = &(bio->bi_next);
  358. bio->bi_next = NULL;
  359. }
  360. desc->data_dma_handle = dma_handle;
  361. desc->pci_addr = cpu_to_le64((u64)desc->data_dma_handle);
  362. desc->local_addr = cpu_to_le64(card->current_sector << 9);
  363. desc->transfer_size = cpu_to_le32(len);
  364. offset = ( ((char*)&desc->sem_control_bits) - ((char*)p->desc));
  365. desc->sem_addr = cpu_to_le64((u64)(p->page_dma+offset));
  366. desc->zero1 = desc->zero2 = 0;
  367. offset = ( ((char*)(desc+1)) - ((char*)p->desc));
  368. desc->next_desc_addr = cpu_to_le64(p->page_dma+offset);
  369. desc->control_bits = cpu_to_le32(DMASCR_GO|DMASCR_ERR_INT_EN|
  370. DMASCR_PARITY_INT_EN|
  371. DMASCR_CHAIN_EN |
  372. DMASCR_SEM_EN |
  373. pci_cmds);
  374. if (rw == WRITE)
  375. desc->control_bits |= cpu_to_le32(DMASCR_TRANSFER_READ);
  376. desc->sem_control_bits = desc->control_bits;
  377. card->current_sector += (len >> 9);
  378. idx++;
  379. card->current_idx = idx;
  380. if (idx >= bio->bi_vcnt)
  381. card->currentbio = NULL;
  382. return 1;
  383. }
  384. static void process_page(unsigned long data)
  385. {
  386. /* check if any of the requests in the page are DMA_COMPLETE,
  387. * and deal with them appropriately.
  388. * If we find a descriptor without DMA_COMPLETE in the semaphore, then
  389. * dma must have hit an error on that descriptor, so use dma_status instead
  390. * and assume that all following descriptors must be re-tried.
  391. */
  392. struct mm_page *page;
  393. struct bio *return_bio=NULL;
  394. struct cardinfo *card = (struct cardinfo *)data;
  395. unsigned int dma_status = card->dma_status;
  396. spin_lock_bh(&card->lock);
  397. if (card->Active < 0)
  398. goto out_unlock;
  399. page = &card->mm_pages[card->Active];
  400. while (page->headcnt < page->cnt) {
  401. struct bio *bio = page->bio;
  402. struct mm_dma_desc *desc = &page->desc[page->headcnt];
  403. int control = le32_to_cpu(desc->sem_control_bits);
  404. int last=0;
  405. int idx;
  406. if (!(control & DMASCR_DMA_COMPLETE)) {
  407. control = dma_status;
  408. last=1;
  409. }
  410. page->headcnt++;
  411. idx = page->idx;
  412. page->idx++;
  413. if (page->idx >= bio->bi_vcnt) {
  414. page->bio = bio->bi_next;
  415. page->idx = page->bio->bi_idx;
  416. }
  417. pci_unmap_page(card->dev, desc->data_dma_handle,
  418. bio_iovec_idx(bio,idx)->bv_len,
  419. (control& DMASCR_TRANSFER_READ) ?
  420. PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
  421. if (control & DMASCR_HARD_ERROR) {
  422. /* error */
  423. clear_bit(BIO_UPTODATE, &bio->bi_flags);
  424. dev_printk(KERN_WARNING, &card->dev->dev,
  425. "I/O error on sector %d/%d\n",
  426. le32_to_cpu(desc->local_addr)>>9,
  427. le32_to_cpu(desc->transfer_size));
  428. dump_dmastat(card, control);
  429. } else if (test_bit(BIO_RW, &bio->bi_rw) &&
  430. le32_to_cpu(desc->local_addr)>>9 == card->init_size) {
  431. card->init_size += le32_to_cpu(desc->transfer_size)>>9;
  432. if (card->init_size>>1 >= card->mm_size) {
  433. dev_printk(KERN_INFO, &card->dev->dev,
  434. "memory now initialised\n");
  435. set_userbit(card, MEMORY_INITIALIZED, 1);
  436. }
  437. }
  438. if (bio != page->bio) {
  439. bio->bi_next = return_bio;
  440. return_bio = bio;
  441. }
  442. if (last) break;
  443. }
  444. if (debug & DEBUG_LED_ON_TRANSFER)
  445. set_led(card, LED_REMOVE, LED_OFF);
  446. if (card->check_batteries) {
  447. card->check_batteries = 0;
  448. check_batteries(card);
  449. }
  450. if (page->headcnt >= page->cnt) {
  451. reset_page(page);
  452. card->Active = -1;
  453. activate(card);
  454. } else {
  455. /* haven't finished with this one yet */
  456. pr_debug("do some more\n");
  457. mm_start_io(card);
  458. }
  459. out_unlock:
  460. spin_unlock_bh(&card->lock);
  461. while(return_bio) {
  462. struct bio *bio = return_bio;
  463. return_bio = bio->bi_next;
  464. bio->bi_next = NULL;
  465. bio_endio(bio, 0);
  466. }
  467. }
  468. /*
  469. -----------------------------------------------------------------------------------
  470. -- mm_make_request
  471. -----------------------------------------------------------------------------------
  472. */
  473. static int mm_make_request(struct request_queue *q, struct bio *bio)
  474. {
  475. struct cardinfo *card = q->queuedata;
  476. pr_debug("mm_make_request %llu %u\n",
  477. (unsigned long long)bio->bi_sector, bio->bi_size);
  478. spin_lock_irq(&card->lock);
  479. *card->biotail = bio;
  480. bio->bi_next = NULL;
  481. card->biotail = &bio->bi_next;
  482. blk_plug_device(q);
  483. spin_unlock_irq(&card->lock);
  484. return 0;
  485. }
  486. /*
  487. -----------------------------------------------------------------------------------
  488. -- mm_interrupt
  489. -----------------------------------------------------------------------------------
  490. */
  491. static irqreturn_t mm_interrupt(int irq, void *__card)
  492. {
  493. struct cardinfo *card = (struct cardinfo *) __card;
  494. unsigned int dma_status;
  495. unsigned short cfg_status;
  496. HW_TRACE(0x30);
  497. dma_status = le32_to_cpu(readl(card->csr_remap + DMA_STATUS_CTRL));
  498. if (!(dma_status & (DMASCR_ERROR_MASK | DMASCR_CHAIN_COMPLETE))) {
  499. /* interrupt wasn't for me ... */
  500. return IRQ_NONE;
  501. }
  502. /* clear COMPLETION interrupts */
  503. if (card->flags & UM_FLAG_NO_BYTE_STATUS)
  504. writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE),
  505. card->csr_remap+ DMA_STATUS_CTRL);
  506. else
  507. writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16,
  508. card->csr_remap+ DMA_STATUS_CTRL + 2);
  509. /* log errors and clear interrupt status */
  510. if (dma_status & DMASCR_ANY_ERR) {
  511. unsigned int data_log1, data_log2;
  512. unsigned int addr_log1, addr_log2;
  513. unsigned char stat, count, syndrome, check;
  514. stat = readb(card->csr_remap + MEMCTRLCMD_ERRSTATUS);
  515. data_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG));
  516. data_log2 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG + 4));
  517. addr_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_ADDR_LOG));
  518. addr_log2 = readb(card->csr_remap + ERROR_ADDR_LOG + 4);
  519. count = readb(card->csr_remap + ERROR_COUNT);
  520. syndrome = readb(card->csr_remap + ERROR_SYNDROME);
  521. check = readb(card->csr_remap + ERROR_CHECK);
  522. dump_dmastat(card, dma_status);
  523. if (stat & 0x01)
  524. dev_printk(KERN_ERR, &card->dev->dev,
  525. "Memory access error detected (err count %d)\n",
  526. count);
  527. if (stat & 0x02)
  528. dev_printk(KERN_ERR, &card->dev->dev,
  529. "Multi-bit EDC error\n");
  530. dev_printk(KERN_ERR, &card->dev->dev,
  531. "Fault Address 0x%02x%08x, Fault Data 0x%08x%08x\n",
  532. addr_log2, addr_log1, data_log2, data_log1);
  533. dev_printk(KERN_ERR, &card->dev->dev,
  534. "Fault Check 0x%02x, Fault Syndrome 0x%02x\n",
  535. check, syndrome);
  536. writeb(0, card->csr_remap + ERROR_COUNT);
  537. }
  538. if (dma_status & DMASCR_PARITY_ERR_REP) {
  539. dev_printk(KERN_ERR, &card->dev->dev,
  540. "PARITY ERROR REPORTED\n");
  541. pci_read_config_word(card->dev, PCI_STATUS, &cfg_status);
  542. pci_write_config_word(card->dev, PCI_STATUS, cfg_status);
  543. }
  544. if (dma_status & DMASCR_PARITY_ERR_DET) {
  545. dev_printk(KERN_ERR, &card->dev->dev,
  546. "PARITY ERROR DETECTED\n");
  547. pci_read_config_word(card->dev, PCI_STATUS, &cfg_status);
  548. pci_write_config_word(card->dev, PCI_STATUS, cfg_status);
  549. }
  550. if (dma_status & DMASCR_SYSTEM_ERR_SIG) {
  551. dev_printk(KERN_ERR, &card->dev->dev, "SYSTEM ERROR\n");
  552. pci_read_config_word(card->dev, PCI_STATUS, &cfg_status);
  553. pci_write_config_word(card->dev, PCI_STATUS, cfg_status);
  554. }
  555. if (dma_status & DMASCR_TARGET_ABT) {
  556. dev_printk(KERN_ERR, &card->dev->dev, "TARGET ABORT\n");
  557. pci_read_config_word(card->dev, PCI_STATUS, &cfg_status);
  558. pci_write_config_word(card->dev, PCI_STATUS, cfg_status);
  559. }
  560. if (dma_status & DMASCR_MASTER_ABT) {
  561. dev_printk(KERN_ERR, &card->dev->dev, "MASTER ABORT\n");
  562. pci_read_config_word(card->dev, PCI_STATUS, &cfg_status);
  563. pci_write_config_word(card->dev, PCI_STATUS, cfg_status);
  564. }
  565. /* and process the DMA descriptors */
  566. card->dma_status = dma_status;
  567. tasklet_schedule(&card->tasklet);
  568. HW_TRACE(0x36);
  569. return IRQ_HANDLED;
  570. }
  571. /*
  572. -----------------------------------------------------------------------------------
  573. -- set_fault_to_battery_status
  574. -----------------------------------------------------------------------------------
  575. */
  576. /*
  577. * If both batteries are good, no LED
  578. * If either battery has been warned, solid LED
  579. * If both batteries are bad, flash the LED quickly
  580. * If either battery is bad, flash the LED semi quickly
  581. */
  582. static void set_fault_to_battery_status(struct cardinfo *card)
  583. {
  584. if (card->battery[0].good && card->battery[1].good)
  585. set_led(card, LED_FAULT, LED_OFF);
  586. else if (card->battery[0].warned || card->battery[1].warned)
  587. set_led(card, LED_FAULT, LED_ON);
  588. else if (!card->battery[0].good && !card->battery[1].good)
  589. set_led(card, LED_FAULT, LED_FLASH_7_0);
  590. else
  591. set_led(card, LED_FAULT, LED_FLASH_3_5);
  592. }
  593. static void init_battery_timer(void);
  594. /*
  595. -----------------------------------------------------------------------------------
  596. -- check_battery
  597. -----------------------------------------------------------------------------------
  598. */
  599. static int check_battery(struct cardinfo *card, int battery, int status)
  600. {
  601. if (status != card->battery[battery].good) {
  602. card->battery[battery].good = !card->battery[battery].good;
  603. card->battery[battery].last_change = jiffies;
  604. if (card->battery[battery].good) {
  605. dev_printk(KERN_ERR, &card->dev->dev,
  606. "Battery %d now good\n", battery + 1);
  607. card->battery[battery].warned = 0;
  608. } else
  609. dev_printk(KERN_ERR, &card->dev->dev,
  610. "Battery %d now FAILED\n", battery + 1);
  611. return 1;
  612. } else if (!card->battery[battery].good &&
  613. !card->battery[battery].warned &&
  614. time_after_eq(jiffies, card->battery[battery].last_change +
  615. (HZ * 60 * 60 * 5))) {
  616. dev_printk(KERN_ERR, &card->dev->dev,
  617. "Battery %d still FAILED after 5 hours\n", battery + 1);
  618. card->battery[battery].warned = 1;
  619. return 1;
  620. }
  621. return 0;
  622. }
  623. /*
  624. -----------------------------------------------------------------------------------
  625. -- check_batteries
  626. -----------------------------------------------------------------------------------
  627. */
  628. static void check_batteries(struct cardinfo *card)
  629. {
  630. /* NOTE: this must *never* be called while the card
  631. * is doing (bus-to-card) DMA, or you will need the
  632. * reset switch
  633. */
  634. unsigned char status;
  635. int ret1, ret2;
  636. status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY);
  637. if (debug & DEBUG_BATTERY_POLLING)
  638. dev_printk(KERN_DEBUG, &card->dev->dev,
  639. "checking battery status, 1 = %s, 2 = %s\n",
  640. (status & BATTERY_1_FAILURE) ? "FAILURE" : "OK",
  641. (status & BATTERY_2_FAILURE) ? "FAILURE" : "OK");
  642. ret1 = check_battery(card, 0, !(status & BATTERY_1_FAILURE));
  643. ret2 = check_battery(card, 1, !(status & BATTERY_2_FAILURE));
  644. if (ret1 || ret2)
  645. set_fault_to_battery_status(card);
  646. }
  647. static void check_all_batteries(unsigned long ptr)
  648. {
  649. int i;
  650. for (i = 0; i < num_cards; i++)
  651. if (!(cards[i].flags & UM_FLAG_NO_BATT)) {
  652. struct cardinfo *card = &cards[i];
  653. spin_lock_bh(&card->lock);
  654. if (card->Active >= 0)
  655. card->check_batteries = 1;
  656. else
  657. check_batteries(card);
  658. spin_unlock_bh(&card->lock);
  659. }
  660. init_battery_timer();
  661. }
  662. /*
  663. -----------------------------------------------------------------------------------
  664. -- init_battery_timer
  665. -----------------------------------------------------------------------------------
  666. */
  667. static void init_battery_timer(void)
  668. {
  669. init_timer(&battery_timer);
  670. battery_timer.function = check_all_batteries;
  671. battery_timer.expires = jiffies + (HZ * 60);
  672. add_timer(&battery_timer);
  673. }
  674. /*
  675. -----------------------------------------------------------------------------------
  676. -- del_battery_timer
  677. -----------------------------------------------------------------------------------
  678. */
  679. static void del_battery_timer(void)
  680. {
  681. del_timer(&battery_timer);
  682. }
  683. /*
  684. -----------------------------------------------------------------------------------
  685. -- mm_revalidate
  686. -----------------------------------------------------------------------------------
  687. */
  688. /*
  689. * Note no locks taken out here. In a worst case scenario, we could drop
  690. * a chunk of system memory. But that should never happen, since validation
  691. * happens at open or mount time, when locks are held.
  692. *
  693. * That's crap, since doing that while some partitions are opened
  694. * or mounted will give you really nasty results.
  695. */
  696. static int mm_revalidate(struct gendisk *disk)
  697. {
  698. struct cardinfo *card = disk->private_data;
  699. set_capacity(disk, card->mm_size << 1);
  700. return 0;
  701. }
  702. static int mm_getgeo(struct block_device *bdev, struct hd_geometry *geo)
  703. {
  704. struct cardinfo *card = bdev->bd_disk->private_data;
  705. int size = card->mm_size * (1024 / MM_HARDSECT);
  706. /*
  707. * get geometry: we have to fake one... trim the size to a
  708. * multiple of 2048 (1M): tell we have 32 sectors, 64 heads,
  709. * whatever cylinders.
  710. */
  711. geo->heads = 64;
  712. geo->sectors = 32;
  713. geo->cylinders = size / (geo->heads * geo->sectors);
  714. return 0;
  715. }
  716. /*
  717. -----------------------------------------------------------------------------------
  718. -- mm_check_change
  719. -----------------------------------------------------------------------------------
  720. Future support for removable devices
  721. */
  722. static int mm_check_change(struct gendisk *disk)
  723. {
  724. /* struct cardinfo *dev = disk->private_data; */
  725. return 0;
  726. }
  727. /*
  728. -----------------------------------------------------------------------------------
  729. -- mm_fops
  730. -----------------------------------------------------------------------------------
  731. */
  732. static struct block_device_operations mm_fops = {
  733. .owner = THIS_MODULE,
  734. .getgeo = mm_getgeo,
  735. .revalidate_disk= mm_revalidate,
  736. .media_changed = mm_check_change,
  737. };
  738. /*
  739. -----------------------------------------------------------------------------------
  740. -- mm_pci_probe
  741. -----------------------------------------------------------------------------------
  742. */
  743. static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
  744. {
  745. int ret = -ENODEV;
  746. struct cardinfo *card = &cards[num_cards];
  747. unsigned char mem_present;
  748. unsigned char batt_status;
  749. unsigned int saved_bar, data;
  750. unsigned long csr_base;
  751. unsigned long csr_len;
  752. int magic_number;
  753. static int printed_version;
  754. if (!printed_version++)
  755. printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n");
  756. ret = pci_enable_device(dev);
  757. if (ret)
  758. return ret;
  759. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF8);
  760. pci_set_master(dev);
  761. card->dev = dev;
  762. csr_base = pci_resource_start(dev, 0);
  763. csr_len = pci_resource_len(dev, 0);
  764. if (!csr_base || !csr_len)
  765. return -ENODEV;
  766. dev_printk(KERN_INFO, &dev->dev,
  767. "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n");
  768. if (pci_set_dma_mask(dev, DMA_64BIT_MASK) &&
  769. pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
  770. dev_printk(KERN_WARNING, &dev->dev, "NO suitable DMA found\n");
  771. return -ENOMEM;
  772. }
  773. ret = pci_request_regions(dev, DRIVER_NAME);
  774. if (ret) {
  775. dev_printk(KERN_ERR, &card->dev->dev,
  776. "Unable to request memory region\n");
  777. goto failed_req_csr;
  778. }
  779. card->csr_remap = ioremap_nocache(csr_base, csr_len);
  780. if (!card->csr_remap) {
  781. dev_printk(KERN_ERR, &card->dev->dev,
  782. "Unable to remap memory region\n");
  783. ret = -ENOMEM;
  784. goto failed_remap_csr;
  785. }
  786. dev_printk(KERN_INFO, &card->dev->dev,
  787. "CSR 0x%08lx -> 0x%p (0x%lx)\n",
  788. csr_base, card->csr_remap, csr_len);
  789. switch(card->dev->device) {
  790. case 0x5415:
  791. card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG;
  792. magic_number = 0x59;
  793. break;
  794. case 0x5425:
  795. card->flags |= UM_FLAG_NO_BYTE_STATUS;
  796. magic_number = 0x5C;
  797. break;
  798. case 0x6155:
  799. card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT;
  800. magic_number = 0x99;
  801. break;
  802. default:
  803. magic_number = 0x100;
  804. break;
  805. }
  806. if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) {
  807. dev_printk(KERN_ERR, &card->dev->dev, "Magic number invalid\n");
  808. ret = -ENOMEM;
  809. goto failed_magic;
  810. }
  811. card->mm_pages[0].desc = pci_alloc_consistent(card->dev,
  812. PAGE_SIZE*2,
  813. &card->mm_pages[0].page_dma);
  814. card->mm_pages[1].desc = pci_alloc_consistent(card->dev,
  815. PAGE_SIZE*2,
  816. &card->mm_pages[1].page_dma);
  817. if (card->mm_pages[0].desc == NULL ||
  818. card->mm_pages[1].desc == NULL) {
  819. dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n");
  820. goto failed_alloc;
  821. }
  822. reset_page(&card->mm_pages[0]);
  823. reset_page(&card->mm_pages[1]);
  824. card->Ready = 0; /* page 0 is ready */
  825. card->Active = -1; /* no page is active */
  826. card->bio = NULL;
  827. card->biotail = &card->bio;
  828. card->queue = blk_alloc_queue(GFP_KERNEL);
  829. if (!card->queue)
  830. goto failed_alloc;
  831. blk_queue_make_request(card->queue, mm_make_request);
  832. card->queue->queuedata = card;
  833. card->queue->unplug_fn = mm_unplug_device;
  834. tasklet_init(&card->tasklet, process_page, (unsigned long)card);
  835. card->check_batteries = 0;
  836. mem_present = readb(card->csr_remap + MEMCTRLSTATUS_MEMORY);
  837. switch (mem_present) {
  838. case MEM_128_MB:
  839. card->mm_size = 1024 * 128;
  840. break;
  841. case MEM_256_MB:
  842. card->mm_size = 1024 * 256;
  843. break;
  844. case MEM_512_MB:
  845. card->mm_size = 1024 * 512;
  846. break;
  847. case MEM_1_GB:
  848. card->mm_size = 1024 * 1024;
  849. break;
  850. case MEM_2_GB:
  851. card->mm_size = 1024 * 2048;
  852. break;
  853. default:
  854. card->mm_size = 0;
  855. break;
  856. }
  857. /* Clear the LED's we control */
  858. set_led(card, LED_REMOVE, LED_OFF);
  859. set_led(card, LED_FAULT, LED_OFF);
  860. batt_status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY);
  861. card->battery[0].good = !(batt_status & BATTERY_1_FAILURE);
  862. card->battery[1].good = !(batt_status & BATTERY_2_FAILURE);
  863. card->battery[0].last_change = card->battery[1].last_change = jiffies;
  864. if (card->flags & UM_FLAG_NO_BATT)
  865. dev_printk(KERN_INFO, &card->dev->dev,
  866. "Size %d KB\n", card->mm_size);
  867. else {
  868. dev_printk(KERN_INFO, &card->dev->dev,
  869. "Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n",
  870. card->mm_size,
  871. (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"),
  872. card->battery[0].good ? "OK" : "FAILURE",
  873. (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"),
  874. card->battery[1].good ? "OK" : "FAILURE");
  875. set_fault_to_battery_status(card);
  876. }
  877. pci_read_config_dword(dev, PCI_BASE_ADDRESS_1, &saved_bar);
  878. data = 0xffffffff;
  879. pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, data);
  880. pci_read_config_dword(dev, PCI_BASE_ADDRESS_1, &data);
  881. pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, saved_bar);
  882. data &= 0xfffffff0;
  883. data = ~data;
  884. data += 1;
  885. if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, DRIVER_NAME, card)) {
  886. dev_printk(KERN_ERR, &card->dev->dev,
  887. "Unable to allocate IRQ\n");
  888. ret = -ENODEV;
  889. goto failed_req_irq;
  890. }
  891. dev_printk(KERN_INFO, &card->dev->dev,
  892. "Window size %d bytes, IRQ %d\n", data, dev->irq);
  893. spin_lock_init(&card->lock);
  894. pci_set_drvdata(dev, card);
  895. if (pci_write_cmd != 0x0F) /* If not Memory Write & Invalidate */
  896. pci_write_cmd = 0x07; /* then Memory Write command */
  897. if (pci_write_cmd & 0x08) { /* use Memory Write and Invalidate */
  898. unsigned short cfg_command;
  899. pci_read_config_word(dev, PCI_COMMAND, &cfg_command);
  900. cfg_command |= 0x10; /* Memory Write & Invalidate Enable */
  901. pci_write_config_word(dev, PCI_COMMAND, cfg_command);
  902. }
  903. pci_cmds = (pci_read_cmd << 28) | (pci_write_cmd << 24);
  904. num_cards++;
  905. if (!get_userbit(card, MEMORY_INITIALIZED)) {
  906. dev_printk(KERN_INFO, &card->dev->dev,
  907. "memory NOT initialized. Consider over-writing whole device.\n");
  908. card->init_size = 0;
  909. } else {
  910. dev_printk(KERN_INFO, &card->dev->dev,
  911. "memory already initialized\n");
  912. card->init_size = card->mm_size;
  913. }
  914. /* Enable ECC */
  915. writeb(EDC_STORE_CORRECT, card->csr_remap + MEMCTRLCMD_ERRCTRL);
  916. return 0;
  917. failed_req_irq:
  918. failed_alloc:
  919. if (card->mm_pages[0].desc)
  920. pci_free_consistent(card->dev, PAGE_SIZE*2,
  921. card->mm_pages[0].desc,
  922. card->mm_pages[0].page_dma);
  923. if (card->mm_pages[1].desc)
  924. pci_free_consistent(card->dev, PAGE_SIZE*2,
  925. card->mm_pages[1].desc,
  926. card->mm_pages[1].page_dma);
  927. failed_magic:
  928. iounmap(card->csr_remap);
  929. failed_remap_csr:
  930. pci_release_regions(dev);
  931. failed_req_csr:
  932. return ret;
  933. }
  934. /*
  935. -----------------------------------------------------------------------------------
  936. -- mm_pci_remove
  937. -----------------------------------------------------------------------------------
  938. */
  939. static void mm_pci_remove(struct pci_dev *dev)
  940. {
  941. struct cardinfo *card = pci_get_drvdata(dev);
  942. tasklet_kill(&card->tasklet);
  943. free_irq(dev->irq, card);
  944. iounmap(card->csr_remap);
  945. if (card->mm_pages[0].desc)
  946. pci_free_consistent(card->dev, PAGE_SIZE*2,
  947. card->mm_pages[0].desc,
  948. card->mm_pages[0].page_dma);
  949. if (card->mm_pages[1].desc)
  950. pci_free_consistent(card->dev, PAGE_SIZE*2,
  951. card->mm_pages[1].desc,
  952. card->mm_pages[1].page_dma);
  953. blk_cleanup_queue(card->queue);
  954. pci_release_regions(dev);
  955. pci_disable_device(dev);
  956. }
  957. static const struct pci_device_id mm_pci_ids[] = {
  958. {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_5415CN)},
  959. {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_5425CN)},
  960. {PCI_DEVICE(PCI_VENDOR_ID_MICRO_MEMORY,PCI_DEVICE_ID_MICRO_MEMORY_6155)},
  961. {
  962. .vendor = 0x8086,
  963. .device = 0xB555,
  964. .subvendor= 0x1332,
  965. .subdevice= 0x5460,
  966. .class = 0x050000,
  967. .class_mask= 0,
  968. }, { /* end: all zeroes */ }
  969. };
  970. MODULE_DEVICE_TABLE(pci, mm_pci_ids);
  971. static struct pci_driver mm_pci_driver = {
  972. .name = DRIVER_NAME,
  973. .id_table = mm_pci_ids,
  974. .probe = mm_pci_probe,
  975. .remove = mm_pci_remove,
  976. };
  977. /*
  978. -----------------------------------------------------------------------------------
  979. -- mm_init
  980. -----------------------------------------------------------------------------------
  981. */
  982. static int __init mm_init(void)
  983. {
  984. int retval, i;
  985. int err;
  986. retval = pci_register_driver(&mm_pci_driver);
  987. if (retval)
  988. return -ENOMEM;
  989. err = major_nr = register_blkdev(0, DRIVER_NAME);
  990. if (err < 0) {
  991. pci_unregister_driver(&mm_pci_driver);
  992. return -EIO;
  993. }
  994. for (i = 0; i < num_cards; i++) {
  995. mm_gendisk[i] = alloc_disk(1 << MM_SHIFT);
  996. if (!mm_gendisk[i])
  997. goto out;
  998. }
  999. for (i = 0; i < num_cards; i++) {
  1000. struct gendisk *disk = mm_gendisk[i];
  1001. sprintf(disk->disk_name, "umem%c", 'a'+i);
  1002. spin_lock_init(&cards[i].lock);
  1003. disk->major = major_nr;
  1004. disk->first_minor = i << MM_SHIFT;
  1005. disk->fops = &mm_fops;
  1006. disk->private_data = &cards[i];
  1007. disk->queue = cards[i].queue;
  1008. set_capacity(disk, cards[i].mm_size << 1);
  1009. add_disk(disk);
  1010. }
  1011. init_battery_timer();
  1012. printk(KERN_INFO "MM: desc_per_page = %ld\n", DESC_PER_PAGE);
  1013. /* printk("mm_init: Done. 10-19-01 9:00\n"); */
  1014. return 0;
  1015. out:
  1016. pci_unregister_driver(&mm_pci_driver);
  1017. unregister_blkdev(major_nr, DRIVER_NAME);
  1018. while (i--)
  1019. put_disk(mm_gendisk[i]);
  1020. return -ENOMEM;
  1021. }
  1022. /*
  1023. -----------------------------------------------------------------------------------
  1024. -- mm_cleanup
  1025. -----------------------------------------------------------------------------------
  1026. */
  1027. static void __exit mm_cleanup(void)
  1028. {
  1029. int i;
  1030. del_battery_timer();
  1031. for (i=0; i < num_cards ; i++) {
  1032. del_gendisk(mm_gendisk[i]);
  1033. put_disk(mm_gendisk[i]);
  1034. }
  1035. pci_unregister_driver(&mm_pci_driver);
  1036. unregister_blkdev(major_nr, DRIVER_NAME);
  1037. }
  1038. module_init(mm_init);
  1039. module_exit(mm_cleanup);
  1040. MODULE_AUTHOR(DRIVER_AUTHOR);
  1041. MODULE_DESCRIPTION(DRIVER_DESC);
  1042. MODULE_LICENSE("GPL");