public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] 3ware add MSI support
@ 2008-07-22 23:36 adam radford
  2008-07-22 23:47 ` adam radford
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: adam radford @ 2008-07-22 23:36 UTC (permalink / raw)
  To: James Bottomley, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 6456 bytes --]

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().

James, could you please apply this?

Thanks,

-Adam

Note: This patch is included in-line below and also as an attachment
in case Gmail hoses the patch.

diff -Naur scsi-misc/drivers/scsi/3w-9xxx.c scsi-misc.new/drivers/scsi/3w-9xxx.c
--- scsi-misc/drivers/scsi/3w-9xxx.c	2008-07-22 15:00:10.000000000 -0700
+++ scsi-misc.new/drivers/scsi/3w-9xxx.c	2008-07-22 15:14:34.000000000 -0700
@@ -4,7 +4,7 @@
    Written By: Adam Radford <linuxraid@amcc.com>
    Modifications By: Tom Couch <linuxraid@amcc.com>

-   Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
+   Copyright (C) 2004-2008 Applied Micro Circuits Corporation.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -71,6 +71,10 @@
                  Add support for 9650SE controllers.
    2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails.
    2.26.02.010 - Add support for 9690SA controllers.
+   2.26.02.011 - 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().
 */

 #include <linux/module.h>
@@ -95,7 +99,7 @@
 #include "3w-9xxx.h"

 /* Globals */
-#define TW_DRIVER_VERSION "2.26.02.010"
+#define TW_DRIVER_VERSION "2.26.02.011"
 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
 static unsigned int twa_device_extension_count;
 static int twa_major = -1;
@@ -107,6 +111,10 @@
 MODULE_LICENSE("GPL");
 MODULE_VERSION(TW_DRIVER_VERSION);

+static int use_msi = 0;
+module_param(use_msi, int, S_IRUGO);
+MODULE_PARM_DESC(use_msi, "Use Message Signaled Interrupts.  Default: 0");
+
 /* Function prototypes */
 static void twa_aen_queue_event(TW_Device_Extension *tw_dev,
TW_Command_Apache_Header *header);
 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
@@ -1038,7 +1046,6 @@
 	TW_Command_Full *full_command_packet;
 	TW_Command *command_packet;
 	TW_Param_Apache *param;
-	unsigned long param_value;
 	void *retval = NULL;

 	/* Setup the command packet */
@@ -1057,9 +1064,8 @@
 	param->table_id = cpu_to_le16(table_id | 0x8000);
 	param->parameter_id = cpu_to_le16(parameter_id);
 	param->parameter_size_bytes = cpu_to_le16(parameter_size_bytes);
-	param_value = tw_dev->generic_buffer_phys[request_id];

-	command_packet->byte8_offset.param.sgl[0].address =
TW_CPU_TO_SGL(param_value);
+	command_packet->byte8_offset.param.sgl[0].address =
TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
 	command_packet->byte8_offset.param.sgl[0].length =
cpu_to_le32(TW_SECTOR_SIZE);

 	/* Post the command packet to the board */
@@ -2000,7 +2006,7 @@
 {
 	struct Scsi_Host *host = NULL;
 	TW_Device_Extension *tw_dev;
-	u32 mem_addr;
+	unsigned long mem_addr, mem_len;
 	int retval = -ENODEV;

 	retval = pci_enable_device(pdev);
@@ -2045,13 +2051,16 @@
 		goto out_free_device_extension;
 	}

-	if (pdev->device == PCI_DEVICE_ID_3WARE_9000)
+	if (pdev->device == PCI_DEVICE_ID_3WARE_9000) {
 		mem_addr = pci_resource_start(pdev, 1);
-	else
+		mem_len = pci_resource_len(pdev, 1);
+	} else {
 		mem_addr = pci_resource_start(pdev, 2);
+		mem_len = pci_resource_len(pdev, 2);
+	}

 	/* Save base address */
-	tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE);
+	tw_dev->base_addr = ioremap(mem_addr, mem_len);
 	if (!tw_dev->base_addr) {
 		TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap");
 		goto out_release_mem_region;
@@ -2086,7 +2095,7 @@

 	pci_set_drvdata(pdev, host);

-	printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage
Controller at 0x%x, IRQ: %d.\n",
+	printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage
Controller at 0x%lx, IRQ: %d.\n",
 	       host->host_no, mem_addr, pdev->irq);
 	printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s, Ports: %d.\n",
 	       host->host_no,
@@ -2097,6 +2106,11 @@
 	       le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE,
 				     TW_PARAM_PORTCOUNT, TW_PARAM_PORTCOUNT_LENGTH)));

+	/* Try to enable MSI */
+	if (use_msi && (pdev->device != PCI_DEVICE_ID_3WARE_9000) &&
+	    !pci_enable_msi(pdev))
+		set_bit(TW_USING_MSI, &tw_dev->flags);
+
 	/* Now setup the interrupt handler */
 	retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED,
"3w-9xxx", tw_dev);
 	if (retval) {
@@ -2120,6 +2134,8 @@
 	return 0;

 out_remove_host:
+	if (test_bit(TW_USING_MSI, &tw_dev->flags))
+		pci_disable_msi(pdev);
 	scsi_remove_host(host);
 out_iounmap:
 	iounmap(tw_dev->base_addr);
@@ -2151,6 +2167,10 @@
 	/* Shutdown the card */
 	__twa_shutdown(tw_dev);

+	/* Disable MSI if enabled */
+	if (test_bit(TW_USING_MSI, &tw_dev->flags))
+		pci_disable_msi(pdev);
+
 	/* Free IO remapping */
 	iounmap(tw_dev->base_addr);

diff -Naur scsi-misc/drivers/scsi/3w-9xxx.h scsi-misc.new/drivers/scsi/3w-9xxx.h
--- scsi-misc/drivers/scsi/3w-9xxx.h	2008-07-13 14:51:29.000000000 -0700
+++ scsi-misc.new/drivers/scsi/3w-9xxx.h	2008-07-22 15:14:35.000000000 -0700
@@ -4,7 +4,7 @@
    Written By: Adam Radford <linuxraid@amcc.com>
    Modifications By: Tom Couch <linuxraid@amcc.com>

-   Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
+   Copyright (C) 2004-2008 Applied Micro Circuits Corporation.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -319,8 +319,8 @@

 /* Compatibility defines */
 #define TW_9000_ARCH_ID 0x5
-#define TW_CURRENT_DRIVER_SRL 30
-#define TW_CURRENT_DRIVER_BUILD 80
+#define TW_CURRENT_DRIVER_SRL 35
+#define TW_CURRENT_DRIVER_BUILD 0
 #define TW_CURRENT_DRIVER_BRANCH 0

 /* Phase defines */
@@ -352,8 +352,9 @@
 #define TW_MAX_RESET_TRIES		      2
 #define TW_MAX_CMDS_PER_LUN		      254
 #define TW_MAX_RESPONSE_DRAIN		      256
-#define TW_MAX_AEN_DRAIN		      40
+#define TW_MAX_AEN_DRAIN		      255
 #define TW_IN_RESET                           2
+#define TW_USING_MSI			      3
 #define TW_IN_ATTENTION_LOOP		      4
 #define TW_MAX_SECTORS                        256
 #define TW_AEN_WAIT_TIME                      1000

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 3ware_2.6.26-git10.patch --]
[-- Type: text/x-patch; name=3ware_2.6.26-git10.patch, Size: 6033 bytes --]

diff -Naur scsi-misc/drivers/scsi/3w-9xxx.c scsi-misc.new/drivers/scsi/3w-9xxx.c
--- scsi-misc/drivers/scsi/3w-9xxx.c	2008-07-22 15:00:10.000000000 -0700
+++ scsi-misc.new/drivers/scsi/3w-9xxx.c	2008-07-22 15:14:34.000000000 -0700
@@ -4,7 +4,7 @@
    Written By: Adam Radford <linuxraid@amcc.com>
    Modifications By: Tom Couch <linuxraid@amcc.com>
 
-   Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
+   Copyright (C) 2004-2008 Applied Micro Circuits Corporation.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -71,6 +71,10 @@
                  Add support for 9650SE controllers.
    2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails.
    2.26.02.010 - Add support for 9690SA controllers.
+   2.26.02.011 - 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().
 */
 
 #include <linux/module.h>
@@ -95,7 +99,7 @@
 #include "3w-9xxx.h"
 
 /* Globals */
-#define TW_DRIVER_VERSION "2.26.02.010"
+#define TW_DRIVER_VERSION "2.26.02.011"
 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
 static unsigned int twa_device_extension_count;
 static int twa_major = -1;
@@ -107,6 +111,10 @@
 MODULE_LICENSE("GPL");
 MODULE_VERSION(TW_DRIVER_VERSION);
 
+static int use_msi = 0;
+module_param(use_msi, int, S_IRUGO);
+MODULE_PARM_DESC(use_msi, "Use Message Signaled Interrupts.  Default: 0");
+
 /* Function prototypes */
 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header);
 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
@@ -1038,7 +1046,6 @@
 	TW_Command_Full *full_command_packet;
 	TW_Command *command_packet;
 	TW_Param_Apache *param;
-	unsigned long param_value;
 	void *retval = NULL;
 
 	/* Setup the command packet */
@@ -1057,9 +1064,8 @@
 	param->table_id = cpu_to_le16(table_id | 0x8000);
 	param->parameter_id = cpu_to_le16(parameter_id);
 	param->parameter_size_bytes = cpu_to_le16(parameter_size_bytes);
-	param_value = tw_dev->generic_buffer_phys[request_id];
 
-	command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(param_value);
+	command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
 	command_packet->byte8_offset.param.sgl[0].length = cpu_to_le32(TW_SECTOR_SIZE);
 
 	/* Post the command packet to the board */
@@ -2000,7 +2006,7 @@
 {
 	struct Scsi_Host *host = NULL;
 	TW_Device_Extension *tw_dev;
-	u32 mem_addr;
+	unsigned long mem_addr, mem_len;
 	int retval = -ENODEV;
 
 	retval = pci_enable_device(pdev);
@@ -2045,13 +2051,16 @@
 		goto out_free_device_extension;
 	}
 
-	if (pdev->device == PCI_DEVICE_ID_3WARE_9000)
+	if (pdev->device == PCI_DEVICE_ID_3WARE_9000) {
 		mem_addr = pci_resource_start(pdev, 1);
-	else
+		mem_len = pci_resource_len(pdev, 1);
+	} else {
 		mem_addr = pci_resource_start(pdev, 2);
+		mem_len = pci_resource_len(pdev, 2);
+	}
 
 	/* Save base address */
-	tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE);
+	tw_dev->base_addr = ioremap(mem_addr, mem_len);
 	if (!tw_dev->base_addr) {
 		TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap");
 		goto out_release_mem_region;
@@ -2086,7 +2095,7 @@
 
 	pci_set_drvdata(pdev, host);
 
-	printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%x, IRQ: %d.\n",
+	printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%lx, IRQ: %d.\n",
 	       host->host_no, mem_addr, pdev->irq);
 	printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s, Ports: %d.\n",
 	       host->host_no,
@@ -2097,6 +2106,11 @@
 	       le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE,
 				     TW_PARAM_PORTCOUNT, TW_PARAM_PORTCOUNT_LENGTH)));
 
+	/* Try to enable MSI */
+	if (use_msi && (pdev->device != PCI_DEVICE_ID_3WARE_9000) &&
+	    !pci_enable_msi(pdev))
+		set_bit(TW_USING_MSI, &tw_dev->flags);
+
 	/* Now setup the interrupt handler */
 	retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev);
 	if (retval) {
@@ -2120,6 +2134,8 @@
 	return 0;
 
 out_remove_host:
+	if (test_bit(TW_USING_MSI, &tw_dev->flags))
+		pci_disable_msi(pdev);
 	scsi_remove_host(host);
 out_iounmap:
 	iounmap(tw_dev->base_addr);
@@ -2151,6 +2167,10 @@
 	/* Shutdown the card */
 	__twa_shutdown(tw_dev);
 
+	/* Disable MSI if enabled */
+	if (test_bit(TW_USING_MSI, &tw_dev->flags))
+		pci_disable_msi(pdev);
+
 	/* Free IO remapping */
 	iounmap(tw_dev->base_addr);
 
diff -Naur scsi-misc/drivers/scsi/3w-9xxx.h scsi-misc.new/drivers/scsi/3w-9xxx.h
--- scsi-misc/drivers/scsi/3w-9xxx.h	2008-07-13 14:51:29.000000000 -0700
+++ scsi-misc.new/drivers/scsi/3w-9xxx.h	2008-07-22 15:14:35.000000000 -0700
@@ -4,7 +4,7 @@
    Written By: Adam Radford <linuxraid@amcc.com>
    Modifications By: Tom Couch <linuxraid@amcc.com>
 
-   Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
+   Copyright (C) 2004-2008 Applied Micro Circuits Corporation.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -319,8 +319,8 @@
 
 /* Compatibility defines */
 #define TW_9000_ARCH_ID 0x5
-#define TW_CURRENT_DRIVER_SRL 30
-#define TW_CURRENT_DRIVER_BUILD 80
+#define TW_CURRENT_DRIVER_SRL 35
+#define TW_CURRENT_DRIVER_BUILD 0
 #define TW_CURRENT_DRIVER_BRANCH 0
 
 /* Phase defines */
@@ -352,8 +352,9 @@
 #define TW_MAX_RESET_TRIES		      2
 #define TW_MAX_CMDS_PER_LUN		      254
 #define TW_MAX_RESPONSE_DRAIN		      256
-#define TW_MAX_AEN_DRAIN		      40
+#define TW_MAX_AEN_DRAIN		      255
 #define TW_IN_RESET                           2
+#define TW_USING_MSI			      3
 #define TW_IN_ATTENTION_LOOP		      4
 #define TW_MAX_SECTORS                        256
 #define TW_AEN_WAIT_TIME                      1000

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/1] 3ware add MSI support
  2008-07-22 23:36 [PATCH 1/1] 3ware add MSI support adam radford
@ 2008-07-22 23:47 ` adam radford
  2008-07-23  1:47 ` Matthew Wilcox
  2008-07-23  5:29 ` Rolf Eike Beer
  2 siblings, 0 replies; 8+ messages in thread
From: adam radford @ 2008-07-22 23:47 UTC (permalink / raw)
  To: linux-scsi

[-- Attachment #1: Type: text/plain, Size: 6982 bytes --]

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().

James, could you please apply this?

Thanks,

-Adam

Note: This patch is included in-line below and also as an attachment
in case Gmail hoses the patch.

diff -Naur scsi-misc/drivers/scsi/3w-9xxx.c scsi-misc.new/drivers/scsi/3w-9xxx.c
--- scsi-misc/drivers/scsi/3w-9xxx.c    2008-07-22 15:00:10.000000000 -0700
+++ scsi-misc.new/drivers/scsi/3w-9xxx.c        2008-07-22
15:14:34.000000000 -0700
@@ -4,7 +4,7 @@
   Written By: Adam Radford <linuxraid@amcc.com>
   Modifications By: Tom Couch <linuxraid@amcc.com>

-   Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
+   Copyright (C) 2004-2008 Applied Micro Circuits Corporation.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -71,6 +71,10 @@
                 Add support for 9650SE controllers.
   2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails.
   2.26.02.010 - Add support for 9690SA controllers.
+   2.26.02.011 - 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().
 */

 #include <linux/module.h>
@@ -95,7 +99,7 @@
 #include "3w-9xxx.h"

 /* Globals */
-#define TW_DRIVER_VERSION "2.26.02.010"
+#define TW_DRIVER_VERSION "2.26.02.011"
 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
 static unsigned int twa_device_extension_count;
 static int twa_major = -1;
@@ -107,6 +111,10 @@
 MODULE_LICENSE("GPL");
 MODULE_VERSION(TW_DRIVER_VERSION);

+static int use_msi = 0;
+module_param(use_msi, int, S_IRUGO);
+MODULE_PARM_DESC(use_msi, "Use Message Signaled Interrupts.  Default: 0");
+
 /* Function prototypes */
 static void twa_aen_queue_event(TW_Device_Extension *tw_dev,
TW_Command_Apache_Header *header);
 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
@@ -1038,7 +1046,6 @@
       TW_Command_Full *full_command_packet;
       TW_Command *command_packet;
       TW_Param_Apache *param;
-       unsigned long param_value;
       void *retval = NULL;

       /* Setup the command packet */
@@ -1057,9 +1064,8 @@
       param->table_id = cpu_to_le16(table_id | 0x8000);
       param->parameter_id = cpu_to_le16(parameter_id);
       param->parameter_size_bytes = cpu_to_le16(parameter_size_bytes);
-       param_value = tw_dev->generic_buffer_phys[request_id];

-       command_packet->byte8_offset.param.sgl[0].address =
TW_CPU_TO_SGL(param_value);
+       command_packet->byte8_offset.param.sgl[0].address =
TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
       command_packet->byte8_offset.param.sgl[0].length =
cpu_to_le32(TW_SECTOR_SIZE);

       /* Post the command packet to the board */
@@ -2000,7 +2006,7 @@
 {
       struct Scsi_Host *host = NULL;
       TW_Device_Extension *tw_dev;
-       u32 mem_addr;
+       unsigned long mem_addr, mem_len;
       int retval = -ENODEV;

       retval = pci_enable_device(pdev);
@@ -2045,13 +2051,16 @@
               goto out_free_device_extension;
       }

-       if (pdev->device == PCI_DEVICE_ID_3WARE_9000)
+       if (pdev->device == PCI_DEVICE_ID_3WARE_9000) {
               mem_addr = pci_resource_start(pdev, 1);
-       else
+               mem_len = pci_resource_len(pdev, 1);
+       } else {
               mem_addr = pci_resource_start(pdev, 2);
+               mem_len = pci_resource_len(pdev, 2);
+       }

       /* Save base address */
-       tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE);
+       tw_dev->base_addr = ioremap(mem_addr, mem_len);
       if (!tw_dev->base_addr) {
               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap");
               goto out_release_mem_region;
@@ -2086,7 +2095,7 @@

       pci_set_drvdata(pdev, host);

-       printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage
Controller at 0x%x, IRQ: %d.\n",
+       printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage
Controller at 0x%lx, IRQ: %d.\n",
              host->host_no, mem_addr, pdev->irq);
       printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s,
Ports: %d.\n",
              host->host_no,
@@ -2097,6 +2106,11 @@
              le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE,
                                    TW_PARAM_PORTCOUNT,
TW_PARAM_PORTCOUNT_LENGTH)));

+       /* Try to enable MSI */
+       if (use_msi && (pdev->device != PCI_DEVICE_ID_3WARE_9000) &&
+           !pci_enable_msi(pdev))
+               set_bit(TW_USING_MSI, &tw_dev->flags);
+
       /* Now setup the interrupt handler */
       retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED,
"3w-9xxx", tw_dev);
       if (retval) {
@@ -2120,6 +2134,8 @@
       return 0;

 out_remove_host:
+       if (test_bit(TW_USING_MSI, &tw_dev->flags))
+               pci_disable_msi(pdev);
       scsi_remove_host(host);
 out_iounmap:
       iounmap(tw_dev->base_addr);
@@ -2151,6 +2167,10 @@
       /* Shutdown the card */
       __twa_shutdown(tw_dev);

+       /* Disable MSI if enabled */
+       if (test_bit(TW_USING_MSI, &tw_dev->flags))
+               pci_disable_msi(pdev);
+
       /* Free IO remapping */
       iounmap(tw_dev->base_addr);

diff -Naur scsi-misc/drivers/scsi/3w-9xxx.h scsi-misc.new/drivers/scsi/3w-9xxx.h
--- scsi-misc/drivers/scsi/3w-9xxx.h    2008-07-13 14:51:29.000000000 -0700
+++ scsi-misc.new/drivers/scsi/3w-9xxx.h        2008-07-22
15:14:35.000000000 -0700
@@ -4,7 +4,7 @@
   Written By: Adam Radford <linuxraid@amcc.com>
   Modifications By: Tom Couch <linuxraid@amcc.com>

-   Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
+   Copyright (C) 2004-2008 Applied Micro Circuits Corporation.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -319,8 +319,8 @@

 /* Compatibility defines */
 #define TW_9000_ARCH_ID 0x5
-#define TW_CURRENT_DRIVER_SRL 30
-#define TW_CURRENT_DRIVER_BUILD 80
+#define TW_CURRENT_DRIVER_SRL 35
+#define TW_CURRENT_DRIVER_BUILD 0
 #define TW_CURRENT_DRIVER_BRANCH 0

 /* Phase defines */
@@ -352,8 +352,9 @@
 #define TW_MAX_RESET_TRIES                   2
 #define TW_MAX_CMDS_PER_LUN                  254
 #define TW_MAX_RESPONSE_DRAIN                256
-#define TW_MAX_AEN_DRAIN                     40
+#define TW_MAX_AEN_DRAIN                     255
 #define TW_IN_RESET                           2
+#define TW_USING_MSI                         3
 #define TW_IN_ATTENTION_LOOP                 4
 #define TW_MAX_SECTORS                        256
 #define TW_AEN_WAIT_TIME                      1000

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 3ware_2.6.26-git10.patch --]
[-- Type: text/x-patch; name=3ware_2.6.26-git10.patch, Size: 6033 bytes --]

diff -Naur scsi-misc/drivers/scsi/3w-9xxx.c scsi-misc.new/drivers/scsi/3w-9xxx.c
--- scsi-misc/drivers/scsi/3w-9xxx.c	2008-07-22 15:00:10.000000000 -0700
+++ scsi-misc.new/drivers/scsi/3w-9xxx.c	2008-07-22 15:14:34.000000000 -0700
@@ -4,7 +4,7 @@
    Written By: Adam Radford <linuxraid@amcc.com>
    Modifications By: Tom Couch <linuxraid@amcc.com>
 
-   Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
+   Copyright (C) 2004-2008 Applied Micro Circuits Corporation.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -71,6 +71,10 @@
                  Add support for 9650SE controllers.
    2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails.
    2.26.02.010 - Add support for 9690SA controllers.
+   2.26.02.011 - 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().
 */
 
 #include <linux/module.h>
@@ -95,7 +99,7 @@
 #include "3w-9xxx.h"
 
 /* Globals */
-#define TW_DRIVER_VERSION "2.26.02.010"
+#define TW_DRIVER_VERSION "2.26.02.011"
 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
 static unsigned int twa_device_extension_count;
 static int twa_major = -1;
@@ -107,6 +111,10 @@
 MODULE_LICENSE("GPL");
 MODULE_VERSION(TW_DRIVER_VERSION);
 
+static int use_msi = 0;
+module_param(use_msi, int, S_IRUGO);
+MODULE_PARM_DESC(use_msi, "Use Message Signaled Interrupts.  Default: 0");
+
 /* Function prototypes */
 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header);
 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
@@ -1038,7 +1046,6 @@
 	TW_Command_Full *full_command_packet;
 	TW_Command *command_packet;
 	TW_Param_Apache *param;
-	unsigned long param_value;
 	void *retval = NULL;
 
 	/* Setup the command packet */
@@ -1057,9 +1064,8 @@
 	param->table_id = cpu_to_le16(table_id | 0x8000);
 	param->parameter_id = cpu_to_le16(parameter_id);
 	param->parameter_size_bytes = cpu_to_le16(parameter_size_bytes);
-	param_value = tw_dev->generic_buffer_phys[request_id];
 
-	command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(param_value);
+	command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
 	command_packet->byte8_offset.param.sgl[0].length = cpu_to_le32(TW_SECTOR_SIZE);
 
 	/* Post the command packet to the board */
@@ -2000,7 +2006,7 @@
 {
 	struct Scsi_Host *host = NULL;
 	TW_Device_Extension *tw_dev;
-	u32 mem_addr;
+	unsigned long mem_addr, mem_len;
 	int retval = -ENODEV;
 
 	retval = pci_enable_device(pdev);
@@ -2045,13 +2051,16 @@
 		goto out_free_device_extension;
 	}
 
-	if (pdev->device == PCI_DEVICE_ID_3WARE_9000)
+	if (pdev->device == PCI_DEVICE_ID_3WARE_9000) {
 		mem_addr = pci_resource_start(pdev, 1);
-	else
+		mem_len = pci_resource_len(pdev, 1);
+	} else {
 		mem_addr = pci_resource_start(pdev, 2);
+		mem_len = pci_resource_len(pdev, 2);
+	}
 
 	/* Save base address */
-	tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE);
+	tw_dev->base_addr = ioremap(mem_addr, mem_len);
 	if (!tw_dev->base_addr) {
 		TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap");
 		goto out_release_mem_region;
@@ -2086,7 +2095,7 @@
 
 	pci_set_drvdata(pdev, host);
 
-	printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%x, IRQ: %d.\n",
+	printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%lx, IRQ: %d.\n",
 	       host->host_no, mem_addr, pdev->irq);
 	printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s, Ports: %d.\n",
 	       host->host_no,
@@ -2097,6 +2106,11 @@
 	       le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE,
 				     TW_PARAM_PORTCOUNT, TW_PARAM_PORTCOUNT_LENGTH)));
 
+	/* Try to enable MSI */
+	if (use_msi && (pdev->device != PCI_DEVICE_ID_3WARE_9000) &&
+	    !pci_enable_msi(pdev))
+		set_bit(TW_USING_MSI, &tw_dev->flags);
+
 	/* Now setup the interrupt handler */
 	retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev);
 	if (retval) {
@@ -2120,6 +2134,8 @@
 	return 0;
 
 out_remove_host:
+	if (test_bit(TW_USING_MSI, &tw_dev->flags))
+		pci_disable_msi(pdev);
 	scsi_remove_host(host);
 out_iounmap:
 	iounmap(tw_dev->base_addr);
@@ -2151,6 +2167,10 @@
 	/* Shutdown the card */
 	__twa_shutdown(tw_dev);
 
+	/* Disable MSI if enabled */
+	if (test_bit(TW_USING_MSI, &tw_dev->flags))
+		pci_disable_msi(pdev);
+
 	/* Free IO remapping */
 	iounmap(tw_dev->base_addr);
 
diff -Naur scsi-misc/drivers/scsi/3w-9xxx.h scsi-misc.new/drivers/scsi/3w-9xxx.h
--- scsi-misc/drivers/scsi/3w-9xxx.h	2008-07-13 14:51:29.000000000 -0700
+++ scsi-misc.new/drivers/scsi/3w-9xxx.h	2008-07-22 15:14:35.000000000 -0700
@@ -4,7 +4,7 @@
    Written By: Adam Radford <linuxraid@amcc.com>
    Modifications By: Tom Couch <linuxraid@amcc.com>
 
-   Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
+   Copyright (C) 2004-2008 Applied Micro Circuits Corporation.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -319,8 +319,8 @@
 
 /* Compatibility defines */
 #define TW_9000_ARCH_ID 0x5
-#define TW_CURRENT_DRIVER_SRL 30
-#define TW_CURRENT_DRIVER_BUILD 80
+#define TW_CURRENT_DRIVER_SRL 35
+#define TW_CURRENT_DRIVER_BUILD 0
 #define TW_CURRENT_DRIVER_BRANCH 0
 
 /* Phase defines */
@@ -352,8 +352,9 @@
 #define TW_MAX_RESET_TRIES		      2
 #define TW_MAX_CMDS_PER_LUN		      254
 #define TW_MAX_RESPONSE_DRAIN		      256
-#define TW_MAX_AEN_DRAIN		      40
+#define TW_MAX_AEN_DRAIN		      255
 #define TW_IN_RESET                           2
+#define TW_USING_MSI			      3
 #define TW_IN_ATTENTION_LOOP		      4
 #define TW_MAX_SECTORS                        256
 #define TW_AEN_WAIT_TIME                      1000

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] 3ware add MSI support
  2008-07-22 23:36 [PATCH 1/1] 3ware add MSI support adam radford
  2008-07-22 23:47 ` adam radford
@ 2008-07-23  1:47 ` Matthew Wilcox
  2008-07-23 11:47   ` James Bottomley
  2008-07-23  5:29 ` Rolf Eike Beer
  2 siblings, 1 reply; 8+ messages in thread
From: Matthew Wilcox @ 2008-07-23  1:47 UTC (permalink / raw)
  To: adam radford; +Cc: James Bottomley, linux-scsi

On Tue, Jul 22, 2008 at 04:36:32PM -0700, adam radford wrote:
> 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().

Is there a reason you default use_msi to off?  I would have thought
you'd want to enable it as widely as possible.

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] 3ware add MSI support
  2008-07-22 23:36 [PATCH 1/1] 3ware add MSI support adam radford
  2008-07-22 23:47 ` adam radford
  2008-07-23  1:47 ` Matthew Wilcox
@ 2008-07-23  5:29 ` Rolf Eike Beer
  2 siblings, 0 replies; 8+ messages in thread
From: Rolf Eike Beer @ 2008-07-23  5:29 UTC (permalink / raw)
  To: adam radford; +Cc: James Bottomley, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 584 bytes --]

Am Mittwoch, 23. Juli 2008 schrieb adam radford:
> 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().

Why not simply use pci_iomap()? Also I bet someone will step up and request 
this should be split into one patch for each change. #1 and #3 can get a 
little more description at the same time.

Greetings,

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] 3ware add MSI support
  2008-07-23  1:47 ` Matthew Wilcox
@ 2008-07-23 11:47   ` James Bottomley
  2008-07-23 11:59     ` Boaz Harrosh
  0 siblings, 1 reply; 8+ messages in thread
From: James Bottomley @ 2008-07-23 11:47 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: adam radford, linux-scsi, linux-pci

On Tue, 2008-07-22 at 19:47 -0600, Matthew Wilcox wrote:
> On Tue, Jul 22, 2008 at 04:36:32PM -0700, adam radford wrote:
> > 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().
> 
> Is there a reason you default use_msi to off?  I would have thought
> you'd want to enable it as widely as possible.

Hardly ... just look at our LSI fiasco with globally enabling them.

Right at the moment, due to motherboard bugs, it looks like global
enabling of MSI by default would produce a significant increase in "my
system doesn't boot" type bugs.

I asked Jesse if we could actually get better recognition of
motherboards with MSI problems in pci/quirks.c to forestall some of
this, but it seems to be a hard problem.  I've cc'd the PCI list in case
they have better suggestions.

James

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] 3ware add MSI support
  2008-07-23 11:47   ` James Bottomley
@ 2008-07-23 11:59     ` Boaz Harrosh
  2008-07-23 12:05       ` James Bottomley
  0 siblings, 1 reply; 8+ messages in thread
From: Boaz Harrosh @ 2008-07-23 11:59 UTC (permalink / raw)
  To: James Bottomley; +Cc: Matthew Wilcox, adam radford, linux-scsi, linux-pci

James Bottomley wrote:
> On Tue, 2008-07-22 at 19:47 -0600, Matthew Wilcox wrote:
>> On Tue, Jul 22, 2008 at 04:36:32PM -0700, adam radford wrote:
>>> 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().
>> Is there a reason you default use_msi to off?  I would have thought
>> you'd want to enable it as widely as possible.
> 
> Hardly ... just look at our LSI fiasco with globally enabling them.
> 
> Right at the moment, due to motherboard bugs, it looks like global
> enabling of MSI by default would produce a significant increase in "my
> system doesn't boot" type bugs.
> 
> I asked Jesse if we could actually get better recognition of
> motherboards with MSI problems in pci/quirks.c to forestall some of
> this, but it seems to be a hard problem.  I've cc'd the PCI list in case
> they have better suggestions.
> 
> James
> 

This seems to be a general problem. Maybe there should be an LSI_SYSTEM_DEFAULT
kind of parameter or function, that will enable LSI if it is default for the
system on all supporting drivers. This way a user can configure LSI=on for all
drivers in one place instead of configuring each driver individually.

Boaz
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] 3ware add MSI support
  2008-07-23 11:59     ` Boaz Harrosh
@ 2008-07-23 12:05       ` James Bottomley
  2008-07-24 14:27         ` Matthew Wilcox
  0 siblings, 1 reply; 8+ messages in thread
From: James Bottomley @ 2008-07-23 12:05 UTC (permalink / raw)
  To: Boaz Harrosh; +Cc: Matthew Wilcox, adam radford, linux-scsi, linux-pci

On Wed, 2008-07-23 at 14:59 +0300, Boaz Harrosh wrote:
> James Bottomley wrote:
> > On Tue, 2008-07-22 at 19:47 -0600, Matthew Wilcox wrote:
> >> On Tue, Jul 22, 2008 at 04:36:32PM -0700, adam radford wrote:
> >>> 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().
> >> Is there a reason you default use_msi to off?  I would have thought
> >> you'd want to enable it as widely as possible.
> > 
> > Hardly ... just look at our LSI fiasco with globally enabling them.
> > 
> > Right at the moment, due to motherboard bugs, it looks like global
> > enabling of MSI by default would produce a significant increase in "my
> > system doesn't boot" type bugs.
> > 
> > I asked Jesse if we could actually get better recognition of
> > motherboards with MSI problems in pci/quirks.c to forestall some of
> > this, but it seems to be a hard problem.  I've cc'd the PCI list in case
> > they have better suggestions.
> > 
> > James
> > 
> 
> This seems to be a general problem. Maybe there should be an LSI_SYSTEM_DEFAULT
> kind of parameter or function, that will enable LSI if it is default for the
> system on all supporting drivers. This way a user can configure LSI=on for all
> drivers in one place instead of configuring each driver individually.

There is ... it's the mpt_msi_enable parameter.  It defaults to off for
SPI and FC and on for SAS.  When questioned (mainly because I have a
working MSI SPI controller), LSI admitted it was because SPI was most
likely to be installed in an older motherboard with some type of MSI
failure (which gets blamed on the SCSI driver because it causes a boot
failure).

If you mean a general msi enable/disable; then again we sort of have it
in PCI; it's pci=nomsi (without this, PCI will enable msi if at all
possible).

I'd love to toss out the one per driver msi enable/disable parameters,
but until we can sort out recognition of the bad MSI motherboards
reliably we're a bit stuck.

James


James

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] 3ware add MSI support
  2008-07-23 12:05       ` James Bottomley
@ 2008-07-24 14:27         ` Matthew Wilcox
  0 siblings, 0 replies; 8+ messages in thread
From: Matthew Wilcox @ 2008-07-24 14:27 UTC (permalink / raw)
  To: James Bottomley; +Cc: Boaz Harrosh, adam radford, linux-scsi, linux-pci

On Wed, Jul 23, 2008 at 08:05:23AM -0400, James Bottomley wrote:
> On Wed, 2008-07-23 at 14:59 +0300, Boaz Harrosh wrote:
> > James Bottomley wrote:
> > > On Tue, 2008-07-22 at 19:47 -0600, Matthew Wilcox wrote:
> > >> On Tue, Jul 22, 2008 at 04:36:32PM -0700, adam radford wrote:
> > >>> 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().
> > >> Is there a reason you default use_msi to off?  I would have thought
> > >> you'd want to enable it as widely as possible.
> > > 
> > > Hardly ... just look at our LSI fiasco with globally enabling them.
> > > 
> > > Right at the moment, due to motherboard bugs, it looks like global
> > > enabling of MSI by default would produce a significant increase in "my
> > > system doesn't boot" type bugs.
> > > 
> > > I asked Jesse if we could actually get better recognition of
> > > motherboards with MSI problems in pci/quirks.c to forestall some of
> > > this, but it seems to be a hard problem.  I've cc'd the PCI list in case
> > > they have better suggestions.

With my PCI hat on ... er, not sure.  It's a rather hard thing to test
generically.  You need to do a write from a card to a specific address
and see whether an interrupt is generated.  I don't think trying the
write from a CPU is sufficient as the bug can be in the host bridge, or
indeed in a PCI-PCI bridge.

Obviously, finding which systems need to be blacklisted is an important
thing to do.  Jeff Garzik claimed recently that adding MSI support to
ahci had found a lot of machines which didn't support MSI properly.

> > This seems to be a general problem. Maybe there should be an LSI_SYSTEM_DEFAULT
> > kind of parameter or function, that will enable LSI if it is default for the
> > system on all supporting drivers. This way a user can configure LSI=on for all
> > drivers in one place instead of configuring each driver individually.

I believe Boaz meant MSI_SYSTEM_DEFAULT ...

> There is ... it's the mpt_msi_enable parameter.  It defaults to off for
> SPI and FC and on for SAS.  When questioned (mainly because I have a
> working MSI SPI controller), LSI admitted it was because SPI was most
> likely to be installed in an older motherboard with some type of MSI
> failure (which gets blamed on the SCSI driver because it causes a boot
> failure).

I certainly understand that point of view.  sym2 gets blamed all the
time when it's actually an interrupt routing problem.

> If you mean a general msi enable/disable; then again we sort of have it
> in PCI; it's pci=nomsi (without this, PCI will enable msi if at all
> possible).
> 
> I'd love to toss out the one per driver msi enable/disable parameters,
> but until we can sort out recognition of the bad MSI motherboards
> reliably we're a bit stuck.

Maybe we can persuade the kind, happy, generous people at Fedora to help
out here?  We can pick a reasonably common driver (eg Fusion) and craft
a test which prints out an oops.  The oopses will be caught by
kerneloops.org and then we can add the chipsets in question to the
MSI blacklist.

We have to make the system boot anyway after this oops, or the oops
will never get collected.  So nobody should get nastygrams about boot
failing.

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-07-24 14:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22 23:36 [PATCH 1/1] 3ware add MSI support adam radford
2008-07-22 23:47 ` adam radford
2008-07-23  1:47 ` Matthew Wilcox
2008-07-23 11:47   ` James Bottomley
2008-07-23 11:59     ` Boaz Harrosh
2008-07-23 12:05       ` James Bottomley
2008-07-24 14:27         ` Matthew Wilcox
2008-07-23  5:29 ` Rolf Eike Beer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox