Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: 3w-xxxx: Whitespace cleanup

Link: https://lore.kernel.org/r/20210113090500.129644-3-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Hannes Reinecke and committed by
Martin K. Petersen
8148dfba 0653c358

+220 -212
+121 -122
drivers/scsi/3w-xxxx.c
··· 1 - /* 1 + /* 2 2 3w-xxxx.c -- 3ware Storage Controller device driver for Linux. 3 3 4 4 Written By: Adam Radford <aradford@gmail.com> 5 5 Modifications By: Joel Jacobson <linux@3ware.com> 6 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> 6 + Arnaldo Carvalho de Melo <acme@conectiva.com.br> 7 7 Brad Strand <linux@3ware.com> 8 8 9 9 Copyright (C) 1999-2010 3ware Inc. 10 10 11 - Kernel compatibility By: Andre Hedrick <andre@suse.com> 11 + Kernel compatibility By: Andre Hedrick <andre@suse.com> 12 12 Non-Copyright (C) 2000 Andre Hedrick <andre@suse.com> 13 - 13 + 14 14 Further tiny build fixes and trivial hoovering Alan Cox 15 15 16 16 This program is free software; you can redistribute it and/or modify 17 17 it under the terms of the GNU General Public License as published by 18 18 the Free Software Foundation; version 2 of the License. 19 19 20 - This program is distributed in the hope that it will be useful, 21 - but WITHOUT ANY WARRANTY; without even the implied warranty of 22 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 - GNU General Public License for more details. 20 + This program is distributed in the hope that it will be useful, 21 + but WITHOUT ANY WARRANTY; without even the implied warranty of 22 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 + GNU General Public License for more details. 24 24 25 - NO WARRANTY 26 - THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 27 - CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 28 - LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 29 - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 30 - solely responsible for determining the appropriateness of using and 31 - distributing the Program and assumes all risks associated with its 32 - exercise of rights under this Agreement, including but not limited to 33 - the risks and costs of program errors, damage to or loss of data, 34 - programs or equipment, and unavailability or interruption of operations. 25 + NO WARRANTY 26 + THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 27 + CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 28 + LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 29 + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 30 + solely responsible for determining the appropriateness of using and 31 + distributing the Program and assumes all risks associated with its 32 + exercise of rights under this Agreement, including but not limited to 33 + the risks and costs of program errors, damage to or loss of data, 34 + programs or equipment, and unavailability or interruption of operations. 35 35 36 - DISCLAIMER OF LIABILITY 37 - NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 38 - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 - DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 40 - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 41 - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 42 - USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 43 - HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 36 + DISCLAIMER OF LIABILITY 37 + NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 38 + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 + DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 40 + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 41 + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 42 + USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 43 + HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 44 44 45 - You should have received a copy of the GNU General Public License 46 - along with this program; if not, write to the Free Software 47 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 45 + You should have received a copy of the GNU General Public License 46 + along with this program; if not, write to the Free Software 47 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 48 48 49 - Bugs/Comments/Suggestions should be mailed to: 49 + Bugs/Comments/Suggestions should be mailed to: 50 50 51 51 aradford@gmail.com 52 52 ··· 70 70 1.02.00.003 - Fix tw_interrupt() to report error to scsi layer when 71 71 controller status is non-zero. 72 72 Added handling of request_sense opcode. 73 - Fix possible null pointer dereference in 73 + Fix possible null pointer dereference in 74 74 tw_reset_device_extension() 75 75 1.02.00.004 - Add support for device id of 3ware 7000 series controllers. 76 76 Make tw_setfeature() call with interrupts disabled. ··· 239 239 /* This function will check the status register for unexpected bits */ 240 240 static int tw_check_bits(u32 status_reg_value) 241 241 { 242 - if ((status_reg_value & TW_STATUS_EXPECTED_BITS) != TW_STATUS_EXPECTED_BITS) { 242 + if ((status_reg_value & TW_STATUS_EXPECTED_BITS) != TW_STATUS_EXPECTED_BITS) { 243 243 dprintk(KERN_WARNING "3w-xxxx: tw_check_bits(): No expected bits (0x%x).\n", status_reg_value); 244 244 return 1; 245 245 } ··· 291 291 } 292 292 return 1; 293 293 } 294 - 294 + 295 295 return 0; 296 296 } /* End tw_decode_bits() */ 297 297 ··· 390 390 } else { 391 391 tw_dev->pending_tail = tw_dev->pending_tail + 1; 392 392 } 393 - } 393 + } 394 394 TW_UNMASK_COMMAND_INTERRUPT(tw_dev); 395 395 return 1; 396 396 } ··· 403 403 int i; 404 404 TW_Command *command; 405 405 406 - dprintk(KERN_WARNING "3w-xxxx: tw_decode_sense()\n"); 406 + dprintk(KERN_WARNING "3w-xxxx: tw_decode_sense()\n"); 407 407 command = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; 408 408 409 409 printk(KERN_WARNING "3w-xxxx: scsi%d: Command failed: status = 0x%x, flags = 0x%x, unit #%d.\n", tw_dev->host->host_no, command->status, command->flags, TW_UNIT_OUT(command->unit__hostid)); ··· 443 443 } /* End tw_decode_sense() */ 444 444 445 445 /* This function will report controller error status */ 446 - static int tw_check_errors(TW_Device_Extension *tw_dev) 446 + static int tw_check_errors(TW_Device_Extension *tw_dev) 447 447 { 448 448 u32 status_reg_value; 449 - 449 + 450 450 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); 451 451 452 452 if (TW_STATUS_ERRORS(status_reg_value) || tw_check_bits(status_reg_value)) { ··· 458 458 } /* End tw_check_errors() */ 459 459 460 460 /* This function will empty the response que */ 461 - static void tw_empty_response_que(TW_Device_Extension *tw_dev) 461 + static void tw_empty_response_que(TW_Device_Extension *tw_dev) 462 462 { 463 463 u32 status_reg_value, response_que_value; 464 464 ··· 525 525 /* Create sysfs 'stats' entry */ 526 526 static struct device_attribute tw_host_stats_attr = { 527 527 .attr = { 528 - .name = "stats", 528 + .name = "stats", 529 529 .mode = S_IRUGO, 530 530 }, 531 531 .show = tw_show_stats ··· 538 538 }; 539 539 540 540 /* This function will read the aen queue from the isr */ 541 - static int tw_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) 541 + static int tw_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) 542 542 { 543 543 TW_Command *command_packet; 544 544 TW_Param *param; ··· 604 604 } /* End tw_aen_read_queue() */ 605 605 606 606 /* This function will complete an aen request from the isr */ 607 - static int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id) 607 + static int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id) 608 608 { 609 609 TW_Param *param; 610 610 unsigned short aen; ··· 628 628 if ((tw_aen_string[aen & 0xff][strlen(tw_aen_string[aen & 0xff])-1]) == '#') { 629 629 printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: %s%d.\n", tw_dev->host->host_no, tw_aen_string[aen & 0xff], aen >> 8); 630 630 } else { 631 - if (aen != 0x0) 631 + if (aen != 0x0) 632 632 printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: %s.\n", tw_dev->host->host_no, tw_aen_string[aen & 0xff]); 633 633 } 634 634 } else { ··· 746 746 printk(KERN_WARNING "3w-xxxx: tw_aen_drain_queue(): Unexpected request id.\n"); 747 747 return 1; 748 748 } 749 - 749 + 750 750 if (command_packet->status != 0) { 751 751 if (command_packet->flags != TW_AEN_TABLE_UNDEFINED) { 752 752 /* Bad response */ ··· 908 908 909 909 /* Hardware can only do multiple of 512 byte transfers */ 910 910 data_buffer_length_adjusted = (data_buffer_length + 511) & ~511; 911 - 911 + 912 912 /* Now allocate ioctl buf memory */ 913 913 cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, &dma_handle, GFP_KERNEL); 914 914 if (cpu_addr == NULL) { ··· 1075 1075 } /* End tw_free_device_extension() */ 1076 1076 1077 1077 /* This function will send an initconnection command to controller */ 1078 - static int tw_initconnection(TW_Device_Extension *tw_dev, int message_credits) 1078 + static int tw_initconnection(TW_Device_Extension *tw_dev, int message_credits) 1079 1079 { 1080 1080 unsigned long command_que_value; 1081 1081 TW_Command *command_packet; ··· 1105 1105 printk(KERN_WARNING "3w-xxxx: tw_initconnection(): Bad command packet physical address.\n"); 1106 1106 return 1; 1107 1107 } 1108 - 1108 + 1109 1109 /* Send command packet to the board */ 1110 1110 outl(command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); 1111 - 1111 + 1112 1112 /* Poll for completion */ 1113 1113 if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) { 1114 1114 response_queue.value = inl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev)); ··· 1130 1130 1131 1131 /* Set a value in the features table */ 1132 1132 static int tw_setfeature(TW_Device_Extension *tw_dev, int parm, int param_size, 1133 - unsigned char *val) 1133 + unsigned char *val) 1134 1134 { 1135 1135 TW_Param *param; 1136 1136 TW_Command *command_packet; ··· 1139 1139 unsigned long command_que_value; 1140 1140 unsigned long param_value; 1141 1141 1142 - /* Initialize SetParam command packet */ 1142 + /* Initialize SetParam command packet */ 1143 1143 if (tw_dev->command_packet_virtual_address[request_id] == NULL) { 1144 1144 printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet virtual address.\n"); 1145 1145 return 1; ··· 1169 1169 command_packet->request_id = request_id; 1170 1170 command_packet->byte6.parameter_count = 1; 1171 1171 1172 - command_que_value = tw_dev->command_packet_physical_address[request_id]; 1172 + command_que_value = tw_dev->command_packet_physical_address[request_id]; 1173 1173 if (command_que_value == 0) { 1174 1174 printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet physical address.\n"); 1175 1175 return 1; ··· 1199 1199 } /* End tw_setfeature() */ 1200 1200 1201 1201 /* This function will reset a controller */ 1202 - static int tw_reset_sequence(TW_Device_Extension *tw_dev) 1202 + static int tw_reset_sequence(TW_Device_Extension *tw_dev) 1203 1203 { 1204 1204 int error = 0; 1205 1205 int tries = 0; ··· 1298 1298 1299 1299 /* Abort all requests that are in progress */ 1300 1300 for (i=0;i<TW_Q_LENGTH;i++) { 1301 - if ((tw_dev->state[i] != TW_S_FINISHED) && 1301 + if ((tw_dev->state[i] != TW_S_FINISHED) && 1302 1302 (tw_dev->state[i] != TW_S_INITIAL) && 1303 1303 (tw_dev->state[i] != TW_S_COMPLETED)) { 1304 1304 srb = tw_dev->srb[i]; ··· 1339 1339 1340 1340 /* This funciton returns unit geometry in cylinders/heads/sectors */ 1341 1341 static int tw_scsi_biosparam(struct scsi_device *sdev, struct block_device *bdev, 1342 - sector_t capacity, int geom[]) 1342 + sector_t capacity, int geom[]) 1343 1343 { 1344 1344 int heads, sectors, cylinders; 1345 1345 TW_Device_Extension *tw_dev; 1346 - 1346 + 1347 1347 dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_biosparam()\n"); 1348 1348 tw_dev = (TW_Device_Extension *)sdev->host->hostdata; 1349 1349 ··· 1358 1358 } 1359 1359 1360 1360 dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_biosparam(): heads = %d, sectors = %d, cylinders = %d\n", heads, sectors, cylinders); 1361 - geom[0] = heads; 1361 + geom[0] = heads; 1362 1362 geom[1] = sectors; 1363 1363 geom[2] = cylinders; 1364 1364 ··· 1366 1366 } /* End tw_scsi_biosparam() */ 1367 1367 1368 1368 /* This is the new scsi eh reset function */ 1369 - static int tw_scsi_eh_reset(struct scsi_cmnd *SCpnt) 1369 + static int tw_scsi_eh_reset(struct scsi_cmnd *SCpnt) 1370 1370 { 1371 1371 TW_Device_Extension *tw_dev=NULL; 1372 1372 int retval = FAILED; ··· 1554 1554 1555 1555 /* Now try to post the command packet */ 1556 1556 tw_post_command_packet(tw_dev, request_id); 1557 - 1557 + 1558 1558 return 0; 1559 1559 } /* End tw_scsiop_mode_sense() */ 1560 1560 ··· 1575 1575 flags = (char *)&(param->data[0]); 1576 1576 memset(request_buffer, 0, sizeof(request_buffer)); 1577 1577 1578 - request_buffer[0] = 0xf; /* mode data length */ 1579 - request_buffer[1] = 0; /* default medium type */ 1580 - request_buffer[2] = 0x10; /* dpo/fua support on */ 1581 - request_buffer[3] = 0; /* no block descriptors */ 1582 - request_buffer[4] = 0x8; /* caching page */ 1583 - request_buffer[5] = 0xa; /* page length */ 1578 + request_buffer[0] = 0xf; /* mode data length */ 1579 + request_buffer[1] = 0; /* default medium type */ 1580 + request_buffer[2] = 0x10; /* dpo/fua support on */ 1581 + request_buffer[3] = 0; /* no block descriptors */ 1582 + request_buffer[4] = 0x8; /* caching page */ 1583 + request_buffer[5] = 0xa; /* page length */ 1584 1584 if (*flags & 0x1) 1585 - request_buffer[6] = 0x5; /* WCE on, RCD on */ 1585 + request_buffer[6] = 0x5; /* WCE on, RCD on */ 1586 1586 else 1587 - request_buffer[6] = 0x1; /* WCE off, RCD on */ 1587 + request_buffer[6] = 0x1; /* WCE off, RCD on */ 1588 1588 tw_transfer_internal(tw_dev, request_id, request_buffer, 1589 1589 sizeof(request_buffer)); 1590 1590 ··· 1592 1592 } /* End tw_scsiop_mode_sense_complete() */ 1593 1593 1594 1594 /* This function handles scsi read_capacity commands */ 1595 - static int tw_scsiop_read_capacity(TW_Device_Extension *tw_dev, int request_id) 1595 + static int tw_scsiop_read_capacity(TW_Device_Extension *tw_dev, int request_id) 1596 1596 { 1597 1597 TW_Param *param; 1598 1598 TW_Command *command_packet; ··· 1624 1624 } 1625 1625 param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; 1626 1626 memset(param, 0, sizeof(TW_Sector)); 1627 - param->table_id = TW_UNIT_INFORMATION_TABLE_BASE + 1628 - tw_dev->srb[request_id]->device->id; 1627 + param->table_id = TW_UNIT_INFORMATION_TABLE_BASE + 1628 + tw_dev->srb[request_id]->device->id; 1629 1629 param->parameter_id = 4; /* unitcapacity parameter */ 1630 1630 param->parameter_size_bytes = 4; 1631 1631 param_value = tw_dev->alignment_physical_address[request_id]; ··· 1633 1633 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity(): Bad alignment physical address.\n"); 1634 1634 return 1; 1635 1635 } 1636 - 1636 + 1637 1637 command_packet->byte8.param.sgl[0].address = param_value; 1638 1638 command_packet->byte8.param.sgl[0].length = sizeof(TW_Sector); 1639 1639 command_que_value = tw_dev->command_packet_physical_address[request_id]; ··· 1644 1644 1645 1645 /* Now try to post the command to the board */ 1646 1646 tw_post_command_packet(tw_dev, request_id); 1647 - 1647 + 1648 1648 return 0; 1649 1649 } /* End tw_scsiop_read_capacity() */ 1650 1650 ··· 1666 1666 } 1667 1667 param_data = &(param->data[0]); 1668 1668 1669 - capacity = (param_data[3] << 24) | (param_data[2] << 16) | 1669 + capacity = (param_data[3] << 24) | (param_data[2] << 16) | 1670 1670 (param_data[1] << 8) | param_data[0]; 1671 1671 1672 1672 /* Subtract one sector to fix get last sector ioctl */ ··· 1692 1692 } /* End tw_scsiop_read_capacity_complete() */ 1693 1693 1694 1694 /* This function handles scsi read or write commands */ 1695 - static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id) 1695 + static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id) 1696 1696 { 1697 1697 TW_Command *command_packet; 1698 1698 unsigned long command_que_value; ··· 1742 1742 lba = ((u32)srb->cmnd[2] << 24) | ((u32)srb->cmnd[3] << 16) | ((u32)srb->cmnd[4] << 8) | (u32)srb->cmnd[5]; 1743 1743 num_sectors = (u32)srb->cmnd[8] | ((u32)srb->cmnd[7] << 8); 1744 1744 } 1745 - 1745 + 1746 1746 /* Update sector statistic */ 1747 1747 tw_dev->sector_count = num_sectors; 1748 1748 if (tw_dev->sector_count > tw_dev->max_sector_count) 1749 1749 tw_dev->max_sector_count = tw_dev->sector_count; 1750 - 1750 + 1751 1751 dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_read_write(): lba = 0x%x num_sectors = 0x%x\n", lba, num_sectors); 1752 1752 command_packet->byte8.io.lba = lba; 1753 1753 command_packet->byte6.block_count = num_sectors; ··· 1772 1772 dprintk(KERN_WARNING "3w-xxxx: tw_scsiop_read_write(): Bad command packet physical address.\n"); 1773 1773 return 1; 1774 1774 } 1775 - 1775 + 1776 1776 /* Now try to post the command to the board */ 1777 1777 tw_post_command_packet(tw_dev, request_id); 1778 1778 ··· 1933 1933 1934 1934 /* Save done function into struct scsi_cmnd */ 1935 1935 SCpnt->scsi_done = done; 1936 - 1936 + 1937 1937 /* Queue the command and get a request id */ 1938 1938 tw_state_request_start(tw_dev, &request_id); 1939 1939 ··· 1941 1941 tw_dev->srb[request_id] = SCpnt; 1942 1942 1943 1943 switch (*command) { 1944 - case READ_10: 1945 - case READ_6: 1946 - case WRITE_10: 1947 - case WRITE_6: 1948 - dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught READ/WRITE.\n"); 1949 - retval = tw_scsiop_read_write(tw_dev, request_id); 1950 - break; 1951 - case TEST_UNIT_READY: 1952 - dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught TEST_UNIT_READY.\n"); 1953 - retval = tw_scsiop_test_unit_ready(tw_dev, request_id); 1954 - break; 1955 - case INQUIRY: 1956 - dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught INQUIRY.\n"); 1957 - retval = tw_scsiop_inquiry(tw_dev, request_id); 1958 - break; 1959 - case READ_CAPACITY: 1960 - dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught READ_CAPACITY.\n"); 1961 - retval = tw_scsiop_read_capacity(tw_dev, request_id); 1962 - break; 1963 - case REQUEST_SENSE: 1964 - dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught REQUEST_SENSE.\n"); 1965 - retval = tw_scsiop_request_sense(tw_dev, request_id); 1966 - break; 1967 - case MODE_SENSE: 1968 - dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught MODE_SENSE.\n"); 1969 - retval = tw_scsiop_mode_sense(tw_dev, request_id); 1970 - break; 1971 - case SYNCHRONIZE_CACHE: 1972 - dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught SYNCHRONIZE_CACHE.\n"); 1973 - retval = tw_scsiop_synchronize_cache(tw_dev, request_id); 1974 - break; 1975 - case TW_IOCTL: 1976 - printk(KERN_WARNING "3w-xxxx: SCSI_IOCTL_SEND_COMMAND deprecated, please update your 3ware tools.\n"); 1977 - break; 1978 - default: 1979 - printk(KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->host->host_no, *command); 1980 - tw_dev->state[request_id] = TW_S_COMPLETED; 1981 - tw_state_request_finish(tw_dev, request_id); 1982 - SCpnt->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 1983 - scsi_build_sense_buffer(1, SCpnt->sense_buffer, ILLEGAL_REQUEST, 0x20, 0); 1984 - done(SCpnt); 1985 - retval = 0; 1944 + case READ_10: 1945 + case READ_6: 1946 + case WRITE_10: 1947 + case WRITE_6: 1948 + dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught READ/WRITE.\n"); 1949 + retval = tw_scsiop_read_write(tw_dev, request_id); 1950 + break; 1951 + case TEST_UNIT_READY: 1952 + dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught TEST_UNIT_READY.\n"); 1953 + retval = tw_scsiop_test_unit_ready(tw_dev, request_id); 1954 + break; 1955 + case INQUIRY: 1956 + dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught INQUIRY.\n"); 1957 + retval = tw_scsiop_inquiry(tw_dev, request_id); 1958 + break; 1959 + case READ_CAPACITY: 1960 + dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught READ_CAPACITY.\n"); 1961 + retval = tw_scsiop_read_capacity(tw_dev, request_id); 1962 + break; 1963 + case REQUEST_SENSE: 1964 + dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught REQUEST_SENSE.\n"); 1965 + retval = tw_scsiop_request_sense(tw_dev, request_id); 1966 + break; 1967 + case MODE_SENSE: 1968 + dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught MODE_SENSE.\n"); 1969 + retval = tw_scsiop_mode_sense(tw_dev, request_id); 1970 + break; 1971 + case SYNCHRONIZE_CACHE: 1972 + dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue(): caught SYNCHRONIZE_CACHE.\n"); 1973 + retval = tw_scsiop_synchronize_cache(tw_dev, request_id); 1974 + break; 1975 + case TW_IOCTL: 1976 + printk(KERN_WARNING "3w-xxxx: SCSI_IOCTL_SEND_COMMAND deprecated, please update your 3ware tools.\n"); 1977 + break; 1978 + default: 1979 + printk(KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->host->host_no, *command); 1980 + tw_dev->state[request_id] = TW_S_COMPLETED; 1981 + tw_state_request_finish(tw_dev, request_id); 1982 + scsi_build_sense_buffer(1, SCpnt->sense_buffer, ILLEGAL_REQUEST, 0x20, 0); 1983 + done(SCpnt); 1984 + retval = 0; 1986 1985 } 1987 1986 if (retval) { 1988 1987 tw_dev->state[request_id] = TW_S_COMPLETED; ··· 1996 1997 static DEF_SCSI_QCMD(tw_scsi_queue) 1997 1998 1998 1999 /* This function is the interrupt service routine */ 1999 - static irqreturn_t tw_interrupt(int irq, void *dev_instance) 2000 + static irqreturn_t tw_interrupt(int irq, void *dev_instance) 2000 2001 { 2001 2002 int request_id; 2002 2003 u32 status_reg_value; ··· 2072 2073 } 2073 2074 } 2074 2075 /* If there are no more pending requests, we mask command interrupt */ 2075 - if (tw_dev->pending_request_count == 0) 2076 + if (tw_dev->pending_request_count == 0) 2076 2077 TW_MASK_COMMAND_INTERRUPT(tw_dev); 2077 2078 } 2078 2079 ··· 2173 2174 tw_dev->posted_request_count--; 2174 2175 } 2175 2176 } 2176 - 2177 + 2177 2178 /* Check for valid status after each drain */ 2178 2179 status_reg_value = inl(TW_STATUS_REG_ADDR(tw_dev)); 2179 2180 if (tw_check_bits(status_reg_value)) { ··· 2243 2244 .this_id = -1, 2244 2245 .sg_tablesize = TW_MAX_SGL_LENGTH, 2245 2246 .max_sectors = TW_MAX_SECTORS, 2246 - .cmd_per_lun = TW_MAX_CMDS_PER_LUN, 2247 + .cmd_per_lun = TW_MAX_CMDS_PER_LUN, 2247 2248 .shost_attrs = tw_host_attrs, 2248 2249 .emulated = 1, 2249 2250 .no_write_same = 1,
+99 -90
drivers/scsi/3w-xxxx.h
··· 1 - /* 1 + /* 2 2 3w-xxxx.h -- 3ware Storage Controller device driver for Linux. 3 - 3 + 4 4 Written By: Adam Radford <aradford@gmail.com> 5 5 Modifications By: Joel Jacobson <linux@3ware.com> 6 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> 6 + Arnaldo Carvalho de Melo <acme@conectiva.com.br> 7 7 Brad Strand <linux@3ware.com> 8 8 9 9 Copyright (C) 1999-2010 3ware Inc. ··· 15 15 it under the terms of the GNU General Public License as published by 16 16 the Free Software Foundation; version 2 of the License. 17 17 18 - This program is distributed in the hope that it will be useful, 19 - but WITHOUT ANY WARRANTY; without even the implied warranty of 20 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 - GNU General Public License for more details. 18 + This program is distributed in the hope that it will be useful, 19 + but WITHOUT ANY WARRANTY; without even the implied warranty of 20 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 + GNU General Public License for more details. 22 22 23 - NO WARRANTY 24 - THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 25 - CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 26 - LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 27 - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 28 - solely responsible for determining the appropriateness of using and 29 - distributing the Program and assumes all risks associated with its 30 - exercise of rights under this Agreement, including but not limited to 31 - the risks and costs of program errors, damage to or loss of data, 32 - programs or equipment, and unavailability or interruption of operations. 23 + NO WARRANTY 24 + THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 25 + CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 26 + LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 27 + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 28 + solely responsible for determining the appropriateness of using and 29 + distributing the Program and assumes all risks associated with its 30 + exercise of rights under this Agreement, including but not limited to 31 + the risks and costs of program errors, damage to or loss of data, 32 + programs or equipment, and unavailability or interruption of operations. 33 33 34 - DISCLAIMER OF LIABILITY 35 - NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 36 - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 - DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 38 - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 39 - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 40 - USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 41 - HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 34 + DISCLAIMER OF LIABILITY 35 + NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 36 + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 + DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 38 + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 39 + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 40 + USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 41 + HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 42 42 43 - You should have received a copy of the GNU General Public License 44 - along with this program; if not, write to the Free Software 45 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 43 + You should have received a copy of the GNU General Public License 44 + along with this program; if not, write to the Free Software 45 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 46 46 47 - Bugs/Comments/Suggestions should be mailed to: 47 + Bugs/Comments/Suggestions should be mailed to: 48 48 49 49 aradford@gmail.com 50 - 50 + 51 51 For more information, goto: 52 52 http://www.lsi.com 53 53 */ ··· 99 99 static unsigned char tw_sense_table[][4] = 100 100 { 101 101 /* Codes for newer firmware */ 102 - // ATA Error SCSI Error 103 - {0x01, 0x03, 0x13, 0x00}, // Address mark not found Address mark not found for data field 104 - {0x04, 0x0b, 0x00, 0x00}, // Aborted command Aborted command 105 - {0x10, 0x0b, 0x14, 0x00}, // ID not found Recorded entity not found 106 - {0x40, 0x03, 0x11, 0x00}, // Uncorrectable ECC error Unrecovered read error 107 - {0x61, 0x04, 0x00, 0x00}, // Device fault Hardware error 108 - {0x84, 0x0b, 0x47, 0x00}, // Data CRC error SCSI parity error 109 - {0xd0, 0x0b, 0x00, 0x00}, // Device busy Aborted command 110 - {0xd1, 0x0b, 0x00, 0x00}, // Device busy Aborted command 111 - {0x37, 0x02, 0x04, 0x00}, // Unit offline Not ready 112 - {0x09, 0x02, 0x04, 0x00}, // Unrecovered disk error Not ready 102 + // ATA Error SCSI Error 103 + {0x01, 0x03, 0x13, 0x00}, // Address mark not found Address mark not found for data field 104 + {0x04, 0x0b, 0x00, 0x00}, // Aborted command Aborted command 105 + {0x10, 0x0b, 0x14, 0x00}, // ID not found Recorded entity not found 106 + {0x40, 0x03, 0x11, 0x00}, // Uncorrectable ECC error Unrecovered read error 107 + {0x61, 0x04, 0x00, 0x00}, // Device fault Hardware error 108 + {0x84, 0x0b, 0x47, 0x00}, // Data CRC error SCSI parity error 109 + {0xd0, 0x0b, 0x00, 0x00}, // Device busy Aborted command 110 + {0xd1, 0x0b, 0x00, 0x00}, // Device busy Aborted command 111 + {0x37, 0x02, 0x04, 0x00}, // Unit offline Not ready 112 + {0x09, 0x02, 0x04, 0x00}, // Unrecovered disk error Not ready 113 113 114 - /* Codes for older firmware */ 115 - // 3ware Error SCSI Error 116 - {0x51, 0x0b, 0x00, 0x00} // Unspecified Aborted command 114 + /* Codes for older firmware */ 115 + // 3ware Error SCSI Error 116 + {0x51, 0x0b, 0x00, 0x00} // Unspecified Aborted command 117 117 }; 118 118 119 119 /* Control register bit definitions */ ··· 128 128 #define TW_CONTROL_ENABLE_INTERRUPTS 0x00000080 129 129 #define TW_CONTROL_DISABLE_INTERRUPTS 0x00000040 130 130 #define TW_CONTROL_ISSUE_HOST_INTERRUPT 0x00000020 131 - #define TW_CONTROL_CLEAR_PARITY_ERROR 0x00800000 132 - #define TW_CONTROL_CLEAR_QUEUE_ERROR 0x00400000 133 - #define TW_CONTROL_CLEAR_PCI_ABORT 0x00100000 131 + #define TW_CONTROL_CLEAR_PARITY_ERROR 0x00800000 132 + #define TW_CONTROL_CLEAR_QUEUE_ERROR 0x00400000 133 + #define TW_CONTROL_CLEAR_PCI_ABORT 0x00100000 134 134 #define TW_CONTROL_CLEAR_SBUF_WRITE_ERROR 0x00000008 135 135 136 136 /* Status register bit definitions */ ··· 152 152 #define TW_STATUS_CLEARABLE_BITS 0x00D00000 153 153 #define TW_STATUS_EXPECTED_BITS 0x00002000 154 154 #define TW_STATUS_UNEXPECTED_BITS 0x00F00008 155 - #define TW_STATUS_SBUF_WRITE_ERROR 0x00000008 156 - #define TW_STATUS_VALID_INTERRUPT 0x00DF0008 155 + #define TW_STATUS_SBUF_WRITE_ERROR 0x00000008 156 + #define TW_STATUS_VALID_INTERRUPT 0x00DF0008 157 157 158 158 /* RESPONSE QUEUE BIT DEFINITIONS */ 159 159 #define TW_RESPONSE_ID_MASK 0x00000FF0 ··· 179 179 #define TW_OP_SECTOR_INFO 0x1a 180 180 #define TW_OP_AEN_LISTEN 0x1c 181 181 #define TW_OP_FLUSH_CACHE 0x0e 182 - #define TW_CMD_PACKET 0x1d 182 + #define TW_CMD_PACKET 0x1d 183 183 #define TW_CMD_PACKET_WITH_DATA 0x1f 184 184 185 185 /* Asynchronous Event Notification (AEN) Codes */ 186 186 #define TW_AEN_QUEUE_EMPTY 0x0000 187 - #define TW_AEN_SOFT_RESET 0x0001 187 + #define TW_AEN_SOFT_RESET 0x0001 188 188 #define TW_AEN_DEGRADED_MIRROR 0x0002 189 189 #define TW_AEN_CONTROLLER_ERROR 0x0003 190 190 #define TW_AEN_REBUILD_FAIL 0x0004 191 191 #define TW_AEN_REBUILD_DONE 0x0005 192 - #define TW_AEN_QUEUE_FULL 0x00ff 192 + #define TW_AEN_QUEUE_FULL 0x00ff 193 193 #define TW_AEN_TABLE_UNDEFINED 0x15 194 194 #define TW_AEN_APORT_TIMEOUT 0x0009 195 195 #define TW_AEN_DRIVE_ERROR 0x000A 196 - #define TW_AEN_SMART_FAIL 0x000F 197 - #define TW_AEN_SBUF_FAIL 0x0024 196 + #define TW_AEN_SMART_FAIL 0x000F 197 + #define TW_AEN_SBUF_FAIL 0x0024 198 198 199 199 /* Misc defines */ 200 200 #define TW_ALIGNMENT_6000 64 /* 64 bytes */ 201 - #define TW_ALIGNMENT_7000 4 /* 4 bytes */ 201 + #define TW_ALIGNMENT_7000 4 /* 4 bytes */ 202 202 #define TW_MAX_UNITS 16 203 203 #define TW_COMMAND_ALIGNMENT_MASK 0x1ff 204 204 #define TW_INIT_MESSAGE_CREDITS 0x100 205 205 #define TW_INIT_COMMAND_PACKET_SIZE 0x3 206 - #define TW_POLL_MAX_RETRIES 20000 206 + #define TW_POLL_MAX_RETRIES 20000 207 207 #define TW_MAX_SGL_LENGTH 62 208 - #define TW_ATA_PASS_SGL_MAX 60 208 + #define TW_ATA_PASS_SGL_MAX 60 209 209 #define TW_Q_LENGTH 256 210 210 #define TW_Q_START 0 211 211 #define TW_MAX_SLOT 32 ··· 216 216 chrdev ioctl, one for 217 217 internal aen post */ 218 218 #define TW_BLOCK_SIZE 0x200 /* 512-byte blocks */ 219 - #define TW_IOCTL 0x80 220 - #define TW_UNIT_ONLINE 1 221 - #define TW_IN_INTR 1 222 - #define TW_IN_RESET 2 223 - #define TW_IN_CHRDEV_IOCTL 3 224 - #define TW_MAX_SECTORS 256 219 + #define TW_IOCTL 0x80 220 + #define TW_UNIT_ONLINE 1 221 + #define TW_IN_INTR 1 222 + #define TW_IN_RESET 2 223 + #define TW_IN_CHRDEV_IOCTL 3 224 + #define TW_MAX_SECTORS 256 225 225 #define TW_MAX_IOCTL_SECTORS 512 226 - #define TW_AEN_WAIT_TIME 1000 227 - #define TW_IOCTL_WAIT_TIME (1 * HZ) /* 1 second */ 228 - #define TW_ISR_DONT_COMPLETE 2 229 - #define TW_ISR_DONT_RESULT 3 230 - #define TW_IOCTL_TIMEOUT 25 /* 25 seconds */ 231 - #define TW_IOCTL_CHRDEV_TIMEOUT 60 /* 60 seconds */ 232 - #define TW_IOCTL_CHRDEV_FREE -1 226 + #define TW_AEN_WAIT_TIME 1000 227 + #define TW_IOCTL_WAIT_TIME (1 * HZ) /* 1 second */ 228 + #define TW_ISR_DONT_COMPLETE 2 229 + #define TW_ISR_DONT_RESULT 3 230 + #define TW_IOCTL_TIMEOUT 25 /* 25 seconds */ 231 + #define TW_IOCTL_CHRDEV_TIMEOUT 60 /* 60 seconds */ 232 + #define TW_IOCTL_CHRDEV_FREE -1 233 233 #define TW_MAX_CDB_LEN 16 234 234 235 235 /* Bitmask macros to eliminate bitfields */ ··· 250 250 #define TW_STATUS_REG_ADDR(x) (x->base_addr + 0x4) 251 251 #define TW_COMMAND_QUEUE_REG_ADDR(x) (x->base_addr + 0x8) 252 252 #define TW_RESPONSE_QUEUE_REG_ADDR(x) (x->base_addr + 0xC) 253 - #define TW_CLEAR_ALL_INTERRUPTS(x) (outl(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 254 - #define TW_CLEAR_ATTENTION_INTERRUPT(x) (outl(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 255 - #define TW_CLEAR_HOST_INTERRUPT(x) (outl(TW_CONTROL_CLEAR_HOST_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 256 - #define TW_DISABLE_INTERRUPTS(x) (outl(TW_CONTROL_DISABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x))) 257 - #define TW_ENABLE_AND_CLEAR_INTERRUPTS(x) (outl(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT | TW_CONTROL_UNMASK_RESPONSE_INTERRUPT | TW_CONTROL_ENABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x))) 258 - #define TW_MASK_COMMAND_INTERRUPT(x) (outl(TW_CONTROL_MASK_COMMAND_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 259 - #define TW_UNMASK_COMMAND_INTERRUPT(x) (outl(TW_CONTROL_UNMASK_COMMAND_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 260 - #define TW_SOFT_RESET(x) (outl(TW_CONTROL_ISSUE_SOFT_RESET | \ 261 - TW_CONTROL_CLEAR_HOST_INTERRUPT | \ 262 - TW_CONTROL_CLEAR_ATTENTION_INTERRUPT | \ 263 - TW_CONTROL_MASK_COMMAND_INTERRUPT | \ 264 - TW_CONTROL_MASK_RESPONSE_INTERRUPT | \ 265 - TW_CONTROL_CLEAR_ERROR_STATUS | \ 266 - TW_CONTROL_DISABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x))) 267 - #define TW_STATUS_ERRORS(x) \ 268 - (((x & TW_STATUS_PCI_ABORT) || \ 269 - (x & TW_STATUS_PCI_PARITY_ERROR) || \ 270 - (x & TW_STATUS_QUEUE_ERROR) || \ 271 - (x & TW_STATUS_MICROCONTROLLER_ERROR)) && \ 272 - (x & TW_STATUS_MICROCONTROLLER_READY)) 253 + #define TW_CLEAR_ALL_INTERRUPTS(x) \ 254 + (outl(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 255 + #define TW_CLEAR_ATTENTION_INTERRUPT(x) \ 256 + (outl(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 257 + #define TW_CLEAR_HOST_INTERRUPT(x) \ 258 + (outl(TW_CONTROL_CLEAR_HOST_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 259 + #define TW_DISABLE_INTERRUPTS(x) \ 260 + (outl(TW_CONTROL_DISABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x))) 261 + #define TW_ENABLE_AND_CLEAR_INTERRUPTS(x) \ 262 + (outl(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT | \ 263 + TW_CONTROL_UNMASK_RESPONSE_INTERRUPT | \ 264 + TW_CONTROL_ENABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x))) 265 + #define TW_MASK_COMMAND_INTERRUPT(x) \ 266 + (outl(TW_CONTROL_MASK_COMMAND_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 267 + #define TW_UNMASK_COMMAND_INTERRUPT(x) \ 268 + (outl(TW_CONTROL_UNMASK_COMMAND_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 269 + #define TW_SOFT_RESET(x) (outl(TW_CONTROL_ISSUE_SOFT_RESET | \ 270 + TW_CONTROL_CLEAR_HOST_INTERRUPT | \ 271 + TW_CONTROL_CLEAR_ATTENTION_INTERRUPT | \ 272 + TW_CONTROL_MASK_COMMAND_INTERRUPT | \ 273 + TW_CONTROL_MASK_RESPONSE_INTERRUPT | \ 274 + TW_CONTROL_CLEAR_ERROR_STATUS | \ 275 + TW_CONTROL_DISABLE_INTERRUPTS, TW_CONTROL_REG_ADDR(x))) 276 + #define TW_STATUS_ERRORS(x) \ 277 + (((x & TW_STATUS_PCI_ABORT) || \ 278 + (x & TW_STATUS_PCI_PARITY_ERROR) || \ 279 + (x & TW_STATUS_QUEUE_ERROR) || \ 280 + (x & TW_STATUS_MICROCONTROLLER_ERROR)) && \ 281 + (x & TW_STATUS_MICROCONTROLLER_READY)) 273 282 274 283 #ifdef TW_DEBUG 275 284 #define dprintk(msg...) printk(msg)