All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump
@ 2007-01-05 15:10 Sumant Patro
  2007-01-05 21:34 ` Randy Dunlap
  2007-01-31 17:49   ` Matthias Urlichs
  0 siblings, 2 replies; 13+ messages in thread
From: Sumant Patro @ 2007-01-05 15:10 UTC (permalink / raw)
  To: James.Bottomley, akpm, rdunlap
  Cc: linux-scsi, linux-kernel, neela.kolli, bo.yang, sumant.patro

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


1.      Changes in Initialization to fix kdump failure.
        Send SYNC command on loading.
        This command clears the pending commands in the adapter
        and re-initialize its internal RAID structure.
        Without this change, megaraid driver either panics or fails to
        initialize the adapter during kdump's second kernel boot
        if there are pending commands or interrupts from other devices
        sharing the same IRQ.
2.      Authors email-id domain name changed from lsil.com to lsi.com.
        Also modified the MODULE_AUTHOR to megaraidlinux@lsi.com

Signed-off-by: Sumant Patro <sumant.patro@lsi.com>
---

 Documentation/scsi/ChangeLog.megaraid |   16 ++
 drivers/scsi/megaraid/megaraid_mbox.c |  140 +++++++++++++++++++-----
 drivers/scsi/megaraid/megaraid_mbox.h |    4
 3 files changed, 130 insertions(+), 30 deletions(-)

diff -uprN linux-2.6.orig/Documentation/scsi/ChangeLog.megaraid linux-2.6.new/Documentation/scsi/ChangeLog.megaraid
--- linux-2.6.orig/Documentation/scsi/ChangeLog.megaraid 2006-12-28 10:10:31.000000000 -0800
+++ linux-2.6.new/Documentation/scsi/ChangeLog.megaraid 2007-01-04 12:09:36.000000000 -0800
@@ -1,3 +1,19 @@
+Release Date : Thu Nov 16 15:32:35 EST 2006 -
+    Sumant Patro <sumant.patro@lsi.com>
+Current Version : 2.20.5.1 (scsi module), 2.20.2.6 (cmm module)
+Older Version : 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)
+
+1. Changes in Initialization to fix kdump failure.
+ Send SYNC command on loading.
+ This command clears the pending commands in the adapter
+ and re-initialize its internal RAID structure.
+ Without this change, megaraid driver either panics or fails to
+ initialize the adapter during kdump's second kernel boot
+ if there are pending commands or interrupts from other devices
+ sharing the same IRQ.
+2.  Authors email-id domain name changed from lsil.com to lsi.com.
+ Also modified the MODULE_AUTHOR to megaraidlinux@lsi.com
+
 Release Date : Fri May 19 09:31:45 EST 2006 - Seokmann Ju <sju@lsil.com>
 Current Version : 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)
 Older Version : 2.20.4.8 (scsi module), 2.20.2.6 (cmm module)
diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
--- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c	2006-12-28 09:56:04.000000000 -0800
+++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c	2007-01-04 11:22:21.000000000 -0800
@@ -10,13 +10,13 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mbox.c
- * Version	: v2.20.4.9 (Jul 16 2006)
+ * Version	: v2.20.5.1 (Nov 16 2006)
  *
  * Authors:
- * 	Atul Mukker		<Atul.Mukker@lsil.com>
- * 	Sreenivas Bagalkote	<Sreenivas.Bagalkote@lsil.com>
- * 	Manoj Jose		<Manoj.Jose@lsil.com>
- * 	Seokmann Ju		<Seokmann.Ju@lsil.com>
+ * 	Atul Mukker		<Atul.Mukker@lsi.com>
+ * 	Sreenivas Bagalkote	<Sreenivas.Bagalkote@lsi.com>
+ * 	Manoj Jose		<Manoj.Jose@lsi.com>
+ * 	Seokmann Ju
  *
  * List of supported controllers
  *
@@ -107,6 +107,7 @@ static int megaraid_mbox_support_random_
 static int megaraid_mbox_get_max_sg(adapter_t *);
 static void megaraid_mbox_enum_raid_scsi(adapter_t *);
 static void megaraid_mbox_flush_cache(adapter_t *);
+static int megaraid_mbox_fire_sync_cmd(adapter_t *);
 
 static void megaraid_mbox_display_scb(adapter_t *, scb_t *);
 static void megaraid_mbox_setup_device_map(adapter_t *);
@@ -137,7 +138,7 @@ static int wait_till_fw_empty(adapter_t 
 
 
 
-MODULE_AUTHOR("sju@lsil.com");
+MODULE_AUTHOR("megaraidlinux@lsi.com");
 MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(MEGARAID_VERSION);
@@ -779,33 +780,39 @@ megaraid_init_mbox(adapter_t *adapter)
 		goto out_release_regions;
 	}
 
-	//
-	// Setup the rest of the soft state using the library of FW routines
-	//
+	/* initialize the mutual exclusion lock for the mailbox */
+	spin_lock_init(&raid_dev->mailbox_lock);
+
+	/* allocate memory required for commands */
+	if (megaraid_alloc_cmd_packets(adapter) != 0)
+		goto out_iounmap;
 
-	// request IRQ and register the interrupt service routine
+	/*
+	 * Issue SYNC cmd to flush the pending cmds in the adapter
+	 * and initialize its internal state
+	 */
+
+	if (megaraid_mbox_fire_sync_cmd(adapter))
+		con_log(CL_ANN, ("megaraid: sync cmd failed\n"));
+
+	/*
+	 * Setup the rest of the soft state using the library of
+	 * FW routines
+	 */
+
+	/* request IRQ and register the interrupt service routine */
 	if (request_irq(adapter->irq, megaraid_isr, IRQF_SHARED, "megaraid",
 		adapter)) {
 
 		con_log(CL_ANN, (KERN_WARNING
 			"megaraid: Couldn't register IRQ %d!\n", adapter->irq));
+		goto out_alloc_cmds;
 
-		goto out_iounmap;
-	}
-
-
-	// initialize the mutual exclusion lock for the mailbox
-	spin_lock_init(&raid_dev->mailbox_lock);
-
-	// allocate memory required for commands
-	if (megaraid_alloc_cmd_packets(adapter) != 0) {
-		goto out_free_irq;
 	}
 
 	// Product info
-	if (megaraid_mbox_product_info(adapter) != 0) {
-		goto out_alloc_cmds;
-	}
+	if (megaraid_mbox_product_info(adapter) != 0)
+		goto out_free_irq;
 
 	// Do we support extended CDBs
 	adapter->max_cdb_sz = 10;
@@ -874,9 +881,8 @@ megaraid_init_mbox(adapter_t *adapter)
 	 * Allocate resources required to issue FW calls, when sysfs is
 	 * accessed
 	 */
-	if (megaraid_sysfs_alloc_resources(adapter) != 0) {
-		goto out_alloc_cmds;
-	}
+	if (megaraid_sysfs_alloc_resources(adapter) != 0)
+		goto out_free_irq;
 
 	// Set the DMA mask to 64-bit. All supported controllers as capable of
 	// DMA in this range
@@ -920,10 +926,10 @@ megaraid_init_mbox(adapter_t *adapter)
 
 out_free_sysfs_res:
 	megaraid_sysfs_free_resources(adapter);
-out_alloc_cmds:
-	megaraid_free_cmd_packets(adapter);
 out_free_irq:
 	free_irq(adapter->irq, adapter);
+out_alloc_cmds:
+	megaraid_free_cmd_packets(adapter);
 out_iounmap:
 	iounmap(raid_dev->baseaddr);
 out_release_regions:
@@ -3380,6 +3386,84 @@ megaraid_mbox_flush_cache(adapter_t *ada
 
 
 /**
+ * megaraid_mbox_fire_sync_cmd - fire the sync cmd
+ * @param adapter	: soft state for the controller
+ *
+ * Clears the pending cmds in FW and reinits its RAID structs
+ */
+static int
+megaraid_mbox_fire_sync_cmd(adapter_t *adapter)
+{
+	mbox_t	*mbox;
+	uint8_t	raw_mbox[sizeof(mbox_t)];
+	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
+	mbox64_t *mbox64;
+	int	status = 0;
+	int i;
+	uint32_t dword;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
+
+	raw_mbox[0] = 0xFF;
+
+	mbox64	= raid_dev->mbox64;
+	mbox	= raid_dev->mbox;
+
+	/* Wait until mailbox is free */
+	if (megaraid_busywait_mbox(raid_dev) != 0) {
+		status = 1;
+		goto blocked_mailbox;
+	}
+
+	/* Copy mailbox data into host structure */
+	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
+	mbox->cmdid		= 0xFE;
+	mbox->busy		= 1;
+	mbox->poll		= 0;
+	mbox->ack		= 0;
+	mbox->numstatus		= 0;
+	mbox->status		= 0;
+
+	wmb();
+	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
+
+	/* Wait for maximum 1 min for status to post.
+	 * If the Firmware SUPPORTS the ABOVE COMMAND,
+	 * mbox->cmd will be set to 0
+	 * else
+	 * the firmware will reject the command with
+	 * mbox->numstatus set to 1
+	 */
+
+	i = 0;
+	status = 0;
+	while (!mbox->numstatus && mbox->cmd == 0xFF) {
+		rmb();
+		msleep(1);
+		i++;
+		if (i > 1000 * 60) {
+			status = 1;
+			break;
+		}
+	}
+	if (mbox->numstatus == 1)
+		status = 1; /*cmd not supported*/
+
+	/* Check for interrupt line */
+	dword = RDOUTDOOR(raid_dev);
+	WROUTDOOR(raid_dev, dword);
+	WRINDOOR(raid_dev,2);
+
+	return status;
+
+blocked_mailbox:
+	con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
+	return status;
+}
+
+/**
  * megaraid_mbox_display_scb - display SCB information, mostly debug purposes
  * @param adapter	: controllers' soft state
  * @param scb  : SCB to be displayed
diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.h linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.h
--- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.h 2006-12-28 09:56:04.000000000 -0800
+++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.h	2007-01-04 05:24:22.000000000 -0800
@@ -21,8 +21,8 @@
 #include "megaraid_ioctl.h"
 
 
-#define MEGARAID_VERSION	"2.20.4.9"
-#define MEGARAID_EXT_VERSION	"(Release Date: Sun Jul 16 12:27:22 EST 2006)"
+#define MEGARAID_VERSION	"2.20.5.1"
+#define MEGARAID_EXT_VERSION	"(Release Date: Thu Nov 16 15:32:35 EST 2006)"
 
 
 /*


[-- Attachment #2: Type: text/x-patch, Size: 7576 bytes --]

diff -uprN linux-2.6.orig/Documentation/scsi/ChangeLog.megaraid linux-2.6.new/Documentation/scsi/ChangeLog.megaraid
--- linux-2.6.orig/Documentation/scsi/ChangeLog.megaraid	2006-12-28 10:10:31.000000000 -0800
+++ linux-2.6.new/Documentation/scsi/ChangeLog.megaraid	2007-01-04 12:09:36.000000000 -0800
@@ -1,3 +1,19 @@
+Release Date	: Thu Nov 16 15:32:35 EST 2006 -
+				Sumant Patro <sumant.patro@lsi.com>
+Current Version : 2.20.5.1 (scsi module), 2.20.2.6 (cmm module)
+Older Version	: 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)
+
+1.	Changes in Initialization to fix kdump failure.
+	Send SYNC command on loading.
+	This command clears the pending commands in the adapter
+	and re-initialize its internal RAID structure.
+	Without this change, megaraid driver either panics or fails to
+	initialize the adapter during kdump's second kernel boot
+	if there are pending commands or interrupts from other devices
+	sharing the same IRQ.
+2. 	Authors email-id domain name changed from lsil.com to lsi.com.
+	Also modified the MODULE_AUTHOR to megaraidlinux@lsi.com
+
 Release Date	: Fri May 19 09:31:45 EST 2006 - Seokmann Ju <sju@lsil.com>
 Current Version : 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)
 Older Version	: 2.20.4.8 (scsi module), 2.20.2.6 (cmm module)
diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
--- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c	2006-12-28 09:56:04.000000000 -0800
+++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c	2007-01-04 11:22:21.000000000 -0800
@@ -10,13 +10,13 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mbox.c
- * Version	: v2.20.4.9 (Jul 16 2006)
+ * Version	: v2.20.5.1 (Nov 16 2006)
  *
  * Authors:
- * 	Atul Mukker		<Atul.Mukker@lsil.com>
- * 	Sreenivas Bagalkote	<Sreenivas.Bagalkote@lsil.com>
- * 	Manoj Jose		<Manoj.Jose@lsil.com>
- * 	Seokmann Ju		<Seokmann.Ju@lsil.com>
+ * 	Atul Mukker		<Atul.Mukker@lsi.com>
+ * 	Sreenivas Bagalkote	<Sreenivas.Bagalkote@lsi.com>
+ * 	Manoj Jose		<Manoj.Jose@lsi.com>
+ * 	Seokmann Ju
  *
  * List of supported controllers
  *
@@ -107,6 +107,7 @@ static int megaraid_mbox_support_random_
 static int megaraid_mbox_get_max_sg(adapter_t *);
 static void megaraid_mbox_enum_raid_scsi(adapter_t *);
 static void megaraid_mbox_flush_cache(adapter_t *);
+static int megaraid_mbox_fire_sync_cmd(adapter_t *);
 
 static void megaraid_mbox_display_scb(adapter_t *, scb_t *);
 static void megaraid_mbox_setup_device_map(adapter_t *);
@@ -137,7 +138,7 @@ static int wait_till_fw_empty(adapter_t 
 
 
 
-MODULE_AUTHOR("sju@lsil.com");
+MODULE_AUTHOR("megaraidlinux@lsi.com");
 MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(MEGARAID_VERSION);
@@ -779,33 +780,39 @@ megaraid_init_mbox(adapter_t *adapter)
 		goto out_release_regions;
 	}
 
-	//
-	// Setup the rest of the soft state using the library of FW routines
-	//
+	/* initialize the mutual exclusion lock for the mailbox */
+	spin_lock_init(&raid_dev->mailbox_lock);
+
+	/* allocate memory required for commands */
+	if (megaraid_alloc_cmd_packets(adapter) != 0)
+		goto out_iounmap;
 
-	// request IRQ and register the interrupt service routine
+	/*
+	 * Issue SYNC cmd to flush the pending cmds in the adapter
+	 * and initialize its internal state
+	 */
+
+	if (megaraid_mbox_fire_sync_cmd(adapter))
+		con_log(CL_ANN, ("megaraid: sync cmd failed\n"));
+
+	/*
+	 * Setup the rest of the soft state using the library of
+	 * FW routines
+	 */
+
+	/* request IRQ and register the interrupt service routine */
 	if (request_irq(adapter->irq, megaraid_isr, IRQF_SHARED, "megaraid",
 		adapter)) {
 
 		con_log(CL_ANN, (KERN_WARNING
 			"megaraid: Couldn't register IRQ %d!\n", adapter->irq));
+		goto out_alloc_cmds;
 
-		goto out_iounmap;
-	}
-
-
-	// initialize the mutual exclusion lock for the mailbox
-	spin_lock_init(&raid_dev->mailbox_lock);
-
-	// allocate memory required for commands
-	if (megaraid_alloc_cmd_packets(adapter) != 0) {
-		goto out_free_irq;
 	}
 
 	// Product info
-	if (megaraid_mbox_product_info(adapter) != 0) {
-		goto out_alloc_cmds;
-	}
+	if (megaraid_mbox_product_info(adapter) != 0)
+		goto out_free_irq;
 
 	// Do we support extended CDBs
 	adapter->max_cdb_sz = 10;
@@ -874,9 +881,8 @@ megaraid_init_mbox(adapter_t *adapter)
 	 * Allocate resources required to issue FW calls, when sysfs is
 	 * accessed
 	 */
-	if (megaraid_sysfs_alloc_resources(adapter) != 0) {
-		goto out_alloc_cmds;
-	}
+	if (megaraid_sysfs_alloc_resources(adapter) != 0)
+		goto out_free_irq;
 
 	// Set the DMA mask to 64-bit. All supported controllers as capable of
 	// DMA in this range
@@ -920,10 +926,10 @@ megaraid_init_mbox(adapter_t *adapter)
 
 out_free_sysfs_res:
 	megaraid_sysfs_free_resources(adapter);
-out_alloc_cmds:
-	megaraid_free_cmd_packets(adapter);
 out_free_irq:
 	free_irq(adapter->irq, adapter);
+out_alloc_cmds:
+	megaraid_free_cmd_packets(adapter);
 out_iounmap:
 	iounmap(raid_dev->baseaddr);
 out_release_regions:
@@ -3380,6 +3386,84 @@ megaraid_mbox_flush_cache(adapter_t *ada
 
 
 /**
+ * megaraid_mbox_fire_sync_cmd - fire the sync cmd
+ * @param adapter	: soft state for the controller
+ *
+ * Clears the pending cmds in FW and reinits its RAID structs
+ */
+static int
+megaraid_mbox_fire_sync_cmd(adapter_t *adapter)
+{
+	mbox_t	*mbox;
+	uint8_t	raw_mbox[sizeof(mbox_t)];
+	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
+	mbox64_t *mbox64;
+	int	status = 0;
+	int i;
+	uint32_t dword;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
+
+	raw_mbox[0] = 0xFF;
+
+	mbox64	= raid_dev->mbox64;
+	mbox	= raid_dev->mbox;
+
+	/* Wait until mailbox is free */
+	if (megaraid_busywait_mbox(raid_dev) != 0) {
+		status = 1;
+		goto blocked_mailbox;
+	}
+
+	/* Copy mailbox data into host structure */
+	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
+	mbox->cmdid		= 0xFE;
+	mbox->busy		= 1;
+	mbox->poll		= 0;
+	mbox->ack		= 0;
+	mbox->numstatus		= 0;
+	mbox->status		= 0;
+
+	wmb();
+	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
+
+	/* Wait for maximum 1 min for status to post.
+	 * If the Firmware SUPPORTS the ABOVE COMMAND,
+	 * mbox->cmd will be set to 0
+	 * else
+	 * the firmware will reject the command with
+	 * mbox->numstatus set to 1
+	 */
+
+	i = 0;
+	status = 0;
+	while (!mbox->numstatus && mbox->cmd == 0xFF) {
+		rmb();
+		msleep(1);
+		i++;
+		if (i > 1000 * 60) {
+			status = 1;
+			break;
+		}
+	}
+	if (mbox->numstatus == 1)
+		status = 1; /*cmd not supported*/
+
+	/* Check for interrupt line */
+	dword = RDOUTDOOR(raid_dev);
+	WROUTDOOR(raid_dev, dword);
+	WRINDOOR(raid_dev,2);
+
+	return status;
+
+blocked_mailbox:
+	con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
+	return status;
+}
+
+/**
  * megaraid_mbox_display_scb - display SCB information, mostly debug purposes
  * @param adapter	: controllers' soft state
  * @param scb		: SCB to be displayed
diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.h linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.h
--- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.h	2006-12-28 09:56:04.000000000 -0800
+++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.h	2007-01-04 05:24:22.000000000 -0800
@@ -21,8 +21,8 @@
 #include "megaraid_ioctl.h"
 
 
-#define MEGARAID_VERSION	"2.20.4.9"
-#define MEGARAID_EXT_VERSION	"(Release Date: Sun Jul 16 12:27:22 EST 2006)"
+#define MEGARAID_VERSION	"2.20.5.1"
+#define MEGARAID_EXT_VERSION	"(Release Date: Thu Nov 16 15:32:35 EST 2006)"
 
 
 /*

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

* Re: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump
  2007-01-05 15:10 [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump Sumant Patro
@ 2007-01-05 21:34 ` Randy Dunlap
  2007-01-31 17:49   ` Matthias Urlichs
  1 sibling, 0 replies; 13+ messages in thread
From: Randy Dunlap @ 2007-01-05 21:34 UTC (permalink / raw)
  To: Sumant Patro
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, neela.kolli,
	bo.yang, sumant.patro

On Fri, 05 Jan 2007 07:10:09 -0800 Sumant Patro wrote:

Hi,

> ---
> 
>  Documentation/scsi/ChangeLog.megaraid |   16 ++
>  drivers/scsi/megaraid/megaraid_mbox.c |  140 +++++++++++++++++++-----
>  drivers/scsi/megaraid/megaraid_mbox.h |    4
>  3 files changed, 130 insertions(+), 30 deletions(-)
> 
> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c	2006-12-28 09:56:04.000000000 -0800
> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c	2007-01-04 11:22:21.000000000 -0800
> @@ -3380,6 +3386,84 @@ megaraid_mbox_flush_cache(adapter_t *ada
>  
>  
>  /**
> + * megaraid_mbox_fire_sync_cmd - fire the sync cmd
> + * @param adapter	: soft state for the controller

That (above) should just be:
 * @adapter:  (plus its description; the description there
   doesn't seem to agree with its parameter name).


> + *
> + * Clears the pending cmds in FW and reinits its RAID structs
> + */
> +static int
> +megaraid_mbox_fire_sync_cmd(adapter_t *adapter)
> +{
> +	mbox_t	*mbox;
> +	uint8_t	raw_mbox[sizeof(mbox_t)];
> +	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
> +	mbox64_t *mbox64;
> +	int	status = 0;
> +	int i;
> +	uint32_t dword;
> +
> +	mbox = (mbox_t *)raw_mbox;
> +
> +	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
> +
> +	raw_mbox[0] = 0xFF;
> +
> +	mbox64	= raid_dev->mbox64;
> +	mbox	= raid_dev->mbox;
> +
> +	/* Wait until mailbox is free */
> +	if (megaraid_busywait_mbox(raid_dev) != 0) {
> +		status = 1;
> +		goto blocked_mailbox;
> +	}
> +
> +	/* Copy mailbox data into host structure */
> +	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
> +	mbox->cmdid		= 0xFE;
> +	mbox->busy		= 1;
> +	mbox->poll		= 0;
> +	mbox->ack		= 0;
> +	mbox->numstatus		= 0;
> +	mbox->status		= 0;
> +
> +	wmb();
> +	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
> +
> +	/* Wait for maximum 1 min for status to post.
> +	 * If the Firmware SUPPORTS the ABOVE COMMAND,
> +	 * mbox->cmd will be set to 0
> +	 * else
> +	 * the firmware will reject the command with
> +	 * mbox->numstatus set to 1
> +	 */
> +
> +	i = 0;
> +	status = 0;
> +	while (!mbox->numstatus && mbox->cmd == 0xFF) {
> +		rmb();
> +		msleep(1);
> +		i++;
> +		if (i > 1000 * 60) {
> +			status = 1;
> +			break;
> +		}
> +	}
> +	if (mbox->numstatus == 1)
> +		status = 1; /*cmd not supported*/
> +
> +	/* Check for interrupt line */
> +	dword = RDOUTDOOR(raid_dev);
> +	WROUTDOOR(raid_dev, dword);
> +	WRINDOOR(raid_dev,2);
> +
> +	return status;
> +
> +blocked_mailbox:
> +	con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
> +	return status;
> +}
> +
> +/**
>   * megaraid_mbox_display_scb - display SCB information, mostly debug purposes
>   * @param adapter	: controllers' soft state
>   * @param scb  : SCB to be displayed

I haven't looked at the entire source file, but these extra
"param" words should not be there.  kernel-doc syntax is just
  @name: description


---
~Randy

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

* Re: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump
  2007-01-05 15:10 [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump Sumant Patro
@ 2007-01-31 17:49   ` Matthias Urlichs
  2007-01-31 17:49   ` Matthias Urlichs
  1 sibling, 0 replies; 13+ messages in thread
From: Matthias Urlichs @ 2007-01-31 17:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-scsi

On Fri, 05 Jan 2007 07:10:09 -0800, Sumant Patro wrote:

>         This command clears the pending commands in the adapter
>         and re-initialize its internal RAID structure.
>         Without this change, megaraid driver either panics or fails to
>         initialize the adapter during kdump's second kernel boot
>         if there are pending commands or interrupts from other devices
>         sharing the same IRQ.

Nice. Is there a chance that this patch will also fix the regression I've
noticed (today, unfortunately) on (at least one) Dell server?

FWIW, here's the relevant LSPCI output and kernel logs:

0d:0e.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID (rev 07)
        Subsystem: Dell Unknown device 0002
        Flags: bus master, stepping, 66MHz, medium devsel, latency 64, IRQ 18
        Memory at d80f0000 (32-bit, prefetchable) [size=64K]
        Memory at fc4c0000 (32-bit, non-prefetchable) [size=256K]
        Expansion ROM at fc500000 [disabled] [size=128K]
        Capabilities: [c0] Power Management version 2
        Capabilities: [d0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/1 Enable-
        Capabilities: [e0] PCI-X non-bridge device

Jan 31 14:41:34 kernel: [ 232.873327] megaraid cmm: 2.20.2.7 (Release Date: Sun Jul 16 00:01:03 EST 2006)
Jan 31 14:41:34 kernel: [ 232.877616] SCSI subsystem initialized
Jan 31 14:41:34 kernel: [ 232.888779] megaraid: 2.20.4.9 (Release Date: Sun Jul 16 12:27:22 EST 2006)
Jan 31 14:41:34 kernel: [ 232.889835] megasas: 00.00.03.05 Mon Oct 02 11:21:32 PDT 2006
Jan 31 14:41:34 kernel: [ 233.513659] megasas: 0x1028:0x0015:0x1028:0x1f03: <6>megaraid: probe new device 0x1000:0x0408:0x1028:0x0002: bus 13:slot 14:func 0
Jan 31 14:41:34 kernel: [ 233.514770] megasas: FW now in Ready state
Jan 31 14:41:34 kernel: [ 233.528893] megaraid: fw version:[522A] bios version:[H430]
Jan 31 14:41:34 kernel: [ 233.554778] scsi2 : LSI Logic SAS based MegaRAID driver
Jan 31 14:41:34 kernel: [ 233.555536] scsi 2:0:0:0: Direct-Access MAXTOR ATLAS10K5_073SAS BP00 PQ: 0 ANSI: 5
Jan 31 14:41:34 kernel: [ 233.556173] scsi 2:0:1:0: Direct-Access MAXTOR ATLAS10K5_073SAS BP00 PQ: 0 ANSI: 5
Jan 31 14:41:34 kernel: [ 233.569337] scsi3 : LSI Logic MegaRAID driver
Jan 31 14:41:34 kernel: [ 233.569550] scsi[3]: scanning scsi channel 0 [Phy 0] for non-raid devices
Jan 31 14:41:34 kernel: [ 233.604522] scsi 2:0:8:0: Enclosure DP BACKPLANE 1.00 PQ: 0 ANSI: 5
Jan 31 14:41:41 kernel: [ 243.115199] megaraid: aborting-16 cmd=12 <c=0 t=12 l=0>
Jan 31 14:41:41 kernel: [ 243.115206] megaraid abort: 16:0[0:12], fw owner
Jan 31 14:41:41 kernel: [ 243.115217] megaraid: 1 outstanding commands. Max wait 300 sec
Jan 31 14:41:41 kernel: [ 243.115221] megaraid mbox: Wait for 1 commands to complete:300
Jan 31 14:41:46 kernel: [ 248.125812] megaraid mbox: Wait for 1 commands to complete:295
Jan 31 14:41:48 kernel: [ 250.134075] megaraid mbox: reset sequence completed sucessfully
Jan 31 14:41:58 kernel: [ 260.117201] megaraid: aborting-16 cmd=0 <c=0 t=12 l=0>Jan 31 14:41:58 kernel: [ 260.117207] megaraid abort: 16:0[0:12], fw owner
Jan 31 14:41:58 kernel: [ 260.117217] megaraid: 1 outstanding commands. Max wait 300 sec
Jan 31 14:41:58 kernel: [ 260.117223] megaraid mbox: Wait for 1 commands to complete:300
Jan 31 14:42:03 kernel: [ 265.127417] megaraid mbox: Wait for 1 commands to complete:295
Jan 31 14:42:08 kernel: [ 270.140211] megaraid mbox: Wait for 1 commands to complete:290
Jan 31 14:42:12 kernel: [ 274.146803] megaraid mbox: reset sequence completed sucessfully
[ nothing else that appears relevant ]


-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
Those who welcome death have only tried it from the ears up.
					-- Wilson Mizner


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

* Re: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump
@ 2007-01-31 17:49   ` Matthias Urlichs
  0 siblings, 0 replies; 13+ messages in thread
From: Matthias Urlichs @ 2007-01-31 17:49 UTC (permalink / raw)
  To: linux-scsi; +Cc: linux-kernel

On Fri, 05 Jan 2007 07:10:09 -0800, Sumant Patro wrote:

>         This command clears the pending commands in the adapter
>         and re-initialize its internal RAID structure.
>         Without this change, megaraid driver either panics or fails to
>         initialize the adapter during kdump's second kernel boot
>         if there are pending commands or interrupts from other devices
>         sharing the same IRQ.

Nice. Is there a chance that this patch will also fix the regression I've
noticed (today, unfortunately) on (at least one) Dell server?

FWIW, here's the relevant LSPCI output and kernel logs:

0d:0e.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID (rev 07)
        Subsystem: Dell Unknown device 0002
        Flags: bus master, stepping, 66MHz, medium devsel, latency 64, IRQ 18
        Memory at d80f0000 (32-bit, prefetchable) [size=64K]
        Memory at fc4c0000 (32-bit, non-prefetchable) [size=256K]
        Expansion ROM at fc500000 [disabled] [size=128K]
        Capabilities: [c0] Power Management version 2
        Capabilities: [d0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/1 Enable-
        Capabilities: [e0] PCI-X non-bridge device

Jan 31 14:41:34 kernel: [ 232.873327] megaraid cmm: 2.20.2.7 (Release Date: Sun Jul 16 00:01:03 EST 2006)
Jan 31 14:41:34 kernel: [ 232.877616] SCSI subsystem initialized
Jan 31 14:41:34 kernel: [ 232.888779] megaraid: 2.20.4.9 (Release Date: Sun Jul 16 12:27:22 EST 2006)
Jan 31 14:41:34 kernel: [ 232.889835] megasas: 00.00.03.05 Mon Oct 02 11:21:32 PDT 2006
Jan 31 14:41:34 kernel: [ 233.513659] megasas: 0x1028:0x0015:0x1028:0x1f03: <6>megaraid: probe new device 0x1000:0x0408:0x1028:0x0002: bus 13:slot 14:func 0
Jan 31 14:41:34 kernel: [ 233.514770] megasas: FW now in Ready state
Jan 31 14:41:34 kernel: [ 233.528893] megaraid: fw version:[522A] bios version:[H430]
Jan 31 14:41:34 kernel: [ 233.554778] scsi2 : LSI Logic SAS based MegaRAID driver
Jan 31 14:41:34 kernel: [ 233.555536] scsi 2:0:0:0: Direct-Access MAXTOR ATLAS10K5_073SAS BP00 PQ: 0 ANSI: 5
Jan 31 14:41:34 kernel: [ 233.556173] scsi 2:0:1:0: Direct-Access MAXTOR ATLAS10K5_073SAS BP00 PQ: 0 ANSI: 5
Jan 31 14:41:34 kernel: [ 233.569337] scsi3 : LSI Logic MegaRAID driver
Jan 31 14:41:34 kernel: [ 233.569550] scsi[3]: scanning scsi channel 0 [Phy 0] for non-raid devices
Jan 31 14:41:34 kernel: [ 233.604522] scsi 2:0:8:0: Enclosure DP BACKPLANE 1.00 PQ: 0 ANSI: 5
Jan 31 14:41:41 kernel: [ 243.115199] megaraid: aborting-16 cmd=12 <c=0 t=12 l=0>
Jan 31 14:41:41 kernel: [ 243.115206] megaraid abort: 16:0[0:12], fw owner
Jan 31 14:41:41 kernel: [ 243.115217] megaraid: 1 outstanding commands. Max wait 300 sec
Jan 31 14:41:41 kernel: [ 243.115221] megaraid mbox: Wait for 1 commands to complete:300
Jan 31 14:41:46 kernel: [ 248.125812] megaraid mbox: Wait for 1 commands to complete:295
Jan 31 14:41:48 kernel: [ 250.134075] megaraid mbox: reset sequence completed sucessfully
Jan 31 14:41:58 kernel: [ 260.117201] megaraid: aborting-16 cmd=0 <c=0 t=12 l=0>Jan 31 14:41:58 kernel: [ 260.117207] megaraid abort: 16:0[0:12], fw owner
Jan 31 14:41:58 kernel: [ 260.117217] megaraid: 1 outstanding commands. Max wait 300 sec
Jan 31 14:41:58 kernel: [ 260.117223] megaraid mbox: Wait for 1 commands to complete:300
Jan 31 14:42:03 kernel: [ 265.127417] megaraid mbox: Wait for 1 commands to complete:295
Jan 31 14:42:08 kernel: [ 270.140211] megaraid mbox: Wait for 1 commands to complete:290
Jan 31 14:42:12 kernel: [ 274.146803] megaraid mbox: reset sequence completed sucessfully
[ nothing else that appears relevant ]


-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
Those who welcome death have only tried it from the ears up.
					-- Wilson Mizner


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

* Re: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump
  2007-01-05 23:47 ` Patro, Sumant
  (?)
@ 2007-01-05 23:50 ` Randy Dunlap
  -1 siblings, 0 replies; 13+ messages in thread
From: Randy Dunlap @ 2007-01-05 23:50 UTC (permalink / raw)
  To: Patro, Sumant
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, Kolli, Neela, Yang, Bo

Patro, Sumant wrote:
> Hello Randy,
> 
> 	At this time I am not trying to modify the function comment
> style of existing megaraid_mbox code. For the new function the
> description style is in sync with the preexisting code.
> 	So, I request for the patch to be accepted in its current
> submitted form. 

I have no problem with that as long as you'll allow it to be
corrected to match kernel-doc syntax.  Or don't use kernel-doc
syntax there at all.

> Regards,
> 
> Sumant 
> 
> -----Original Message-----
> From: Randy Dunlap [mailto:randy.dunlap@oracle.com] 
> Sent: Friday, January 05, 2007 1:35 PM
> To: Patro, Sumant
> Cc: James.Bottomley@SteelEye.com; akpm@osdl.org;
> linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; Kolli, Neela;
> Yang, Bo; Patro, Sumant
> Subject: Re: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump
> 
> On Fri, 05 Jan 2007 07:10:09 -0800 Sumant Patro wrote:
> 
> Hi,
> 
>> ---
>>
>>  Documentation/scsi/ChangeLog.megaraid |   16 ++
>>  drivers/scsi/megaraid/megaraid_mbox.c |  140 +++++++++++++++++++-----
>>  drivers/scsi/megaraid/megaraid_mbox.h |    4
>>  3 files changed, 130 insertions(+), 30 deletions(-)
>>
>> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c
> linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
>> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c
> 2006-12-28 09:56:04.000000000 -0800
>> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
> 2007-01-04 11:22:21.000000000 -0800
>> @@ -3380,6 +3386,84 @@ megaraid_mbox_flush_cache(adapter_t *ada
>>  
>>  
>>  /**
>> + * megaraid_mbox_fire_sync_cmd - fire the sync cmd
>> + * @param adapter	: soft state for the controller
> 
> That (above) should just be:
>  * @adapter:  (plus its description; the description there
>    doesn't seem to agree with its parameter name).
> 
> 
>> + *
>> + * Clears the pending cmds in FW and reinits its RAID structs  */ 
>> +static int megaraid_mbox_fire_sync_cmd(adapter_t *adapter) {
>> +	mbox_t	*mbox;
>> +	uint8_t	raw_mbox[sizeof(mbox_t)];
>> +	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
>> +	mbox64_t *mbox64;
>> +	int	status = 0;
>> +	int i;
>> +	uint32_t dword;
>> +
>> +	mbox = (mbox_t *)raw_mbox;
>> +
>> +	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
>> +
>> +	raw_mbox[0] = 0xFF;
>> +
>> +	mbox64	= raid_dev->mbox64;
>> +	mbox	= raid_dev->mbox;
>> +
>> +	/* Wait until mailbox is free */
>> +	if (megaraid_busywait_mbox(raid_dev) != 0) {
>> +		status = 1;
>> +		goto blocked_mailbox;
>> +	}
>> +
>> +	/* Copy mailbox data into host structure */
>> +	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
>> +	mbox->cmdid		= 0xFE;
>> +	mbox->busy		= 1;
>> +	mbox->poll		= 0;
>> +	mbox->ack		= 0;
>> +	mbox->numstatus		= 0;
>> +	mbox->status		= 0;
>> +
>> +	wmb();
>> +	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
>> +
>> +	/* Wait for maximum 1 min for status to post.
>> +	 * If the Firmware SUPPORTS the ABOVE COMMAND,
>> +	 * mbox->cmd will be set to 0
>> +	 * else
>> +	 * the firmware will reject the command with
>> +	 * mbox->numstatus set to 1
>> +	 */
>> +
>> +	i = 0;
>> +	status = 0;
>> +	while (!mbox->numstatus && mbox->cmd == 0xFF) {
>> +		rmb();
>> +		msleep(1);
>> +		i++;
>> +		if (i > 1000 * 60) {
>> +			status = 1;
>> +			break;
>> +		}
>> +	}
>> +	if (mbox->numstatus == 1)
>> +		status = 1; /*cmd not supported*/
>> +
>> +	/* Check for interrupt line */
>> +	dword = RDOUTDOOR(raid_dev);
>> +	WROUTDOOR(raid_dev, dword);
>> +	WRINDOOR(raid_dev,2);
>> +
>> +	return status;
>> +
>> +blocked_mailbox:
>> +	con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
>> +	return status;
>> +}
>> +
>> +/**
>>   * megaraid_mbox_display_scb - display SCB information, mostly debug
> purposes
>>   * @param adapter	: controllers' soft state
>>   * @param scb  : SCB to be displayed
> 
> I haven't looked at the entire source file, but these extra "param"
> words should not be there.  kernel-doc syntax is just
>   @name: description
> 
> 
> ---
> ~Randy


-- 
~Randy

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

* RE: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump
@ 2007-01-05 23:47 ` Patro, Sumant
  0 siblings, 0 replies; 13+ messages in thread
From: Patro, Sumant @ 2007-01-05 23:47 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, Kolli, Neela, Yang, Bo

Hello Randy,

	At this time I am not trying to modify the function comment
style of existing megaraid_mbox code. For the new function the
description style is in sync with the preexisting code.
	So, I request for the patch to be accepted in its current
submitted form. 

Regards,

Sumant 

-----Original Message-----
From: Randy Dunlap [mailto:randy.dunlap@oracle.com] 
Sent: Friday, January 05, 2007 1:35 PM
To: Patro, Sumant
Cc: James.Bottomley@SteelEye.com; akpm@osdl.org;
linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; Kolli, Neela;
Yang, Bo; Patro, Sumant
Subject: Re: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump

On Fri, 05 Jan 2007 07:10:09 -0800 Sumant Patro wrote:

Hi,

> ---
> 
>  Documentation/scsi/ChangeLog.megaraid |   16 ++
>  drivers/scsi/megaraid/megaraid_mbox.c |  140 +++++++++++++++++++-----
>  drivers/scsi/megaraid/megaraid_mbox.h |    4
>  3 files changed, 130 insertions(+), 30 deletions(-)
> 
> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c
linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c
2006-12-28 09:56:04.000000000 -0800
> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
2007-01-04 11:22:21.000000000 -0800
> @@ -3380,6 +3386,84 @@ megaraid_mbox_flush_cache(adapter_t *ada
>  
>  
>  /**
> + * megaraid_mbox_fire_sync_cmd - fire the sync cmd
> + * @param adapter	: soft state for the controller

That (above) should just be:
 * @adapter:  (plus its description; the description there
   doesn't seem to agree with its parameter name).


> + *
> + * Clears the pending cmds in FW and reinits its RAID structs  */ 
> +static int megaraid_mbox_fire_sync_cmd(adapter_t *adapter) {
> +	mbox_t	*mbox;
> +	uint8_t	raw_mbox[sizeof(mbox_t)];
> +	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
> +	mbox64_t *mbox64;
> +	int	status = 0;
> +	int i;
> +	uint32_t dword;
> +
> +	mbox = (mbox_t *)raw_mbox;
> +
> +	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
> +
> +	raw_mbox[0] = 0xFF;
> +
> +	mbox64	= raid_dev->mbox64;
> +	mbox	= raid_dev->mbox;
> +
> +	/* Wait until mailbox is free */
> +	if (megaraid_busywait_mbox(raid_dev) != 0) {
> +		status = 1;
> +		goto blocked_mailbox;
> +	}
> +
> +	/* Copy mailbox data into host structure */
> +	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
> +	mbox->cmdid		= 0xFE;
> +	mbox->busy		= 1;
> +	mbox->poll		= 0;
> +	mbox->ack		= 0;
> +	mbox->numstatus		= 0;
> +	mbox->status		= 0;
> +
> +	wmb();
> +	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
> +
> +	/* Wait for maximum 1 min for status to post.
> +	 * If the Firmware SUPPORTS the ABOVE COMMAND,
> +	 * mbox->cmd will be set to 0
> +	 * else
> +	 * the firmware will reject the command with
> +	 * mbox->numstatus set to 1
> +	 */
> +
> +	i = 0;
> +	status = 0;
> +	while (!mbox->numstatus && mbox->cmd == 0xFF) {
> +		rmb();
> +		msleep(1);
> +		i++;
> +		if (i > 1000 * 60) {
> +			status = 1;
> +			break;
> +		}
> +	}
> +	if (mbox->numstatus == 1)
> +		status = 1; /*cmd not supported*/
> +
> +	/* Check for interrupt line */
> +	dword = RDOUTDOOR(raid_dev);
> +	WROUTDOOR(raid_dev, dword);
> +	WRINDOOR(raid_dev,2);
> +
> +	return status;
> +
> +blocked_mailbox:
> +	con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
> +	return status;
> +}
> +
> +/**
>   * megaraid_mbox_display_scb - display SCB information, mostly debug
purposes
>   * @param adapter	: controllers' soft state
>   * @param scb  : SCB to be displayed

I haven't looked at the entire source file, but these extra "param"
words should not be there.  kernel-doc syntax is just
  @name: description


---
~Randy

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

* RE: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump
@ 2007-01-05 23:47 ` Patro, Sumant
  0 siblings, 0 replies; 13+ messages in thread
From: Patro, Sumant @ 2007-01-05 23:47 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, Kolli, Neela, Yang, Bo

Hello Randy,

	At this time I am not trying to modify the function comment
style of existing megaraid_mbox code. For the new function the
description style is in sync with the preexisting code.
	So, I request for the patch to be accepted in its current
submitted form. 

Regards,

Sumant 

-----Original Message-----
From: Randy Dunlap [mailto:randy.dunlap@oracle.com] 
Sent: Friday, January 05, 2007 1:35 PM
To: Patro, Sumant
Cc: James.Bottomley@SteelEye.com; akpm@osdl.org;
linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; Kolli, Neela;
Yang, Bo; Patro, Sumant
Subject: Re: [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump

On Fri, 05 Jan 2007 07:10:09 -0800 Sumant Patro wrote:

Hi,

> ---
> 
>  Documentation/scsi/ChangeLog.megaraid |   16 ++
>  drivers/scsi/megaraid/megaraid_mbox.c |  140 +++++++++++++++++++-----
>  drivers/scsi/megaraid/megaraid_mbox.h |    4
>  3 files changed, 130 insertions(+), 30 deletions(-)
> 
> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c
linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c
2006-12-28 09:56:04.000000000 -0800
> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
2007-01-04 11:22:21.000000000 -0800
> @@ -3380,6 +3386,84 @@ megaraid_mbox_flush_cache(adapter_t *ada
>  
>  
>  /**
> + * megaraid_mbox_fire_sync_cmd - fire the sync cmd
> + * @param adapter	: soft state for the controller

That (above) should just be:
 * @adapter:  (plus its description; the description there
   doesn't seem to agree with its parameter name).


> + *
> + * Clears the pending cmds in FW and reinits its RAID structs  */ 
> +static int megaraid_mbox_fire_sync_cmd(adapter_t *adapter) {
> +	mbox_t	*mbox;
> +	uint8_t	raw_mbox[sizeof(mbox_t)];
> +	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
> +	mbox64_t *mbox64;
> +	int	status = 0;
> +	int i;
> +	uint32_t dword;
> +
> +	mbox = (mbox_t *)raw_mbox;
> +
> +	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
> +
> +	raw_mbox[0] = 0xFF;
> +
> +	mbox64	= raid_dev->mbox64;
> +	mbox	= raid_dev->mbox;
> +
> +	/* Wait until mailbox is free */
> +	if (megaraid_busywait_mbox(raid_dev) != 0) {
> +		status = 1;
> +		goto blocked_mailbox;
> +	}
> +
> +	/* Copy mailbox data into host structure */
> +	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
> +	mbox->cmdid		= 0xFE;
> +	mbox->busy		= 1;
> +	mbox->poll		= 0;
> +	mbox->ack		= 0;
> +	mbox->numstatus		= 0;
> +	mbox->status		= 0;
> +
> +	wmb();
> +	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
> +
> +	/* Wait for maximum 1 min for status to post.
> +	 * If the Firmware SUPPORTS the ABOVE COMMAND,
> +	 * mbox->cmd will be set to 0
> +	 * else
> +	 * the firmware will reject the command with
> +	 * mbox->numstatus set to 1
> +	 */
> +
> +	i = 0;
> +	status = 0;
> +	while (!mbox->numstatus && mbox->cmd == 0xFF) {
> +		rmb();
> +		msleep(1);
> +		i++;
> +		if (i > 1000 * 60) {
> +			status = 1;
> +			break;
> +		}
> +	}
> +	if (mbox->numstatus == 1)
> +		status = 1; /*cmd not supported*/
> +
> +	/* Check for interrupt line */
> +	dword = RDOUTDOOR(raid_dev);
> +	WROUTDOOR(raid_dev, dword);
> +	WRINDOOR(raid_dev,2);
> +
> +	return status;
> +
> +blocked_mailbox:
> +	con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
> +	return status;
> +}
> +
> +/**
>   * megaraid_mbox_display_scb - display SCB information, mostly debug
purposes
>   * @param adapter	: controllers' soft state
>   * @param scb  : SCB to be displayed

I haven't looked at the entire source file, but these extra "param"
words should not be there.  kernel-doc syntax is just
  @name: description


---
~Randy

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

* RE: [Patch] scsi: megaraid_{mm,mbox}: init fix for kdump
@ 2007-01-03  2:37 ` Patro, Sumant
  0 siblings, 0 replies; 13+ messages in thread
From: Patro, Sumant @ 2007-01-03  2:37 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, Kolli, Neela, Yang, Bo


Thanks for the review. 
I will resubmit the patch.

Regards,

Sumant

-----Original Message-----
From: Randy Dunlap [mailto:rdunlap@xenotime.net] 
Sent: Friday, December 29, 2006 1:38 PM
To: Patro, Sumant
Cc: James.Bottomley@SteelEye.com; akpm@osdl.org;
linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; Kolli, Neela;
Yang, Bo; Patro, Sumant
Subject: Re: [Patch] scsi: megaraid_{mm,mbox}: init fix for kdump

On Fri, 29 Dec 2006 08:02:17 -0800 Sumant Patro wrote:

See Documentation/SubmittingPatches:
Please include output of "diffstat -p1 -w70" so that we can easily see
the scope of the changes.

and see Documentation/CodingStyle for comments below:


> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c 
> linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-28 
> 09:56:04.000000000 -0800
> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-29 
> +++ 05:31:48.000000000 -0800
> @@ -779,6 +780,22 @@ megaraid_init_mbox(adapter_t *adapter)
>  		goto out_release_regions;
>  	}
>  
> +	// initialize the mutual exclusion lock for the mailbox
> +	spin_lock_init(&raid_dev->mailbox_lock);

Linux uses /*...*/ C89-style comments, not // C99 comments.

> +	// allocate memory required for commands
> +	if (megaraid_alloc_cmd_packets(adapter) != 0) {
> +		goto out_iounmap;
> +	}
> +
> +	/*
> +	 * Issue SYNC cmd to flush the pending cmds in the adapter
> +	 * and initialize its internal state
> +	 */
> +
> +	if (megaraid_mbox_fire_sync_cmd(adapter))
> +		con_log(CL_ANN, ("megaraid: sync cmd failed\n"));
> +

>  	// Product info
>  	if (megaraid_mbox_product_info(adapter) != 0) {
> -		goto out_alloc_cmds;
> +		goto out_free_irq;

Don't uses {} braces around 1-statement "blocks".

> @@ -875,7 +883,7 @@ megaraid_init_mbox(adapter_t *adapter)
>  	 * accessed
>  	 */
>  	if (megaraid_sysfs_alloc_resources(adapter) != 0) {
> -		goto out_alloc_cmds;
> +		goto out_free_irq;

Ditto.

>  	}
>  
>  	// Set the DMA mask to 64-bit. All supported controllers as
capable 
> of @@ -3380,6 +3388,86 @@ megaraid_mbox_flush_cache(adapter_t *ada
>  
>  
>  /**
> + * megaraid_mbox_fire_sync_cmd - fire the sync cmd
> + * @param adapter	: soft state for the controller
> + */
> +static int
> +megaraid_mbox_fire_sync_cmd(adapter_t *adapter) {
> +	mbox_t	*mbox;
> +	uint8_t	raw_mbox[sizeof(mbox_t)];
> +	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
> +	mbox64_t *mbox64;
> +	uint8_t	status = 0;
> +	int i;
> +	uint32_t dword;
> +
> +	mbox = (mbox_t *)raw_mbox;
> +
> +	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
> +
> +	raw_mbox[0] = 0xFF;
> +
> +	mbox64	= raid_dev->mbox64;
> +	mbox	= raid_dev->mbox;
> +
> +	/*
> +	 * Wait until mailbox is free
> +	 */
> +	if (megaraid_busywait_mbox(raid_dev) != 0) {
> +		status = 1;
> +		goto blocked_mailbox;
> +	}
> +
> +	/*
> +	 * Copy mailbox data into host structure
> +	 */
> +	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
> +	mbox->cmdid		= 0xFE;
> +	mbox->busy		= 1;
> +	mbox->poll		= 0;
> +	mbox->ack		= 0;
> +	mbox->numstatus		= 0;
> +	mbox->status		= 0;
> +
> +	wmb();
> +	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
> +
> +	// wait for maximum 1 min for status to post.
> +	// If the Firmware SUPPORTS the ABOVE COMMAND,
> +	// mbox->cmd will be set to 0
> +	// else
> +	// the firmware will reject the command with
> +	// mbox->numstatus set to 1

Don't use // comment style.  Also, for multi-line comments in Linux,
please use this preferred style:

	/*
	 * This is the preferred style for multi-line
	 * comments in the Linux kernel source code.
	 * Please use it consistently.
	 *
	 * Description:  A column of asterisks on the left side,
	 * with beginning and ending almost-blank lines.
	 */

Thanks.
---
~Randy

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

* RE: [Patch] scsi: megaraid_{mm,mbox}: init fix for kdump
@ 2007-01-03  2:37 ` Patro, Sumant
  0 siblings, 0 replies; 13+ messages in thread
From: Patro, Sumant @ 2007-01-03  2:37 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, Kolli, Neela, Yang, Bo


Thanks for the review. 
I will resubmit the patch.

Regards,

Sumant

-----Original Message-----
From: Randy Dunlap [mailto:rdunlap@xenotime.net] 
Sent: Friday, December 29, 2006 1:38 PM
To: Patro, Sumant
Cc: James.Bottomley@SteelEye.com; akpm@osdl.org;
linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; Kolli, Neela;
Yang, Bo; Patro, Sumant
Subject: Re: [Patch] scsi: megaraid_{mm,mbox}: init fix for kdump

On Fri, 29 Dec 2006 08:02:17 -0800 Sumant Patro wrote:

See Documentation/SubmittingPatches:
Please include output of "diffstat -p1 -w70" so that we can easily see
the scope of the changes.

and see Documentation/CodingStyle for comments below:


> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c 
> linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-28 
> 09:56:04.000000000 -0800
> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-29 
> +++ 05:31:48.000000000 -0800
> @@ -779,6 +780,22 @@ megaraid_init_mbox(adapter_t *adapter)
>  		goto out_release_regions;
>  	}
>  
> +	// initialize the mutual exclusion lock for the mailbox
> +	spin_lock_init(&raid_dev->mailbox_lock);

Linux uses /*...*/ C89-style comments, not // C99 comments.

> +	// allocate memory required for commands
> +	if (megaraid_alloc_cmd_packets(adapter) != 0) {
> +		goto out_iounmap;
> +	}
> +
> +	/*
> +	 * Issue SYNC cmd to flush the pending cmds in the adapter
> +	 * and initialize its internal state
> +	 */
> +
> +	if (megaraid_mbox_fire_sync_cmd(adapter))
> +		con_log(CL_ANN, ("megaraid: sync cmd failed\n"));
> +

>  	// Product info
>  	if (megaraid_mbox_product_info(adapter) != 0) {
> -		goto out_alloc_cmds;
> +		goto out_free_irq;

Don't uses {} braces around 1-statement "blocks".

> @@ -875,7 +883,7 @@ megaraid_init_mbox(adapter_t *adapter)
>  	 * accessed
>  	 */
>  	if (megaraid_sysfs_alloc_resources(adapter) != 0) {
> -		goto out_alloc_cmds;
> +		goto out_free_irq;

Ditto.

>  	}
>  
>  	// Set the DMA mask to 64-bit. All supported controllers as
capable 
> of @@ -3380,6 +3388,86 @@ megaraid_mbox_flush_cache(adapter_t *ada
>  
>  
>  /**
> + * megaraid_mbox_fire_sync_cmd - fire the sync cmd
> + * @param adapter	: soft state for the controller
> + */
> +static int
> +megaraid_mbox_fire_sync_cmd(adapter_t *adapter) {
> +	mbox_t	*mbox;
> +	uint8_t	raw_mbox[sizeof(mbox_t)];
> +	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
> +	mbox64_t *mbox64;
> +	uint8_t	status = 0;
> +	int i;
> +	uint32_t dword;
> +
> +	mbox = (mbox_t *)raw_mbox;
> +
> +	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
> +
> +	raw_mbox[0] = 0xFF;
> +
> +	mbox64	= raid_dev->mbox64;
> +	mbox	= raid_dev->mbox;
> +
> +	/*
> +	 * Wait until mailbox is free
> +	 */
> +	if (megaraid_busywait_mbox(raid_dev) != 0) {
> +		status = 1;
> +		goto blocked_mailbox;
> +	}
> +
> +	/*
> +	 * Copy mailbox data into host structure
> +	 */
> +	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
> +	mbox->cmdid		= 0xFE;
> +	mbox->busy		= 1;
> +	mbox->poll		= 0;
> +	mbox->ack		= 0;
> +	mbox->numstatus		= 0;
> +	mbox->status		= 0;
> +
> +	wmb();
> +	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
> +
> +	// wait for maximum 1 min for status to post.
> +	// If the Firmware SUPPORTS the ABOVE COMMAND,
> +	// mbox->cmd will be set to 0
> +	// else
> +	// the firmware will reject the command with
> +	// mbox->numstatus set to 1

Don't use // comment style.  Also, for multi-line comments in Linux,
please use this preferred style:

	/*
	 * This is the preferred style for multi-line
	 * comments in the Linux kernel source code.
	 * Please use it consistently.
	 *
	 * Description:  A column of asterisks on the left side,
	 * with beginning and ending almost-blank lines.
	 */

Thanks.
---
~Randy

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

* Re: [Patch] scsi: megaraid_{mm,mbox}: init fix for kdump
  2006-12-30 14:31   ` Douglas Gilbert
@ 2006-12-30 15:38     ` Randy Dunlap
  0 siblings, 0 replies; 13+ messages in thread
From: Randy Dunlap @ 2006-12-30 15:38 UTC (permalink / raw)
  To: dougg
  Cc: Sumant Patro, James.Bottomley, akpm, linux-scsi, linux-kernel,
	neela.kolli, bo.yang, sumant.patro

On Sat, 30 Dec 2006 09:31:38 -0500 Douglas Gilbert wrote:

> Randy Dunlap wrote:
> > On Fri, 29 Dec 2006 08:02:17 -0800 Sumant Patro wrote:
> > 
> > See Documentation/SubmittingPatches:
> > Please include output of "diffstat -p1 -w70" so that we can easily see
> > the scope of the changes.
> > 
> > and see Documentation/CodingStyle for comments below:
> > 
> > 
> >> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
> >> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-28 09:56:04.000000000 -0800
> >> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-29 05:31:48.000000000 -0800
> >> @@ -779,6 +780,22 @@ megaraid_init_mbox(adapter_t *adapter)
> >>  		goto out_release_regions;
> >>  	}
> >>  
> >> +	// initialize the mutual exclusion lock for the mailbox
> >> +	spin_lock_init(&raid_dev->mailbox_lock);
> > 
> > Linux uses /*...*/ C89-style comments, not // C99 comments.
> 
> Randy
> It is about time this absurd stipulation was dropped.
> Are there any C compilers that can compile the linux
> kernel and that don't accept both _standard_ comment styles?

It's not a technical issue, it's just a style point.

---
~Randy

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

* Re: [Patch] scsi: megaraid_{mm,mbox}: init fix for kdump
  2006-12-29 21:37 ` Randy Dunlap
@ 2006-12-30 14:31   ` Douglas Gilbert
  2006-12-30 15:38     ` Randy Dunlap
  0 siblings, 1 reply; 13+ messages in thread
From: Douglas Gilbert @ 2006-12-30 14:31 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Sumant Patro, James.Bottomley, akpm, linux-scsi, linux-kernel,
	neela.kolli, bo.yang, sumant.patro

Randy Dunlap wrote:
> On Fri, 29 Dec 2006 08:02:17 -0800 Sumant Patro wrote:
> 
> See Documentation/SubmittingPatches:
> Please include output of "diffstat -p1 -w70" so that we can easily see
> the scope of the changes.
> 
> and see Documentation/CodingStyle for comments below:
> 
> 
>> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
>> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-28 09:56:04.000000000 -0800
>> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-29 05:31:48.000000000 -0800
>> @@ -779,6 +780,22 @@ megaraid_init_mbox(adapter_t *adapter)
>>  		goto out_release_regions;
>>  	}
>>  
>> +	// initialize the mutual exclusion lock for the mailbox
>> +	spin_lock_init(&raid_dev->mailbox_lock);
> 
> Linux uses /*...*/ C89-style comments, not // C99 comments.

Randy
It is about time this absurd stipulation was dropped.
Are there any C compilers that can compile the linux
kernel and that don't accept both _standard_ comment styles?

Doug Gilbert

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

* Re: [Patch] scsi: megaraid_{mm,mbox}: init fix for kdump
  2006-12-29 16:02 Sumant Patro
@ 2006-12-29 21:37 ` Randy Dunlap
  2006-12-30 14:31   ` Douglas Gilbert
  0 siblings, 1 reply; 13+ messages in thread
From: Randy Dunlap @ 2006-12-29 21:37 UTC (permalink / raw)
  To: Sumant Patro
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, neela.kolli,
	bo.yang, sumant.patro

On Fri, 29 Dec 2006 08:02:17 -0800 Sumant Patro wrote:

See Documentation/SubmittingPatches:
Please include output of "diffstat -p1 -w70" so that we can easily see
the scope of the changes.

and see Documentation/CodingStyle for comments below:


> diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
> --- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-28 09:56:04.000000000 -0800
> +++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-29 05:31:48.000000000 -0800
> @@ -779,6 +780,22 @@ megaraid_init_mbox(adapter_t *adapter)
>  		goto out_release_regions;
>  	}
>  
> +	// initialize the mutual exclusion lock for the mailbox
> +	spin_lock_init(&raid_dev->mailbox_lock);

Linux uses /*...*/ C89-style comments, not // C99 comments.

> +	// allocate memory required for commands
> +	if (megaraid_alloc_cmd_packets(adapter) != 0) {
> +		goto out_iounmap;
> +	}
> +
> +	/*
> +	 * Issue SYNC cmd to flush the pending cmds in the adapter
> +	 * and initialize its internal state
> +	 */
> +
> +	if (megaraid_mbox_fire_sync_cmd(adapter))
> +		con_log(CL_ANN, ("megaraid: sync cmd failed\n"));
> +

>  	// Product info
>  	if (megaraid_mbox_product_info(adapter) != 0) {
> -		goto out_alloc_cmds;
> +		goto out_free_irq;

Don't uses {} braces around 1-statement "blocks".

> @@ -875,7 +883,7 @@ megaraid_init_mbox(adapter_t *adapter)
>  	 * accessed
>  	 */
>  	if (megaraid_sysfs_alloc_resources(adapter) != 0) {
> -		goto out_alloc_cmds;
> +		goto out_free_irq;

Ditto.

>  	}
>  
>  	// Set the DMA mask to 64-bit. All supported controllers as capable of
> @@ -3380,6 +3388,86 @@ megaraid_mbox_flush_cache(adapter_t *ada
>  
>  
>  /**
> + * megaraid_mbox_fire_sync_cmd - fire the sync cmd
> + * @param adapter	: soft state for the controller
> + */
> +static int
> +megaraid_mbox_fire_sync_cmd(adapter_t *adapter)
> +{
> +	mbox_t	*mbox;
> +	uint8_t	raw_mbox[sizeof(mbox_t)];
> +	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
> +	mbox64_t *mbox64;
> +	uint8_t	status = 0;
> +	int i;
> +	uint32_t dword;
> +
> +	mbox = (mbox_t *)raw_mbox;
> +
> +	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
> +
> +	raw_mbox[0] = 0xFF;
> +
> +	mbox64	= raid_dev->mbox64;
> +	mbox	= raid_dev->mbox;
> +
> +	/*
> +	 * Wait until mailbox is free
> +	 */
> +	if (megaraid_busywait_mbox(raid_dev) != 0) {
> +		status = 1;
> +		goto blocked_mailbox;
> +	}
> +
> +	/*
> +	 * Copy mailbox data into host structure
> +	 */
> +	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
> +	mbox->cmdid		= 0xFE;
> +	mbox->busy		= 1;
> +	mbox->poll		= 0;
> +	mbox->ack		= 0;
> +	mbox->numstatus		= 0;
> +	mbox->status		= 0;
> +
> +	wmb();
> +	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
> +
> +	// wait for maximum 1 min for status to post.
> +	// If the Firmware SUPPORTS the ABOVE COMMAND,
> +	// mbox->cmd will be set to 0
> +	// else
> +	// the firmware will reject the command with
> +	// mbox->numstatus set to 1

Don't use // comment style.  Also, for multi-line comments
in Linux, please use this preferred style:

	/*
	 * This is the preferred style for multi-line
	 * comments in the Linux kernel source code.
	 * Please use it consistently.
	 *
	 * Description:  A column of asterisks on the left side,
	 * with beginning and ending almost-blank lines.
	 */

Thanks.
---
~Randy

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

* [Patch] scsi: megaraid_{mm,mbox}: init fix for kdump
@ 2006-12-29 16:02 Sumant Patro
  2006-12-29 21:37 ` Randy Dunlap
  0 siblings, 1 reply; 13+ messages in thread
From: Sumant Patro @ 2006-12-29 16:02 UTC (permalink / raw)
  To: James.Bottomley, akpm
  Cc: linux-scsi, linux-kernel, neela.kolli, bo.yang, sumant.patro

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


- Changes in Initialization to fix kdump failure.
Without this fix, megaraid driver either panics or fails to
initialize the adapter during the kdump's 2nd kernel boot
if there are pending commands or interrupts from other devices
sharing the same IRQ.
Fix:Send SYNC command on loading.
This command clears the pending commands in the adapter
and re-initialize its internal RAID structure.

Signed-Off By: Sumant Patro <sumant.patro@lsi.com>

diff -uprN linux-2.6.orig/Documentation/scsi/ChangeLog.megaraid linux-2.6.new/Documentation/scsi/ChangeLog.megaraid
--- linux-2.6.orig/Documentation/scsi/ChangeLog.megaraid 2006-12-28 10:10:31.000000000 -0800
+++ linux-2.6.new/Documentation/scsi/ChangeLog.megaraid 2006-12-29 06:57:44.000000000 -0800
@@ -1,3 +1,16 @@
+Release Date : Thu Nov 16 15:32:35 EST 2006 - Sumant Patro <sumant.patro@lsi.com>
+Current Version : 2.20.5.1 (scsi module), 2.20.2.6 (cmm module)
+Older Version : 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)
+
+1. Changes in Initialization to fix kdump failure.
+Without this fix, megaraid driver either panics or fails to
+initialize the adapter during the kdump's 2nd kernel boot
+if there are pending commands or interrupts from other devices
+sharing the same IRQ.
+  - Send SYNC command on loading.
+    This command clears the pending commands in the adapter
+    and re-initialize its internal RAID structure.
+
 Release Date : Fri May 19 09:31:45 EST 2006 - Seokmann Ju <sju@lsil.com>
 Current Version : 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)
 Older Version : 2.20.4.8 (scsi module), 2.20.2.6 (cmm module)
diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
--- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-28 09:56:04.000000000 -0800
+++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c 2006-12-29 05:31:48.000000000 -0800
@@ -10,13 +10,13 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mbox.c
- * Version	: v2.20.4.9 (Jul 16 2006)
+ * Version	: v2.20.5.1 (Nov 16 2006)
  *
  * Authors:
- * 	Atul Mukker		<Atul.Mukker@lsil.com>
- * 	Sreenivas Bagalkote	<Sreenivas.Bagalkote@lsil.com>
- * 	Manoj Jose		<Manoj.Jose@lsil.com>
- * 	Seokmann Ju		<Seokmann.Ju@lsil.com>
+ * 	Atul Mukker		<Atul.Mukker@lsi.com>
+ * 	Sreenivas Bagalkote	<Sreenivas.Bagalkote@lsi.com>
+ * 	Manoj Jose		<Manoj.Jose@lsi.com>
+ * 	Seokmann Ju		<Seokmann.Ju@lsi.com>
  *
  * List of supported controllers
  *
@@ -107,6 +107,7 @@ static int megaraid_mbox_support_random_
 static int megaraid_mbox_get_max_sg(adapter_t *);
 static void megaraid_mbox_enum_raid_scsi(adapter_t *);
 static void megaraid_mbox_flush_cache(adapter_t *);
+static int megaraid_mbox_fire_sync_cmd(adapter_t *);
 
 static void megaraid_mbox_display_scb(adapter_t *, scb_t *);
 static void megaraid_mbox_setup_device_map(adapter_t *);
@@ -137,7 +138,7 @@ static int wait_till_fw_empty(adapter_t 
 
 
 
-MODULE_AUTHOR("sju@lsil.com");
+MODULE_AUTHOR("sumant.patro@lsi.com");
 MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(MEGARAID_VERSION);
@@ -779,6 +780,22 @@ megaraid_init_mbox(adapter_t *adapter)
 		goto out_release_regions;
 	}
 
+	// initialize the mutual exclusion lock for the mailbox
+	spin_lock_init(&raid_dev->mailbox_lock);
+
+	// allocate memory required for commands
+	if (megaraid_alloc_cmd_packets(adapter) != 0) {
+		goto out_iounmap;
+	}
+
+	/*
+	 * Issue SYNC cmd to flush the pending cmds in the adapter
+	 * and initialize its internal state
+	 */
+
+	if (megaraid_mbox_fire_sync_cmd(adapter))
+		con_log(CL_ANN, ("megaraid: sync cmd failed\n"));
+
 	//
 	// Setup the rest of the soft state using the library of FW routines
 	//
@@ -789,22 +806,13 @@ megaraid_init_mbox(adapter_t *adapter)
 
 		con_log(CL_ANN, (KERN_WARNING
 			"megaraid: Couldn't register IRQ %d!\n", adapter->irq));
+		goto out_alloc_cmds;
 
-		goto out_iounmap;
-	}
-
-
-	// initialize the mutual exclusion lock for the mailbox
-	spin_lock_init(&raid_dev->mailbox_lock);
-
-	// allocate memory required for commands
-	if (megaraid_alloc_cmd_packets(adapter) != 0) {
-		goto out_free_irq;
 	}
 
 	// Product info
 	if (megaraid_mbox_product_info(adapter) != 0) {
-		goto out_alloc_cmds;
+		goto out_free_irq;
 	}
 
 	// Do we support extended CDBs
@@ -875,7 +883,7 @@ megaraid_init_mbox(adapter_t *adapter)
 	 * accessed
 	 */
 	if (megaraid_sysfs_alloc_resources(adapter) != 0) {
-		goto out_alloc_cmds;
+		goto out_free_irq;
 	}
 
 	// Set the DMA mask to 64-bit. All supported controllers as capable of
@@ -920,10 +928,10 @@ megaraid_init_mbox(adapter_t *adapter)
 
 out_free_sysfs_res:
 	megaraid_sysfs_free_resources(adapter);
-out_alloc_cmds:
-	megaraid_free_cmd_packets(adapter);
 out_free_irq:
 	free_irq(adapter->irq, adapter);
+out_alloc_cmds:
+	megaraid_free_cmd_packets(adapter);
 out_iounmap:
 	iounmap(raid_dev->baseaddr);
 out_release_regions:
@@ -3380,6 +3388,86 @@ megaraid_mbox_flush_cache(adapter_t *ada
 
 
 /**
+ * megaraid_mbox_fire_sync_cmd - fire the sync cmd
+ * @param adapter	: soft state for the controller
+ */
+static int
+megaraid_mbox_fire_sync_cmd(adapter_t *adapter)
+{
+	mbox_t	*mbox;
+	uint8_t	raw_mbox[sizeof(mbox_t)];
+	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
+	mbox64_t *mbox64;
+	uint8_t	status = 0;
+	int i;
+	uint32_t dword;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
+
+	raw_mbox[0] = 0xFF;
+
+	mbox64	= raid_dev->mbox64;
+	mbox	= raid_dev->mbox;
+
+	/*
+	 * Wait until mailbox is free
+	 */
+	if (megaraid_busywait_mbox(raid_dev) != 0) {
+		status = 1;
+		goto blocked_mailbox;
+	}
+
+	/*
+	 * Copy mailbox data into host structure
+	 */
+	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
+	mbox->cmdid		= 0xFE;
+	mbox->busy		= 1;
+	mbox->poll		= 0;
+	mbox->ack		= 0;
+	mbox->numstatus		= 0;
+	mbox->status		= 0;
+
+	wmb();
+	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
+
+	// wait for maximum 1 min for status to post.
+	// If the Firmware SUPPORTS the ABOVE COMMAND,
+	// mbox->cmd will be set to 0
+	// else
+	// the firmware will reject the command with
+	// mbox->numstatus set to 1
+
+	i = 0;
+	status = 0;
+	while (!mbox->numstatus && mbox->cmd == 0xFF) {
+		rmb();
+		msleep(1);
+		i++;
+		if (i > 1000 * 60) {
+			status = 1;
+			break;
+		}
+	}
+	if (mbox->numstatus == 1)
+		status = 1; /*cmd not supported*/
+	/*
+	 * Check for interrupt line
+	 */
+	dword = RDOUTDOOR(raid_dev);
+	WROUTDOOR(raid_dev, dword);
+	WRINDOOR(raid_dev,2);
+
+	return status;
+
+blocked_mailbox:
+	con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
+	return status;
+}
+
+/**
  * megaraid_mbox_display_scb - display SCB information, mostly debug purposes
  * @param adapter	: controllers' soft state
  * @param scb  : SCB to be displayed
diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.h linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.h
--- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.h 2006-12-28 09:56:04.000000000 -0800
+++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.h	2006-12-29 05:31:50.000000000 -0800
@@ -21,8 +21,8 @@
 #include "megaraid_ioctl.h"
 
 
-#define MEGARAID_VERSION	"2.20.4.9"
-#define MEGARAID_EXT_VERSION	"(Release Date: Sun Jul 16 12:27:22 EST 2006)"
+#define MEGARAID_VERSION	"2.20.5.1"
+#define MEGARAID_EXT_VERSION	"(Release Date: Thu Nov 16 15:32:35 EST 2006)"
 
 
 /*


[-- Attachment #2: megaraid-initialization-fix-for-kdump.patch --]
[-- Type: text/x-patch, Size: 6967 bytes --]

diff -uprN linux-2.6.orig/Documentation/scsi/ChangeLog.megaraid linux-2.6.new/Documentation/scsi/ChangeLog.megaraid
--- linux-2.6.orig/Documentation/scsi/ChangeLog.megaraid	2006-12-28 10:10:31.000000000 -0800
+++ linux-2.6.new/Documentation/scsi/ChangeLog.megaraid	2006-12-29 06:57:44.000000000 -0800
@@ -1,3 +1,16 @@
+Release Date	: Thu Nov 16 15:32:35 EST 2006 - Sumant Patro <sumant.patro@lsi.com>
+Current Version : 2.20.5.1 (scsi module), 2.20.2.6 (cmm module)
+Older Version	: 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)
+
+1. Changes in Initialization to fix kdump failure.
+Without this fix, megaraid driver either panics or fails to
+initialize the adapter during the kdump's 2nd kernel boot
+if there are pending commands or interrupts from other devices
+sharing the same IRQ.
+  - Send SYNC command on loading.
+    This command clears the pending commands in the adapter
+    and re-initialize its internal RAID structure.
+
 Release Date	: Fri May 19 09:31:45 EST 2006 - Seokmann Ju <sju@lsil.com>
 Current Version : 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)
 Older Version	: 2.20.4.8 (scsi module), 2.20.2.6 (cmm module)
diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c
--- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.c	2006-12-28 09:56:04.000000000 -0800
+++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.c	2006-12-29 05:31:48.000000000 -0800
@@ -10,13 +10,13 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mbox.c
- * Version	: v2.20.4.9 (Jul 16 2006)
+ * Version	: v2.20.5.1 (Nov 16 2006)
  *
  * Authors:
- * 	Atul Mukker		<Atul.Mukker@lsil.com>
- * 	Sreenivas Bagalkote	<Sreenivas.Bagalkote@lsil.com>
- * 	Manoj Jose		<Manoj.Jose@lsil.com>
- * 	Seokmann Ju		<Seokmann.Ju@lsil.com>
+ * 	Atul Mukker		<Atul.Mukker@lsi.com>
+ * 	Sreenivas Bagalkote	<Sreenivas.Bagalkote@lsi.com>
+ * 	Manoj Jose		<Manoj.Jose@lsi.com>
+ * 	Seokmann Ju		<Seokmann.Ju@lsi.com>
  *
  * List of supported controllers
  *
@@ -107,6 +107,7 @@ static int megaraid_mbox_support_random_
 static int megaraid_mbox_get_max_sg(adapter_t *);
 static void megaraid_mbox_enum_raid_scsi(adapter_t *);
 static void megaraid_mbox_flush_cache(adapter_t *);
+static int megaraid_mbox_fire_sync_cmd(adapter_t *);
 
 static void megaraid_mbox_display_scb(adapter_t *, scb_t *);
 static void megaraid_mbox_setup_device_map(adapter_t *);
@@ -137,7 +138,7 @@ static int wait_till_fw_empty(adapter_t 
 
 
 
-MODULE_AUTHOR("sju@lsil.com");
+MODULE_AUTHOR("sumant.patro@lsi.com");
 MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(MEGARAID_VERSION);
@@ -779,6 +780,22 @@ megaraid_init_mbox(adapter_t *adapter)
 		goto out_release_regions;
 	}
 
+	// initialize the mutual exclusion lock for the mailbox
+	spin_lock_init(&raid_dev->mailbox_lock);
+
+	// allocate memory required for commands
+	if (megaraid_alloc_cmd_packets(adapter) != 0) {
+		goto out_iounmap;
+	}
+
+	/*
+	 * Issue SYNC cmd to flush the pending cmds in the adapter
+	 * and initialize its internal state
+	 */
+
+	if (megaraid_mbox_fire_sync_cmd(adapter))
+		con_log(CL_ANN, ("megaraid: sync cmd failed\n"));
+
 	//
 	// Setup the rest of the soft state using the library of FW routines
 	//
@@ -789,22 +806,13 @@ megaraid_init_mbox(adapter_t *adapter)
 
 		con_log(CL_ANN, (KERN_WARNING
 			"megaraid: Couldn't register IRQ %d!\n", adapter->irq));
+		goto out_alloc_cmds;
 
-		goto out_iounmap;
-	}
-
-
-	// initialize the mutual exclusion lock for the mailbox
-	spin_lock_init(&raid_dev->mailbox_lock);
-
-	// allocate memory required for commands
-	if (megaraid_alloc_cmd_packets(adapter) != 0) {
-		goto out_free_irq;
 	}
 
 	// Product info
 	if (megaraid_mbox_product_info(adapter) != 0) {
-		goto out_alloc_cmds;
+		goto out_free_irq;
 	}
 
 	// Do we support extended CDBs
@@ -875,7 +883,7 @@ megaraid_init_mbox(adapter_t *adapter)
 	 * accessed
 	 */
 	if (megaraid_sysfs_alloc_resources(adapter) != 0) {
-		goto out_alloc_cmds;
+		goto out_free_irq;
 	}
 
 	// Set the DMA mask to 64-bit. All supported controllers as capable of
@@ -920,10 +928,10 @@ megaraid_init_mbox(adapter_t *adapter)
 
 out_free_sysfs_res:
 	megaraid_sysfs_free_resources(adapter);
-out_alloc_cmds:
-	megaraid_free_cmd_packets(adapter);
 out_free_irq:
 	free_irq(adapter->irq, adapter);
+out_alloc_cmds:
+	megaraid_free_cmd_packets(adapter);
 out_iounmap:
 	iounmap(raid_dev->baseaddr);
 out_release_regions:
@@ -3380,6 +3388,86 @@ megaraid_mbox_flush_cache(adapter_t *ada
 
 
 /**
+ * megaraid_mbox_fire_sync_cmd - fire the sync cmd
+ * @param adapter	: soft state for the controller
+ */
+static int
+megaraid_mbox_fire_sync_cmd(adapter_t *adapter)
+{
+	mbox_t	*mbox;
+	uint8_t	raw_mbox[sizeof(mbox_t)];
+	mraid_device_t	*raid_dev = ADAP2RAIDDEV(adapter);
+	mbox64_t *mbox64;
+	uint8_t	status = 0;
+	int i;
+	uint32_t dword;
+
+	mbox = (mbox_t *)raw_mbox;
+
+	memset((caddr_t)raw_mbox, 0, sizeof(mbox_t));
+
+	raw_mbox[0] = 0xFF;
+
+	mbox64	= raid_dev->mbox64;
+	mbox	= raid_dev->mbox;
+
+	/*
+	 * Wait until mailbox is free
+	 */
+	if (megaraid_busywait_mbox(raid_dev) != 0) {
+		status = 1;
+		goto blocked_mailbox;
+	}
+
+	/*
+	 * Copy mailbox data into host structure
+	 */
+	memcpy((caddr_t)mbox, (caddr_t)raw_mbox, 16);
+	mbox->cmdid		= 0xFE;
+	mbox->busy		= 1;
+	mbox->poll		= 0;
+	mbox->ack		= 0;
+	mbox->numstatus		= 0;
+	mbox->status		= 0;
+
+	wmb();
+	WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
+
+	// wait for maximum 1 min for status to post.
+	// If the Firmware SUPPORTS the ABOVE COMMAND,
+	// mbox->cmd will be set to 0
+	// else
+	// the firmware will reject the command with
+	// mbox->numstatus set to 1
+
+	i = 0;
+	status = 0;
+	while (!mbox->numstatus && mbox->cmd == 0xFF) {
+		rmb();
+		msleep(1);
+		i++;
+		if (i > 1000 * 60) {
+			status = 1;
+			break;
+		}
+	}
+	if (mbox->numstatus == 1)
+		status = 1; /*cmd not supported*/
+	/*
+	 * Check for interrupt line
+	 */
+	dword = RDOUTDOOR(raid_dev);
+	WROUTDOOR(raid_dev, dword);
+	WRINDOOR(raid_dev,2);
+
+	return status;
+
+blocked_mailbox:
+	con_log(CL_ANN, (KERN_WARNING "megaraid: blocked mailbox\n"));
+	return status;
+}
+
+/**
  * megaraid_mbox_display_scb - display SCB information, mostly debug purposes
  * @param adapter	: controllers' soft state
  * @param scb		: SCB to be displayed
diff -uprN linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.h linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.h
--- linux-2.6.orig/drivers/scsi/megaraid/megaraid_mbox.h	2006-12-28 09:56:04.000000000 -0800
+++ linux-2.6.new/drivers/scsi/megaraid/megaraid_mbox.h	2006-12-29 05:31:50.000000000 -0800
@@ -21,8 +21,8 @@
 #include "megaraid_ioctl.h"
 
 
-#define MEGARAID_VERSION	"2.20.4.9"
-#define MEGARAID_EXT_VERSION	"(Release Date: Sun Jul 16 12:27:22 EST 2006)"
+#define MEGARAID_VERSION	"2.20.5.1"
+#define MEGARAID_EXT_VERSION	"(Release Date: Thu Nov 16 15:32:35 EST 2006)"
 
 
 /*

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

end of thread, other threads:[~2007-01-31 18:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-05 15:10 [PATCH] scsi: megaraid_{mm,mbox} init fix for kdump Sumant Patro
2007-01-05 21:34 ` Randy Dunlap
2007-01-31 17:49 ` Matthias Urlichs
2007-01-31 17:49   ` Matthias Urlichs
  -- strict thread matches above, loose matches on Subject: below --
2007-01-05 23:47 Patro, Sumant
2007-01-05 23:47 ` Patro, Sumant
2007-01-05 23:50 ` Randy Dunlap
2007-01-03  2:37 [Patch] scsi: megaraid_{mm,mbox}: " Patro, Sumant
2007-01-03  2:37 ` Patro, Sumant
2006-12-29 16:02 Sumant Patro
2006-12-29 21:37 ` Randy Dunlap
2006-12-30 14:31   ` Douglas Gilbert
2006-12-30 15:38     ` Randy Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.