aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/cciss.c115
-rw-r--r--drivers/block/cciss_cmd.h2
-rw-r--r--drivers/block/cciss_scsi.c26
3 files changed, 59 insertions, 84 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 74fc85aded92..885ea1e38e42 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -180,11 +180,10 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *,
180 __u32); 180 __u32);
181static void start_io(ctlr_info_t *h); 181static void start_io(ctlr_info_t *h);
182static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size, 182static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size,
183 unsigned int use_unit_num, unsigned int log_unit,
184 __u8 page_code, unsigned char *scsi3addr, int cmd_type); 183 __u8 page_code, unsigned char *scsi3addr, int cmd_type);
185static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, 184static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size,
186 unsigned int use_unit_num, unsigned int log_unit, 185 __u8 page_code, unsigned char scsi3addr[],
187 __u8 page_code, int cmd_type); 186 int cmd_type);
188 187
189static void fail_all_cmds(unsigned long ctlr); 188static void fail_all_cmds(unsigned long ctlr);
190static int scan_thread(void *data); 189static int scan_thread(void *data);
@@ -1520,6 +1519,15 @@ static void cciss_softirq_done(struct request *rq)
1520 spin_unlock_irqrestore(&h->lock, flags); 1519 spin_unlock_irqrestore(&h->lock, flags);
1521} 1520}
1522 1521
1522static void log_unit_to_scsi3addr(ctlr_info_t *h, unsigned char scsi3addr[],
1523 uint32_t log_unit)
1524{
1525 log_unit = h->drv[log_unit].LunID & 0x03fff;
1526 memset(&scsi3addr[4], 0, 4);
1527 memcpy(&scsi3addr[0], &log_unit, 4);
1528 scsi3addr[3] |= 0x40;
1529}
1530
1523/* This function gets the SCSI vendor, model, and revision of a logical drive 1531/* This function gets the SCSI vendor, model, and revision of a logical drive
1524 * via the inquiry page 0. Model, vendor, and rev are set to empty strings if 1532 * via the inquiry page 0. Model, vendor, and rev are set to empty strings if
1525 * they cannot be read. 1533 * they cannot be read.
@@ -1529,6 +1537,7 @@ static void cciss_get_device_descr(int ctlr, int logvol, int withirq,
1529{ 1537{
1530 int rc; 1538 int rc;
1531 InquiryData_struct *inq_buf; 1539 InquiryData_struct *inq_buf;
1540 unsigned char scsi3addr[8];
1532 1541
1533 *vendor = '\0'; 1542 *vendor = '\0';
1534 *model = '\0'; 1543 *model = '\0';
@@ -1538,14 +1547,15 @@ static void cciss_get_device_descr(int ctlr, int logvol, int withirq,
1538 if (!inq_buf) 1547 if (!inq_buf)
1539 return; 1548 return;
1540 1549
1550 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
1541 if (withirq) 1551 if (withirq)
1542 rc = sendcmd_withirq(CISS_INQUIRY, ctlr, inq_buf, 1552 rc = sendcmd_withirq(CISS_INQUIRY, ctlr, inq_buf,
1543 sizeof(InquiryData_struct), 1, logvol, 1553 sizeof(InquiryData_struct), 0,
1544 0, TYPE_CMD); 1554 scsi3addr, TYPE_CMD);
1545 else 1555 else
1546 rc = sendcmd(CISS_INQUIRY, ctlr, inq_buf, 1556 rc = sendcmd(CISS_INQUIRY, ctlr, inq_buf,
1547 sizeof(InquiryData_struct), 1, logvol, 0, NULL, 1557 sizeof(InquiryData_struct), 0,
1548 TYPE_CMD); 1558 scsi3addr, TYPE_CMD);
1549 if (rc == IO_OK) { 1559 if (rc == IO_OK) {
1550 memcpy(vendor, &inq_buf->data_byte[8], VENDOR_LEN); 1560 memcpy(vendor, &inq_buf->data_byte[8], VENDOR_LEN);
1551 vendor[VENDOR_LEN] = '\0'; 1561 vendor[VENDOR_LEN] = '\0';
@@ -1570,6 +1580,7 @@ static void cciss_get_serial_no(int ctlr, int logvol, int withirq,
1570#define PAGE_83_INQ_BYTES 64 1580#define PAGE_83_INQ_BYTES 64
1571 int rc; 1581 int rc;
1572 unsigned char *buf; 1582 unsigned char *buf;
1583 unsigned char scsi3addr[8];
1573 1584
1574 if (buflen > 16) 1585 if (buflen > 16)
1575 buflen = 16; 1586 buflen = 16;
@@ -1578,12 +1589,13 @@ static void cciss_get_serial_no(int ctlr, int logvol, int withirq,
1578 if (!buf) 1589 if (!buf)
1579 return; 1590 return;
1580 memset(serial_no, 0, buflen); 1591 memset(serial_no, 0, buflen);
1592 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
1581 if (withirq) 1593 if (withirq)
1582 rc = sendcmd_withirq(CISS_INQUIRY, ctlr, buf, 1594 rc = sendcmd_withirq(CISS_INQUIRY, ctlr, buf,
1583 PAGE_83_INQ_BYTES, 1, logvol, 0x83, TYPE_CMD); 1595 PAGE_83_INQ_BYTES, 0x83, scsi3addr, TYPE_CMD);
1584 else 1596 else
1585 rc = sendcmd(CISS_INQUIRY, ctlr, buf, 1597 rc = sendcmd(CISS_INQUIRY, ctlr, buf,
1586 PAGE_83_INQ_BYTES, 1, logvol, 0x83, NULL, TYPE_CMD); 1598 PAGE_83_INQ_BYTES, 0x83, scsi3addr, TYPE_CMD);
1587 if (rc == IO_OK) 1599 if (rc == IO_OK)
1588 memcpy(serial_no, &buf[8], buflen); 1600 memcpy(serial_no, &buf[8], buflen);
1589 kfree(buf); 1601 kfree(buf);
@@ -1902,8 +1914,8 @@ static int rebuild_lun_table(ctlr_info_t *h, int first_time)
1902 goto mem_msg; 1914 goto mem_msg;
1903 1915
1904 return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff, 1916 return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff,
1905 sizeof(ReportLunData_struct), 0, 1917 sizeof(ReportLunData_struct),
1906 0, 0, TYPE_CMD); 1918 0, CTLR_LUNID, TYPE_CMD);
1907 1919
1908 if (return_code == IO_OK) 1920 if (return_code == IO_OK)
1909 listlength = be32_to_cpu(*(__be32 *) ld_buff->LUNListLength); 1921 listlength = be32_to_cpu(*(__be32 *) ld_buff->LUNListLength);
@@ -2112,11 +2124,9 @@ static int deregister_disk(ctlr_info_t *h, int drv_index,
2112 return 0; 2124 return 0;
2113} 2125}
2114 2126
2115static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_t size, unsigned int use_unit_num, /* 0: address the controller, 2127static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff,
2116 1: address logical volume log_unit, 2128 size_t size, __u8 page_code, unsigned char *scsi3addr,
2117 2: periph device address is scsi3addr */ 2129 int cmd_type)
2118 unsigned int log_unit, __u8 page_code,
2119 unsigned char *scsi3addr, int cmd_type)
2120{ 2130{
2121 ctlr_info_t *h = hba[ctlr]; 2131 ctlr_info_t *h = hba[ctlr];
2122 u64bit buff_dma_handle; 2132 u64bit buff_dma_handle;
@@ -2132,27 +2142,12 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_
2132 c->Header.SGTotal = 0; 2142 c->Header.SGTotal = 0;
2133 } 2143 }
2134 c->Header.Tag.lower = c->busaddr; 2144 c->Header.Tag.lower = c->busaddr;
2145 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8);
2135 2146
2136 c->Request.Type.Type = cmd_type; 2147 c->Request.Type.Type = cmd_type;
2137 if (cmd_type == TYPE_CMD) { 2148 if (cmd_type == TYPE_CMD) {
2138 switch (cmd) { 2149 switch (cmd) {
2139 case CISS_INQUIRY: 2150 case CISS_INQUIRY:
2140 /* If the logical unit number is 0 then, this is going
2141 to controller so It's a physical command
2142 mode = 0 target = 0. So we have nothing to write.
2143 otherwise, if use_unit_num == 1,
2144 mode = 1(volume set addressing) target = LUNID
2145 otherwise, if use_unit_num == 2,
2146 mode = 0(periph dev addr) target = scsi3addr */
2147 if (use_unit_num == 1) {
2148 c->Header.LUN.LogDev.VolId =
2149 h->drv[log_unit].LunID;
2150 c->Header.LUN.LogDev.Mode = 1;
2151 } else if (use_unit_num == 2) {
2152 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr,
2153 8);
2154 c->Header.LUN.LogDev.Mode = 0;
2155 }
2156 /* are we trying to read a vital product page */ 2151 /* are we trying to read a vital product page */
2157 if (page_code != 0) { 2152 if (page_code != 0) {
2158 c->Request.CDB[1] = 0x01; 2153 c->Request.CDB[1] = 0x01;
@@ -2182,8 +2177,6 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_
2182 break; 2177 break;
2183 2178
2184 case CCISS_READ_CAPACITY: 2179 case CCISS_READ_CAPACITY:
2185 c->Header.LUN.LogDev.VolId = h->drv[log_unit].LunID;
2186 c->Header.LUN.LogDev.Mode = 1;
2187 c->Request.CDBLen = 10; 2180 c->Request.CDBLen = 10;
2188 c->Request.Type.Attribute = ATTR_SIMPLE; 2181 c->Request.Type.Attribute = ATTR_SIMPLE;
2189 c->Request.Type.Direction = XFER_READ; 2182 c->Request.Type.Direction = XFER_READ;
@@ -2191,8 +2184,6 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_
2191 c->Request.CDB[0] = cmd; 2184 c->Request.CDB[0] = cmd;
2192 break; 2185 break;
2193 case CCISS_READ_CAPACITY_16: 2186 case CCISS_READ_CAPACITY_16:
2194 c->Header.LUN.LogDev.VolId = h->drv[log_unit].LunID;
2195 c->Header.LUN.LogDev.Mode = 1;
2196 c->Request.CDBLen = 16; 2187 c->Request.CDBLen = 16;
2197 c->Request.Type.Attribute = ATTR_SIMPLE; 2188 c->Request.Type.Attribute = ATTR_SIMPLE;
2198 c->Request.Type.Direction = XFER_READ; 2189 c->Request.Type.Direction = XFER_READ;
@@ -2215,7 +2206,6 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_
2215 c->Request.CDB[6] = BMIC_CACHE_FLUSH; 2206 c->Request.CDB[6] = BMIC_CACHE_FLUSH;
2216 break; 2207 break;
2217 case TEST_UNIT_READY: 2208 case TEST_UNIT_READY:
2218 memcpy(c->Header. LUN.LunAddrBytes, scsi3addr, 8);
2219 c->Request.CDBLen = 6; 2209 c->Request.CDBLen = 6;
2220 c->Request.Type.Attribute = ATTR_SIMPLE; 2210 c->Request.Type.Attribute = ATTR_SIMPLE;
2221 c->Request.Type.Direction = XFER_NONE; 2211 c->Request.Type.Direction = XFER_NONE;
@@ -2239,7 +2229,6 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_
2239 memcpy(&c->Request.CDB[4], buff, 8); 2229 memcpy(&c->Request.CDB[4], buff, 8);
2240 break; 2230 break;
2241 case 1: /* RESET message */ 2231 case 1: /* RESET message */
2242 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8);
2243 c->Request.CDBLen = 16; 2232 c->Request.CDBLen = 16;
2244 c->Request.Type.Attribute = ATTR_SIMPLE; 2233 c->Request.Type.Attribute = ATTR_SIMPLE;
2245 c->Request.Type.Direction = XFER_NONE; 2234 c->Request.Type.Direction = XFER_NONE;
@@ -2307,6 +2296,9 @@ resend_cmd2:
2307 printk(KERN_WARNING "cciss: cmd 0x%02x " 2296 printk(KERN_WARNING "cciss: cmd 0x%02x "
2308 "has SCSI Status = %x\n", 2297 "has SCSI Status = %x\n",
2309 c->Request.CDB[0], c->err_info->ScsiStatus); 2298 c->Request.CDB[0], c->err_info->ScsiStatus);
2299 if (c->err_info->ScsiStatus == SAM_STAT_CHECK_CONDITION)
2300 printk(KERN_WARNING "sense key = 0x%02x\n",
2301 0xf & c->err_info->SenseInfo[2]);
2310 } 2302 }
2311 break; 2303 break;
2312 case CMD_DATA_UNDERRUN: 2304 case CMD_DATA_UNDERRUN:
@@ -2377,12 +2369,9 @@ command_done:
2377 return return_status; 2369 return return_status;
2378} 2370}
2379 2371
2380static int sendcmd_withirq(__u8 cmd, 2372static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size,
2381 int ctlr, 2373 __u8 page_code, unsigned char scsi3addr[],
2382 void *buff, 2374 int cmd_type)
2383 size_t size,
2384 unsigned int use_unit_num,
2385 unsigned int log_unit, __u8 page_code, int cmd_type)
2386{ 2375{
2387 ctlr_info_t *h = hba[ctlr]; 2376 ctlr_info_t *h = hba[ctlr];
2388 CommandList_struct *c; 2377 CommandList_struct *c;
@@ -2391,8 +2380,8 @@ static int sendcmd_withirq(__u8 cmd,
2391 c = cmd_alloc(h, 0); 2380 c = cmd_alloc(h, 0);
2392 if (!c) 2381 if (!c)
2393 return -ENOMEM; 2382 return -ENOMEM;
2394 return_status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, 2383 return_status = fill_cmd(c, cmd, ctlr, buff, size, page_code,
2395 log_unit, page_code, NULL, cmd_type); 2384 scsi3addr, cmd_type);
2396 if (return_status == IO_OK) 2385 if (return_status == IO_OK)
2397 return_status = sendcmd_withirq_core(h, c); 2386 return_status = sendcmd_withirq_core(h, c);
2398 cmd_free(h, c, 0); 2387 cmd_free(h, c, 0);
@@ -2407,15 +2396,17 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
2407{ 2396{
2408 int return_code; 2397 int return_code;
2409 unsigned long t; 2398 unsigned long t;
2399 unsigned char scsi3addr[8];
2410 2400
2411 memset(inq_buff, 0, sizeof(InquiryData_struct)); 2401 memset(inq_buff, 0, sizeof(InquiryData_struct));
2402 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
2412 if (withirq) 2403 if (withirq)
2413 return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, 2404 return_code = sendcmd_withirq(CISS_INQUIRY, ctlr,
2414 inq_buff, sizeof(*inq_buff), 1, 2405 inq_buff, sizeof(*inq_buff),
2415 logvol, 0xC1, TYPE_CMD); 2406 0xC1, scsi3addr, TYPE_CMD);
2416 else 2407 else
2417 return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff, 2408 return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff,
2418 sizeof(*inq_buff), 1, logvol, 0xC1, NULL, 2409 sizeof(*inq_buff), 0xC1, scsi3addr,
2419 TYPE_CMD); 2410 TYPE_CMD);
2420 if (return_code == IO_OK) { 2411 if (return_code == IO_OK) {
2421 if (inq_buff->data_byte[8] == 0xFF) { 2412 if (inq_buff->data_byte[8] == 0xFF) {
@@ -2456,6 +2447,7 @@ cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size,
2456{ 2447{
2457 ReadCapdata_struct *buf; 2448 ReadCapdata_struct *buf;
2458 int return_code; 2449 int return_code;
2450 unsigned char scsi3addr[8];
2459 2451
2460 buf = kzalloc(sizeof(ReadCapdata_struct), GFP_KERNEL); 2452 buf = kzalloc(sizeof(ReadCapdata_struct), GFP_KERNEL);
2461 if (!buf) { 2453 if (!buf) {
@@ -2463,14 +2455,15 @@ cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size,
2463 return; 2455 return;
2464 } 2456 }
2465 2457
2458 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
2466 if (withirq) 2459 if (withirq)
2467 return_code = sendcmd_withirq(CCISS_READ_CAPACITY, 2460 return_code = sendcmd_withirq(CCISS_READ_CAPACITY,
2468 ctlr, buf, sizeof(ReadCapdata_struct), 2461 ctlr, buf, sizeof(ReadCapdata_struct),
2469 1, logvol, 0, TYPE_CMD); 2462 0, scsi3addr, TYPE_CMD);
2470 else 2463 else
2471 return_code = sendcmd(CCISS_READ_CAPACITY, 2464 return_code = sendcmd(CCISS_READ_CAPACITY,
2472 ctlr, buf, sizeof(ReadCapdata_struct), 2465 ctlr, buf, sizeof(ReadCapdata_struct),
2473 1, logvol, 0, NULL, TYPE_CMD); 2466 0, scsi3addr, TYPE_CMD);
2474 if (return_code == IO_OK) { 2467 if (return_code == IO_OK) {
2475 *total_size = be32_to_cpu(*(__be32 *) buf->total_size); 2468 *total_size = be32_to_cpu(*(__be32 *) buf->total_size);
2476 *block_size = be32_to_cpu(*(__be32 *) buf->block_size); 2469 *block_size = be32_to_cpu(*(__be32 *) buf->block_size);
@@ -2490,6 +2483,7 @@ cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size,
2490{ 2483{
2491 ReadCapdata_struct_16 *buf; 2484 ReadCapdata_struct_16 *buf;
2492 int return_code; 2485 int return_code;
2486 unsigned char scsi3addr[8];
2493 2487
2494 buf = kzalloc(sizeof(ReadCapdata_struct_16), GFP_KERNEL); 2488 buf = kzalloc(sizeof(ReadCapdata_struct_16), GFP_KERNEL);
2495 if (!buf) { 2489 if (!buf) {
@@ -2497,15 +2491,16 @@ cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size,
2497 return; 2491 return;
2498 } 2492 }
2499 2493
2494 log_unit_to_scsi3addr(hba[ctlr], scsi3addr, logvol);
2500 if (withirq) { 2495 if (withirq) {
2501 return_code = sendcmd_withirq(CCISS_READ_CAPACITY_16, 2496 return_code = sendcmd_withirq(CCISS_READ_CAPACITY_16,
2502 ctlr, buf, sizeof(ReadCapdata_struct_16), 2497 ctlr, buf, sizeof(ReadCapdata_struct_16),
2503 1, logvol, 0, TYPE_CMD); 2498 0, scsi3addr, TYPE_CMD);
2504 } 2499 }
2505 else { 2500 else {
2506 return_code = sendcmd(CCISS_READ_CAPACITY_16, 2501 return_code = sendcmd(CCISS_READ_CAPACITY_16,
2507 ctlr, buf, sizeof(ReadCapdata_struct_16), 2502 ctlr, buf, sizeof(ReadCapdata_struct_16),
2508 1, logvol, 0, NULL, TYPE_CMD); 2503 0, scsi3addr, TYPE_CMD);
2509 } 2504 }
2510 if (return_code == IO_OK) { 2505 if (return_code == IO_OK) {
2511 *total_size = be64_to_cpu(*(__be64 *) buf->total_size); 2506 *total_size = be64_to_cpu(*(__be64 *) buf->total_size);
@@ -2760,10 +2755,6 @@ cleanup1:
2760 * Used at init time, and during SCSI error recovery. 2755 * Used at init time, and during SCSI error recovery.
2761 */ 2756 */
2762static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size, 2757static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size,
2763 unsigned int use_unit_num,/* 0: address the controller,
2764 1: address logical volume log_unit,
2765 2: periph device address is scsi3addr */
2766 unsigned int log_unit,
2767 __u8 page_code, unsigned char *scsi3addr, int cmd_type) 2758 __u8 page_code, unsigned char *scsi3addr, int cmd_type)
2768{ 2759{
2769 CommandList_struct *c; 2760 CommandList_struct *c;
@@ -2774,8 +2765,8 @@ static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size,
2774 printk(KERN_WARNING "cciss: unable to get memory"); 2765 printk(KERN_WARNING "cciss: unable to get memory");
2775 return IO_ERROR; 2766 return IO_ERROR;
2776 } 2767 }
2777 status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, 2768 status = fill_cmd(c, cmd, ctlr, buff, size, page_code,
2778 log_unit, page_code, scsi3addr, cmd_type); 2769 scsi3addr, cmd_type);
2779 if (status == IO_OK) 2770 if (status == IO_OK)
2780 status = sendcmd_core(hba[ctlr], c); 2771 status = sendcmd_core(hba[ctlr], c);
2781 cmd_free(hba[ctlr], c, 1); 2772 cmd_free(hba[ctlr], c, 1);
@@ -4076,7 +4067,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
4076 } 4067 }
4077 4068
4078 return_code = sendcmd_withirq(CISS_INQUIRY, i, inq_buff, 4069 return_code = sendcmd_withirq(CISS_INQUIRY, i, inq_buff,
4079 sizeof(InquiryData_struct), 0, 0 , 0, TYPE_CMD); 4070 sizeof(InquiryData_struct), 0, CTLR_LUNID, TYPE_CMD);
4080 if (return_code == IO_OK) { 4071 if (return_code == IO_OK) {
4081 hba[i]->firm_ver[0] = inq_buff->data_byte[32]; 4072 hba[i]->firm_ver[0] = inq_buff->data_byte[32];
4082 hba[i]->firm_ver[1] = inq_buff->data_byte[33]; 4073 hba[i]->firm_ver[1] = inq_buff->data_byte[33];
@@ -4157,8 +4148,8 @@ static void cciss_shutdown(struct pci_dev *pdev)
4157 /* sendcmd will turn off interrupt, and send the flush... 4148 /* sendcmd will turn off interrupt, and send the flush...
4158 * To write all data in the battery backed cache to disks */ 4149 * To write all data in the battery backed cache to disks */
4159 memset(flush_buf, 0, 4); 4150 memset(flush_buf, 0, 4);
4160 return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL, 4151 return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0,
4161 TYPE_CMD); 4152 CTLR_LUNID, TYPE_CMD);
4162 if (return_code == IO_OK) { 4153 if (return_code == IO_OK) {
4163 printk(KERN_INFO "Completed flushing cache on controller %d\n", i); 4154 printk(KERN_INFO "Completed flushing cache on controller %d\n", i);
4164 } else { 4155 } else {
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h
index 40b1b92dae7f..cd665b00c7c5 100644
--- a/drivers/block/cciss_cmd.h
+++ b/drivers/block/cciss_cmd.h
@@ -217,6 +217,8 @@ typedef union _LUNAddr_struct {
217 LogDevAddr_struct LogDev; 217 LogDevAddr_struct LogDev;
218} LUNAddr_struct; 218} LUNAddr_struct;
219 219
220#define CTLR_LUNID "\0\0\0\0\0\0\0\0"
221
220typedef struct _CommandListHeader_struct { 222typedef struct _CommandListHeader_struct {
221 BYTE ReplyQueue; 223 BYTE ReplyQueue;
222 BYTE SGList; 224 BYTE SGList;
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 134fdf25d7f4..007ab8aea85b 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -44,26 +44,9 @@
44#define CCISS_ABORT_MSG 0x00 44#define CCISS_ABORT_MSG 0x00
45#define CCISS_RESET_MSG 0x01 45#define CCISS_RESET_MSG 0x01
46 46
47/* some prototypes... */
48static int sendcmd(
49 __u8 cmd,
50 int ctlr,
51 void *buff,
52 size_t size,
53 unsigned int use_unit_num, /* 0: address the controller,
54 1: address logical volume log_unit,
55 2: address is in scsi3addr */
56 unsigned int log_unit,
57 __u8 page_code,
58 unsigned char *scsi3addr,
59 int cmd_type);
60
61static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, 47static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff,
62 size_t size, 48 size_t size,
63 unsigned int use_unit_num, /* 0: address the controller, 49 __u8 page_code, unsigned char *scsi3addr,
64 1: address logical volume log_unit,
65 2: periph device address is scsi3addr */
66 unsigned int log_unit, __u8 page_code, unsigned char *scsi3addr,
67 int cmd_type); 50 int cmd_type);
68 51
69static int sendcmd_core(ctlr_info_t *h, CommandList_struct *c); 52static int sendcmd_core(ctlr_info_t *h, CommandList_struct *c);
@@ -1616,7 +1599,7 @@ static int wait_for_device_to_become_ready(ctlr_info_t *h,
1616 waittime = waittime * 2; 1599 waittime = waittime * 2;
1617 1600
1618 /* Send the Test Unit Ready */ 1601 /* Send the Test Unit Ready */
1619 rc = fill_cmd(c, TEST_UNIT_READY, h->ctlr, NULL, 0, 0, 0, 0, 1602 rc = fill_cmd(c, TEST_UNIT_READY, h->ctlr, NULL, 0, 0,
1620 lunaddr, TYPE_CMD); 1603 lunaddr, TYPE_CMD);
1621 if (rc == 0) { 1604 if (rc == 0) {
1622 rc = sendcmd_core(h, c); 1605 rc = sendcmd_core(h, c);
@@ -1680,7 +1663,7 @@ static int cciss_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
1680 return FAILED; 1663 return FAILED;
1681 memcpy(lunaddr, &cmd_in_trouble->Header.LUN.LunAddrBytes[0], 8); 1664 memcpy(lunaddr, &cmd_in_trouble->Header.LUN.LunAddrBytes[0], 8);
1682 /* send a reset to the SCSI LUN which the command was sent to */ 1665 /* send a reset to the SCSI LUN which the command was sent to */
1683 rc = sendcmd(CCISS_RESET_MSG, ctlr, NULL, 0, 2, 0, 0, lunaddr, 1666 rc = sendcmd(CCISS_RESET_MSG, ctlr, NULL, 0, 0, lunaddr,
1684 TYPE_MSG); 1667 TYPE_MSG);
1685 /* sendcmd turned off interrupts on the board, turn 'em back on. */ 1668 /* sendcmd turned off interrupts on the board, turn 'em back on. */
1686 (*c)->access.set_intr_mask(*c, CCISS_INTR_ON); 1669 (*c)->access.set_intr_mask(*c, CCISS_INTR_ON);
@@ -1708,8 +1691,7 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd)
1708 cmd_to_abort = (CommandList_struct *) scsicmd->host_scribble; 1691 cmd_to_abort = (CommandList_struct *) scsicmd->host_scribble;
1709 if (cmd_to_abort == NULL) /* paranoia */ 1692 if (cmd_to_abort == NULL) /* paranoia */
1710 return FAILED; 1693 return FAILED;
1711 rc = sendcmd(CCISS_ABORT_MSG, ctlr, &cmd_to_abort->Header.Tag, 1694 rc = sendcmd(CCISS_ABORT_MSG, ctlr, &cmd_to_abort->Header.Tag, 0, 0,
1712 0, 2, 0, 0,
1713 (unsigned char *) &cmd_to_abort->Header.LUN.LunAddrBytes[0], 1695 (unsigned char *) &cmd_to_abort->Header.LUN.LunAddrBytes[0],
1714 TYPE_MSG); 1696 TYPE_MSG);
1715 /* sendcmd turned off interrupts on the board, turn 'em back on. */ 1697 /* sendcmd turned off interrupts on the board, turn 'em back on. */