[SCSI] 3w-9xxx: add MSI support and misc fixes

This patch for the 3w-9xxx scsi driver applies on top of the
BKL-pushdown changes in -git9.

This patch does the following:

- Increase max AENs drained to 256.
- Add MSI support and "use_msi" module parameter.
- Fix bug in twa_get_param() on 4GB+.
- Use pci_resource_len() for ioremap().

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

authored by

adam radford and committed by
James Bottomley
3dabec71 6bd522f6

+35 -14
+30 -10
drivers/scsi/3w-9xxx.c
··· 4 Written By: Adam Radford <linuxraid@amcc.com> 5 Modifications By: Tom Couch <linuxraid@amcc.com> 6 7 - Copyright (C) 2004-2007 Applied Micro Circuits Corporation. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by ··· 71 Add support for 9650SE controllers. 72 2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails. 73 2.26.02.010 - Add support for 9690SA controllers. 74 */ 75 76 #include <linux/module.h> ··· 99 #include "3w-9xxx.h" 100 101 /* Globals */ 102 - #define TW_DRIVER_VERSION "2.26.02.010" 103 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 104 static unsigned int twa_device_extension_count; 105 static int twa_major = -1; ··· 110 MODULE_DESCRIPTION ("3ware 9000 Storage Controller Linux Driver"); 111 MODULE_LICENSE("GPL"); 112 MODULE_VERSION(TW_DRIVER_VERSION); 113 114 /* Function prototypes */ 115 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header); ··· 1046 TW_Command_Full *full_command_packet; 1047 TW_Command *command_packet; 1048 TW_Param_Apache *param; 1049 - unsigned long param_value; 1050 void *retval = NULL; 1051 1052 /* Setup the command packet */ ··· 1064 param->table_id = cpu_to_le16(table_id | 0x8000); 1065 param->parameter_id = cpu_to_le16(parameter_id); 1066 param->parameter_size_bytes = cpu_to_le16(parameter_size_bytes); 1067 - param_value = tw_dev->generic_buffer_phys[request_id]; 1068 1069 - command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(param_value); 1070 command_packet->byte8_offset.param.sgl[0].length = cpu_to_le32(TW_SECTOR_SIZE); 1071 1072 /* Post the command packet to the board */ ··· 2006 { 2007 struct Scsi_Host *host = NULL; 2008 TW_Device_Extension *tw_dev; 2009 - u32 mem_addr; 2010 int retval = -ENODEV; 2011 2012 retval = pci_enable_device(pdev); ··· 2051 goto out_free_device_extension; 2052 } 2053 2054 - if (pdev->device == PCI_DEVICE_ID_3WARE_9000) 2055 mem_addr = pci_resource_start(pdev, 1); 2056 - else 2057 mem_addr = pci_resource_start(pdev, 2); 2058 2059 /* Save base address */ 2060 - tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE); 2061 if (!tw_dev->base_addr) { 2062 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap"); 2063 goto out_release_mem_region; ··· 2095 2096 pci_set_drvdata(pdev, host); 2097 2098 - printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%x, IRQ: %d.\n", 2099 host->host_no, mem_addr, pdev->irq); 2100 printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s, Ports: %d.\n", 2101 host->host_no, ··· 2105 TW_PARAM_BIOSVER, TW_PARAM_BIOSVER_LENGTH), 2106 le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE, 2107 TW_PARAM_PORTCOUNT, TW_PARAM_PORTCOUNT_LENGTH))); 2108 2109 /* Now setup the interrupt handler */ 2110 retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev); ··· 2134 return 0; 2135 2136 out_remove_host: 2137 scsi_remove_host(host); 2138 out_iounmap: 2139 iounmap(tw_dev->base_addr); ··· 2166 2167 /* Shutdown the card */ 2168 __twa_shutdown(tw_dev); 2169 2170 /* Free IO remapping */ 2171 iounmap(tw_dev->base_addr);
··· 4 Written By: Adam Radford <linuxraid@amcc.com> 5 Modifications By: Tom Couch <linuxraid@amcc.com> 6 7 + Copyright (C) 2004-2008 Applied Micro Circuits Corporation. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by ··· 71 Add support for 9650SE controllers. 72 2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails. 73 2.26.02.010 - Add support for 9690SA controllers. 74 + 2.26.02.011 - Increase max AENs drained to 256. 75 + Add MSI support and "use_msi" module parameter. 76 + Fix bug in twa_get_param() on 4GB+. 77 + Use pci_resource_len() for ioremap(). 78 */ 79 80 #include <linux/module.h> ··· 95 #include "3w-9xxx.h" 96 97 /* Globals */ 98 + #define TW_DRIVER_VERSION "2.26.02.011" 99 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 100 static unsigned int twa_device_extension_count; 101 static int twa_major = -1; ··· 106 MODULE_DESCRIPTION ("3ware 9000 Storage Controller Linux Driver"); 107 MODULE_LICENSE("GPL"); 108 MODULE_VERSION(TW_DRIVER_VERSION); 109 + 110 + static int use_msi = 0; 111 + module_param(use_msi, int, S_IRUGO); 112 + MODULE_PARM_DESC(use_msi, "Use Message Signaled Interrupts. Default: 0"); 113 114 /* Function prototypes */ 115 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header); ··· 1038 TW_Command_Full *full_command_packet; 1039 TW_Command *command_packet; 1040 TW_Param_Apache *param; 1041 void *retval = NULL; 1042 1043 /* Setup the command packet */ ··· 1057 param->table_id = cpu_to_le16(table_id | 0x8000); 1058 param->parameter_id = cpu_to_le16(parameter_id); 1059 param->parameter_size_bytes = cpu_to_le16(parameter_size_bytes); 1060 1061 + command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]); 1062 command_packet->byte8_offset.param.sgl[0].length = cpu_to_le32(TW_SECTOR_SIZE); 1063 1064 /* Post the command packet to the board */ ··· 2000 { 2001 struct Scsi_Host *host = NULL; 2002 TW_Device_Extension *tw_dev; 2003 + unsigned long mem_addr, mem_len; 2004 int retval = -ENODEV; 2005 2006 retval = pci_enable_device(pdev); ··· 2045 goto out_free_device_extension; 2046 } 2047 2048 + if (pdev->device == PCI_DEVICE_ID_3WARE_9000) { 2049 mem_addr = pci_resource_start(pdev, 1); 2050 + mem_len = pci_resource_len(pdev, 1); 2051 + } else { 2052 mem_addr = pci_resource_start(pdev, 2); 2053 + mem_len = pci_resource_len(pdev, 2); 2054 + } 2055 2056 /* Save base address */ 2057 + tw_dev->base_addr = ioremap(mem_addr, mem_len); 2058 if (!tw_dev->base_addr) { 2059 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap"); 2060 goto out_release_mem_region; ··· 2086 2087 pci_set_drvdata(pdev, host); 2088 2089 + printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%lx, IRQ: %d.\n", 2090 host->host_no, mem_addr, pdev->irq); 2091 printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s, Ports: %d.\n", 2092 host->host_no, ··· 2096 TW_PARAM_BIOSVER, TW_PARAM_BIOSVER_LENGTH), 2097 le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE, 2098 TW_PARAM_PORTCOUNT, TW_PARAM_PORTCOUNT_LENGTH))); 2099 + 2100 + /* Try to enable MSI */ 2101 + if (use_msi && (pdev->device != PCI_DEVICE_ID_3WARE_9000) && 2102 + !pci_enable_msi(pdev)) 2103 + set_bit(TW_USING_MSI, &tw_dev->flags); 2104 2105 /* Now setup the interrupt handler */ 2106 retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev); ··· 2120 return 0; 2121 2122 out_remove_host: 2123 + if (test_bit(TW_USING_MSI, &tw_dev->flags)) 2124 + pci_disable_msi(pdev); 2125 scsi_remove_host(host); 2126 out_iounmap: 2127 iounmap(tw_dev->base_addr); ··· 2150 2151 /* Shutdown the card */ 2152 __twa_shutdown(tw_dev); 2153 + 2154 + /* Disable MSI if enabled */ 2155 + if (test_bit(TW_USING_MSI, &tw_dev->flags)) 2156 + pci_disable_msi(pdev); 2157 2158 /* Free IO remapping */ 2159 iounmap(tw_dev->base_addr);
+5 -4
drivers/scsi/3w-9xxx.h
··· 4 Written By: Adam Radford <linuxraid@amcc.com> 5 Modifications By: Tom Couch <linuxraid@amcc.com> 6 7 - Copyright (C) 2004-2007 Applied Micro Circuits Corporation. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by ··· 319 320 /* Compatibility defines */ 321 #define TW_9000_ARCH_ID 0x5 322 - #define TW_CURRENT_DRIVER_SRL 30 323 - #define TW_CURRENT_DRIVER_BUILD 80 324 #define TW_CURRENT_DRIVER_BRANCH 0 325 326 /* Phase defines */ ··· 352 #define TW_MAX_RESET_TRIES 2 353 #define TW_MAX_CMDS_PER_LUN 254 354 #define TW_MAX_RESPONSE_DRAIN 256 355 - #define TW_MAX_AEN_DRAIN 40 356 #define TW_IN_RESET 2 357 #define TW_IN_ATTENTION_LOOP 4 358 #define TW_MAX_SECTORS 256 359 #define TW_AEN_WAIT_TIME 1000
··· 4 Written By: Adam Radford <linuxraid@amcc.com> 5 Modifications By: Tom Couch <linuxraid@amcc.com> 6 7 + Copyright (C) 2004-2008 Applied Micro Circuits Corporation. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by ··· 319 320 /* Compatibility defines */ 321 #define TW_9000_ARCH_ID 0x5 322 + #define TW_CURRENT_DRIVER_SRL 35 323 + #define TW_CURRENT_DRIVER_BUILD 0 324 #define TW_CURRENT_DRIVER_BRANCH 0 325 326 /* Phase defines */ ··· 352 #define TW_MAX_RESET_TRIES 2 353 #define TW_MAX_CMDS_PER_LUN 254 354 #define TW_MAX_RESPONSE_DRAIN 256 355 + #define TW_MAX_AEN_DRAIN 255 356 #define TW_IN_RESET 2 357 + #define TW_USING_MSI 3 358 #define TW_IN_ATTENTION_LOOP 4 359 #define TW_MAX_SECTORS 256 360 #define TW_AEN_WAIT_TIME 1000