aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/megaraid
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/megaraid')
-rw-r--r--drivers/scsi/megaraid/mbox_defs.h2
-rw-r--r--drivers/scsi/megaraid/mega_common.h122
-rw-r--r--drivers/scsi/megaraid/megaraid_ioctl.h36
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c421
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.h46
-rw-r--r--drivers/scsi/megaraid/megaraid_mm.c65
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.h14
7 files changed, 389 insertions, 317 deletions
diff --git a/drivers/scsi/megaraid/mbox_defs.h b/drivers/scsi/megaraid/mbox_defs.h
index 3052869f51f4..170399ef06f4 100644
--- a/drivers/scsi/megaraid/mbox_defs.h
+++ b/drivers/scsi/megaraid/mbox_defs.h
@@ -748,7 +748,7 @@ typedef struct {
748 748
749 749
750/** 750/**
751 * private_bios_data - bios private data for boot devices 751 * struct private_bios_data - bios private data for boot devices
752 * @geometry : bits 0-3 - BIOS geometry, 0x0001 - 1GB, 0x0010 - 2GB, 752 * @geometry : bits 0-3 - BIOS geometry, 0x0001 - 1GB, 0x0010 - 2GB,
753 * 0x1000 - 8GB, Others values are invalid 753 * 0x1000 - 8GB, Others values are invalid
754 * @unused : bits 4-7 are unused 754 * @unused : bits 4-7 are unused
diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h
index b50e27e66024..26e1e6c55654 100644
--- a/drivers/scsi/megaraid/mega_common.h
+++ b/drivers/scsi/megaraid/mega_common.h
@@ -46,17 +46,17 @@
46 46
47/** 47/**
48 * scb_t - scsi command control block 48 * scb_t - scsi command control block
49 * @param ccb : command control block for individual driver 49 * @ccb : command control block for individual driver
50 * @param list : list of control blocks 50 * @list : list of control blocks
51 * @param gp : general purpose field for LLDs 51 * @gp : general purpose field for LLDs
52 * @param sno : all SCBs have a serial number 52 * @sno : all SCBs have a serial number
53 * @param scp : associated scsi command 53 * @scp : associated scsi command
54 * @param state : current state of scb 54 * @state : current state of scb
55 * @param dma_dir : direction of data transfer 55 * @dma_dir : direction of data transfer
56 * @param dma_type : transfer with sg list, buffer, or no data transfer 56 * @dma_type : transfer with sg list, buffer, or no data transfer
57 * @param dev_channel : actual channel on the device 57 * @dev_channel : actual channel on the device
58 * @param dev_target : actual target on the device 58 * @dev_target : actual target on the device
59 * @param status : completion status 59 * @status : completion status
60 * 60 *
61 * This is our central data structure to issue commands the each driver. 61 * This is our central data structure to issue commands the each driver.
62 * Driver specific data structures are maintained in the ccb field. 62 * Driver specific data structures are maintained in the ccb field.
@@ -99,42 +99,42 @@ typedef struct {
99 99
100/** 100/**
101 * struct adapter_t - driver's initialization structure 101 * struct adapter_t - driver's initialization structure
102 * @param dpc_h : tasklet handle 102 * @aram dpc_h : tasklet handle
103 * @param pdev : pci configuration pointer for kernel 103 * @pdev : pci configuration pointer for kernel
104 * @param host : pointer to host structure of mid-layer 104 * @host : pointer to host structure of mid-layer
105 * @param lock : synchronization lock for mid-layer and driver 105 * @lock : synchronization lock for mid-layer and driver
106 * @param quiescent : driver is quiescent for now. 106 * @quiescent : driver is quiescent for now.
107 * @param outstanding_cmds : number of commands pending in the driver 107 * @outstanding_cmds : number of commands pending in the driver
108 * @param kscb_list : pointer to the bulk of SCBs pointers for IO 108 * @kscb_list : pointer to the bulk of SCBs pointers for IO
109 * @param kscb_pool : pool of free scbs for IO 109 * @kscb_pool : pool of free scbs for IO
110 * @param kscb_pool_lock : lock for pool of free scbs 110 * @kscb_pool_lock : lock for pool of free scbs
111 * @param pend_list : pending commands list 111 * @pend_list : pending commands list
112 * @param pend_list_lock : exlusion lock for pending commands list 112 * @pend_list_lock : exclusion lock for pending commands list
113 * @param completed_list : list of completed commands 113 * @completed_list : list of completed commands
114 * @param completed_list_lock : exclusion lock for list of completed commands 114 * @completed_list_lock : exclusion lock for list of completed commands
115 * @param sglen : max sg elements supported 115 * @sglen : max sg elements supported
116 * @param device_ids : to convert kernel device addr to our devices. 116 * @device_ids : to convert kernel device addr to our devices.
117 * @param raid_device : raid adapter specific pointer 117 * @raid_device : raid adapter specific pointer
118 * @param max_channel : maximum channel number supported - inclusive 118 * @max_channel : maximum channel number supported - inclusive
119 * @param max_target : max target supported - inclusive 119 * @max_target : max target supported - inclusive
120 * @param max_lun : max lun supported - inclusive 120 * @max_lun : max lun supported - inclusive
121 * @param unique_id : unique identifier for each adapter 121 * @unique_id : unique identifier for each adapter
122 * @param irq : IRQ for this adapter 122 * @irq : IRQ for this adapter
123 * @param ito : internal timeout value, (-1) means no timeout 123 * @ito : internal timeout value, (-1) means no timeout
124 * @param ibuf : buffer to issue internal commands 124 * @ibuf : buffer to issue internal commands
125 * @param ibuf_dma_h : dma handle for the above buffer 125 * @ibuf_dma_h : dma handle for the above buffer
126 * @param uscb_list : SCB pointers for user cmds, common mgmt module 126 * @uscb_list : SCB pointers for user cmds, common mgmt module
127 * @param uscb_pool : pool of SCBs for user commands 127 * @uscb_pool : pool of SCBs for user commands
128 * @param uscb_pool_lock : exclusion lock for these SCBs 128 * @uscb_pool_lock : exclusion lock for these SCBs
129 * @param max_cmds : max outstanding commands 129 * @max_cmds : max outstanding commands
130 * @param fw_version : firmware version 130 * @fw_version : firmware version
131 * @param bios_version : bios version 131 * @bios_version : bios version
132 * @param max_cdb_sz : biggest CDB size supported. 132 * @max_cdb_sz : biggest CDB size supported.
133 * @param ha : is high availability present - clustering 133 * @ha : is high availability present - clustering
134 * @param init_id : initiator ID, the default value should be 7 134 * @init_id : initiator ID, the default value should be 7
135 * @param max_sectors : max sectors per request 135 * @max_sectors : max sectors per request
136 * @param cmd_per_lun : max outstanding commands per LUN 136 * @cmd_per_lun : max outstanding commands per LUN
137 * @param being_detached : set when unloading, no more mgmt calls 137 * @being_detached : set when unloading, no more mgmt calls
138 * 138 *
139 * 139 *
140 * mraid_setup_device_map() can be called anytime after the device map is 140 * mraid_setup_device_map() can be called anytime after the device map is
@@ -211,23 +211,23 @@ typedef struct {
211#define SCP2ADAPTER(scp) (adapter_t *)SCSIHOST2ADAP(SCP2HOST(scp)) 211#define SCP2ADAPTER(scp) (adapter_t *)SCSIHOST2ADAP(SCP2HOST(scp))
212 212
213 213
214/**
215 * MRAID_GET_DEVICE_MAP - device ids
216 * @param adp - Adapter's soft state
217 * @param scp - mid-layer scsi command pointer
218 * @param p_chan - physical channel on the controller
219 * @param target - target id of the device or logical drive number
220 * @param islogical - set if the command is for the logical drive
221 *
222 * Macro to retrieve information about device class, logical or physical and
223 * the corresponding physical channel and target or logical drive number
224 **/
225#define MRAID_IS_LOGICAL(adp, scp) \ 214#define MRAID_IS_LOGICAL(adp, scp) \
226 (SCP2CHANNEL(scp) == (adp)->max_channel) ? 1 : 0 215 (SCP2CHANNEL(scp) == (adp)->max_channel) ? 1 : 0
227 216
228#define MRAID_IS_LOGICAL_SDEV(adp, sdev) \ 217#define MRAID_IS_LOGICAL_SDEV(adp, sdev) \
229 (sdev->channel == (adp)->max_channel) ? 1 : 0 218 (sdev->channel == (adp)->max_channel) ? 1 : 0
230 219
220/**
221 * MRAID_GET_DEVICE_MAP - device ids
222 * @adp : adapter's soft state
223 * @scp : mid-layer scsi command pointer
224 * @p_chan : physical channel on the controller
225 * @target : target id of the device or logical drive number
226 * @islogical : set if the command is for the logical drive
227 *
228 * Macro to retrieve information about device class, logical or physical and
229 * the corresponding physical channel and target or logical drive number
230 */
231#define MRAID_GET_DEVICE_MAP(adp, scp, p_chan, target, islogical) \ 231#define MRAID_GET_DEVICE_MAP(adp, scp, p_chan, target, islogical) \
232 /* \ 232 /* \
233 * Is the request coming for the virtual channel \ 233 * Is the request coming for the virtual channel \
@@ -271,10 +271,10 @@ typedef struct {
271#define ASSERT(expression) 271#define ASSERT(expression)
272#endif 272#endif
273 273
274/* 274/**
275 * struct mraid_pci_blk - structure holds DMA memory block info 275 * struct mraid_pci_blk - structure holds DMA memory block info
276 * @param vaddr : virtual address to a memory block 276 * @vaddr : virtual address to a memory block
277 * @param dma_addr : DMA handle to a memory block 277 * @dma_addr : DMA handle to a memory block
278 * 278 *
279 * This structure is filled up for the caller. It is the responsibilty of the 279 * This structure is filled up for the caller. It is the responsibilty of the
280 * caller to allocate this array big enough to store addresses for all 280 * caller to allocate this array big enough to store addresses for all
diff --git a/drivers/scsi/megaraid/megaraid_ioctl.h b/drivers/scsi/megaraid/megaraid_ioctl.h
index b8aa34202ec3..706fa05a187a 100644
--- a/drivers/scsi/megaraid/megaraid_ioctl.h
+++ b/drivers/scsi/megaraid/megaraid_ioctl.h
@@ -22,23 +22,23 @@
22 22
23#include "mbox_defs.h" 23#include "mbox_defs.h"
24 24
25/*
26 * console messages debug levels
27 */
28#define CL_ANN 0 /* print unconditionally, announcements */
29#define CL_DLEVEL1 1 /* debug level 1, informative */
30#define CL_DLEVEL2 2 /* debug level 2, verbose */
31#define CL_DLEVEL3 3 /* debug level 3, very verbose */
32
25/** 33/**
26 * con_log() - console log routine 34 * con_log() - console log routine
27 * @param level : indicates the severity of the message. 35 * @level : indicates the severity of the message.
28 * @fparam mt : format string 36 * @fmt : format string
29 * 37 *
30 * con_log displays the error messages on the console based on the current 38 * con_log displays the error messages on the console based on the current
31 * debug level. Also it attaches the appropriate kernel severity level with 39 * debug level. Also it attaches the appropriate kernel severity level with
32 * the message. 40 * the message.
33 *
34 *
35 * consolge messages debug levels
36 */ 41 */
37#define CL_ANN 0 /* print unconditionally, announcements */
38#define CL_DLEVEL1 1 /* debug level 1, informative */
39#define CL_DLEVEL2 2 /* debug level 2, verbose */
40#define CL_DLEVEL3 3 /* debug level 3, very verbose */
41
42#define con_log(level, fmt) if (LSI_DBGLVL >= level) printk fmt; 42#define con_log(level, fmt) if (LSI_DBGLVL >= level) printk fmt;
43 43
44/* 44/*
@@ -157,14 +157,14 @@ typedef struct uioc {
157/** 157/**
158 * struct mraid_hba_info - information about the controller 158 * struct mraid_hba_info - information about the controller
159 * 159 *
160 * @param pci_vendor_id : PCI vendor id 160 * @pci_vendor_id : PCI vendor id
161 * @param pci_device_id : PCI device id 161 * @pci_device_id : PCI device id
162 * @param subsystem_vendor_id : PCI subsystem vendor id 162 * @subsystem_vendor_id : PCI subsystem vendor id
163 * @param subsystem_device_id : PCI subsystem device id 163 * @subsystem_device_id : PCI subsystem device id
164 * @param baseport : base port of hba memory 164 * @baseport : base port of hba memory
165 * @param pci_bus : PCI bus 165 * @pci_bus : PCI bus
166 * @param pci_dev_fn : PCI device/function values 166 * @pci_dev_fn : PCI device/function values
167 * @param irq : interrupt vector for the device 167 * @irq : interrupt vector for the device
168 * 168 *
169 * Extended information of 256 bytes about the controller. Align on the single 169 * Extended information of 256 bytes about the controller. Align on the single
170 * byte boundary so that 32-bit applications can be run on 64-bit platform 170 * byte boundary so that 32-bit applications can be run on 64-bit platform
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 7bac86dda88f..04d0b6918c61 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -10,13 +10,13 @@
10 * 2 of the License, or (at your option) any later version. 10 * 2 of the License, or (at your option) any later version.
11 * 11 *
12 * FILE : megaraid_mbox.c 12 * FILE : megaraid_mbox.c
13 * Version : v2.20.4.9 (Jul 16 2006) 13 * Version : v2.20.5.1 (Nov 16 2006)
14 * 14 *
15 * Authors: 15 * Authors:
16 * Atul Mukker <Atul.Mukker@lsil.com> 16 * Atul Mukker <Atul.Mukker@lsi.com>
17 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsil.com> 17 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsi.com>
18 * Manoj Jose <Manoj.Jose@lsil.com> 18 * Manoj Jose <Manoj.Jose@lsi.com>
19 * Seokmann Ju <Seokmann.Ju@lsil.com> 19 * Seokmann Ju
20 * 20 *
21 * List of supported controllers 21 * List of supported controllers
22 * 22 *
@@ -107,6 +107,7 @@ static int megaraid_mbox_support_random_del(adapter_t *);
107static int megaraid_mbox_get_max_sg(adapter_t *); 107static int megaraid_mbox_get_max_sg(adapter_t *);
108static void megaraid_mbox_enum_raid_scsi(adapter_t *); 108static void megaraid_mbox_enum_raid_scsi(adapter_t *);
109static void megaraid_mbox_flush_cache(adapter_t *); 109static void megaraid_mbox_flush_cache(adapter_t *);
110static int megaraid_mbox_fire_sync_cmd(adapter_t *);
110 111
111static void megaraid_mbox_display_scb(adapter_t *, scb_t *); 112static void megaraid_mbox_display_scb(adapter_t *, scb_t *);
112static void megaraid_mbox_setup_device_map(adapter_t *); 113static void megaraid_mbox_setup_device_map(adapter_t *);
@@ -137,7 +138,7 @@ static int wait_till_fw_empty(adapter_t *);
137 138
138 139
139 140
140MODULE_AUTHOR("sju@lsil.com"); 141MODULE_AUTHOR("megaraidlinux@lsi.com");
141MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver"); 142MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver");
142MODULE_LICENSE("GPL"); 143MODULE_LICENSE("GPL");
143MODULE_VERSION(MEGARAID_VERSION); 144MODULE_VERSION(MEGARAID_VERSION);
@@ -146,7 +147,7 @@ MODULE_VERSION(MEGARAID_VERSION);
146 * ### modules parameters for driver ### 147 * ### modules parameters for driver ###
147 */ 148 */
148 149
149/** 150/*
150 * Set to enable driver to expose unconfigured disk to kernel 151 * Set to enable driver to expose unconfigured disk to kernel
151 */ 152 */
152static int megaraid_expose_unconf_disks = 0; 153static int megaraid_expose_unconf_disks = 0;
@@ -154,7 +155,7 @@ module_param_named(unconf_disks, megaraid_expose_unconf_disks, int, 0);
154MODULE_PARM_DESC(unconf_disks, 155MODULE_PARM_DESC(unconf_disks,
155 "Set to expose unconfigured disks to kernel (default=0)"); 156 "Set to expose unconfigured disks to kernel (default=0)");
156 157
157/** 158/*
158 * driver wait time if the adapter's mailbox is busy 159 * driver wait time if the adapter's mailbox is busy
159 */ 160 */
160static unsigned int max_mbox_busy_wait = MBOX_BUSY_WAIT; 161static unsigned int max_mbox_busy_wait = MBOX_BUSY_WAIT;
@@ -162,7 +163,7 @@ module_param_named(busy_wait, max_mbox_busy_wait, int, 0);
162MODULE_PARM_DESC(busy_wait, 163MODULE_PARM_DESC(busy_wait,
163 "Max wait for mailbox in microseconds if busy (default=10)"); 164 "Max wait for mailbox in microseconds if busy (default=10)");
164 165
165/** 166/*
166 * number of sectors per IO command 167 * number of sectors per IO command
167 */ 168 */
168static unsigned int megaraid_max_sectors = MBOX_MAX_SECTORS; 169static unsigned int megaraid_max_sectors = MBOX_MAX_SECTORS;
@@ -170,7 +171,7 @@ module_param_named(max_sectors, megaraid_max_sectors, int, 0);
170MODULE_PARM_DESC(max_sectors, 171MODULE_PARM_DESC(max_sectors,
171 "Maximum number of sectors per IO command (default=128)"); 172 "Maximum number of sectors per IO command (default=128)");
172 173
173/** 174/*
174 * number of commands per logical unit 175 * number of commands per logical unit
175 */ 176 */
176static unsigned int megaraid_cmd_per_lun = MBOX_DEF_CMD_PER_LUN; 177static unsigned int megaraid_cmd_per_lun = MBOX_DEF_CMD_PER_LUN;
@@ -179,7 +180,7 @@ MODULE_PARM_DESC(cmd_per_lun,
179 "Maximum number of commands per logical unit (default=64)"); 180 "Maximum number of commands per logical unit (default=64)");
180 181
181 182
182/** 183/*
183 * Fast driver load option, skip scanning for physical devices during load. 184 * Fast driver load option, skip scanning for physical devices during load.
184 * This would result in non-disk devices being skipped during driver load 185 * This would result in non-disk devices being skipped during driver load
185 * time. These can be later added though, using /proc/scsi/scsi 186 * time. These can be later added though, using /proc/scsi/scsi
@@ -190,7 +191,7 @@ MODULE_PARM_DESC(fast_load,
190 "Faster loading of the driver, skips physical devices! (default=0)"); 191 "Faster loading of the driver, skips physical devices! (default=0)");
191 192
192 193
193/** 194/*
194 * mraid_debug level - threshold for amount of information to be displayed by 195 * mraid_debug level - threshold for amount of information to be displayed by
195 * the driver. This level can be changed through modules parameters, ioctl or 196 * the driver. This level can be changed through modules parameters, ioctl or
196 * sysfs/proc interface. By default, print the announcement messages only. 197 * sysfs/proc interface. By default, print the announcement messages only.
@@ -337,7 +338,7 @@ static struct device_attribute *megaraid_sdev_attrs[] = {
337 * 338 *
338 * Return value: 339 * Return value:
339 * actual depth set 340 * actual depth set
340 **/ 341 */
341static int megaraid_change_queue_depth(struct scsi_device *sdev, int qdepth) 342static int megaraid_change_queue_depth(struct scsi_device *sdev, int qdepth)
342{ 343{
343 if (qdepth > MBOX_MAX_SCSI_CMDS) 344 if (qdepth > MBOX_MAX_SCSI_CMDS)
@@ -369,8 +370,8 @@ static struct scsi_host_template megaraid_template_g = {
369 * megaraid_init - module load hook 370 * megaraid_init - module load hook
370 * 371 *
371 * We register ourselves as hotplug enabled module and let PCI subsystem 372 * We register ourselves as hotplug enabled module and let PCI subsystem
372 * discover our adaters 373 * discover our adapters.
373 **/ 374 */
374static int __init 375static int __init
375megaraid_init(void) 376megaraid_init(void)
376{ 377{
@@ -405,7 +406,7 @@ megaraid_init(void)
405/** 406/**
406 * megaraid_exit - driver unload entry point 407 * megaraid_exit - driver unload entry point
407 * 408 *
408 * We simply unwrap the megaraid_init routine here 409 * We simply unwrap the megaraid_init routine here.
409 */ 410 */
410static void __exit 411static void __exit
411megaraid_exit(void) 412megaraid_exit(void)
@@ -421,12 +422,12 @@ megaraid_exit(void)
421 422
422/** 423/**
423 * megaraid_probe_one - PCI hotplug entry point 424 * megaraid_probe_one - PCI hotplug entry point
424 * @param pdev : handle to this controller's PCI configuration space 425 * @pdev : handle to this controller's PCI configuration space
425 * @param id : pci device id of the class of controllers 426 * @id : pci device id of the class of controllers
426 * 427 *
427 * This routine should be called whenever a new adapter is detected by the 428 * This routine should be called whenever a new adapter is detected by the
428 * PCI hotplug susbsytem. 429 * PCI hotplug susbsytem.
429 **/ 430 */
430static int __devinit 431static int __devinit
431megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) 432megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
432{ 433{
@@ -542,16 +543,15 @@ out_probe_one:
542 543
543 544
544/** 545/**
545 * megaraid_detach_one - release the framework resources and call LLD release 546 * megaraid_detach_one - release framework resources and call LLD release routine
546 * routine 547 * @pdev : handle for our PCI cofiguration space
547 * @param pdev : handle for our PCI cofiguration space
548 * 548 *
549 * This routine is called during driver unload. We free all the allocated 549 * This routine is called during driver unload. We free all the allocated
550 * resources and call the corresponding LLD so that it can also release all 550 * resources and call the corresponding LLD so that it can also release all
551 * its resources. 551 * its resources.
552 * 552 *
553 * This routine is also called from the PCI hotplug system 553 * This routine is also called from the PCI hotplug system.
554 **/ 554 */
555static void 555static void
556megaraid_detach_one(struct pci_dev *pdev) 556megaraid_detach_one(struct pci_dev *pdev)
557{ 557{
@@ -615,9 +615,9 @@ megaraid_detach_one(struct pci_dev *pdev)
615 615
616/** 616/**
617 * megaraid_mbox_shutdown - PCI shutdown for megaraid HBA 617 * megaraid_mbox_shutdown - PCI shutdown for megaraid HBA
618 * @param device : generice driver model device 618 * @pdev : generic driver model device
619 * 619 *
620 * Shutdown notification, perform flush cache 620 * Shutdown notification, perform flush cache.
621 */ 621 */
622static void 622static void
623megaraid_mbox_shutdown(struct pci_dev *pdev) 623megaraid_mbox_shutdown(struct pci_dev *pdev)
@@ -643,10 +643,10 @@ megaraid_mbox_shutdown(struct pci_dev *pdev)
643 643
644/** 644/**
645 * megaraid_io_attach - attach a device with the IO subsystem 645 * megaraid_io_attach - attach a device with the IO subsystem
646 * @param adapter : controller's soft state 646 * @adapter : controller's soft state
647 * 647 *
648 * Attach this device with the IO subsystem 648 * Attach this device with the IO subsystem.
649 **/ 649 */
650static int 650static int
651megaraid_io_attach(adapter_t *adapter) 651megaraid_io_attach(adapter_t *adapter)
652{ 652{
@@ -695,10 +695,10 @@ megaraid_io_attach(adapter_t *adapter)
695 695
696/** 696/**
697 * megaraid_io_detach - detach a device from the IO subsystem 697 * megaraid_io_detach - detach a device from the IO subsystem
698 * @param adapter : controller's soft state 698 * @adapter : controller's soft state
699 * 699 *
700 * Detach this device from the IO subsystem 700 * Detach this device from the IO subsystem.
701 **/ 701 */
702static void 702static void
703megaraid_io_detach(adapter_t *adapter) 703megaraid_io_detach(adapter_t *adapter)
704{ 704{
@@ -722,13 +722,13 @@ megaraid_io_detach(adapter_t *adapter)
722 722
723/** 723/**
724 * megaraid_init_mbox - initialize controller 724 * megaraid_init_mbox - initialize controller
725 * @param adapter - our soft state 725 * @adapter : our soft state
726 * 726 *
727 * . Allocate 16-byte aligned mailbox memory for firmware handshake 727 * - Allocate 16-byte aligned mailbox memory for firmware handshake
728 * . Allocate controller's memory resources 728 * - Allocate controller's memory resources
729 * . Find out all initialization data 729 * - Find out all initialization data
730 * . Allocate memory required for all the commands 730 * - Allocate memory required for all the commands
731 * . Use internal library of FW routines, build up complete soft state 731 * - Use internal library of FW routines, build up complete soft state
732 */ 732 */
733static int __devinit 733static int __devinit
734megaraid_init_mbox(adapter_t *adapter) 734megaraid_init_mbox(adapter_t *adapter)
@@ -779,33 +779,39 @@ megaraid_init_mbox(adapter_t *adapter)
779 goto out_release_regions; 779 goto out_release_regions;
780 } 780 }
781 781
782 // 782 /* initialize the mutual exclusion lock for the mailbox */
783 // Setup the rest of the soft state using the library of FW routines 783 spin_lock_init(&raid_dev->mailbox_lock);
784 //
785 784
786 // request IRQ and register the interrupt service routine 785 /* allocate memory required for commands */
786 if (megaraid_alloc_cmd_packets(adapter) != 0)
787 goto out_iounmap;
788
789 /*
790 * Issue SYNC cmd to flush the pending cmds in the adapter
791 * and initialize its internal state
792 */
793
794 if (megaraid_mbox_fire_sync_cmd(adapter))
795 con_log(CL_ANN, ("megaraid: sync cmd failed\n"));
796
797 /*
798 * Setup the rest of the soft state using the library of
799 * FW routines
800 */
801
802 /* request IRQ and register the interrupt service routine */
787 if (request_irq(adapter->irq, megaraid_isr, IRQF_SHARED, "megaraid", 803 if (request_irq(adapter->irq, megaraid_isr, IRQF_SHARED, "megaraid",
788 adapter)) { 804 adapter)) {
789 805
790 con_log(CL_ANN, (KERN_WARNING 806 con_log(CL_ANN, (KERN_WARNING
791 "megaraid: Couldn't register IRQ %d!\n", adapter->irq)); 807 "megaraid: Couldn't register IRQ %d!\n", adapter->irq));
808 goto out_alloc_cmds;
792 809
793 goto out_iounmap;
794 }
795
796
797 // initialize the mutual exclusion lock for the mailbox
798 spin_lock_init(&raid_dev->mailbox_lock);
799
800 // allocate memory required for commands
801 if (megaraid_alloc_cmd_packets(adapter) != 0) {
802 goto out_free_irq;
803 } 810 }
804 811
805 // Product info 812 // Product info
806 if (megaraid_mbox_product_info(adapter) != 0) { 813 if (megaraid_mbox_product_info(adapter) != 0)
807 goto out_alloc_cmds; 814 goto out_free_irq;
808 }
809 815
810 // Do we support extended CDBs 816 // Do we support extended CDBs
811 adapter->max_cdb_sz = 10; 817 adapter->max_cdb_sz = 10;
@@ -874,9 +880,8 @@ megaraid_init_mbox(adapter_t *adapter)
874 * Allocate resources required to issue FW calls, when sysfs is 880 * Allocate resources required to issue FW calls, when sysfs is
875 * accessed 881 * accessed
876 */ 882 */
877 if (megaraid_sysfs_alloc_resources(adapter) != 0) { 883 if (megaraid_sysfs_alloc_resources(adapter) != 0)
878 goto out_alloc_cmds; 884 goto out_free_irq;
879 }
880 885
881 // Set the DMA mask to 64-bit. All supported controllers as capable of 886 // Set the DMA mask to 64-bit. All supported controllers as capable of
882 // DMA in this range 887 // DMA in this range
@@ -920,10 +925,10 @@ megaraid_init_mbox(adapter_t *adapter)
920 925
921out_free_sysfs_res: 926out_free_sysfs_res:
922 megaraid_sysfs_free_resources(adapter); 927 megaraid_sysfs_free_resources(adapter);
923out_alloc_cmds:
924 megaraid_free_cmd_packets(adapter);
925out_free_irq: 928out_free_irq:
926 free_irq(adapter->irq, adapter); 929 free_irq(adapter->irq, adapter);
930out_alloc_cmds:
931 megaraid_free_cmd_packets(adapter);
927out_iounmap: 932out_iounmap:
928 iounmap(raid_dev->baseaddr); 933 iounmap(raid_dev->baseaddr);
929out_release_regions: 934out_release_regions:
@@ -937,7 +942,7 @@ out_free_raid_dev:
937 942
938/** 943/**
939 * megaraid_fini_mbox - undo controller initialization 944 * megaraid_fini_mbox - undo controller initialization
940 * @param adapter : our soft state 945 * @adapter : our soft state
941 */ 946 */
942static void 947static void
943megaraid_fini_mbox(adapter_t *adapter) 948megaraid_fini_mbox(adapter_t *adapter)
@@ -967,12 +972,12 @@ megaraid_fini_mbox(adapter_t *adapter)
967 972
968/** 973/**
969 * megaraid_alloc_cmd_packets - allocate shared mailbox 974 * megaraid_alloc_cmd_packets - allocate shared mailbox
970 * @param adapter : soft state of the raid controller 975 * @adapter : soft state of the raid controller
971 * 976 *
972 * Allocate and align the shared mailbox. This maibox is used to issue 977 * Allocate and align the shared mailbox. This maibox is used to issue
973 * all the commands. For IO based controllers, the mailbox is also regsitered 978 * all the commands. For IO based controllers, the mailbox is also regsitered
974 * with the FW. Allocate memory for all commands as well. 979 * with the FW. Allocate memory for all commands as well.
975 * This is our big allocator 980 * This is our big allocator.
976 */ 981 */
977static int 982static int
978megaraid_alloc_cmd_packets(adapter_t *adapter) 983megaraid_alloc_cmd_packets(adapter_t *adapter)
@@ -1132,9 +1137,9 @@ out_free_common_mbox:
1132 1137
1133/** 1138/**
1134 * megaraid_free_cmd_packets - free memory 1139 * megaraid_free_cmd_packets - free memory
1135 * @param adapter : soft state of the raid controller 1140 * @adapter : soft state of the raid controller
1136 * 1141 *
1137 * Release memory resources allocated for commands 1142 * Release memory resources allocated for commands.
1138 */ 1143 */
1139static void 1144static void
1140megaraid_free_cmd_packets(adapter_t *adapter) 1145megaraid_free_cmd_packets(adapter_t *adapter)
@@ -1156,10 +1161,10 @@ megaraid_free_cmd_packets(adapter_t *adapter)
1156 1161
1157/** 1162/**
1158 * megaraid_mbox_setup_dma_pools - setup dma pool for command packets 1163 * megaraid_mbox_setup_dma_pools - setup dma pool for command packets
1159 * @param adapter : HBA soft state 1164 * @adapter : HBA soft state
1160 * 1165 *
1161 * setup the dma pools for mailbox, passthru and extended passthru structures, 1166 * Setup the dma pools for mailbox, passthru and extended passthru structures,
1162 * and scatter-gather lists 1167 * and scatter-gather lists.
1163 */ 1168 */
1164static int 1169static int
1165megaraid_mbox_setup_dma_pools(adapter_t *adapter) 1170megaraid_mbox_setup_dma_pools(adapter_t *adapter)
@@ -1252,10 +1257,10 @@ fail_setup_dma_pool:
1252 1257
1253/** 1258/**
1254 * megaraid_mbox_teardown_dma_pools - teardown dma pools for command packets 1259 * megaraid_mbox_teardown_dma_pools - teardown dma pools for command packets
1255 * @param adapter : HBA soft state 1260 * @adapter : HBA soft state
1256 * 1261 *
1257 * teardown the dma pool for mailbox, passthru and extended passthru 1262 * Teardown the dma pool for mailbox, passthru and extended passthru
1258 * structures, and scatter-gather lists 1263 * structures, and scatter-gather lists.
1259 */ 1264 */
1260static void 1265static void
1261megaraid_mbox_teardown_dma_pools(adapter_t *adapter) 1266megaraid_mbox_teardown_dma_pools(adapter_t *adapter)
@@ -1300,10 +1305,11 @@ megaraid_mbox_teardown_dma_pools(adapter_t *adapter)
1300/** 1305/**
1301 * megaraid_alloc_scb - detach and return a scb from the free list 1306 * megaraid_alloc_scb - detach and return a scb from the free list
1302 * @adapter : controller's soft state 1307 * @adapter : controller's soft state
1308 * @scp : pointer to the scsi command to be executed
1303 * 1309 *
1304 * return the scb from the head of the free list. NULL if there are none 1310 * Return the scb from the head of the free list. %NULL if there are none
1305 * available 1311 * available.
1306 **/ 1312 */
1307static scb_t * 1313static scb_t *
1308megaraid_alloc_scb(adapter_t *adapter, struct scsi_cmnd *scp) 1314megaraid_alloc_scb(adapter_t *adapter, struct scsi_cmnd *scp)
1309{ 1315{
@@ -1337,11 +1343,11 @@ megaraid_alloc_scb(adapter_t *adapter, struct scsi_cmnd *scp)
1337 * @adapter : controller's soft state 1343 * @adapter : controller's soft state
1338 * @scb : scb to be freed 1344 * @scb : scb to be freed
1339 * 1345 *
1340 * return the scb back to the free list of scbs. The caller must 'flush' the 1346 * Return the scb back to the free list of scbs. The caller must 'flush' the
1341 * SCB before calling us. E.g., performing pci_unamp and/or pci_sync etc. 1347 * SCB before calling us. E.g., performing pci_unamp and/or pci_sync etc.
1342 * NOTE NOTE: Make sure the scb is not on any list before calling this 1348 * NOTE NOTE: Make sure the scb is not on any list before calling this
1343 * routine. 1349 * routine.
1344 **/ 1350 */
1345static inline void 1351static inline void
1346megaraid_dealloc_scb(adapter_t *adapter, scb_t *scb) 1352megaraid_dealloc_scb(adapter_t *adapter, scb_t *scb)
1347{ 1353{
@@ -1362,10 +1368,10 @@ megaraid_dealloc_scb(adapter_t *adapter, scb_t *scb)
1362 1368
1363/** 1369/**
1364 * megaraid_mbox_mksgl - make the scatter-gather list 1370 * megaraid_mbox_mksgl - make the scatter-gather list
1365 * @adapter - controller's soft state 1371 * @adapter : controller's soft state
1366 * @scb - scsi control block 1372 * @scb : scsi control block
1367 * 1373 *
1368 * prepare the scatter-gather list 1374 * Prepare the scatter-gather list.
1369 */ 1375 */
1370static int 1376static int
1371megaraid_mbox_mksgl(adapter_t *adapter, scb_t *scb) 1377megaraid_mbox_mksgl(adapter_t *adapter, scb_t *scb)
@@ -1435,10 +1441,10 @@ megaraid_mbox_mksgl(adapter_t *adapter, scb_t *scb)
1435 1441
1436/** 1442/**
1437 * mbox_post_cmd - issue a mailbox command 1443 * mbox_post_cmd - issue a mailbox command
1438 * @adapter - controller's soft state 1444 * @adapter : controller's soft state
1439 * @scb - command to be issued 1445 * @scb : command to be issued
1440 * 1446 *
1441 * post the command to the controller if mailbox is availble. 1447 * Post the command to the controller if mailbox is available.
1442 */ 1448 */
1443static int 1449static int
1444mbox_post_cmd(adapter_t *adapter, scb_t *scb) 1450mbox_post_cmd(adapter_t *adapter, scb_t *scb)
@@ -1518,7 +1524,7 @@ mbox_post_cmd(adapter_t *adapter, scb_t *scb)
1518 * Queue entry point for mailbox based controllers. 1524 * Queue entry point for mailbox based controllers.
1519 */ 1525 */
1520static int 1526static int
1521megaraid_queue_command(struct scsi_cmnd *scp, void (* done)(struct scsi_cmnd *)) 1527megaraid_queue_command(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
1522{ 1528{
1523 adapter_t *adapter; 1529 adapter_t *adapter;
1524 scb_t *scb; 1530 scb_t *scb;
@@ -1548,15 +1554,15 @@ megaraid_queue_command(struct scsi_cmnd *scp, void (* done)(struct scsi_cmnd *))
1548} 1554}
1549 1555
1550/** 1556/**
1551 * megaraid_mbox_build_cmd - transform the mid-layer scsi command to megaraid 1557 * megaraid_mbox_build_cmd - transform the mid-layer scsi commands
1552 * firmware lingua 1558 * @adapter : controller's soft state
1553 * @adapter - controller's soft state 1559 * @scp : mid-layer scsi command pointer
1554 * @scp - mid-layer scsi command pointer 1560 * @busy : set if request could not be completed because of lack of
1555 * @busy - set if request could not be completed because of lack of
1556 * resources 1561 * resources
1557 * 1562 *
1558 * convert the command issued by mid-layer to format understood by megaraid 1563 * Transform the mid-layer scsi command to megaraid firmware lingua.
1559 * firmware. We also complete certain command without sending them to firmware 1564 * Convert the command issued by mid-layer to format understood by megaraid
1565 * firmware. We also complete certain commands without sending them to firmware.
1560 */ 1566 */
1561static scb_t * 1567static scb_t *
1562megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) 1568megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
@@ -1937,9 +1943,9 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
1937/** 1943/**
1938 * megaraid_mbox_runpendq - execute commands queued in the pending queue 1944 * megaraid_mbox_runpendq - execute commands queued in the pending queue
1939 * @adapter : controller's soft state 1945 * @adapter : controller's soft state
1940 * @scb : SCB to be queued in the pending list 1946 * @scb_q : SCB to be queued in the pending list
1941 * 1947 *
1942 * scan the pending list for commands which are not yet issued and try to 1948 * Scan the pending list for commands which are not yet issued and try to
1943 * post to the controller. The SCB can be a null pointer, which would indicate 1949 * post to the controller. The SCB can be a null pointer, which would indicate
1944 * no SCB to be queue, just try to execute the ones in the pending list. 1950 * no SCB to be queue, just try to execute the ones in the pending list.
1945 * 1951 *
@@ -2012,11 +2018,11 @@ megaraid_mbox_runpendq(adapter_t *adapter, scb_t *scb_q)
2012 2018
2013/** 2019/**
2014 * megaraid_mbox_prepare_pthru - prepare a command for physical devices 2020 * megaraid_mbox_prepare_pthru - prepare a command for physical devices
2015 * @adapter - pointer to controller's soft state 2021 * @adapter : pointer to controller's soft state
2016 * @scb - scsi control block 2022 * @scb : scsi control block
2017 * @scp - scsi command from the mid-layer 2023 * @scp : scsi command from the mid-layer
2018 * 2024 *
2019 * prepare a command for the scsi physical devices 2025 * Prepare a command for the scsi physical devices.
2020 */ 2026 */
2021static void 2027static void
2022megaraid_mbox_prepare_pthru(adapter_t *adapter, scb_t *scb, 2028megaraid_mbox_prepare_pthru(adapter_t *adapter, scb_t *scb,
@@ -2060,12 +2066,12 @@ megaraid_mbox_prepare_pthru(adapter_t *adapter, scb_t *scb,
2060 2066
2061/** 2067/**
2062 * megaraid_mbox_prepare_epthru - prepare a command for physical devices 2068 * megaraid_mbox_prepare_epthru - prepare a command for physical devices
2063 * @adapter - pointer to controller's soft state 2069 * @adapter : pointer to controller's soft state
2064 * @scb - scsi control block 2070 * @scb : scsi control block
2065 * @scp - scsi command from the mid-layer 2071 * @scp : scsi command from the mid-layer
2066 * 2072 *
2067 * prepare a command for the scsi physical devices. This rountine prepares 2073 * Prepare a command for the scsi physical devices. This rountine prepares
2068 * commands for devices which can take extended CDBs (>10 bytes) 2074 * commands for devices which can take extended CDBs (>10 bytes).
2069 */ 2075 */
2070static void 2076static void
2071megaraid_mbox_prepare_epthru(adapter_t *adapter, scb_t *scb, 2077megaraid_mbox_prepare_epthru(adapter_t *adapter, scb_t *scb,
@@ -2109,9 +2115,9 @@ megaraid_mbox_prepare_epthru(adapter_t *adapter, scb_t *scb,
2109 2115
2110/** 2116/**
2111 * megaraid_ack_sequence - interrupt ack sequence for memory mapped HBAs 2117 * megaraid_ack_sequence - interrupt ack sequence for memory mapped HBAs
2112 * @adapter - controller's soft state 2118 * @adapter : controller's soft state
2113 * 2119 *
2114 * Interrupt ackrowledgement sequence for memory mapped HBAs. Find out the 2120 * Interrupt acknowledgement sequence for memory mapped HBAs. Find out the
2115 * completed command and put them on the completed list for later processing. 2121 * completed command and put them on the completed list for later processing.
2116 * 2122 *
2117 * Returns: 1 if the interrupt is valid, 0 otherwise 2123 * Returns: 1 if the interrupt is valid, 0 otherwise
@@ -2224,9 +2230,8 @@ megaraid_ack_sequence(adapter_t *adapter)
2224 2230
2225/** 2231/**
2226 * megaraid_isr - isr for memory based mailbox based controllers 2232 * megaraid_isr - isr for memory based mailbox based controllers
2227 * @irq - irq 2233 * @irq : irq
2228 * @devp - pointer to our soft state 2234 * @devp : pointer to our soft state
2229 * @regs - unused
2230 * 2235 *
2231 * Interrupt service routine for memory-mapped mailbox controllers. 2236 * Interrupt service routine for memory-mapped mailbox controllers.
2232 */ 2237 */
@@ -2671,7 +2676,7 @@ megaraid_abort_handler(struct scsi_cmnd *scp)
2671 * the FW is still live, in which case the outstanding commands counter mut go 2676 * the FW is still live, in which case the outstanding commands counter mut go
2672 * down to 0. If that happens, also issue the reservation reset command to 2677 * down to 0. If that happens, also issue the reservation reset command to
2673 * relinquish (possible) reservations on the logical drives connected to this 2678 * relinquish (possible) reservations on the logical drives connected to this
2674 * host 2679 * host.
2675 **/ 2680 **/
2676static int 2681static int
2677megaraid_reset_handler(struct scsi_cmnd *scp) 2682megaraid_reset_handler(struct scsi_cmnd *scp)
@@ -2823,11 +2828,11 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
2823 2828
2824/** 2829/**
2825 * mbox_post_sync_cmd() - blocking command to the mailbox based controllers 2830 * mbox_post_sync_cmd() - blocking command to the mailbox based controllers
2826 * @adapter - controller's soft state 2831 * @adapter : controller's soft state
2827 * @raw_mbox - the mailbox 2832 * @raw_mbox : the mailbox
2828 * 2833 *
2829 * Issue a scb in synchronous and non-interrupt mode for mailbox based 2834 * Issue a scb in synchronous and non-interrupt mode for mailbox based
2830 * controllers 2835 * controllers.
2831 */ 2836 */
2832static int 2837static int
2833mbox_post_sync_cmd(adapter_t *adapter, uint8_t raw_mbox[]) 2838mbox_post_sync_cmd(adapter_t *adapter, uint8_t raw_mbox[])
@@ -2955,12 +2960,12 @@ blocked_mailbox:
2955 2960
2956/** 2961/**
2957 * mbox_post_sync_cmd_fast - blocking command to the mailbox based controllers 2962 * mbox_post_sync_cmd_fast - blocking command to the mailbox based controllers
2958 * @adapter - controller's soft state 2963 * @adapter : controller's soft state
2959 * @raw_mbox - the mailbox 2964 * @raw_mbox : the mailbox
2960 * 2965 *
2961 * Issue a scb in synchronous and non-interrupt mode for mailbox based 2966 * Issue a scb in synchronous and non-interrupt mode for mailbox based
2962 * controllers. This is a faster version of the synchronous command and 2967 * controllers. This is a faster version of the synchronous command and
2963 * therefore can be called in interrupt-context as well 2968 * therefore can be called in interrupt-context as well.
2964 */ 2969 */
2965static int 2970static int
2966mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[]) 2971mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[])
@@ -3008,10 +3013,10 @@ mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[])
3008 3013
3009/** 3014/**
3010 * megaraid_busywait_mbox() - Wait until the controller's mailbox is available 3015 * megaraid_busywait_mbox() - Wait until the controller's mailbox is available
3011 * @raid_dev - RAID device (HBA) soft state 3016 * @raid_dev : RAID device (HBA) soft state
3012 * 3017 *
3013 * wait until the controller's mailbox is available to accept more commands. 3018 * Wait until the controller's mailbox is available to accept more commands.
3014 * wait for at most 1 second 3019 * Wait for at most 1 second.
3015 */ 3020 */
3016static int 3021static int
3017megaraid_busywait_mbox(mraid_device_t *raid_dev) 3022megaraid_busywait_mbox(mraid_device_t *raid_dev)
@@ -3032,9 +3037,9 @@ megaraid_busywait_mbox(mraid_device_t *raid_dev)
3032 3037
3033/** 3038/**
3034 * megaraid_mbox_product_info - some static information about the controller 3039 * megaraid_mbox_product_info - some static information about the controller
3035 * @adapter - our soft state 3040 * @adapter : our soft state
3036 * 3041 *
3037 * issue commands to the controller to grab some parameters required by our 3042 * Issue commands to the controller to grab some parameters required by our
3038 * caller. 3043 * caller.
3039 */ 3044 */
3040static int 3045static int
@@ -3157,10 +3162,10 @@ megaraid_mbox_product_info(adapter_t *adapter)
3157 3162
3158/** 3163/**
3159 * megaraid_mbox_extended_cdb - check for support for extended CDBs 3164 * megaraid_mbox_extended_cdb - check for support for extended CDBs
3160 * @adapter - soft state for the controller 3165 * @adapter : soft state for the controller
3161 * 3166 *
3162 * this routine check whether the controller in question supports extended 3167 * This routine check whether the controller in question supports extended
3163 * ( > 10 bytes ) CDBs 3168 * ( > 10 bytes ) CDBs.
3164 */ 3169 */
3165static int 3170static int
3166megaraid_mbox_extended_cdb(adapter_t *adapter) 3171megaraid_mbox_extended_cdb(adapter_t *adapter)
@@ -3193,8 +3198,8 @@ megaraid_mbox_extended_cdb(adapter_t *adapter)
3193 3198
3194/** 3199/**
3195 * megaraid_mbox_support_ha - Do we support clustering 3200 * megaraid_mbox_support_ha - Do we support clustering
3196 * @adapter - soft state for the controller 3201 * @adapter : soft state for the controller
3197 * @init_id - ID of the initiator 3202 * @init_id : ID of the initiator
3198 * 3203 *
3199 * Determine if the firmware supports clustering and the ID of the initiator. 3204 * Determine if the firmware supports clustering and the ID of the initiator.
3200 */ 3205 */
@@ -3236,9 +3241,9 @@ megaraid_mbox_support_ha(adapter_t *adapter, uint16_t *init_id)
3236 3241
3237/** 3242/**
3238 * megaraid_mbox_support_random_del - Do we support random deletion 3243 * megaraid_mbox_support_random_del - Do we support random deletion
3239 * @adapter - soft state for the controller 3244 * @adapter : soft state for the controller
3240 * 3245 *
3241 * Determine if the firmware supports random deletion 3246 * Determine if the firmware supports random deletion.
3242 * Return: 1 is operation supported, 0 otherwise 3247 * Return: 1 is operation supported, 0 otherwise
3243 */ 3248 */
3244static int 3249static int
@@ -3271,10 +3276,10 @@ megaraid_mbox_support_random_del(adapter_t *adapter)
3271 3276
3272/** 3277/**
3273 * megaraid_mbox_get_max_sg - maximum sg elements supported by the firmware 3278 * megaraid_mbox_get_max_sg - maximum sg elements supported by the firmware
3274 * @adapter - soft state for the controller 3279 * @adapter : soft state for the controller
3275 * 3280 *
3276 * Find out the maximum number of scatter-gather elements supported by the 3281 * Find out the maximum number of scatter-gather elements supported by the
3277 * firmware 3282 * firmware.
3278 */ 3283 */
3279static int 3284static int
3280megaraid_mbox_get_max_sg(adapter_t *adapter) 3285megaraid_mbox_get_max_sg(adapter_t *adapter)
@@ -3311,10 +3316,10 @@ megaraid_mbox_get_max_sg(adapter_t *adapter)
3311 3316
3312/** 3317/**
3313 * megaraid_mbox_enum_raid_scsi - enumerate the RAID and SCSI channels 3318 * megaraid_mbox_enum_raid_scsi - enumerate the RAID and SCSI channels
3314 * @adapter - soft state for the controller 3319 * @adapter : soft state for the controller
3315 * 3320 *
3316 * Enumerate the RAID and SCSI channels for ROMB platoforms so that channels 3321 * Enumerate the RAID and SCSI channels for ROMB platforms so that channels
3317 * can be exported as regular SCSI channels 3322 * can be exported as regular SCSI channels.
3318 */ 3323 */
3319static void 3324static void
3320megaraid_mbox_enum_raid_scsi(adapter_t *adapter) 3325megaraid_mbox_enum_raid_scsi(adapter_t *adapter)
@@ -3348,9 +3353,9 @@ megaraid_mbox_enum_raid_scsi(adapter_t *adapter)
3348 3353
3349/** 3354/**
3350 * megaraid_mbox_flush_cache - flush adapter and disks cache 3355 * megaraid_mbox_flush_cache - flush adapter and disks cache
3351 * @param adapter : soft state for the controller 3356 * @adapter : soft state for the controller
3352 * 3357 *
3353 * Flush adapter cache followed by disks cache 3358 * Flush adapter cache followed by disks cache.
3354 */ 3359 */
3355static void 3360static void
3356megaraid_mbox_flush_cache(adapter_t *adapter) 3361megaraid_mbox_flush_cache(adapter_t *adapter)
@@ -3380,13 +3385,91 @@ megaraid_mbox_flush_cache(adapter_t *adapter)
3380 3385
3381 3386
3382/** 3387/**
3388 * megaraid_mbox_fire_sync_cmd - fire the sync cmd
3389 * @adapter : soft state for the controller
3390 *
3391 * Clears the pending cmds in FW and reinits its RAID structs.
3392 */
3393static int
3394megaraid_mbox_fire_sync_cmd(adapter_t *adapter)
3395{
3396 mbox_t *mbox;
3397 uint8_t raw_mbox[sizeof(mbox_t)];
3398 mraid_device_t *raid_dev = ADAP2RAIDDEV(adapter);
3399 mbox64_t *mbox64;
3400 int status = 0;
3401 int i;
3402 uint32_t dword;
3403
3404 mbox = (mbox_t *)raw_mbox;
3405
3406 memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
3407
3408 raw_mbox[0] = 0xFF;
3409
3410 mbox64 = raid_dev->mbox64;
3411 mbox = raid_dev->mbox;
3412
3413 /* Wait until mailbox is free */
3414 if (megaraid_busywait_mbox(raid_dev) != 0) {
3415 status = 1;
3416 goto blocked_mailbox;
3417 }
3418
3419 /* Copy mailbox data into host structure */
3420 memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
3421 mbox->cmdid = 0xFE;
3422 mbox->busy = 1;
3423 mbox->poll = 0;
3424 mbox->ack = 0;
3425 mbox->numstatus = 0;
3426 mbox->status = 0;
3427
3428 wmb();
3429 WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
3430
3431 /* Wait for maximum 1 min for status to post.
3432 * If the Firmware SUPPORTS the ABOVE COMMAND,
3433 * mbox->cmd will be set to 0
3434 * else
3435 * the firmware will reject the command with
3436 * mbox->numstatus set to 1
3437 */
3438
3439 i = 0;
3440 status = 0;
3441 while (!mbox->numstatus && mbox->cmd == 0xFF) {
3442 rmb();
3443 msleep(1);
3444 i++;
3445 if (i > 1000 * 60) {
3446 status = 1;
3447 break;
3448 }
3449 }
3450 if (mbox->numstatus == 1)
3451 status = 1; /*cmd not supported*/
3452
3453 /* Check for interrupt line */
3454 dword = RDOUTDOOR(raid_dev);
3455 WROUTDOOR(raid_dev, dword);
3456 WRINDOOR(raid_dev,2);
3457
3458 return status;
3459
3460blocked_mailbox:
3461 con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
3462 return status;
3463}
3464
3465/**
3383 * megaraid_mbox_display_scb - display SCB information, mostly debug purposes 3466 * megaraid_mbox_display_scb - display SCB information, mostly debug purposes
3384 * @param adapter : controllers' soft state 3467 * @adapter : controller's soft state
3385 * @param scb : SCB to be displayed 3468 * @scb : SCB to be displayed
3386 * @param level : debug level for console print 3469 * @level : debug level for console print
3387 * 3470 *
3388 * Diplay information about the given SCB iff the current debug level is 3471 * Diplay information about the given SCB iff the current debug level is
3389 * verbose 3472 * verbose.
3390 */ 3473 */
3391static void 3474static void
3392megaraid_mbox_display_scb(adapter_t *adapter, scb_t *scb) 3475megaraid_mbox_display_scb(adapter_t *adapter, scb_t *scb)
@@ -3434,7 +3517,7 @@ megaraid_mbox_display_scb(adapter_t *adapter, scb_t *scb)
3434 * scsi addresses and megaraid scsi and logical drive addresses. We export 3517 * scsi addresses and megaraid scsi and logical drive addresses. We export
3435 * scsi devices on their actual addresses, whereas the logical drives are 3518 * scsi devices on their actual addresses, whereas the logical drives are
3436 * exported on a virtual scsi channel. 3519 * exported on a virtual scsi channel.
3437 **/ 3520 */
3438static void 3521static void
3439megaraid_mbox_setup_device_map(adapter_t *adapter) 3522megaraid_mbox_setup_device_map(adapter_t *adapter)
3440{ 3523{
@@ -3472,7 +3555,7 @@ megaraid_mbox_setup_device_map(adapter_t *adapter)
3472 3555
3473/** 3556/**
3474 * megaraid_cmm_register - register with the mangement module 3557 * megaraid_cmm_register - register with the mangement module
3475 * @param adapter : HBA soft state 3558 * @adapter : HBA soft state
3476 * 3559 *
3477 * Register with the management module, which allows applications to issue 3560 * Register with the management module, which allows applications to issue
3478 * ioctl calls to the drivers. This interface is used by the management module 3561 * ioctl calls to the drivers. This interface is used by the management module
@@ -3562,11 +3645,11 @@ megaraid_cmm_register(adapter_t *adapter)
3562 3645
3563/** 3646/**
3564 * megaraid_cmm_unregister - un-register with the mangement module 3647 * megaraid_cmm_unregister - un-register with the mangement module
3565 * @param adapter : HBA soft state 3648 * @adapter : HBA soft state
3566 * 3649 *
3567 * Un-register with the management module. 3650 * Un-register with the management module.
3568 * FIXME: mgmt module must return failure for unregister if it has pending 3651 * FIXME: mgmt module must return failure for unregister if it has pending
3569 * commands in LLD 3652 * commands in LLD.
3570 */ 3653 */
3571static int 3654static int
3572megaraid_cmm_unregister(adapter_t *adapter) 3655megaraid_cmm_unregister(adapter_t *adapter)
@@ -3579,9 +3662,9 @@ megaraid_cmm_unregister(adapter_t *adapter)
3579 3662
3580/** 3663/**
3581 * megaraid_mbox_mm_handler - interface for CMM to issue commands to LLD 3664 * megaraid_mbox_mm_handler - interface for CMM to issue commands to LLD
3582 * @param drvr_data : LLD specific data 3665 * @drvr_data : LLD specific data
3583 * @param kioc : CMM interface packet 3666 * @kioc : CMM interface packet
3584 * @param action : command action 3667 * @action : command action
3585 * 3668 *
3586 * This routine is invoked whenever the Common Mangement Module (CMM) has a 3669 * This routine is invoked whenever the Common Mangement Module (CMM) has a
3587 * command for us. The 'action' parameter specifies if this is a new command 3670 * command for us. The 'action' parameter specifies if this is a new command
@@ -3634,8 +3717,8 @@ megaraid_mbox_mm_handler(unsigned long drvr_data, uioc_t *kioc, uint32_t action)
3634 3717
3635/** 3718/**
3636 * megaraid_mbox_mm_command - issues commands routed through CMM 3719 * megaraid_mbox_mm_command - issues commands routed through CMM
3637 * @param adapter : HBA soft state 3720 * @adapter : HBA soft state
3638 * @param kioc : management command packet 3721 * @kioc : management command packet
3639 * 3722 *
3640 * Issues commands, which are routed through the management module. 3723 * Issues commands, which are routed through the management module.
3641 */ 3724 */
@@ -3804,8 +3887,8 @@ megaraid_mbox_mm_done(adapter_t *adapter, scb_t *scb)
3804 3887
3805/** 3888/**
3806 * gather_hbainfo - HBA characteristics for the applications 3889 * gather_hbainfo - HBA characteristics for the applications
3807 * @param adapter : HBA soft state 3890 * @adapter : HBA soft state
3808 * @param hinfo : pointer to the caller's host info strucuture 3891 * @hinfo : pointer to the caller's host info strucuture
3809 */ 3892 */
3810static int 3893static int
3811gather_hbainfo(adapter_t *adapter, mraid_hba_info_t *hinfo) 3894gather_hbainfo(adapter_t *adapter, mraid_hba_info_t *hinfo)
@@ -3839,16 +3922,15 @@ gather_hbainfo(adapter_t *adapter, mraid_hba_info_t *hinfo)
3839 3922
3840/** 3923/**
3841 * megaraid_sysfs_alloc_resources - allocate sysfs related resources 3924 * megaraid_sysfs_alloc_resources - allocate sysfs related resources
3925 * @adapter : controller's soft state
3842 * 3926 *
3843 * Allocate packets required to issue FW calls whenever the sysfs attributes 3927 * Allocate packets required to issue FW calls whenever the sysfs attributes
3844 * are read. These attributes would require up-to-date information from the 3928 * are read. These attributes would require up-to-date information from the
3845 * FW. Also set up resources for mutual exclusion to share these resources and 3929 * FW. Also set up resources for mutual exclusion to share these resources and
3846 * the wait queue. 3930 * the wait queue.
3847 * 3931 *
3848 * @param adapter : controller's soft state 3932 * Return 0 on success.
3849 * 3933 * Return -ERROR_CODE on failure.
3850 * @return 0 on success
3851 * @return -ERROR_CODE on failure
3852 */ 3934 */
3853static int 3935static int
3854megaraid_sysfs_alloc_resources(adapter_t *adapter) 3936megaraid_sysfs_alloc_resources(adapter_t *adapter)
@@ -3885,10 +3967,9 @@ megaraid_sysfs_alloc_resources(adapter_t *adapter)
3885 3967
3886/** 3968/**
3887 * megaraid_sysfs_free_resources - free sysfs related resources 3969 * megaraid_sysfs_free_resources - free sysfs related resources
3970 * @adapter : controller's soft state
3888 * 3971 *
3889 * Free packets allocated for sysfs FW commands 3972 * Free packets allocated for sysfs FW commands
3890 *
3891 * @param adapter : controller's soft state
3892 */ 3973 */
3893static void 3974static void
3894megaraid_sysfs_free_resources(adapter_t *adapter) 3975megaraid_sysfs_free_resources(adapter_t *adapter)
@@ -3907,10 +3988,9 @@ megaraid_sysfs_free_resources(adapter_t *adapter)
3907 3988
3908/** 3989/**
3909 * megaraid_sysfs_get_ldmap_done - callback for get ldmap 3990 * megaraid_sysfs_get_ldmap_done - callback for get ldmap
3991 * @uioc : completed packet
3910 * 3992 *
3911 * Callback routine called in the ISR/tasklet context for get ldmap call 3993 * Callback routine called in the ISR/tasklet context for get ldmap call
3912 *
3913 * @param uioc : completed packet
3914 */ 3994 */
3915static void 3995static void
3916megaraid_sysfs_get_ldmap_done(uioc_t *uioc) 3996megaraid_sysfs_get_ldmap_done(uioc_t *uioc)
@@ -3926,12 +4006,11 @@ megaraid_sysfs_get_ldmap_done(uioc_t *uioc)
3926 4006
3927/** 4007/**
3928 * megaraid_sysfs_get_ldmap_timeout - timeout handling for get ldmap 4008 * megaraid_sysfs_get_ldmap_timeout - timeout handling for get ldmap
4009 * @data : timed out packet
3929 * 4010 *
3930 * Timeout routine to recover and return to application, in case the adapter 4011 * Timeout routine to recover and return to application, in case the adapter
3931 * has stopped responding. A timeout of 60 seconds for this command seem like 4012 * has stopped responding. A timeout of 60 seconds for this command seems like
3932 * a good value 4013 * a good value.
3933 *
3934 * @param uioc : timed out packet
3935 */ 4014 */
3936static void 4015static void
3937megaraid_sysfs_get_ldmap_timeout(unsigned long data) 4016megaraid_sysfs_get_ldmap_timeout(unsigned long data)
@@ -3948,6 +4027,7 @@ megaraid_sysfs_get_ldmap_timeout(unsigned long data)
3948 4027
3949/** 4028/**
3950 * megaraid_sysfs_get_ldmap - get update logical drive map 4029 * megaraid_sysfs_get_ldmap - get update logical drive map
4030 * @adapter : controller's soft state
3951 * 4031 *
3952 * This routine will be called whenever user reads the logical drive 4032 * This routine will be called whenever user reads the logical drive
3953 * attributes, go get the current logical drive mapping table from the 4033 * attributes, go get the current logical drive mapping table from the
@@ -3959,10 +4039,8 @@ megaraid_sysfs_get_ldmap_timeout(unsigned long data)
3959 * standalone libary. For now, this should suffice since there is no other 4039 * standalone libary. For now, this should suffice since there is no other
3960 * user of this interface. 4040 * user of this interface.
3961 * 4041 *
3962 * @param adapter : controller's soft state 4042 * Return 0 on success.
3963 * 4043 * Return -1 on failure.
3964 * @return 0 on success
3965 * @return -1 on failure
3966 */ 4044 */
3967static int 4045static int
3968megaraid_sysfs_get_ldmap(adapter_t *adapter) 4046megaraid_sysfs_get_ldmap(adapter_t *adapter)
@@ -4064,13 +4142,12 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
4064 4142
4065/** 4143/**
4066 * megaraid_sysfs_show_app_hndl - display application handle for this adapter 4144 * megaraid_sysfs_show_app_hndl - display application handle for this adapter
4145 * @cdev : class device object representation for the host
4146 * @buf : buffer to send data to
4067 * 4147 *
4068 * Display the handle used by the applications while executing management 4148 * Display the handle used by the applications while executing management
4069 * tasks on the adapter. We invoke a management module API to get the adapter 4149 * tasks on the adapter. We invoke a management module API to get the adapter
4070 * handle, since we do not interface with applications directly. 4150 * handle, since we do not interface with applications directly.
4071 *
4072 * @param cdev : class device object representation for the host
4073 * @param buf : buffer to send data to
4074 */ 4151 */
4075static ssize_t 4152static ssize_t
4076megaraid_sysfs_show_app_hndl(struct class_device *cdev, char *buf) 4153megaraid_sysfs_show_app_hndl(struct class_device *cdev, char *buf)
@@ -4087,16 +4164,18 @@ megaraid_sysfs_show_app_hndl(struct class_device *cdev, char *buf)
4087 4164
4088/** 4165/**
4089 * megaraid_sysfs_show_ldnum - display the logical drive number for this device 4166 * megaraid_sysfs_show_ldnum - display the logical drive number for this device
4167 * @dev : device object representation for the scsi device
4168 * @attr : device attribute to show
4169 * @buf : buffer to send data to
4090 * 4170 *
4091 * Display the logical drive number for the device in question, if it a valid 4171 * Display the logical drive number for the device in question, if it a valid
4092 * logical drive. For physical devices, "-1" is returned 4172 * logical drive. For physical devices, "-1" is returned.
4093 * The logical drive number is displayed in following format 4173 *
4174 * The logical drive number is displayed in following format:
4094 * 4175 *
4095 * <SCSI ID> <LD NUM> <LD STICKY ID> <APP ADAPTER HANDLE> 4176 * <SCSI ID> <LD NUM> <LD STICKY ID> <APP ADAPTER HANDLE>
4096 * <int> <int> <int> <int>
4097 * 4177 *
4098 * @param dev : device object representation for the scsi device 4178 * <int> <int> <int> <int>
4099 * @param buf : buffer to send data to
4100 */ 4179 */
4101static ssize_t 4180static ssize_t
4102megaraid_sysfs_show_ldnum(struct device *dev, struct device_attribute *attr, char *buf) 4181megaraid_sysfs_show_ldnum(struct device *dev, struct device_attribute *attr, char *buf)
diff --git a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h
index 2b5a3285f799..9de803cebd4b 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.h
+++ b/drivers/scsi/megaraid/megaraid_mbox.h
@@ -21,8 +21,8 @@
21#include "megaraid_ioctl.h" 21#include "megaraid_ioctl.h"
22 22
23 23
24#define MEGARAID_VERSION "2.20.4.9" 24#define MEGARAID_VERSION "2.20.5.1"
25#define MEGARAID_EXT_VERSION "(Release Date: Sun Jul 16 12:27:22 EST 2006)" 25#define MEGARAID_EXT_VERSION "(Release Date: Thu Nov 16 15:32:35 EST 2006)"
26 26
27 27
28/* 28/*
@@ -146,27 +146,27 @@ typedef struct {
146 146
147/** 147/**
148 * mraid_device_t - adapter soft state structure for mailbox controllers 148 * mraid_device_t - adapter soft state structure for mailbox controllers
149 * @param una_mbox64 : 64-bit mbox - unaligned 149 * @una_mbox64 : 64-bit mbox - unaligned
150 * @param una_mbox64_dma : mbox dma addr - unaligned 150 * @una_mbox64_dma : mbox dma addr - unaligned
151 * @param mbox : 32-bit mbox - aligned 151 * @mbox : 32-bit mbox - aligned
152 * @param mbox64 : 64-bit mbox - aligned 152 * @mbox64 : 64-bit mbox - aligned
153 * @param mbox_dma : mbox dma addr - aligned 153 * @mbox_dma : mbox dma addr - aligned
154 * @param mailbox_lock : exclusion lock for the mailbox 154 * @mailbox_lock : exclusion lock for the mailbox
155 * @param baseport : base port of hba memory 155 * @baseport : base port of hba memory
156 * @param baseaddr : mapped addr of hba memory 156 * @baseaddr : mapped addr of hba memory
157 * @param mbox_pool : pool of mailboxes 157 * @mbox_pool : pool of mailboxes
158 * @param mbox_pool_handle : handle for the mailbox pool memory 158 * @mbox_pool_handle : handle for the mailbox pool memory
159 * @param epthru_pool : a pool for extended passthru commands 159 * @epthru_pool : a pool for extended passthru commands
160 * @param epthru_pool_handle : handle to the pool above 160 * @epthru_pool_handle : handle to the pool above
161 * @param sg_pool : pool of scatter-gather lists for this driver 161 * @sg_pool : pool of scatter-gather lists for this driver
162 * @param sg_pool_handle : handle to the pool above 162 * @sg_pool_handle : handle to the pool above
163 * @param ccb_list : list of our command control blocks 163 * @ccb_list : list of our command control blocks
164 * @param uccb_list : list of cmd control blocks for mgmt module 164 * @uccb_list : list of cmd control blocks for mgmt module
165 * @param umbox64 : array of mailbox for user commands (cmm) 165 * @umbox64 : array of mailbox for user commands (cmm)
166 * @param pdrv_state : array for state of each physical drive. 166 * @pdrv_state : array for state of each physical drive.
167 * @param last_disp : flag used to show device scanning 167 * @last_disp : flag used to show device scanning
168 * @param hw_error : set if FW not responding 168 * @hw_error : set if FW not responding
169 * @param fast_load : If set, skip physical device scanning 169 * @fast_load : If set, skip physical device scanning
170 * @channel_class : channel class, RAID or SCSI 170 * @channel_class : channel class, RAID or SCSI
171 * @sysfs_sem : semaphore to serialize access to sysfs res. 171 * @sysfs_sem : semaphore to serialize access to sysfs res.
172 * @sysfs_uioc : management packet to issue FW calls from sysfs 172 * @sysfs_uioc : management packet to issue FW calls from sysfs
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index d85b9a8f1b8d..c1ff20c4747d 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -78,10 +78,10 @@ static struct file_operations lsi_fops = {
78 78
79/** 79/**
80 * mraid_mm_open - open routine for char node interface 80 * mraid_mm_open - open routine for char node interface
81 * @inod : unused 81 * @inode : unused
82 * @filep : unused 82 * @filep : unused
83 * 83 *
84 * allow ioctl operations by apps only if they superuser privilege 84 * Allow ioctl operations by apps only if they have superuser privilege.
85 */ 85 */
86static int 86static int
87mraid_mm_open(struct inode *inode, struct file *filep) 87mraid_mm_open(struct inode *inode, struct file *filep)
@@ -214,7 +214,9 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
214/** 214/**
215 * mraid_mm_get_adapter - Returns corresponding adapters for the mimd packet 215 * mraid_mm_get_adapter - Returns corresponding adapters for the mimd packet
216 * @umimd : User space mimd_t ioctl packet 216 * @umimd : User space mimd_t ioctl packet
217 * @adapter : pointer to the adapter (OUT) 217 * @rval : returned success/error status
218 *
219 * The function return value is a pointer to the located @adapter.
218 */ 220 */
219static mraid_mmadp_t * 221static mraid_mmadp_t *
220mraid_mm_get_adapter(mimd_t __user *umimd, int *rval) 222mraid_mm_get_adapter(mimd_t __user *umimd, int *rval)
@@ -252,11 +254,11 @@ mraid_mm_get_adapter(mimd_t __user *umimd, int *rval)
252 return adapter; 254 return adapter;
253} 255}
254 256
255/* 257/**
256 * handle_drvrcmd - This routine checks if the opcode is a driver 258 * handle_drvrcmd - Checks if the opcode is a driver cmd and if it is, handles it.
257 * cmd and if it is, handles it.
258 * @arg : packet sent by the user app 259 * @arg : packet sent by the user app
259 * @old_ioctl : mimd if 1; uioc otherwise 260 * @old_ioctl : mimd if 1; uioc otherwise
261 * @rval : pointer for command's returned value (not function status)
260 */ 262 */
261static int 263static int
262handle_drvrcmd(void __user *arg, uint8_t old_ioctl, int *rval) 264handle_drvrcmd(void __user *arg, uint8_t old_ioctl, int *rval)
@@ -322,8 +324,8 @@ old_packet:
322 324
323/** 325/**
324 * mimd_to_kioc - Converter from old to new ioctl format 326 * mimd_to_kioc - Converter from old to new ioctl format
325 *
326 * @umimd : user space old MIMD IOCTL 327 * @umimd : user space old MIMD IOCTL
328 * @adp : adapter softstate
327 * @kioc : kernel space new format IOCTL 329 * @kioc : kernel space new format IOCTL
328 * 330 *
329 * Routine to convert MIMD interface IOCTL to new interface IOCTL packet. The 331 * Routine to convert MIMD interface IOCTL to new interface IOCTL packet. The
@@ -474,7 +476,6 @@ mimd_to_kioc(mimd_t __user *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
474 476
475/** 477/**
476 * mraid_mm_attch_buf - Attach a free dma buffer for required size 478 * mraid_mm_attch_buf - Attach a free dma buffer for required size
477 *
478 * @adp : Adapter softstate 479 * @adp : Adapter softstate
479 * @kioc : kioc that the buffer needs to be attached to 480 * @kioc : kioc that the buffer needs to be attached to
480 * @xferlen : required length for buffer 481 * @xferlen : required length for buffer
@@ -607,7 +608,6 @@ mraid_mm_alloc_kioc(mraid_mmadp_t *adp)
607 608
608/** 609/**
609 * mraid_mm_dealloc_kioc - Return kioc to free pool 610 * mraid_mm_dealloc_kioc - Return kioc to free pool
610 *
611 * @adp : Adapter softstate 611 * @adp : Adapter softstate
612 * @kioc : uioc_t node to be returned to free pool 612 * @kioc : uioc_t node to be returned to free pool
613 */ 613 */
@@ -652,7 +652,6 @@ mraid_mm_dealloc_kioc(mraid_mmadp_t *adp, uioc_t *kioc)
652 652
653/** 653/**
654 * lld_ioctl - Routine to issue ioctl to low level drvr 654 * lld_ioctl - Routine to issue ioctl to low level drvr
655 *
656 * @adp : The adapter handle 655 * @adp : The adapter handle
657 * @kioc : The ioctl packet with kernel addresses 656 * @kioc : The ioctl packet with kernel addresses
658 */ 657 */
@@ -705,7 +704,6 @@ lld_ioctl(mraid_mmadp_t *adp, uioc_t *kioc)
705 704
706/** 705/**
707 * ioctl_done - callback from the low level driver 706 * ioctl_done - callback from the low level driver
708 *
709 * @kioc : completed ioctl packet 707 * @kioc : completed ioctl packet
710 */ 708 */
711static void 709static void
@@ -756,9 +754,8 @@ ioctl_done(uioc_t *kioc)
756} 754}
757 755
758 756
759/* 757/**
760 * lld_timedout : callback from the expired timer 758 * lld_timedout - callback from the expired timer
761 *
762 * @ptr : ioctl packet that timed out 759 * @ptr : ioctl packet that timed out
763 */ 760 */
764static void 761static void
@@ -776,8 +773,7 @@ lld_timedout(unsigned long ptr)
776 773
777 774
778/** 775/**
779 * kioc_to_mimd : Converter from new back to old format 776 * kioc_to_mimd - Converter from new back to old format
780 *
781 * @kioc : Kernel space IOCTL packet (successfully issued) 777 * @kioc : Kernel space IOCTL packet (successfully issued)
782 * @mimd : User space MIMD packet 778 * @mimd : User space MIMD packet
783 */ 779 */
@@ -855,7 +851,6 @@ kioc_to_mimd(uioc_t *kioc, mimd_t __user *mimd)
855 851
856/** 852/**
857 * hinfo_to_cinfo - Convert new format hba info into old format 853 * hinfo_to_cinfo - Convert new format hba info into old format
858 *
859 * @hinfo : New format, more comprehensive adapter info 854 * @hinfo : New format, more comprehensive adapter info
860 * @cinfo : Old format adapter info to support mimd_t apps 855 * @cinfo : Old format adapter info to support mimd_t apps
861 */ 856 */
@@ -878,10 +873,9 @@ hinfo_to_cinfo(mraid_hba_info_t *hinfo, mcontroller_t *cinfo)
878} 873}
879 874
880 875
881/* 876/**
882 * mraid_mm_register_adp - Registration routine for low level drvrs 877 * mraid_mm_register_adp - Registration routine for low level drivers
883 * 878 * @lld_adp : Adapter objejct
884 * @adp : Adapter objejct
885 */ 879 */
886int 880int
887mraid_mm_register_adp(mraid_mmadp_t *lld_adp) 881mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
@@ -1007,15 +1001,14 @@ memalloc_error:
1007 1001
1008/** 1002/**
1009 * mraid_mm_adapter_app_handle - return the application handle for this adapter 1003 * mraid_mm_adapter_app_handle - return the application handle for this adapter
1004 * @unique_id : adapter unique identifier
1010 * 1005 *
1011 * For the given driver data, locate the adadpter in our global list and 1006 * For the given driver data, locate the adapter in our global list and
1012 * return the corresponding handle, which is also used by applications to 1007 * return the corresponding handle, which is also used by applications to
1013 * uniquely identify an adapter. 1008 * uniquely identify an adapter.
1014 * 1009 *
1015 * @param unique_id : adapter unique identifier 1010 * Return adapter handle if found in the list.
1016 * 1011 * Return 0 if adapter could not be located, should never happen though.
1017 * @return adapter handle if found in the list
1018 * @return 0 if adapter could not be located, should never happen though
1019 */ 1012 */
1020uint32_t 1013uint32_t
1021mraid_mm_adapter_app_handle(uint32_t unique_id) 1014mraid_mm_adapter_app_handle(uint32_t unique_id)
@@ -1040,7 +1033,6 @@ mraid_mm_adapter_app_handle(uint32_t unique_id)
1040 1033
1041/** 1034/**
1042 * mraid_mm_setup_dma_pools - Set up dma buffer pools per adapter 1035 * mraid_mm_setup_dma_pools - Set up dma buffer pools per adapter
1043 *
1044 * @adp : Adapter softstate 1036 * @adp : Adapter softstate
1045 * 1037 *
1046 * We maintain a pool of dma buffers per each adapter. Each pool has one 1038 * We maintain a pool of dma buffers per each adapter. Each pool has one
@@ -1093,11 +1085,11 @@ dma_pool_setup_error:
1093} 1085}
1094 1086
1095 1087
1096/* 1088/**
1097 * mraid_mm_unregister_adp - Unregister routine for low level drivers 1089 * mraid_mm_unregister_adp - Unregister routine for low level drivers
1098 * Assume no outstanding ioctls to llds.
1099 *
1100 * @unique_id : UID of the adpater 1090 * @unique_id : UID of the adpater
1091 *
1092 * Assumes no outstanding ioctls to llds.
1101 */ 1093 */
1102int 1094int
1103mraid_mm_unregister_adp(uint32_t unique_id) 1095mraid_mm_unregister_adp(uint32_t unique_id)
@@ -1131,7 +1123,6 @@ mraid_mm_unregister_adp(uint32_t unique_id)
1131 1123
1132/** 1124/**
1133 * mraid_mm_free_adp_resources - Free adapter softstate 1125 * mraid_mm_free_adp_resources - Free adapter softstate
1134 *
1135 * @adp : Adapter softstate 1126 * @adp : Adapter softstate
1136 */ 1127 */
1137static void 1128static void
@@ -1162,7 +1153,6 @@ mraid_mm_free_adp_resources(mraid_mmadp_t *adp)
1162 1153
1163/** 1154/**
1164 * mraid_mm_teardown_dma_pools - Free all per adapter dma buffers 1155 * mraid_mm_teardown_dma_pools - Free all per adapter dma buffers
1165 *
1166 * @adp : Adapter softstate 1156 * @adp : Adapter softstate
1167 */ 1157 */
1168static void 1158static void
@@ -1190,7 +1180,7 @@ mraid_mm_teardown_dma_pools(mraid_mmadp_t *adp)
1190} 1180}
1191 1181
1192/** 1182/**
1193 * mraid_mm_init : Module entry point 1183 * mraid_mm_init - Module entry point
1194 */ 1184 */
1195static int __init 1185static int __init
1196mraid_mm_init(void) 1186mraid_mm_init(void)
@@ -1214,10 +1204,13 @@ mraid_mm_init(void)
1214} 1204}
1215 1205
1216 1206
1207#ifdef CONFIG_COMPAT
1217/** 1208/**
1218 * mraid_mm_compat_ioctl : 32bit to 64bit ioctl conversion routine 1209 * mraid_mm_compat_ioctl - 32bit to 64bit ioctl conversion routine
1210 * @filep : file operations pointer (ignored)
1211 * @cmd : ioctl command
1212 * @arg : user ioctl packet
1219 */ 1213 */
1220#ifdef CONFIG_COMPAT
1221static long 1214static long
1222mraid_mm_compat_ioctl(struct file *filep, unsigned int cmd, 1215mraid_mm_compat_ioctl(struct file *filep, unsigned int cmd,
1223 unsigned long arg) 1216 unsigned long arg)
@@ -1231,7 +1224,7 @@ mraid_mm_compat_ioctl(struct file *filep, unsigned int cmd,
1231#endif 1224#endif
1232 1225
1233/** 1226/**
1234 * mraid_mm_exit : Module exit point 1227 * mraid_mm_exit - Module exit point
1235 */ 1228 */
1236static void __exit 1229static void __exit
1237mraid_mm_exit(void) 1230mraid_mm_exit(void)
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 55eddcf8eb15..cacb3ad92527 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -15,7 +15,7 @@
15#ifndef LSI_MEGARAID_SAS_H 15#ifndef LSI_MEGARAID_SAS_H
16#define LSI_MEGARAID_SAS_H 16#define LSI_MEGARAID_SAS_H
17 17
18/** 18/*
19 * MegaRAID SAS Driver meta data 19 * MegaRAID SAS Driver meta data
20 */ 20 */
21#define MEGASAS_VERSION "00.00.03.05" 21#define MEGASAS_VERSION "00.00.03.05"
@@ -40,7 +40,7 @@
40 * "message frames" 40 * "message frames"
41 */ 41 */
42 42
43/** 43/*
44 * FW posts its state in upper 4 bits of outbound_msg_0 register 44 * FW posts its state in upper 4 bits of outbound_msg_0 register
45 */ 45 */
46#define MFI_STATE_MASK 0xF0000000 46#define MFI_STATE_MASK 0xF0000000
@@ -58,7 +58,7 @@
58 58
59#define MEGAMFI_FRAME_SIZE 64 59#define MEGAMFI_FRAME_SIZE 64
60 60
61/** 61/*
62 * During FW init, clear pending cmds & reset state using inbound_msg_0 62 * During FW init, clear pending cmds & reset state using inbound_msg_0
63 * 63 *
64 * ABORT : Abort all pending cmds 64 * ABORT : Abort all pending cmds
@@ -78,7 +78,7 @@
78 MFI_INIT_MFIMODE| \ 78 MFI_INIT_MFIMODE| \
79 MFI_INIT_ABORT 79 MFI_INIT_ABORT
80 80
81/** 81/*
82 * MFI frame flags 82 * MFI frame flags
83 */ 83 */
84#define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000 84#define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
@@ -92,12 +92,12 @@
92#define MFI_FRAME_DIR_READ 0x0010 92#define MFI_FRAME_DIR_READ 0x0010
93#define MFI_FRAME_DIR_BOTH 0x0018 93#define MFI_FRAME_DIR_BOTH 0x0018
94 94
95/** 95/*
96 * Definition for cmd_status 96 * Definition for cmd_status
97 */ 97 */
98#define MFI_CMD_STATUS_POLL_MODE 0xFF 98#define MFI_CMD_STATUS_POLL_MODE 0xFF
99 99
100/** 100/*
101 * MFI command opcodes 101 * MFI command opcodes
102 */ 102 */
103#define MFI_CMD_INIT 0x00 103#define MFI_CMD_INIT 0x00
@@ -128,7 +128,7 @@
128#define MR_DCMD_CLUSTER_RESET_ALL 0x08010100 128#define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
129#define MR_DCMD_CLUSTER_RESET_LD 0x08010200 129#define MR_DCMD_CLUSTER_RESET_LD 0x08010200
130 130
131/** 131/*
132 * MFI command completion codes 132 * MFI command completion codes
133 */ 133 */
134enum MFI_STAT { 134enum MFI_STAT {