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