3 * Linux MegaRAID device driver
5 * Copyright (c) 2003-2004 LSI Logic Corporation.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
12 * FILE : megaraid_mm.c
13 * Version : v2.20.2.0 (August 19 2004)
15 * Common management module
18 #include "megaraid_mm.h"
21 // Entry points for char node driver
22 static int mraid_mm_open(struct inode *, struct file *);
23 static int mraid_mm_ioctl(struct inode *, struct file *, uint, unsigned long);
26 // routines to convert to and from the old the format
27 static int mimd_to_kioc(mimd_t __user *, mraid_mmadp_t *, uioc_t *);
28 static int kioc_to_mimd(uioc_t *, mimd_t __user *);
32 static int handle_drvrcmd(void __user *, uint8_t, int *);
33 static int lld_ioctl(mraid_mmadp_t *, uioc_t *);
34 static void ioctl_done(uioc_t *);
35 static void lld_timedout(unsigned long);
36 static void hinfo_to_cinfo(mraid_hba_info_t *, mcontroller_t *);
37 static mraid_mmadp_t *mraid_mm_get_adapter(mimd_t __user *, int *);
38 static uioc_t *mraid_mm_alloc_kioc(mraid_mmadp_t *);
39 static void mraid_mm_dealloc_kioc(mraid_mmadp_t *, uioc_t *);
40 static int mraid_mm_attach_buf(mraid_mmadp_t *, uioc_t *, int);
41 static int mraid_mm_setup_dma_pools(mraid_mmadp_t *);
42 static void mraid_mm_free_adp_resources(mraid_mmadp_t *);
43 static void mraid_mm_teardown_dma_pools(mraid_mmadp_t *);
46 static int mraid_mm_compat_ioctl(unsigned int, unsigned int, unsigned long,
50 MODULE_AUTHOR("LSI Logic Corporation");
51 MODULE_DESCRIPTION("LSI Logic Management Module");
52 MODULE_LICENSE("GPL");
53 MODULE_VERSION(LSI_COMMON_MOD_VERSION);
55 static int dbglevel = CL_ANN;
56 module_param_named(dlevel, dbglevel, int, 0);
57 MODULE_PARM_DESC(dlevel, "Debug level (default=0)");
59 EXPORT_SYMBOL(mraid_mm_register_adp);
60 EXPORT_SYMBOL(mraid_mm_unregister_adp);
63 static uint32_t drvr_ver = 0x02200100;
65 static int adapters_count_g;
66 static struct list_head adapters_list_g;
68 wait_queue_head_t wait_q;
70 static struct file_operations lsi_fops = {
71 .open = mraid_mm_open,
72 .ioctl = mraid_mm_ioctl,
77 * mraid_mm_open - open routine for char node interface
81 * allow ioctl operations by apps only if they superuser privilege
84 mraid_mm_open(struct inode *inode, struct file *filep)
87 * Only allow superuser to access private ioctl interface
89 if (!capable(CAP_SYS_ADMIN)) return (-EACCES);
95 * mraid_mm_ioctl - module entry-point for ioctls
96 * @inode : inode (ignored)
97 * @filep : file operations pointer (ignored)
98 * @cmd : ioctl command
99 * @arg : user ioctl packet
102 mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
106 char signature[EXT_IOCTL_SIGN_SZ] = {0};
111 void __user *argp = (void __user *)arg;
114 * Make sure only USCSICMD are issued through this interface.
115 * MIMD application would still fire different command.
118 if ((_IOC_TYPE(cmd) != MEGAIOC_MAGIC) && (cmd != USCSICMD)) {
123 * Look for signature to see if this is the new or old ioctl format.
125 if (copy_from_user(signature, argp, EXT_IOCTL_SIGN_SZ)) {
126 con_log(CL_ANN, (KERN_WARNING
127 "megaraid cmm: copy from usr addr failed\n"));
131 if (memcmp(signature, EXT_IOCTL_SIGN, EXT_IOCTL_SIGN_SZ) == 0)
137 * At present, we don't support the new ioctl packet
143 * If it is a driver ioctl (as opposed to fw ioctls), then we can
144 * handle the command locally. rval > 0 means it is not a drvr cmd
146 rval = handle_drvrcmd(argp, old_ioctl, &drvrcmd_rval);
154 if ((adp = mraid_mm_get_adapter(argp, &rval)) == NULL) {
159 * The following call will block till a kioc is available
161 kioc = mraid_mm_alloc_kioc(adp);
164 * User sent the old mimd_t ioctl packet. Convert it to uioc_t.
166 if ((rval = mimd_to_kioc(argp, adp, kioc))) {
167 mraid_mm_dealloc_kioc(adp, kioc);
171 kioc->done = ioctl_done;
174 * Issue the IOCTL to the low level driver
176 if ((rval = lld_ioctl(adp, kioc))) {
177 mraid_mm_dealloc_kioc(adp, kioc);
182 * Convert the kioc back to user space
184 rval = kioc_to_mimd(kioc, argp);
187 * Return the kioc to free pool
189 mraid_mm_dealloc_kioc(adp, kioc);
196 * mraid_mm_get_adapter - Returns corresponding adapters for the mimd packet
197 * @umimd : User space mimd_t ioctl packet
198 * @adapter : pointer to the adapter (OUT)
200 static mraid_mmadp_t *
201 mraid_mm_get_adapter(mimd_t __user *umimd, int *rval)
203 mraid_mmadp_t *adapter;
209 if (copy_from_user(&mimd, umimd, sizeof(mimd_t))) {
214 adapno = GETADAP(mimd.ui.fcs.adapno);
216 if (adapno >= adapters_count_g) {
224 list_for_each_entry(adapter, &adapters_list_g, list) {
225 if (iterator++ == adapno) break;
237 * handle_drvrcmd - This routine checks if the opcode is a driver
238 * cmd and if it is, handles it.
239 * @arg : packet sent by the user app
240 * @old_ioctl : mimd if 1; uioc otherwise
243 handle_drvrcmd(void __user *arg, uint8_t old_ioctl, int *rval)
245 mimd_t __user *umimd;
262 if (copy_from_user(&kmimd, umimd, sizeof(mimd_t)))
265 opcode = kmimd.ui.fcs.opcode;
266 subopcode = kmimd.ui.fcs.subopcode;
269 * If the opcode is 0x82 and the subopcode is either GET_DRVRVER or
270 * GET_NUMADP, then we can handle. Otherwise we should return 1 to
271 * indicate that we cannot handle this.
278 case MEGAIOC_QDRVRVER:
280 if (copy_to_user(kmimd.data, &drvr_ver, sizeof(uint32_t)))
287 *rval = adapters_count_g;
289 if (copy_to_user(kmimd.data, &adapters_count_g,
305 * mimd_to_kioc - Converter from old to new ioctl format
307 * @umimd : user space old MIMD IOCTL
308 * @kioc : kernel space new format IOCTL
310 * Routine to convert MIMD interface IOCTL to new interface IOCTL packet. The
311 * new packet is in kernel space so that driver can perform operations on it
316 mimd_to_kioc(mimd_t __user *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
320 mraid_passthru_t *pthru32;
326 if (copy_from_user(&mimd, umimd, sizeof(mimd_t)))
330 * Applications are not allowed to send extd pthru
332 if ((mimd.mbox[0] == MBOXCMD_PASSTHRU64) ||
333 (mimd.mbox[0] == MBOXCMD_EXTPTHRU))
336 opcode = mimd.ui.fcs.opcode;
337 subopcode = mimd.ui.fcs.subopcode;
338 adapno = GETADAP(mimd.ui.fcs.adapno);
340 if (adapno >= adapters_count_g)
343 kioc->adapno = adapno;
344 kioc->mb_type = MBOX_LEGACY;
345 kioc->app_type = APPTYPE_MIMD;
351 if (subopcode == MEGAIOC_QADAPINFO) {
353 kioc->opcode = GET_ADAP_INFO;
354 kioc->data_dir = UIOC_RD;
355 kioc->xferlen = sizeof(mraid_hba_info_t);
357 if (mraid_mm_attach_buf(adp, kioc, kioc->xferlen))
361 con_log(CL_ANN, (KERN_WARNING
362 "megaraid cmm: Invalid subop\n"));
370 kioc->opcode = MBOX_CMD;
371 kioc->xferlen = mimd.ui.fcs.length;
372 kioc->user_data_len = kioc->xferlen;
373 kioc->user_data = mimd.ui.fcs.buffer;
375 if (mraid_mm_attach_buf(adp, kioc, kioc->xferlen))
378 if (mimd.outlen) kioc->data_dir = UIOC_RD;
379 if (mimd.inlen) kioc->data_dir |= UIOC_WR;
385 kioc->opcode = MBOX_CMD;
386 kioc->xferlen = (mimd.outlen > mimd.inlen) ?
387 mimd.outlen : mimd.inlen;
388 kioc->user_data_len = kioc->xferlen;
389 kioc->user_data = mimd.data;
391 if (mraid_mm_attach_buf(adp, kioc, kioc->xferlen))
394 if (mimd.outlen) kioc->data_dir = UIOC_RD;
395 if (mimd.inlen) kioc->data_dir |= UIOC_WR;
404 * If driver command, nothing else to do
410 * This is a mailbox cmd; copy the mailbox from mimd
412 mbox64 = (mbox64_t *)((unsigned long)kioc->cmdbuf);
413 mbox = &mbox64->mbox32;
414 memcpy(mbox, mimd.mbox, 14);
416 if (mbox->cmd != MBOXCMD_PASSTHRU) { // regular DCMD
418 mbox->xferaddr = (uint32_t)kioc->buf_paddr;
420 if (kioc->data_dir & UIOC_WR) {
421 if (copy_from_user(kioc->buf_vaddr, kioc->user_data,
431 * This is a regular 32-bit pthru cmd; mbox points to pthru struct.
432 * Just like in above case, the beginning for memblk is treated as
433 * a mailbox. The passthru will begin at next 1K boundary. And the
434 * data will start 1K after that.
436 pthru32 = kioc->pthru32;
437 kioc->user_pthru = &umimd->pthru;
438 mbox->xferaddr = (uint32_t)kioc->pthru32_h;
440 if (copy_from_user(pthru32, kioc->user_pthru,
441 sizeof(mraid_passthru_t))) {
445 pthru32->dataxferaddr = kioc->buf_paddr;
446 if (kioc->data_dir & UIOC_WR) {
447 if (copy_from_user(kioc->buf_vaddr, kioc->user_data,
448 pthru32->dataxferlen)) {
457 * mraid_mm_attch_buf - Attach a free dma buffer for required size
459 * @adp : Adapter softstate
460 * @kioc : kioc that the buffer needs to be attached to
461 * @xferlen : required length for buffer
463 * First we search for a pool with smallest buffer that is >= @xferlen. If
464 * that pool has no free buffer, we will try for the next bigger size. If none
465 * is available, we will try to allocate the smallest buffer that is >=
466 * @xferlen and attach it the pool.
469 mraid_mm_attach_buf(mraid_mmadp_t *adp, uioc_t *kioc, int xferlen)
476 kioc->pool_index = -1;
477 kioc->buf_vaddr = NULL;
482 * We need xferlen amount of memory. See if we can get it from our
483 * dma pools. If we don't get exact size, we will try bigger buffer
486 for (i = 0; i < MAX_DMA_POOLS; i++) {
488 pool = &adp->dma_pool_list[i];
490 if (xferlen > pool->buf_size)
493 if (right_pool == -1)
496 spin_lock_irqsave(&pool->lock, flags);
501 kioc->pool_index = i;
502 kioc->buf_vaddr = pool->vaddr;
503 kioc->buf_paddr = pool->paddr;
505 spin_unlock_irqrestore(&pool->lock, flags);
509 spin_unlock_irqrestore(&pool->lock, flags);
515 * If xferlen doesn't match any of our pools, return error
517 if (right_pool == -1)
521 * We did not get any buffer from the preallocated pool. Let us try
522 * to allocate one new buffer. NOTE: This is a blocking call.
524 pool = &adp->dma_pool_list[right_pool];
526 spin_lock_irqsave(&pool->lock, flags);
528 kioc->pool_index = right_pool;
530 kioc->buf_vaddr = pci_pool_alloc(pool->handle, GFP_KERNEL,
532 spin_unlock_irqrestore(&pool->lock, flags);
534 if (!kioc->buf_vaddr)
541 * mraid_mm_alloc_kioc - Returns a uioc_t from free list
542 * @adp : Adapter softstate for this module
544 * The kioc_semaphore is initialized with number of kioc nodes in the
545 * free kioc pool. If the kioc pool is empty, this function blocks till
546 * a kioc becomes free.
549 mraid_mm_alloc_kioc(mraid_mmadp_t *adp)
552 struct list_head* head;
555 down(&adp->kioc_semaphore);
557 spin_lock_irqsave(&adp->kioc_pool_lock, flags);
559 head = &adp->kioc_pool;
561 if (list_empty(head)) {
562 up(&adp->kioc_semaphore);
563 spin_unlock_irqrestore(&adp->kioc_pool_lock, flags);
565 con_log(CL_ANN, ("megaraid cmm: kioc list empty!\n"));
569 kioc = list_entry(head->next, uioc_t, list);
570 list_del_init(&kioc->list);
572 spin_unlock_irqrestore(&adp->kioc_pool_lock, flags);
574 memset((caddr_t)(unsigned long)kioc->cmdbuf, 0, sizeof(mbox64_t));
575 memset((caddr_t) kioc->pthru32, 0, sizeof(mraid_passthru_t));
577 kioc->buf_vaddr = NULL;
579 kioc->pool_index =-1;
581 kioc->user_data = NULL;
582 kioc->user_data_len = 0;
583 kioc->user_pthru = NULL;
589 * mraid_mm_dealloc_kioc - Return kioc to free pool
591 * @adp : Adapter softstate
592 * @kioc : uioc_t node to be returned to free pool
595 mraid_mm_dealloc_kioc(mraid_mmadp_t *adp, uioc_t *kioc)
600 pool = &adp->dma_pool_list[kioc->pool_index];
602 /* This routine may be called in non-isr context also */
603 spin_lock_irqsave(&pool->lock, flags);
606 * While attaching the dma buffer, if we didn't get the required
607 * buffer from the pool, we would have allocated it at the run time
608 * and set the free_buf flag. We must free that buffer. Otherwise,
609 * just mark that the buffer is not in use
611 if (kioc->free_buf == 1)
612 pci_pool_free(pool->handle, kioc->buf_vaddr, kioc->buf_paddr);
616 spin_unlock_irqrestore(&pool->lock, flags);
618 /* Return the kioc to the free pool */
619 spin_lock_irqsave(&adp->kioc_pool_lock, flags);
620 list_add(&kioc->list, &adp->kioc_pool);
621 spin_unlock_irqrestore(&adp->kioc_pool_lock, flags);
623 /* increment the free kioc count */
624 up(&adp->kioc_semaphore);
630 * lld_ioctl - Routine to issue ioctl to low level drvr
632 * @adp : The adapter handle
633 * @kioc : The ioctl packet with kernel addresses
636 lld_ioctl(mraid_mmadp_t *adp, uioc_t *kioc)
639 struct timer_list timer;
640 struct timer_list *tp = NULL;
642 kioc->status = -ENODATA;
643 rval = adp->issue_uioc(adp->drvr_data, kioc, IOCTL_ISSUE);
645 if (rval) return rval;
650 if (adp->timeout > 0) {
654 tp->function = lld_timedout;
655 tp->data = (unsigned long)kioc;
656 tp->expires = jiffies + adp->timeout * HZ;
662 * Wait till the low level driver completes the ioctl. After this
663 * call, the ioctl either completed successfully or timedout.
665 wait_event(wait_q, (kioc->status != -ENODATA));
675 * ioctl_done - callback from the low level driver
677 * @kioc : completed ioctl packet
680 ioctl_done(uioc_t *kioc)
683 * When the kioc returns from driver, make sure it still doesn't
684 * have ENODATA in status. Otherwise, driver will hang on wait_event
687 if (kioc->status == -ENODATA) {
688 con_log(CL_ANN, (KERN_WARNING
689 "megaraid cmm: lld didn't change status!\n"));
691 kioc->status = -EINVAL;
699 * lld_timedout : callback from the expired timer
701 * @ptr : ioctl packet that timed out
704 lld_timedout(unsigned long ptr)
706 uioc_t *kioc = (uioc_t *)ptr;
708 kioc->status = -ETIME;
710 con_log(CL_ANN, (KERN_WARNING "megaraid cmm: ioctl timed out\n"));
717 * kioc_to_mimd : Converter from new back to old format
719 * @kioc : Kernel space IOCTL packet (successfully issued)
720 * @mimd : User space MIMD packet
723 kioc_to_mimd(uioc_t *kioc, mimd_t __user *mimd)
730 mraid_passthru_t __user *upthru32;
731 mraid_passthru_t *kpthru32;
733 mraid_hba_info_t *hinfo;
736 if (copy_from_user(&kmimd, mimd, sizeof(mimd_t)))
739 opcode = kmimd.ui.fcs.opcode;
740 subopcode = kmimd.ui.fcs.subopcode;
742 if (opcode == 0x82) {
745 case MEGAIOC_QADAPINFO:
747 hinfo = (mraid_hba_info_t *)(unsigned long)
750 hinfo_to_cinfo(hinfo, &cinfo);
752 if (copy_to_user(kmimd.data, &cinfo, sizeof(cinfo)))
764 mbox64 = (mbox64_t *)(unsigned long)kioc->cmdbuf;
766 if (kioc->user_pthru) {
768 upthru32 = kioc->user_pthru;
769 kpthru32 = kioc->pthru32;
771 if (copy_to_user(&upthru32->scsistatus,
772 &kpthru32->scsistatus,
778 if (kioc->user_data) {
779 if (copy_to_user(kioc->user_data, kioc->buf_vaddr,
780 kioc->user_data_len)) {
785 if (copy_to_user(&mimd->mbox[17],
786 &mbox64->mbox32.status, sizeof(uint8_t))) {
795 * hinfo_to_cinfo - Convert new format hba info into old format
797 * @hinfo : New format, more comprehensive adapter info
798 * @cinfo : Old format adapter info to support mimd_t apps
801 hinfo_to_cinfo(mraid_hba_info_t *hinfo, mcontroller_t *cinfo)
803 if (!hinfo || !cinfo)
806 cinfo->base = hinfo->baseport;
807 cinfo->irq = hinfo->irq;
808 cinfo->numldrv = hinfo->num_ldrv;
809 cinfo->pcibus = hinfo->pci_bus;
810 cinfo->pcidev = hinfo->pci_slot;
811 cinfo->pcifun = PCI_FUNC(hinfo->pci_dev_fn);
812 cinfo->pciid = hinfo->pci_device_id;
813 cinfo->pcivendor = hinfo->pci_vendor_id;
814 cinfo->pcislot = hinfo->pci_slot;
815 cinfo->uid = hinfo->unique_id;
820 * mraid_mm_register_adp - Registration routine for low level drvrs
822 * @adp : Adapter objejct
825 mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
827 mraid_mmadp_t *adapter;
834 if (lld_adp->drvr_type != DRVRTYPE_MBOX)
837 adapter = kmalloc(sizeof(mraid_mmadp_t), GFP_KERNEL);
844 memset(adapter, 0, sizeof(mraid_mmadp_t));
846 adapter->unique_id = lld_adp->unique_id;
847 adapter->drvr_type = lld_adp->drvr_type;
848 adapter->drvr_data = lld_adp->drvr_data;
849 adapter->pdev = lld_adp->pdev;
850 adapter->issue_uioc = lld_adp->issue_uioc;
851 adapter->timeout = lld_adp->timeout;
852 adapter->max_kioc = lld_adp->max_kioc;
855 * Allocate single blocks of memory for all required kiocs,
856 * mailboxes and passthru structures.
858 adapter->kioc_list = kmalloc(sizeof(uioc_t) * lld_adp->max_kioc,
860 adapter->mbox_list = kmalloc(sizeof(mbox64_t) * lld_adp->max_kioc,
862 adapter->pthru_dma_pool = pci_pool_create("megaraid mm pthru pool",
864 sizeof(mraid_passthru_t),
867 if (!adapter->kioc_list || !adapter->mbox_list ||
868 !adapter->pthru_dma_pool) {
870 con_log(CL_ANN, (KERN_WARNING
871 "megaraid cmm: out of memory, %s %d\n", __FUNCTION__,
880 * Slice kioc_list and make a kioc_pool with the individiual kiocs
882 INIT_LIST_HEAD(&adapter->kioc_pool);
883 spin_lock_init(&adapter->kioc_pool_lock);
884 sema_init(&adapter->kioc_semaphore, lld_adp->max_kioc);
886 mbox_list = (mbox64_t *)adapter->mbox_list;
888 for (i = 0; i < lld_adp->max_kioc; i++) {
890 kioc = adapter->kioc_list + i;
891 kioc->cmdbuf = (uint64_t)(unsigned long)(mbox_list + i);
892 kioc->pthru32 = pci_pool_alloc(adapter->pthru_dma_pool,
893 GFP_KERNEL, &kioc->pthru32_h);
895 if (!kioc->pthru32) {
897 con_log(CL_ANN, (KERN_WARNING
898 "megaraid cmm: out of memory, %s %d\n",
899 __FUNCTION__, __LINE__));
903 goto pthru_dma_pool_error;
906 list_add_tail(&kioc->list, &adapter->kioc_pool);
909 // Setup the dma pools for data buffers
910 if ((rval = mraid_mm_setup_dma_pools(adapter)) != 0) {
914 list_add_tail(&adapter->list, &adapters_list_g);
923 pthru_dma_pool_error:
925 for (i = 0; i < lld_adp->max_kioc; i++) {
926 kioc = adapter->kioc_list + i;
928 pci_pool_free(adapter->pthru_dma_pool, kioc->pthru32,
935 if (adapter->kioc_list)
936 kfree(adapter->kioc_list);
938 if (adapter->mbox_list)
939 kfree(adapter->mbox_list);
941 if (adapter->pthru_dma_pool)
942 pci_pool_destroy(adapter->pthru_dma_pool);
951 * mraid_mm_setup_dma_pools - Set up dma buffer pools per adapter
953 * @adp : Adapter softstate
955 * We maintain a pool of dma buffers per each adapter. Each pool has one
956 * buffer. E.g, we may have 5 dma pools - one each for 4k, 8k ... 64k buffers.
957 * We have just one 4k buffer in 4k pool, one 8k buffer in 8k pool etc. We
958 * dont' want to waste too much memory by allocating more buffers per each
962 mraid_mm_setup_dma_pools(mraid_mmadp_t *adp)
969 * Create MAX_DMA_POOLS number of pools
971 bufsize = MRAID_MM_INIT_BUFF_SIZE;
973 for (i = 0; i < MAX_DMA_POOLS; i++){
975 pool = &adp->dma_pool_list[i];
977 pool->buf_size = bufsize;
978 spin_lock_init(&pool->lock);
980 pool->handle = pci_pool_create("megaraid mm data buffer",
981 adp->pdev, bufsize, 16, 0);
984 goto dma_pool_setup_error;
987 pool->vaddr = pci_pool_alloc(pool->handle, GFP_KERNEL,
991 goto dma_pool_setup_error;
993 bufsize = bufsize * 2;
998 dma_pool_setup_error:
1000 mraid_mm_teardown_dma_pools(adp);
1006 * mraid_mm_unregister_adp - Unregister routine for low level drivers
1007 * Assume no outstanding ioctls to llds.
1009 * @unique_id : UID of the adpater
1012 mraid_mm_unregister_adp(uint32_t unique_id)
1014 mraid_mmadp_t *adapter;
1017 list_for_each_entry_safe(adapter, tmp, &adapters_list_g, list) {
1020 if (adapter->unique_id == unique_id) {
1024 list_del_init(&adapter->list);
1026 mraid_mm_free_adp_resources(adapter);
1031 "megaraid cmm: Unregistered one adapter:%#x\n",
1042 * mraid_mm_free_adp_resources - Free adapter softstate
1044 * @adp : Adapter softstate
1047 mraid_mm_free_adp_resources(mraid_mmadp_t *adp)
1052 mraid_mm_teardown_dma_pools(adp);
1054 for (i = 0; i < adp->max_kioc; i++) {
1056 kioc = adp->kioc_list + i;
1058 pci_pool_free(adp->pthru_dma_pool, kioc->pthru32,
1062 kfree(adp->kioc_list);
1064 kfree(adp->mbox_list);
1066 pci_pool_destroy(adp->pthru_dma_pool);
1074 * mraid_mm_teardown_dma_pools - Free all per adapter dma buffers
1076 * @adp : Adapter softstate
1079 mraid_mm_teardown_dma_pools(mraid_mmadp_t *adp)
1084 for (i = 0; i < MAX_DMA_POOLS; i++) {
1086 pool = &adp->dma_pool_list[i];
1091 pci_pool_free(pool->handle, pool->vaddr,
1094 pci_pool_destroy(pool->handle);
1095 pool->handle = NULL;
1103 * mraid_mm_init : Module entry point
1108 // Announce the driver version
1109 con_log(CL_ANN, (KERN_INFO "megaraid cmm: %s %s\n",
1110 LSI_COMMON_MOD_VERSION, LSI_COMMON_MOD_EXT_VERSION));
1112 majorno = register_chrdev(0, "megadev", &lsi_fops);
1115 con_log(CL_ANN, ("megaraid cmm: cannot get major\n"));
1119 init_waitqueue_head(&wait_q);
1121 INIT_LIST_HEAD(&adapters_list_g);
1123 #ifdef CONFIG_COMPAT
1124 register_ioctl32_conversion(MEGAIOCCMD, mraid_mm_compat_ioctl);
1132 * mraid_mm_compat_ioctl : 32bit to 64bit ioctl conversion routine
1134 #ifdef CONFIG_COMPAT
1136 mraid_mm_compat_ioctl(unsigned int fd, unsigned int cmd,
1137 unsigned long arg, struct file *filep)
1139 struct inode *inode = filep->f_dentry->d_inode;
1141 return mraid_mm_ioctl(inode, filep, cmd, arg);
1146 * mraid_mm_exit : Module exit point
1151 con_log(CL_DLEVEL1 , ("exiting common mod\n"));
1153 unregister_chrdev(majorno, "megadev");
1154 unregister_ioctl32_conversion(MEGAIOCCMD);
1157 module_init(mraid_mm_init);
1158 module_exit(mraid_mm_exit);
1160 /* vi: set ts=8 sw=8 tw=78: */