linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/12] scsi: megaraid_sas - tape drive support fix
@ 2009-09-21  2:21 Yang, Bo
  2009-09-21  3:40 ` Daniel Walker
  2009-10-06 20:12 ` Yang, Bo
  0 siblings, 2 replies; 37+ messages in thread
From: Yang, Bo @ 2009-09-21  2:21 UTC (permalink / raw)
  To: Yang, Bo, James.Bottomley, James.Bottomley; +Cc: linux-scsi, akpm, linux-kernel

Add the Tape drive fix to the megaraid_sas driver: If the command is for the tape device, set the FW pthru timeout to the os layer timeout value.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
drivers/scsi/megaraid/megaraid_sas.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff -rupN linux-2.6.28_orig/drivers/scsi/megaraid/megaraid_sas.c linux-2.6.28_new/drivers/scsi/megaraid/megaraid_sas.c
--- linux-2.6.28_orig/drivers/scsi/megaraid/megaraid_sas.c      2009-05-04 20:06:29.000000000 -0400
+++ linux-2.6.28_new/drivers/scsi/megaraid/megaraid_sas.c       2009-05-04 20:08:26.000000000 -0400
@@ -687,6 +687,17 @@ megasas_build_dcdb(struct megasas_instan
        memcpy(pthru->cdb, scp->cmnd, scp->cmd_len);

        /*
+       * If the command is for the tape device, set the
+       * pthru timeout to the os layer timeout value.
+       */
+       if (scp->device->type == TYPE_TAPE) {
+               if ((scp->request->timeout / HZ) > 0xFFFF)
+                       pthru->timeout = 0xFFFF;
+               else
+                       pthru->timeout = scp->request->timeout / HZ;
+       }
+
+       /*
         * Construct SGL
         */
        if (IS_DMA64) {


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

* Re: [PATCH 1/12] scsi: megaraid_sas - tape drive support fix
  2009-09-21  2:21 [PATCH 1/12] scsi: megaraid_sas - tape drive support fix Yang, Bo
@ 2009-09-21  3:40 ` Daniel Walker
  2009-09-21 15:22   ` Yang, Bo
  2009-10-06 20:12 ` Yang, Bo
  1 sibling, 1 reply; 37+ messages in thread
From: Daniel Walker @ 2009-09-21  3:40 UTC (permalink / raw)
  To: Yang, Bo; +Cc: James.Bottomley, James.Bottomley, linux-scsi, akpm, linux-kernel


Your patches all have numerous serious style problems.. There are far
too many to even give a summary here, and they are all different kinds
of problems..

You would need to fix all these issues before these patches could move
forward. Could you run scripts/checkpatch.pl on you patches and fix all
the issues that it reports?

Daniel


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

* RE: [PATCH 1/12] scsi: megaraid_sas - tape drive support fix
  2009-09-21  3:40 ` Daniel Walker
@ 2009-09-21 15:22   ` Yang, Bo
  2009-09-21 15:57     ` Daniel Walker
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2009-09-21 15:22 UTC (permalink / raw)
  To: Daniel Walker
  Cc: James.Bottomley, James.Bottomley, linux-scsi, akpm, linux-kernel

Daniel,

Thanks for viewing the patches.  I did run the checkpatch.pl first before I submit the patches.  Is there possible you can tell me the errors in the specific patch, I need to find out if it is my e-mail setting problems or something else.

Thanks,

Bo Yang  

-----Original Message-----
From: Daniel Walker [mailto:dwalker@fifo99.com] 
Sent: Sunday, September 20, 2009 11:41 PM
To: Yang, Bo
Cc: James.Bottomley@HansenPartnership.com; James.Bottomley@suse.de; linux-scsi@vger.kernel.org; akpm@osdl.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/12] scsi: megaraid_sas - tape drive support fix


Your patches all have numerous serious style problems.. There are far
too many to even give a summary here, and they are all different kinds
of problems..

You would need to fix all these issues before these patches could move
forward. Could you run scripts/checkpatch.pl on you patches and fix all
the issues that it reports?

Daniel


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

* RE: [PATCH 1/12] scsi: megaraid_sas - tape drive support fix
  2009-09-21 15:22   ` Yang, Bo
@ 2009-09-21 15:57     ` Daniel Walker
  2009-09-21 16:04       ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Daniel Walker @ 2009-09-21 15:57 UTC (permalink / raw)
  To: Yang, Bo; +Cc: James.Bottomley, James.Bottomley, linux-scsi, akpm, linux-kernel

On Mon, 2009-09-21 at 09:22 -0600, Yang, Bo wrote:
> Daniel,
> 
> Thanks for viewing the patches.  I did run the checkpatch.pl first before I submit the patches.  Is there possible you can tell me the errors in the specific patch, I need to find out if it is my e-mail setting problems or something else.

There are problems in all your patches.. 

>From patch 1 (not all the errors),

ERROR: patch seems to be corrupt (line wrapped?)
#73: FILE: drivers/scsi/megaraid/megaraid_sas.c:686:
 memcpy(pthru->cdb, scp->cmnd, scp->cmd_len);

ERROR: Invalid UTF-8, patch and commit message should be encoded in
UTF-8
#76: FILE: drivers/scsi/megaraid/megaraid_sas.c:688:
+ * If the command is for the tape device, set the
 ^

ERROR: Invalid UTF-8, patch and commit message should be encoded in
UTF-8
#77: FILE: drivers/scsi/megaraid/megaraid_sas.c:689:
+ * pthru timeout to the os layer timeout value.

>From patch 2,

WARNING: suspect code indent for conditional statements (7, 15)
#107: FILE: drivers/scsi/megaraid/megaraid_sas.c:1306:
+       if ((!cmd->abort_aen) && (instance->unload == 0)) {
+               spin_lock_irqsave(&poll_aen_lock, flags);

ERROR: code indent should use tabs where possible
#108: FILE: drivers/scsi/megaraid/megaraid_sas.c:1307:
+               spin_lock_irqsave(&poll_aen_lock, flags);$

ERROR: code indent should use tabs where possible
#109: FILE: drivers/scsi/megaraid/megaraid_sas.c:1308:
+               megasas_poll_wait_aen = 1;$


Actually, now that I look closer, other than the errors from patch 1 the
rest of the patches have warnings similar to patch 2.. Did you do some
type of copy&paste to put the patches into each email? Often times that
will remove all the tabs which could cause the errors above.

Daniel



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

* RE: [PATCH 1/12] scsi: megaraid_sas - tape drive support fix
  2009-09-21 15:57     ` Daniel Walker
@ 2009-09-21 16:04       ` Yang, Bo
  0 siblings, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2009-09-21 16:04 UTC (permalink / raw)
  To: Daniel Walker
  Cc: James.Bottomley, James.Bottomley, linux-scsi, akpm, linux-kernel

Daniel,

Thanks Daniel.  Let me verify if this copy/paste did those changes.

Bo Yang  

-----Original Message-----
From: Daniel Walker [mailto:dwalker@fifo99.com] 
Sent: Monday, September 21, 2009 11:57 AM
To: Yang, Bo
Cc: James.Bottomley@HansenPartnership.com; James.Bottomley@suse.de; linux-scsi@vger.kernel.org; akpm@osdl.org; linux-kernel@vger.kernel.org
Subject: RE: [PATCH 1/12] scsi: megaraid_sas - tape drive support fix

On Mon, 2009-09-21 at 09:22 -0600, Yang, Bo wrote:
> Daniel,
> 
> Thanks for viewing the patches.  I did run the checkpatch.pl first before I submit the patches.  Is there possible you can tell me the errors in the specific patch, I need to find out if it is my e-mail setting problems or something else.

There are problems in all your patches.. 

>From patch 1 (not all the errors),

ERROR: patch seems to be corrupt (line wrapped?)
#73: FILE: drivers/scsi/megaraid/megaraid_sas.c:686:
 memcpy(pthru->cdb, scp->cmnd, scp->cmd_len);

ERROR: Invalid UTF-8, patch and commit message should be encoded in
UTF-8
#76: FILE: drivers/scsi/megaraid/megaraid_sas.c:688:
+ * If the command is for the tape device, set the
 ^

ERROR: Invalid UTF-8, patch and commit message should be encoded in
UTF-8
#77: FILE: drivers/scsi/megaraid/megaraid_sas.c:689:
+ * pthru timeout to the os layer timeout value.

>From patch 2,

WARNING: suspect code indent for conditional statements (7, 15)
#107: FILE: drivers/scsi/megaraid/megaraid_sas.c:1306:
+       if ((!cmd->abort_aen) && (instance->unload == 0)) {
+               spin_lock_irqsave(&poll_aen_lock, flags);

ERROR: code indent should use tabs where possible
#108: FILE: drivers/scsi/megaraid/megaraid_sas.c:1307:
+               spin_lock_irqsave(&poll_aen_lock, flags);$

ERROR: code indent should use tabs where possible
#109: FILE: drivers/scsi/megaraid/megaraid_sas.c:1308:
+               megasas_poll_wait_aen = 1;$


Actually, now that I look closer, other than the errors from patch 1 the
rest of the patches have warnings similar to patch 2.. Did you do some
type of copy&paste to put the patches into each email? Often times that
will remove all the tabs which could cause the errors above.

Daniel



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

* [PATCH 1/12] scsi: megaraid_sas - tape drive support fix
  2009-09-21  2:21 [PATCH 1/12] scsi: megaraid_sas - tape drive support fix Yang, Bo
  2009-09-21  3:40 ` Daniel Walker
@ 2009-10-06 20:12 ` Yang, Bo
  2009-12-06 15:24   ` [PATCH 1/4] scsi: megaraid_sas - Zero pad_0 in mfi structure Yang, Bo
       [not found]   ` <3A916D859199814BBB666188F96EB165013979165E@cosmail02.lsi.com>
  1 sibling, 2 replies; 37+ messages in thread
From: Yang, Bo @ 2009-10-06 20:12 UTC (permalink / raw)
  To: Yang, Bo, James.Bottomley, James.Bottomley
  Cc: linux-scsi, akpm, linux-kernel, Austria, Winston, Mukker, Atul

RESUBMIT:

Add the Tape drive fix to the megaraid_sas driver: If the command is for the tape device, set the FW pthru timeout to the os layer timeout value.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
drivers/scsi/megaraid/megaraid_sas.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff -rupN linux-2.6.28_orig/drivers/scsi/megaraid/megaraid_sas.c linux-2.6.28_new/drivers/scsi/megaraid/megaraid_sas.c
--- linux-2.6.28_orig/drivers/scsi/megaraid/megaraid_sas.c	2009-05-04 20:06:29.000000000 -0400
+++ linux-2.6.28_new/drivers/scsi/megaraid/megaraid_sas.c	2009-05-04 20:08:26.000000000 -0400
@@ -687,6 +687,17 @@ megasas_build_dcdb(struct megasas_instan
 	memcpy(pthru->cdb, scp->cmnd, scp->cmd_len);
 
 	/*
+	* If the command is for the tape device, set the
+	* pthru timeout to the os layer timeout value.
+	*/
+	if (scp->device->type == TYPE_TAPE) {
+		if ((scp->request->timeout / HZ) > 0xFFFF)
+			pthru->timeout = 0xFFFF;
+		else
+			pthru->timeout = scp->request->timeout / HZ;
+	}
+
+	/*
 	 * Construct SGL
 	 */
 	if (IS_DMA64) {

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

* [PATCH 1/4] scsi: megaraid_sas - Zero pad_0 in mfi structure
  2009-10-06 20:12 ` Yang, Bo
@ 2009-12-06 15:24   ` Yang, Bo
  2009-12-06 15:30     ` [PATCH 2/4] scsi: megaraid_sas - add the ld list to driver Yang, Bo
       [not found]   ` <3A916D859199814BBB666188F96EB165013979165E@cosmail02.lsi.com>
  1 sibling, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2009-12-06 15:24 UTC (permalink / raw)
  To: Yang, Bo, James.Bottomley, James.Bottomley
  Cc: linux-scsi, akpm, linux-kernel, Austria, Winston, Mukker, Atul

Add the pad_0 in mfi frame structure to 0 to fix the context value larger than 32bit value issue.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2009-12-04 05:25:19.000000000 -0500
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2009-12-04 05:29:57.000000000 -0500
@@ -843,6 +843,7 @@ megasas_build_dcdb(struct megasas_instan
 	pthru->lun = scp->device->lun;
 	pthru->cdb_len = scp->cmd_len;
 	pthru->timeout = 0;
+	pthru->pad_0 = 0;
 	pthru->flags = flags;
 	pthru->data_xfer_len = scsi_bufflen(scp);
 
@@ -2250,6 +2251,7 @@ megasas_get_pd_list(struct megasas_insta
 	dcmd->sge_count = 1;
 	dcmd->flags = MFI_FRAME_DIR_READ;
 	dcmd->timeout = 0;
+	dcmd->pad_0 = 0;
 	dcmd->data_xfer_len = MEGASAS_MAX_PD * sizeof(struct MR_PD_LIST);
 	dcmd->opcode = MR_DCMD_PD_LIST_QUERY;
 	dcmd->sgl.sge32[0].phys_addr = ci_h;
@@ -2339,6 +2341,7 @@ megasas_get_ctrl_info(struct megasas_ins
 	dcmd->sge_count = 1;
 	dcmd->flags = MFI_FRAME_DIR_READ;
 	dcmd->timeout = 0;
+	dcmd->pad_0 = 0;
 	dcmd->data_xfer_len = sizeof(struct megasas_ctrl_info);
 	dcmd->opcode = MR_DCMD_CTRL_GET_INFO;
 	dcmd->sgl.sge32[0].phys_addr = ci_h;
@@ -2710,6 +2713,7 @@ megasas_get_seq_num(struct megasas_insta
 	dcmd->sge_count = 1;
 	dcmd->flags = MFI_FRAME_DIR_READ;
 	dcmd->timeout = 0;
+	dcmd->pad_0 = 0;
 	dcmd->data_xfer_len = sizeof(struct megasas_evt_log_info);
 	dcmd->opcode = MR_DCMD_CTRL_EVENT_GET_INFO;
 	dcmd->sgl.sge32[0].phys_addr = el_info_h;
@@ -2824,6 +2828,7 @@ megasas_register_aen(struct megasas_inst
 	dcmd->sge_count = 1;
 	dcmd->flags = MFI_FRAME_DIR_READ;
 	dcmd->timeout = 0;
+	dcmd->pad_0 = 0;
 	dcmd->data_xfer_len = sizeof(struct megasas_evt_detail);
 	dcmd->opcode = MR_DCMD_CTRL_EVENT_WAIT;
 	dcmd->mbox.w[0] = seq_num;
@@ -3162,6 +3167,7 @@ static void megasas_flush_cache(struct m
 	dcmd->sge_count = 0;
 	dcmd->flags = MFI_FRAME_DIR_NONE;
 	dcmd->timeout = 0;
+	dcmd->pad_0 = 0;
 	dcmd->data_xfer_len = 0;
 	dcmd->opcode = MR_DCMD_CTRL_CACHE_FLUSH;
 	dcmd->mbox.b[0] = MR_FLUSH_CTRL_CACHE | MR_FLUSH_DISK_CACHE;
@@ -3201,6 +3207,7 @@ static void megasas_shutdown_controller(
 	dcmd->sge_count = 0;
 	dcmd->flags = MFI_FRAME_DIR_NONE;
 	dcmd->timeout = 0;
+	dcmd->pad_0 = 0;
 	dcmd->data_xfer_len = 0;
 	dcmd->opcode = opcode;


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

* [PATCH 2/4] scsi: megaraid_sas - add the ld list to driver
  2009-12-06 15:24   ` [PATCH 1/4] scsi: megaraid_sas - Zero pad_0 in mfi structure Yang, Bo
@ 2009-12-06 15:30     ` Yang, Bo
  2009-12-06 15:39       ` [PATCH 3/4] scsi: megaraid_sas - driver fixed the device update issue Yang, Bo
  2009-12-06 15:42       ` [PATCH 4/4] scsi: megaraid_sas - version and documentation update Yang, Bo
  0 siblings, 2 replies; 37+ messages in thread
From: Yang, Bo @ 2009-12-06 15:30 UTC (permalink / raw)
  To: Yang, Bo, James.Bottomley, James.Bottomley
  Cc: linux-scsi, akpm, linux-kernel, Austria, Winston, Mukker, Atul

Driver issue the get ld list to fw to get the logic drive list.  Driver will keep the logic drive list for the internal use after driver load.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 megaraid_sas.h |   30 ++++++++++++++++++
 2 files changed, 125 insertions(+)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2009-12-04 05:34:47.000000000 -0500
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2009-12-06 03:50:19.000000000 -0500
@@ -875,6 +875,12 @@ megasas_build_dcdb(struct megasas_instan
 		pthru->sge_count = megasas_make_sgl32(instance, scp,
 						      &pthru->sgl);
 
+	if (pthru->sge_count > instance->max_num_sge) {
+		printk(KERN_ERR "megasas: DCDB two many SGE NUM=%x\n",
+			pthru->sge_count);
+		return 0;
+	}
+
 	/*
 	 * Sense info specific
 	 */
@@ -1001,6 +1007,12 @@ megasas_build_ldio(struct megasas_instan
 	} else
 		ldio->sge_count = megasas_make_sgl32(instance, scp, &ldio->sgl);
 
+	if (ldio->sge_count > instance->max_num_sge) {
+		printk(KERN_ERR "megasas: build_ld_io: sge_count = %x\n",
+			ldio->sge_count);
+		return 0;
+	}
+
 	/*
 	 * Sense info specific
 	 */
@@ -2296,6 +2308,86 @@ megasas_get_pd_list(struct megasas_insta
 	return ret;
 }
 
+/*
+ * megasas_get_ld_list_info -	Returns FW's ld_list structure
+ * @instance:				Adapter soft state
+ * @ld_list:				ld_list structure
+ *
+ * Issues an internal command (DCMD) to get the FW's controller PD
+ * list structure.  This information is mainly used to find out SYSTEM
+ * supported by the FW.
+ */
+static int
+megasas_get_ld_list(struct megasas_instance *instance)
+{
+	int ret = 0, ld_index = 0, ids = 0;
+	struct megasas_cmd *cmd;
+	struct megasas_dcmd_frame *dcmd;
+	struct MR_LD_LIST *ci;
+	dma_addr_t ci_h = 0;
+
+	cmd = megasas_get_cmd(instance);
+
+	if (!cmd) {
+		printk(KERN_DEBUG "megasas_get_ld_list: Failed to get cmd\n");
+		return -ENOMEM;
+	}
+
+	dcmd = &cmd->frame->dcmd;
+
+	ci = pci_alloc_consistent(instance->pdev,
+				sizeof(struct MR_LD_LIST),
+				&ci_h);
+
+	if (!ci) {
+		printk(KERN_DEBUG "Failed to alloc mem in get_ld_list\n");
+		megasas_return_cmd(instance, cmd);
+		return -ENOMEM;
+	}
+
+	memset(ci, 0, sizeof(*ci));
+	memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
+
+	dcmd->cmd = MFI_CMD_DCMD;
+	dcmd->cmd_status = 0xFF;
+	dcmd->sge_count = 1;
+	dcmd->flags = MFI_FRAME_DIR_READ;
+	dcmd->timeout = 0;
+	dcmd->data_xfer_len = sizeof(struct MR_LD_LIST);
+	dcmd->opcode = MR_DCMD_LD_GET_LIST;
+	dcmd->sgl.sge32[0].phys_addr = ci_h;
+	dcmd->sgl.sge32[0].length = sizeof(struct MR_LD_LIST);
+	dcmd->pad_0  = 0;
+
+	if (!megasas_issue_polled(instance, cmd)) {
+		ret = 0;
+	} else {
+		ret = -1;
+	}
+
+	/* the following function will get the instance PD LIST */
+
+	if ((ret == 0) && (ci->ldCount < MAX_LOGICAL_DRIVES)) {
+		memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
+
+		for (ld_index = 0; ld_index < ci->ldCount; ld_index++) {
+			if (ci->ldList[ld_index].state != 0) {
+				ids = ci->ldList[ld_index].ref.targetId;
+				instance->ld_ids[ids] =
+					ci->ldList[ld_index].ref.targetId;
+			}
+		}
+	}
+
+	pci_free_consistent(instance->pdev,
+				sizeof(struct MR_LD_LIST),
+				ci,
+				ci_h);
+
+	megasas_return_cmd(instance, cmd);
+	return ret;
+}
+
 /**
  * megasas_get_controller_info -	Returns FW's controller structure
  * @instance:				Adapter soft state
@@ -2591,6 +2683,9 @@ static int megasas_init_mfi(struct megas
 		(MEGASAS_MAX_PD * sizeof(struct megasas_pd_list)));
 	megasas_get_pd_list(instance);
 
+	memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
+	megasas_get_ld_list(instance);
+
 	ctrl_info = kmalloc(sizeof(struct megasas_ctrl_info), GFP_KERNEL);
 
 	/*
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2009-12-04 05:34:47.000000000 -0500
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2009-12-05 21:54:40.000000000 -0500
@@ -117,6 +117,7 @@
 #define MFI_CMD_STP				0x08
 
 #define MR_DCMD_CTRL_GET_INFO			0x01010000
+#define MR_DCMD_LD_GET_LIST			0x03010000
 
 #define MR_DCMD_CTRL_CACHE_FLUSH		0x01101000
 #define MR_FLUSH_CTRL_CACHE			0x01
@@ -349,6 +350,32 @@ struct megasas_pd_list {
 	u8             driveState;
 } __packed;
 
+ /*
+ * defines the logical drive reference structure
+ */
+union  MR_LD_REF {
+	struct {
+		u8      targetId;
+		u8      reserved;
+		u16     seqNum;
+	};
+	u32     ref;
+} __packed;
+
+/*
+ * defines the logical drive list structure
+ */
+struct MR_LD_LIST {
+	u32     ldCount;
+	u32     reserved;
+	struct {
+		union MR_LD_REF   ref;
+		u8          state;
+		u8          reserved[3];
+		u64         size;
+	} ldList[MAX_LOGICAL_DRIVES];
+} __packed;
+
 /*
  * SAS controller properties
  */
@@ -637,6 +664,8 @@ struct megasas_ctrl_info {
 #define MEGASAS_MAX_LD				64
 #define MEGASAS_MAX_PD                          (MEGASAS_MAX_PD_CHANNELS * \
 						MEGASAS_MAX_DEV_PER_CHANNEL)
+#define MEGASAS_MAX_LD_IDS			(MEGASAS_MAX_LD_CHANNELS * \
+						MEGASAS_MAX_DEV_PER_CHANNEL)
 
 #define MEGASAS_DBG_LVL				1
 
@@ -1187,6 +1216,7 @@ struct megasas_instance {
 	struct megasas_register_set __iomem *reg_set;
 
 	struct megasas_pd_list          pd_list[MEGASAS_MAX_PD];
+	u8     ld_ids[MEGASAS_MAX_LD_IDS];
 	s8 init_id;
 
 	u16 max_num_sge;

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

* [PATCH 3/4] scsi: megaraid_sas -  driver fixed the device update issue
  2009-12-06 15:30     ` [PATCH 2/4] scsi: megaraid_sas - add the ld list to driver Yang, Bo
@ 2009-12-06 15:39       ` Yang, Bo
  2009-12-06 15:42       ` [PATCH 4/4] scsi: megaraid_sas - version and documentation update Yang, Bo
  1 sibling, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2009-12-06 15:39 UTC (permalink / raw)
  To: Yang, Bo, James.Bottomley, James.Bottomley
  Cc: linux-scsi, akpm, linux-kernel, Austria, Winston, Mukker, Atul

driver fixed the device update issue after get the AEN PD delete/ADD and LD add/delete from FW.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |  142 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2009-12-06 03:51:57.000000000 -0500
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2009-12-06 04:42:17.000000000 -0500
@@ -4068,6 +4068,7 @@ megasas_aen_polling(struct work_struct *
 	struct  Scsi_Host *host;
 	struct  scsi_device *sdev1;
 	u16     pd_index = 0;
+	u16	ld_index = 0;
 	int     i, j, doscan = 0;
 	u32 seq_num;
 	int error;
@@ -4083,8 +4084,124 @@ megasas_aen_polling(struct work_struct *
 
 		switch (instance->evt_detail->code) {
 		case MR_EVT_PD_INSERTED:
+			if (megasas_get_pd_list(instance) == 0) {
+			for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) {
+				for (j = 0;
+				j < MEGASAS_MAX_DEV_PER_CHANNEL;
+				j++) {
+
+				pd_index =
+				(i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;
+
+				sdev1 =
+				scsi_device_lookup(host, i, j, 0);
+
+				if (instance->pd_list[pd_index].driveState
+						== MR_PD_STATE_SYSTEM) {
+						if (!sdev1) {
+						scsi_add_device(host, i, j, 0);
+						}
+
+					if (sdev1)
+						scsi_device_put(sdev1);
+					}
+				}
+			}
+			}
+			doscan = 0;
+			break;
+
 		case MR_EVT_PD_REMOVED:
+			if (megasas_get_pd_list(instance) == 0) {
+			megasas_get_pd_list(instance);
+			for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) {
+				for (j = 0;
+				j < MEGASAS_MAX_DEV_PER_CHANNEL;
+				j++) {
+
+				pd_index =
+				(i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;
+
+				sdev1 =
+				scsi_device_lookup(host, i, j, 0);
+
+				if (instance->pd_list[pd_index].driveState
+					== MR_PD_STATE_SYSTEM) {
+					if (sdev1) {
+						scsi_device_put(sdev1);
+					}
+				} else {
+					if (sdev1) {
+						scsi_remove_device(sdev1);
+						scsi_device_put(sdev1);
+					}
+				}
+				}
+			}
+			}
+			doscan = 0;
+			break;
+
+		case MR_EVT_LD_OFFLINE:
+		case MR_EVT_LD_DELETED:
+			megasas_get_ld_list(instance);
+			for (i = 0; i < MEGASAS_MAX_LD_CHANNELS; i++) {
+				for (j = 0;
+				j < MEGASAS_MAX_DEV_PER_CHANNEL;
+				j++) {
+
+				ld_index =
+				(i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;
+
+				sdev1 = scsi_device_lookup(host,
+					i + MEGASAS_MAX_LD_CHANNELS,
+					j,
+					0);
+
+				if (instance->ld_ids[ld_index] != 0xff) {
+					if (sdev1) {
+						scsi_device_put(sdev1);
+					}
+				} else {
+					if (sdev1) {
+						scsi_remove_device(sdev1);
+						scsi_device_put(sdev1);
+					}
+				}
+				}
+			}
+			doscan = 0;
+			break;
+		case MR_EVT_LD_CREATED:
+			megasas_get_ld_list(instance);
+			for (i = 0; i < MEGASAS_MAX_LD_CHANNELS; i++) {
+				for (j = 0;
+					j < MEGASAS_MAX_DEV_PER_CHANNEL;
+					j++) {
+					ld_index =
+					(i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;
+
+					sdev1 = scsi_device_lookup(host,
+						i+MEGASAS_MAX_LD_CHANNELS,
+						j, 0);
+
+					if (instance->ld_ids[ld_index] !=
+								0xff) {
+						if (!sdev1) {
+							scsi_add_device(host,
+								i + 2,
+								j, 0);
+						}
+					}
+					if (sdev1) {
+						scsi_device_put(sdev1);
+					}
+				}
+			}
+			doscan = 0;
+			break;
 		case MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED:
+		case MR_EVT_FOREIGN_CFG_IMPORTED:
 			doscan = 1;
 			break;
 		default:
@@ -4119,6 +4236,31 @@ megasas_aen_polling(struct work_struct *
 				}
 			}
 		}
+
+		megasas_get_ld_list(instance);
+		for (i = 0; i < MEGASAS_MAX_LD_CHANNELS; i++) {
+			for (j = 0; j < MEGASAS_MAX_DEV_PER_CHANNEL; j++) {
+				ld_index =
+				(i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;
+
+				sdev1 = scsi_device_lookup(host,
+					i+MEGASAS_MAX_LD_CHANNELS, j, 0);
+				if (instance->ld_ids[ld_index] != 0xff) {
+					if (!sdev1) {
+						scsi_add_device(host,
+								i+2,
+								j, 0);
+					} else {
+						scsi_device_put(sdev1);
+					}
+				} else {
+					if (sdev1) {
+						scsi_remove_device(sdev1);
+						scsi_device_put(sdev1);
+					}
+				}
+			}
+		}
 	}
 
 	if ( instance->aen_cmd != NULL ) {

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

* [PATCH 4/4] scsi: megaraid_sas - version and documentation update
  2009-12-06 15:30     ` [PATCH 2/4] scsi: megaraid_sas - add the ld list to driver Yang, Bo
  2009-12-06 15:39       ` [PATCH 3/4] scsi: megaraid_sas - driver fixed the device update issue Yang, Bo
@ 2009-12-06 15:42       ` Yang, Bo
  1 sibling, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2009-12-06 15:42 UTC (permalink / raw)
  To: Yang, Bo, James.Bottomley, James.Bottomley
  Cc: linux-scsi, akpm, linux-kernel, Austria, Winston, Mukker, Atul

Update the version and documentation.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
Documentation/scsi/ChangeLog.megaraid_sas |   16 ++++++++++++++++
 drivers/scsi/megaraid/megaraid_sas.c      |    2 +-
 drivers/scsi/megaraid/megaraid_sas.h      |    6 +++---
 3 files changed, 20 insertions(+), 4 deletions(-)

diff -rupN old/Documentation/scsi/ChangeLog.megaraid_sas new/Documentation/scsi/ChangeLog.megaraid_sas
--- old/Documentation/scsi/ChangeLog.megaraid_sas	2009-12-06 04:53:06.000000000 -0500
+++ new/Documentation/scsi/ChangeLog.megaraid_sas	2009-12-06 05:10:00.000000000 -0500
@@ -1,3 +1,19 @@
+1 Release Date    : Thur.  Oct 29, 2009 09:12:45 PST 2009 -
+			(emaild-id:megaraidlinux@lsi.com)
+			Bo Yang
+
+2 Current Version : 00.00.04.17.1-rc1
+3 Older Version   : 00.00.04.12
+
+1.	Add the pad_0 in mfi frame structure to 0 to fix the
+	context value larger than 32bit value issue.
+
+2.	Add the logic drive list to the driver.  Driver will
+	keep the logic drive list internal after driver load.
+
+3.	driver fixed the device update issue after get the AEN
+	PD delete/ADD, LD add/delete from FW.
+
 1 Release Date    : Tues.  July 28, 2009 10:12:45 PST 2009 -
 			(emaild-id:megaraidlinux@lsi.com)
 			Bo Yang
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2009-12-06 04:53:06.000000000 -0500
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2009-12-06 04:53:58.000000000 -0500
@@ -10,7 +10,7 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_sas.c
- * Version     : v00.00.04.12-rc1
+ * Version     : v00.00.04.17.1-rc1
  *
  * Authors:
  *	(email-id : megaraidlinux@lsi.com)
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2009-12-06 04:53:06.000000000 -0500
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2009-12-06 05:12:28.000000000 -0500
@@ -18,9 +18,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION				"00.00.04.12-rc1"
-#define MEGASAS_RELDATE				"Sep. 17, 2009"
-#define MEGASAS_EXT_VERSION			"Thu Sep. 17 11:41:51 PST 2009"
+#define MEGASAS_VERSION			"00.00.04.17.1-rc1"
+#define MEGASAS_RELDATE			"Oct. 29, 2009"
+#define MEGASAS_EXT_VERSION		"Thu. Oct. 29, 11:41:51 PST 2009"
 
 /*
  * Device IDs

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

* [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I
       [not found]   ` <3A916D859199814BBB666188F96EB165013979165E@cosmail02.lsi.com>
@ 2010-05-06 14:42     ` Yang, Bo
  2010-05-06 15:41       ` [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-II Yang, Bo
                         ` (6 more replies)
  0 siblings, 7 replies; 37+ messages in thread
From: Yang, Bo @ 2010-05-06 14:42 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

Add the Controller reset functions to the Driver.  This is first part of the Online Controller Reset.
The driver supports XScle and Gen2 OCR.  The reset functions for those two chips added to the driver.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |  235 +++++++++++++++++++++++++++++++++++++++++++++++++++------
megaraid_sas.h |   40 ++++++++-
 2 files changed, 248 insertions(+), 27 deletions(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c    2010-04-19 09:26:47.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c    2010-04-21 05:03:14.000000000 -0400
@@ -164,7 +164,7 @@ megasas_return_cmd(struct megasas_instan
 static inline void
 megasas_enable_intr_xscale(struct megasas_register_set __iomem * regs)
 {
-       writel(1, &(regs)->outbound_intr_mask);
+       writel(0, &(regs)->outbound_intr_mask);

        /* Dummy readl to force pci flush */
        readl(&regs->outbound_intr_mask);
@@ -200,24 +200,27 @@ static int
 megasas_clear_intr_xscale(struct megasas_register_set __iomem * regs)
 {
        u32 status;
+       u32 mfiStatus = 0;
        /*
         * Check if it is our interrupt
         */
        status = readl(&regs->outbound_intr_status);

-       if (!(status & MFI_OB_INTR_STATUS_MASK)) {
-               return 1;
-       }
+       if (status & MFI_OB_INTR_STATUS_MASK)
+               mfiStatus = MFI_INTR_FLAG_REPLY_MESSAGE;
+       if (status & MFI_XSCALE_OMR0_CHANGE_INTERRUPT)
+               mfiStatus |= MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE;

        /*
         * Clear the interrupt by writing back the same value
         */
-       writel(status, &regs->outbound_intr_status);
+       if (mfiStatus)
+               writel(status, &regs->outbound_intr_status);

        /* Dummy readl to force pci flush */
        readl(&regs->outbound_intr_status);

-       return 0;
+       return mfiStatus;
 }

 /**
@@ -232,8 +235,69 @@ megasas_fire_cmd_xscale(struct megasas_i
                u32 frame_count,
                struct megasas_register_set __iomem *regs)
 {
+       unsigned long flags;
+       spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr >> 3)|(frame_count),
               &(regs)->inbound_queue_port);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+}
+
+/**
+ * megasas_adp_reset_xscale -  For controller reset
+ * @regs:                              MFI register set
+ */
+static int
+megasas_adp_reset_xscale(struct megasas_instance *instance,
+       struct megasas_register_set __iomem *regs)
+{
+       u32 i;
+       u32 pcidata;
+       writel(MFI_ADP_RESET, &regs->inbound_doorbell);
+
+       for (i = 0; i < 3; i++)
+               msleep(1000); /* sleep for 3 secs */
+       pcidata  = 0;
+       pci_read_config_dword(instance->pdev, MFI_1068_PCSR_OFFSET, &pcidata);
+       printk(KERN_NOTICE "pcidata = %x\n", pcidata);
+       if (pcidata & 0x2) {
+               printk(KERN_NOTICE "mfi 1068 offset read=%x\n", pcidata);
+               pcidata &= ~0x2;
+               pci_write_config_dword(instance->pdev,
+                               MFI_1068_PCSR_OFFSET, pcidata);
+
+               for (i = 0; i < 2; i++)
+                       msleep(1000); /* need to wait 2 secs again */
+
+               pcidata  = 0;
+               pci_read_config_dword(instance->pdev,
+                               MFI_1068_FW_HANDSHAKE_OFFSET, &pcidata);
+               printk(KERN_NOTICE "1068 offset handshake read=%x\n", pcidata);
+               if ((pcidata & 0xffff0000) == MFI_1068_FW_READY) {
+                       printk(KERN_NOTICE "1068 offset pcidt=%x\n", pcidata);
+                       pcidata = 0;
+                       pci_write_config_dword(instance->pdev,
+                               MFI_1068_FW_HANDSHAKE_OFFSET, pcidata);
+               }
+       }
+       return 0;
+}
+
+/**
+ * megasas_check_reset_xscale -        For controller reset check
+ * @regs:                              MFI register set
+ */
+static int
+megasas_check_reset_xscale(struct megasas_instance *instance,
+               struct megasas_register_set __iomem *regs)
+{
+       u32 consumer;
+       consumer = *instance->consumer;
+
+       if ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) &&
+               (*instance->consumer == MEGASAS_ADPRESET_INPROG_SIGN)) {
+               return 1;
+       }
+       return 0;
 }

 static struct megasas_instance_template megasas_instance_template_xscale = {
@@ -243,6 +307,8 @@ static struct megasas_instance_template
        .disable_intr = megasas_disable_intr_xscale,
        .clear_intr = megasas_clear_intr_xscale,
        .read_fw_status_reg = megasas_read_fw_status_reg_xscale,
+       .adp_reset = megasas_adp_reset_xscale,
+       .check_reset = megasas_check_reset_xscale,
 };

 /**
@@ -264,7 +330,7 @@ megasas_enable_intr_ppc(struct megasas_r
 {
        writel(0xFFFFFFFF, &(regs)->outbound_doorbell_clear);

-       writel(~0x80000004, &(regs)->outbound_intr_mask);
+       writel(~0x80000000, &(regs)->outbound_intr_mask);

        /* Dummy readl to force pci flush */
        readl(&regs->outbound_intr_mask);
@@ -307,7 +373,7 @@ megasas_clear_intr_ppc(struct megasas_re
        status = readl(&regs->outbound_intr_status);

        if (!(status & MFI_REPLY_1078_MESSAGE_INTERRUPT)) {
-               return 1;
+               return 0;
        }

        /*
@@ -318,7 +384,7 @@ megasas_clear_intr_ppc(struct megasas_re
        /* Dummy readl to force pci flush */
        readl(&regs->outbound_doorbell_clear);

-       return 0;
+       return 1;
 }
 /**
  * megasas_fire_cmd_ppc -      Sends command to the FW
@@ -332,10 +398,34 @@ megasas_fire_cmd_ppc(struct megasas_inst
                u32 frame_count,
                struct megasas_register_set __iomem *regs)
 {
+       unsigned long flags;
+       spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr | (frame_count<<1))|1,
                        &(regs)->inbound_queue_port);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
 }

+/**
+ * megasas_adp_reset_ppc -     For controller reset
+ * @regs:                              MFI register set
+ */
+static int
+megasas_adp_reset_ppc(struct megasas_instance *instance,
+                       struct megasas_register_set __iomem *regs)
+{
+       return 0;
+}
+
+/**
+ * megasas_check_reset_ppc -   For controller reset check
+ * @regs:                              MFI register set
+ */
+static int
+megasas_check_reset_ppc(struct megasas_instance *instance,
+                       struct megasas_register_set __iomem *regs)
+{
+       return 0;
+}
 static struct megasas_instance_template megasas_instance_template_ppc = {

        .fire_cmd = megasas_fire_cmd_ppc,
@@ -343,6 +433,8 @@ static struct megasas_instance_template
        .disable_intr = megasas_disable_intr_ppc,
        .clear_intr = megasas_clear_intr_ppc,
        .read_fw_status_reg = megasas_read_fw_status_reg_ppc,
+       .adp_reset = megasas_adp_reset_ppc,
+       .check_reset = megasas_check_reset_ppc,
 };

 /**
@@ -397,7 +489,7 @@ megasas_clear_intr_skinny(struct megasas
        status = readl(&regs->outbound_intr_status);

        if (!(status & MFI_SKINNY_ENABLE_INTERRUPT_MASK)) {
-               return 1;
+               return 0;
        }

        /*
@@ -410,7 +502,7 @@ megasas_clear_intr_skinny(struct megasas
        */
        readl(&regs->outbound_intr_status);

-       return 0;
+       return 1;
 }

 /**
@@ -426,11 +518,33 @@ megasas_fire_cmd_skinny(struct megasas_i
                        struct megasas_register_set __iomem *regs)
 {
        unsigned long flags;
-       spin_lock_irqsave(&instance->fire_lock, flags);
+       spin_lock_irqsave(&instance->hba_lock, flags);
        writel(0, &(regs)->inbound_high_queue_port);
        writel((frame_phys_addr | (frame_count<<1))|1,
                &(regs)->inbound_low_queue_port);
-       spin_unlock_irqrestore(&instance->fire_lock, flags);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+}
+
+/**
+ * megasas_adp_reset_skinny -  For controller reset
+ * @regs:                              MFI register set
+ */
+static int
+megasas_adp_reset_skinny(struct megasas_instance *instance,
+                       struct megasas_register_set __iomem *regs)
+{
+       return 0;
+}
+
+/**
+ * megasas_check_reset_skinny -        For controller reset check
+ * @regs:                              MFI register set
+ */
+static int
+megasas_check_reset_skinny(struct megasas_instance *instance,
+                               struct megasas_register_set __iomem *regs)
+{
+       return 0;
 }

 static struct megasas_instance_template megasas_instance_template_skinny = {
@@ -440,6 +554,8 @@ static struct megasas_instance_template
        .disable_intr = megasas_disable_intr_skinny,
        .clear_intr = megasas_clear_intr_skinny,
        .read_fw_status_reg = megasas_read_fw_status_reg_skinny,
+       .adp_reset = megasas_adp_reset_skinny,
+       .check_reset = megasas_check_reset_skinny,
 };


@@ -495,23 +611,29 @@ static int
 megasas_clear_intr_gen2(struct megasas_register_set __iomem *regs)
 {
        u32 status;
+       u32 mfiStatus = 0;
        /*
         * Check if it is our interrupt
         */
        status = readl(&regs->outbound_intr_status);

-       if (!(status & MFI_GEN2_ENABLE_INTERRUPT_MASK))
-               return 1;
+       if (status & MFI_GEN2_ENABLE_INTERRUPT_MASK) {
+               mfiStatus = MFI_INTR_FLAG_REPLY_MESSAGE;
+       }
+       if (status & MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT) {
+               mfiStatus |= MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE;
+       }

        /*
         * Clear the interrupt by writing back the same value
         */
-       writel(status, &regs->outbound_doorbell_clear);
+       if (mfiStatus)
+               writel(status, &regs->outbound_doorbell_clear);

        /* Dummy readl to force pci flush */
        readl(&regs->outbound_intr_status);

-       return 0;
+       return mfiStatus;
 }
 /**
  * megasas_fire_cmd_gen2 -     Sends command to the FW
@@ -525,8 +647,74 @@ megasas_fire_cmd_gen2(struct megasas_ins
                        u32 frame_count,
                        struct megasas_register_set __iomem *regs)
 {
+       unsigned long flags;
+       spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr | (frame_count<<1))|1,
                        &(regs)->inbound_queue_port);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+}
+
+/**
+ * megasas_adp_reset_gen2 -    For controller reset
+ * @regs:                              MFI register set
+ */
+static int
+megasas_adp_reset_gen2(struct megasas_instance *instance,
+                       struct megasas_register_set __iomem *reg_set)
+{
+       u32                     retry = 0 ;
+       u32                     HostDiag;
+
+       writel(0, &reg_set->seq_offset);
+       writel(4, &reg_set->seq_offset);
+       writel(0xb, &reg_set->seq_offset);
+       writel(2, &reg_set->seq_offset);
+       writel(7, &reg_set->seq_offset);
+       writel(0xd, &reg_set->seq_offset);
+       msleep(1000);
+
+       HostDiag = (u32)readl(&reg_set->host_diag);
+
+       while ( !( HostDiag & DIAG_WRITE_ENABLE) ) {
+               msleep(100);
+               HostDiag = (u32)readl(&reg_set->host_diag);
+               printk(KERN_NOTICE "RESETGEN2: retry=%x, hostdiag=%x\n",
+                                       retry, HostDiag);
+
+               if (retry++ >= 100)
+                       return 1;
+
+       }
+
+       printk(KERN_NOTICE "ADP_RESET_GEN2: HostDiag=%x\n", HostDiag);
+
+       writel((HostDiag | DIAG_RESET_ADAPTER), &reg_set->host_diag);
+
+       ssleep(10);
+
+       HostDiag = (u32)readl(&reg_set->host_diag);
+       while ( ( HostDiag & DIAG_RESET_ADAPTER) ) {
+               msleep(100);
+               HostDiag = (u32)readl(&reg_set->host_diag);
+               printk(KERN_NOTICE "RESET_GEN2: retry=%x, hostdiag=%x\n",
+                               retry, HostDiag);
+
+               if (retry++ >= 1000)
+                       return 1;
+
+       }
+       return 0;
+}
+
+/**
+ * megasas_check_reset_gen2 -  For controller reset check
+ * @regs:                              MFI register set
+ */
+static int
+megasas_check_reset_gen2(struct megasas_instance *instance,
+               struct megasas_register_set __iomem *regs)
+{
+       return 0;
 }

 static struct megasas_instance_template megasas_instance_template_gen2 = {
@@ -536,11 +724,13 @@ static struct megasas_instance_template
        .disable_intr = megasas_disable_intr_gen2,
        .clear_intr = megasas_clear_intr_gen2,
        .read_fw_status_reg = megasas_read_fw_status_reg_gen2,
+       .adp_reset = megasas_adp_reset_gen2,
+       .check_reset = megasas_check_reset_gen2,
 };

 /**
 *      This is the end of set of functions & definitions
-*      specific to ppc (deviceid : 0x60) controllers
+*       specific to gen2 (deviceid : 0x78, 0x79) controllers
 */

 /**
@@ -599,8 +789,7 @@ megasas_issue_blocked_cmd(struct megasas
        instance->instancet->fire_cmd(instance,
                        cmd->frame_phys_addr, 0, instance->reg_set);

-       wait_event_timeout(instance->int_cmd_wait_q, (cmd->cmd_status != ENODATA),
-               MEGASAS_INTERNAL_CMD_WAIT_TIME*HZ);
+       wait_event(instance->int_cmd_wait_q, cmd->cmd_status != ENODATA);

        return 0;
 }
@@ -648,8 +837,8 @@ megasas_issue_blocked_abort_cmd(struct m
        /*
         * Wait for this cmd to complete
         */
-       wait_event_timeout(instance->abort_cmd_wait_q, (cmd->cmd_status != 0xFF),
-               MEGASAS_INTERNAL_CMD_WAIT_TIME*HZ);
+       wait_event(instance->abort_cmd_wait_q, cmd->cmd_status != 0xFF);
+       cmd->sync_cmd = 0;

        megasas_return_cmd(instance, cmd);
        return 0;
@@ -3137,7 +3326,7 @@ megasas_probe_one(struct pci_dev *pdev,
        init_waitqueue_head(&instance->abort_cmd_wait_q);

        spin_lock_init(&instance->cmd_pool_lock);
-       spin_lock_init(&instance->fire_lock);
+       spin_lock_init(&instance->hba_lock);
        spin_lock_init(&instance->completion_lock);
        spin_lock_init(&poll_aen_lock);

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h    2010-04-19 09:26:47.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h    2010-04-21 05:00:03.000000000 -0400
@@ -73,6 +73,12 @@
  * HOTPLUG     : Resume from Hotplug
  * MFI_STOP_ADP        : Send signal to FW to stop processing
  */
+#define WRITE_SEQUENCE_OFFSET          (0x0000000FC) /* I20 */
+#define HOST_DIAGNOSTIC_OFFSET         (0x000000F8)  /* I20 */
+#define DIAG_WRITE_ENABLE                      (0x00000080)
+#define DIAG_RESET_ADAPTER                     (0x00000004)
+
+#define MFI_ADP_RESET                          0x00000040
 #define MFI_INIT_ABORT                         0x00000001
 #define MFI_INIT_READY                         0x00000002
 #define MFI_INIT_MFIMODE                       0x00000004
@@ -704,6 +710,12 @@ struct megasas_ctrl_info {
  */
 #define IS_DMA64                               (sizeof(dma_addr_t) == 8)

+#define MFI_XSCALE_OMR0_CHANGE_INTERRUPT               0x00000001
+
+#define MFI_INTR_FLAG_REPLY_MESSAGE                    0x00000001
+#define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE            0x00000002
+#define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT      0x00000004
+
 #define MFI_OB_INTR_STATUS_MASK                        0x00000002
 #define MFI_POLL_TIMEOUT_SECS                  60
 #define MEGASAS_COMPLETION_TIMER_INTERVAL      (HZ/10)
@@ -714,6 +726,9 @@ struct megasas_ctrl_info {
 #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT     0x40000000
 #define MFI_SKINNY_ENABLE_INTERRUPT_MASK       (0x00000001)

+#define MFI_1068_PCSR_OFFSET                   0x84
+#define MFI_1068_FW_HANDSHAKE_OFFSET           0x64
+#define MFI_1068_FW_READY                      0xDDDD0000
 /*
 * register set for both 1068 and 1078 controllers
 * structure extended for 1078 registers
@@ -755,8 +770,10 @@ struct megasas_register_set {
        u32     inbound_high_queue_port ;       /*00C4h*/

        u32     reserved_5;                     /*00C8h*/
-       u32     index_registers[820];           /*00CCh*/
-
+       u32     res_6[11];                      /*CCh*/
+       u32     host_diag;
+       u32     seq_offset;
+       u32     index_registers[807];           /*00CCh*/
 } __attribute__ ((packed));

 struct megasas_sge32 {
@@ -1226,11 +1243,12 @@ struct megasas_instance {

        struct megasas_cmd **cmd_list;
        struct list_head cmd_pool;
+       /* used to sync fire the cmd to fw */
        spinlock_t cmd_pool_lock;
+       /* used to sync fire the cmd to fw */
+       spinlock_t hba_lock;
        /* used to synch producer, consumer ptrs in dpc */
        spinlock_t completion_lock;
-       /* used to sync fire the cmd to fw */
-       spinlock_t fire_lock;
        struct dma_pool *frame_dma_pool;
        struct dma_pool *sense_dma_pool;

@@ -1257,11 +1275,21 @@ struct megasas_instance {
        u8 flag;
        u8 unload;
        u8 flag_ieee;
+       u8 adprecovery;
        unsigned long last_time;

        struct timer_list io_completion_timer;
 };

+enum {
+       MEGASAS_HBA_OPERATIONAL                 = 0,
+       MEGASAS_ADPRESET_SM_INFAULT             = 1,
+       MEGASAS_ADPRESET_SM_FW_RESET_SUCCESS    = 2,
+       MEGASAS_ADPRESET_SM_OPERATIONAL         = 3,
+       MEGASAS_HW_CRITICAL_ERROR               = 4,
+       MEGASAS_ADPRESET_INPROG_SIGN            = 0xDEADDEAD,
+};
+
 struct megasas_instance_template {
        void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
                u32, struct megasas_register_set __iomem *);
@@ -1272,6 +1300,10 @@ struct megasas_instance_template {
        int (*clear_intr)(struct megasas_register_set __iomem *);

        u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
+       int (*adp_reset)(struct megasas_instance *, \
+               struct megasas_register_set __iomem *);
+       int (*check_reset)(struct megasas_instance *, \
+               struct megasas_register_set __iomem *);
 };

 #define MEGASAS_IS_LOGICAL(scp)                                                \

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

* [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-II
  2010-05-06 14:42     ` [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I Yang, Bo
@ 2010-05-06 15:41       ` Yang, Bo
  2010-05-26 16:35         ` [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR)-II : Driver return RESET in timeout routine Yang, Bo
  2010-05-06 15:52       ` [PATCH 3/7] scsi: megaraid_sas - Online COntroller Reset (OCR) PART-III Yang, Bo
                         ` (5 subsequent siblings)
  6 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-05-06 15:41 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

This is second part of the Online Controller Reset (OCR).  When driver doesn't finish to issue the pending
Cmds, driver will return BUSY to OS.  Also in driver's timeout routine, if online controller reset is going
On, driver will return RESET to OS. 

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
megaraid_sas.h |    2 +
 2 files changed, 107 insertions(+), 5 deletions(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-04-21 05:16:37.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-04-28 08:52:56.000000000 -0400
@@ -1320,14 +1320,22 @@ megasas_queue_command(struct scsi_cmnd *
 	u32 frame_count;
 	struct megasas_cmd *cmd;
 	struct megasas_instance *instance;
+	unsigned long flags;
 
 	instance = (struct megasas_instance *)
 	    scmd->device->host->hostdata;
 
-	/* Don't process if we have already declared adapter dead */
-	if (instance->hw_crit_error)
+	if (instance->issuepend_done == 0)
 		return SCSI_MLQUEUE_HOST_BUSY;
 
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
+		return SCSI_MLQUEUE_HOST_BUSY;
+	}
+
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+
 	scmd->scsi_done = done;
 	scmd->result = 0;
 
@@ -1463,6 +1471,18 @@ static int megasas_slave_alloc(struct sc
 	return 0;
 }
 
+static void megaraid_sas_kill_hba(struct megasas_instance *instance)
+{
+	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
+		(instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) {
+		writel(MFI_STOP_ADP,
+			&instance->reg_set->reserved_0[0]);
+	} else {
+		writel(MFI_STOP_ADP,
+			&instance->reg_set->inbound_doorbell);
+	}
+}
+
 /**
  * megasas_complete_cmd_dpc	 -	Returns FW's controller structure
  * @instance_addr:			Address of adapter soft state
@@ -1480,7 +1500,7 @@ static void megasas_complete_cmd_dpc(uns
 	unsigned long flags;
 
 	/* If we have already declared adapter dead, donot complete cmds */
-	if (instance->hw_crit_error)
+	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR )
 		return;
 
 	spin_lock_irqsave(&instance->completion_lock, flags);
@@ -1490,6 +1510,11 @@ static void megasas_complete_cmd_dpc(uns
 
 	while (consumer != producer) {
 		context = instance->reply_queue[consumer];
+		if (context >= instance->max_fw_cmds) {
+			printk(KERN_ERR "Unexpected context value %x\n",
+				context);
+			BUG();
+		}
 
 		cmd = instance->cmd_list[context];
 
@@ -1539,7 +1564,76 @@ static void megasas_complete_cmd_dpc(uns
 static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 {
 	int i;
+	u32 reset_index;
 	u32 wait_time = MEGASAS_RESET_WAIT_TIME;
+	u8 adprecovery;
+	unsigned long flags;
+	struct list_head clist_local;
+	struct megasas_cmd *reset_cmd;
+
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	adprecovery = instance->adprecovery;
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+	if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
+
+		INIT_LIST_HEAD(&clist_local);
+		spin_lock_irqsave(&instance->hba_lock, flags);
+		list_splice_init(&instance->internal_reset_pending_q,
+				&clist_local);
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+		printk(KERN_NOTICE "megasas: HBA reset wait ...\n");
+		for (i = 0; i < wait_time; i++) {
+			msleep(1000);
+			spin_lock_irqsave(&instance->hba_lock, flags);
+			adprecovery = instance->adprecovery;
+			spin_unlock_irqrestore(&instance->hba_lock, flags);
+			if (adprecovery == MEGASAS_HBA_OPERATIONAL)
+				break;
+		}
+
+		if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
+			printk(KERN_NOTICE "megasas: reset: Stopping HBA.\n");
+			spin_lock_irqsave(&instance->hba_lock, flags);
+			instance->adprecovery	= MEGASAS_HW_CRITICAL_ERROR;
+			spin_unlock_irqrestore(&instance->hba_lock, flags);
+			return FAILED;
+		}
+
+		reset_index	= 0;
+		while (!list_empty(&clist_local)) {
+			reset_cmd	= list_entry((&clist_local)->next,
+						struct megasas_cmd, list);
+			list_del_init(&reset_cmd->list);
+			if (reset_cmd->scmd) {
+				reset_cmd->scmd->result = DID_RESET << 16;
+				printk(KERN_NOTICE "%d:%p reset [%02x], %#lx\n",
+					reset_index, reset_cmd,
+					reset_cmd->scmd->cmnd[0],
+					reset_cmd->scmd->serial_number);
+
+				reset_cmd->scmd->scsi_done(reset_cmd->scmd);
+				megasas_return_cmd(instance, reset_cmd);
+			} else if (reset_cmd->sync_cmd) {
+				printk(KERN_NOTICE "megasas:%p synch cmds"
+						"reset queue\n",
+						reset_cmd);
+
+				reset_cmd->cmd_status = ENODATA;
+				instance->instancet->fire_cmd(instance,
+						reset_cmd->frame_phys_addr,
+						0, instance->reg_set);
+			} else {
+				printk(KERN_NOTICE "megasas: %p unexpected"
+					"cmds lst\n",
+					reset_cmd);
+			}
+			reset_index++;
+		}
+
+		return SUCCESS;
+	}
 
 	for (i = 0; i < wait_time; i++) {
 
@@ -1562,6 +1656,7 @@ static int megasas_wait_for_outstanding(
 	}
 
 	if (atomic_read(&instance->fw_outstanding)) {
+		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds.
 		* The controller will be taken offline by the OS now.
@@ -1577,10 +1672,14 @@ static int megasas_wait_for_outstanding(
 				&instance->reg_set->inbound_doorbell);
 		}
 		megasas_dump_pending_frames(instance);
-		instance->hw_crit_error = 1;
+		spin_lock_irqsave(&instance->hba_lock, flags);
+		instance->adprecovery	= MEGASAS_HW_CRITICAL_ERROR;
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
 		return FAILED;
 	}
 
+	printk(KERN_NOTICE "megaraid_sas: no pending cmds after reset\n");
+
 	return SUCCESS;
 }
 
@@ -1602,7 +1701,7 @@ static int megasas_generic_reset(struct 
 	scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x retries=%x\n",
 		 scmd->serial_number, scmd->cmnd[0], scmd->retries);
 
-	if (instance->hw_crit_error) {
+	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
 		printk(KERN_ERR "megasas: cannot recover from previous reset "
 		       "failures\n");
 		return FAILED;
@@ -3319,6 +3418,7 @@ megasas_probe_one(struct pci_dev *pdev, 
 	 * Initialize locks and queues
 	 */
 	INIT_LIST_HEAD(&instance->cmd_pool);
+	INIT_LIST_HEAD(&instance->internal_reset_pending_q);
 
 	atomic_set(&instance->fw_outstanding,0);
 
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-04-21 05:16:37.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-04-28 08:01:45.000000000 -0400
@@ -1275,10 +1275,12 @@ struct megasas_instance {
 	u8 flag;
 	u8 unload;
 	u8 flag_ieee;
+	u8 issuepend_done;
 	u8 adprecovery;
 	unsigned long last_time;
 
 	struct timer_list io_completion_timer;
+	struct list_head internal_reset_pending_q;
 };
 
 enum {

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

* [PATCH 3/7] scsi: megaraid_sas - Online COntroller Reset (OCR) PART-III
  2010-05-06 14:42     ` [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I Yang, Bo
  2010-05-06 15:41       ` [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-II Yang, Bo
@ 2010-05-06 15:52       ` Yang, Bo
  2010-05-07 12:54         ` Tomas Henzl
  2010-05-06 16:04       ` [PATCH 4/7] scsi: megaraid_sas - support devices update flag Yang, Bo
                         ` (4 subsequent siblings)
  6 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-05-06 15:52 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

This is third part of the Online Controller Reset. In ISR routine, if driver receive the FW state change interrupt
And the online controller reset support enabled in FW, driver will read the controller register.  Driver will issue
Controller reset if the FW register state failure.  Also driver will back up the pending cmds for the re-fire after
the reset finished.

Also Driver added the CTIO support to this patch.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |  412 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
megaraid_sas.h |   46 +++++-
 2 files changed, 433 insertions(+), 25 deletions(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c    2010-05-02 02:39:12.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c    2010-05-03 03:46:39.000000000 -0400
@@ -107,6 +107,12 @@ static void
 megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                     u8 alt_status);

+static int megasas_transition_to_ready(struct megasas_instance *instance);
+static int megasas_get_pd_list(struct megasas_instance *instance);
+static int megasas_issue_init_mfi(struct megasas_instance *instance);
+static int megasas_register_aen(struct megasas_instance *instance,
+                               u32 seq_num, u32 class_locale_word);
+
 /**
  * megasas_get_cmd -   Get a command from the free pool
  * @instance:          Adapter soft state
@@ -1856,7 +1862,8 @@ megasas_service_aen(struct megasas_insta
        instance->aen_cmd = NULL;
        megasas_return_cmd(instance, cmd);

-       if (instance->unload == 0) {
+       if ((instance->unload == 0) &&
+               ((instance->issuepend_done == 1))) {
                struct megasas_aen_event *ev;
                ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
                if (!ev) {
@@ -1951,6 +1958,9 @@ megasas_complete_cmd(struct megasas_inst
        struct megasas_header *hdr = &cmd->frame->hdr;
        unsigned long flags;

+       /* flag for the retry reset */
+       cmd->retry_for_fw_reset = 0;
+
        if (cmd->scmd)
                cmd->scmd->SCp.ptr = NULL;

@@ -2071,39 +2081,301 @@ megasas_complete_cmd(struct megasas_inst
 }

 /**
+ * megasas_issue_pending_cmds_again -  issue all pending cmds
+ *                                     in FW again because of the fw reset
+ * @instance:                          Adapter soft state
+ */
+static inline void
+megasas_issue_pending_cmds_again(struct megasas_instance *instance)
+{
+       struct megasas_cmd *cmd;
+       struct list_head clist_local;
+       union megasas_evt_class_locale class_locale;
+       unsigned long flags;
+       u32 seq_num;
+
+       INIT_LIST_HEAD(&clist_local);
+       spin_lock_irqsave(&instance->hba_lock, flags);
+       list_splice_init(&instance->internal_reset_pending_q, &clist_local);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+       while (!list_empty(&clist_local)) {
+               cmd     = list_entry((&clist_local)->next,
+                                       struct megasas_cmd, list);
+               list_del_init(&cmd->list);
+
+               if (cmd->sync_cmd || cmd->scmd) {
+                       printk(KERN_NOTICE "megaraid_sas: command %p, %p:%d"
+                               "detected to be pending while HBA reset.\n",
+                                       cmd, cmd->scmd, cmd->sync_cmd);
+
+                       cmd->retry_for_fw_reset++;
+
+                       if (cmd->retry_for_fw_reset == 3) {
+                               printk(KERN_NOTICE "megaraid_sas: cmd %p, %p:%d"
+                                       "was tried multiple times during reset."
+                                       "Shutting down the HBA\n",
+                                       cmd, cmd->scmd, cmd->sync_cmd);
+                               megaraid_sas_kill_hba(instance);
+
+                               instance->adprecovery =
+                                               MEGASAS_HW_CRITICAL_ERROR;
+                               return;
+                       }
+               }
+
+               if (cmd->sync_cmd == 1) {
+                       if (cmd->scmd) {
+                               printk(KERN_NOTICE "megaraid_sas: unexpected"
+                                       "cmd attached to internal command!\n");
+                       }
+                       printk(KERN_NOTICE "megasas: %p synchronous cmd"
+                                               "on the internal reset queue,"
+                                               "issue it again.\n", cmd);
+                       cmd->cmd_status = ENODATA;
+                       instance->instancet->fire_cmd(instance,
+                                                       cmd->frame_phys_addr ,
+                                                       0, instance->reg_set);
+               } else if (cmd->scmd) {
+                       printk(KERN_NOTICE "megasas: %p scsi cmd [%02x],%#lx"
+                       "detected on the internal queue, issue again.\n",
+                       cmd, cmd->scmd->cmnd[0], cmd->scmd->serial_number);
+
+                       atomic_inc(&instance->fw_outstanding);
+                       instance->instancet->fire_cmd(instance,
+                                       cmd->frame_phys_addr,
+                                       cmd->frame_count-1, instance->reg_set);
+               } else {
+                       printk(KERN_NOTICE "megasas: %p unexpected cmd on the"
+                               "internal reset defer list while re-issue!!\n",
+                               cmd);
+               }
+       }
+
+       if (instance->aen_cmd) {
+               printk(KERN_NOTICE "megaraid_sas: aen_cmd in def process\n");
+               megasas_return_cmd(instance, instance->aen_cmd);
+
+               instance->aen_cmd       = NULL;
+       }
+
+       /*
+       * Initiate AEN (Asynchronous Event Notification)
+       */
+       seq_num = instance->last_seq_num;
+       class_locale.members.reserved = 0;
+       class_locale.members.locale = MR_EVT_LOCALE_ALL;
+       class_locale.members.class = MR_EVT_CLASS_DEBUG;
+
+       megasas_register_aen(instance, seq_num, class_locale.word);
+}
+
+/**
+ * Move the internal reset pending commands to a deferred queue.
+ *
+ * We move the commands pending at internal reset time to a
+ * pending queue. This queue would be flushed after successful
+ * completion of the internal reset sequence. if the internal reset
+ * did not complete in time, the kernel reset handler would flush
+ * these commands.
+ **/
+static void
+megasas_internal_reset_defer_cmds(struct megasas_instance *instance)
+{
+       struct megasas_cmd *cmd;
+       int i;
+       u32 max_cmd = instance->max_fw_cmds;
+       u32 defer_index;
+       unsigned long flags;
+
+       defer_index     = 0;
+       spin_lock_irqsave(&instance->cmd_pool_lock, flags);
+       for (i = 0; i < max_cmd; i++) {
+               cmd = instance->cmd_list[i];
+               if (cmd->sync_cmd == 1 || cmd->scmd) {
+                       printk(KERN_NOTICE "megasas: moving cmd[%d]:%p:%d:%p"
+                                       "on the defer queue as internal\n",
+                               defer_index, cmd, cmd->sync_cmd, cmd->scmd);
+
+                       if (!list_empty(&cmd->list)) {
+                               printk(KERN_NOTICE "megaraid_sas: ERROR while"
+                                       " moving this cmd:%p, %d %p, it was"
+                                       "discovered on some list?\n",
+                                       cmd, cmd->sync_cmd, cmd->scmd);
+
+                               list_del_init(&cmd->list);
+                       }
+                       defer_index++;
+                       list_add_tail(&cmd->list,
+                               &instance->internal_reset_pending_q);
+               }
+       }
+       spin_unlock_irqrestore(&instance->cmd_pool_lock, flags);
+}
+
+
+static void
+process_fw_state_change_wq(struct work_struct *work)
+{
+       struct megasas_instance *instance =
+               container_of(work, struct megasas_instance, work_init);
+       u32 wait;
+       unsigned long flags;
+
+       if (instance->adprecovery != MEGASAS_ADPRESET_SM_INFAULT) {
+               printk(KERN_NOTICE "megaraid_sas: error, recovery st %x \n",
+                               instance->adprecovery);
+               return ;
+       }
+
+       if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) {
+               printk(KERN_NOTICE "megaraid_sas: FW detected to be in fault"
+                                       "state, restarting it...\n");
+
+               instance->instancet->disable_intr(instance->reg_set);
+               atomic_set(&instance->fw_outstanding, 0);
+
+               atomic_set(&instance->fw_reset_no_pci_access, 1);
+               instance->instancet->adp_reset(instance, instance->reg_set);
+               atomic_set(&instance->fw_reset_no_pci_access, 0 );
+
+               printk(KERN_NOTICE "megaraid_sas: FW restarted successfully,"
+                                       "initiating next stage...\n");
+
+               printk(KERN_NOTICE "megaraid_sas: HBA recovery state machine,"
+                                       "state 2 starting...\n");
+
+               /*waitting for about 20 second before start the second init*/
+               for (wait = 0; wait < 30; wait++) {
+                       msleep(1000);
+               }
+
+               if (megasas_transition_to_ready(instance)) {
+                       printk(KERN_NOTICE "megaraid_sas:adapter not ready\n");
+
+                       megaraid_sas_kill_hba(instance);
+                       instance->adprecovery   = MEGASAS_HW_CRITICAL_ERROR;
+                       return ;
+               }
+
+               if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) ||
+                       (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) ||
+                       (instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)
+                       ) {
+                       *instance->consumer = *instance->producer;
+               } else {
+                       *instance->consumer = 0;
+                       *instance->producer = 0;
+               }
+
+               megasas_issue_init_mfi(instance);
+
+               spin_lock_irqsave(&instance->hba_lock, flags);
+               instance->adprecovery   = MEGASAS_HBA_OPERATIONAL;
+               spin_unlock_irqrestore(&instance->hba_lock, flags);
+               instance->instancet->enable_intr(instance->reg_set);
+
+               megasas_issue_pending_cmds_again(instance);
+               instance->issuepend_done = 1;
+       }
+       return ;
+}
+
+/**
  * megasas_deplete_reply_queue -       Processes all completed commands
  * @instance:                          Adapter soft state
  * @alt_status:                                Alternate status to be returned to
  *                                     SCSI mid-layer instead of the status
  *                                     returned by the FW
+ * Note: this must be called with hba lock held
  */
 static int
-megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status)
+megasas_deplete_reply_queue(struct megasas_instance *instance,
+                                       u8 alt_status)
 {
-       /*
-        * Check if it is our interrupt
-        * Clear the interrupt
-        */
-       if(instance->instancet->clear_intr(instance->reg_set))
+       u32 mfiStatus;
+       u32 fw_state;
+
+       if ((mfiStatus = instance->instancet->check_reset(instance,
+                                       instance->reg_set)) == 1) {
+               return IRQ_HANDLED;
+       }
+
+       if ((mfiStatus = instance->instancet->clear_intr(
+                                               instance->reg_set)
+                                               ) == 0) {
                return IRQ_NONE;
+       }
+
+       instance->mfiStatus = mfiStatus;
+
+       if ((mfiStatus & MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE)) {
+               fw_state = instance->instancet->read_fw_status_reg(
+                               instance->reg_set) & MFI_STATE_MASK;
+
+               if (fw_state != MFI_STATE_FAULT) {
+                       printk(KERN_NOTICE "megaraid_sas: fw state:%x\n",
+                                               fw_state);
+               }
+
+               if ((fw_state == MFI_STATE_FAULT) &&
+                               (instance->disableOnlineCtrlReset == 0)) {
+                       printk(KERN_NOTICE "megaraid_sas: wait adp restart\n");
+
+                       if ((instance->pdev->device ==
+                                       PCI_DEVICE_ID_LSI_SAS1064R) ||
+                               (instance->pdev->device ==
+                                       PCI_DEVICE_ID_DELL_PERC5) ||
+                               (instance->pdev->device ==
+                                       PCI_DEVICE_ID_LSI_VERDE_ZCR)) {
+
+                               *instance->consumer =
+                                       MEGASAS_ADPRESET_INPROG_SIGN;
+                       }
+
+
+                       instance->instancet->disable_intr(instance->reg_set);
+                       instance->adprecovery   = MEGASAS_ADPRESET_SM_INFAULT;
+                       instance->issuepend_done = 0;
+
+                       atomic_set(&instance->fw_outstanding, 0);
+                       megasas_internal_reset_defer_cmds(instance);
+
+                       printk(KERN_NOTICE "megasas: fwState=%x, stage:%d\n",
+                                       fw_state, instance->adprecovery);
+
+                       schedule_work(&instance->work_init);
+                       return IRQ_HANDLED;
+
+               } else {
+                       printk(KERN_NOTICE "megasas: fwstate:%x, dis_OCR=%x\n",
+                               fw_state, instance->disableOnlineCtrlReset);
+               }
+       }

-       if (instance->hw_crit_error)
-               goto out_done;
-        /*
-        * Schedule the tasklet for cmd completion
-        */
        tasklet_schedule(&instance->isr_tasklet);
-out_done:
        return IRQ_HANDLED;
 }
-
 /**
  * megasas_isr - isr entry point
  */
 static irqreturn_t megasas_isr(int irq, void *devp)
 {
-       return megasas_deplete_reply_queue((struct megasas_instance *)devp,
-                                          DID_OK);
+       struct megasas_instance *instance;
+       unsigned long flags;
+       irqreturn_t     rc;
+
+       if (atomic_read(
+               &(((struct megasas_instance *)devp)->fw_reset_no_pci_access)))
+               return IRQ_HANDLED;
+
+       instance = (struct megasas_instance *)devp;
+
+       spin_lock_irqsave(&instance->hba_lock, flags);
+       rc =  megasas_deplete_reply_queue(instance, DID_OK);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+       return rc;
 }

 /**
@@ -2260,7 +2532,7 @@ megasas_transition_to_ready(struct megas
                               "in %d secs\n", fw_state, max_wait);
                        return -ENODEV;
                }
-       };
+       }
        printk(KERN_INFO "megasas: FW now in Ready state\n");

        return 0;
@@ -2342,6 +2614,7 @@ static int megasas_create_frame_pool(str
         */
        sgl_sz = sge_sz * instance->max_num_sge;
        frame_count = (sgl_sz + MEGAMFI_FRAME_SIZE - 1) / MEGAMFI_FRAME_SIZE;
+       frame_count = 15;

        /*
         * We need one extra frame for the MFI command
@@ -2489,6 +2762,7 @@ static int megasas_alloc_cmds(struct meg
                cmd = instance->cmd_list[i];
                memset(cmd, 0, sizeof(struct megasas_cmd));
                cmd->index = i;
+               cmd->scmd = NULL;
                cmd->instance = instance;

                list_add_tail(&cmd->list, &instance->cmd_pool);
@@ -2656,7 +2930,7 @@ megasas_get_ld_list(struct megasas_insta

        /* the following function will get the instance PD LIST */

-       if ((ret == 0) && (ci->ldCount < MAX_LOGICAL_DRIVES)) {
+       if ((ret == 0) && (ci->ldCount <= MAX_LOGICAL_DRIVES)) {
                memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);

                for (ld_index = 0; ld_index < ci->ldCount; ld_index++) {
@@ -2970,6 +3244,21 @@ static int megasas_init_mfi(struct megas
        if (megasas_issue_init_mfi(instance))
                goto fail_fw_init;

+       instance->fw_support_ieee = 0;
+       instance->fw_support_ieee =
+               (instance->instancet->read_fw_status_reg(reg_set) &
+               0x04000000);
+
+       printk(KERN_NOTICE "megasas_init_mfi: fw_support_ieee=%d",
+                       instance->fw_support_ieee);
+
+       if (instance->fw_support_ieee)
+               instance->flag_ieee = 1;
+
+       /** for passthrough
+       * the following function will get the PD LIST.
+       */
+
        memset(instance->pd_list, 0 ,
                (MEGASAS_MAX_PD * sizeof(struct megasas_pd_list)));
        megasas_get_pd_list(instance);
@@ -2996,6 +3285,8 @@ static int megasas_init_mfi(struct megas
                max_sectors_2 = ctrl_info->max_request_size;

                tmp_sectors = min_t(u32, max_sectors_1 , max_sectors_2);
+               instance->disableOnlineCtrlReset =
+               ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset;
        }

        instance->max_sectors_per_req = instance->max_num_sge *
@@ -3217,6 +3508,7 @@ megasas_register_aen(struct megasas_inst
        dcmd->flags = MFI_FRAME_DIR_READ;
        dcmd->timeout = 0;
        dcmd->pad_0 = 0;
+       instance->last_seq_num = seq_num;
        dcmd->data_xfer_len = sizeof(struct megasas_evt_detail);
        dcmd->opcode = MR_DCMD_CTRL_EVENT_WAIT;
        dcmd->mbox.w[0] = seq_num;
@@ -3385,6 +3677,7 @@ megasas_probe_one(struct pci_dev *pdev,

        instance = (struct megasas_instance *)host->hostdata;
        memset(instance, 0, sizeof(*instance));
+       atomic_set( &instance->fw_reset_no_pci_access, 0 );

        instance->producer = pci_alloc_consistent(pdev, sizeof(u32),
                                                  &instance->producer_h);
@@ -3402,6 +3695,9 @@ megasas_probe_one(struct pci_dev *pdev,
        megasas_poll_wait_aen = 0;
        instance->flag_ieee = 0;
        instance->ev = NULL;
+       instance->issuepend_done = 1;
+       instance->adprecovery = MEGASAS_HBA_OPERATIONAL;
+       megasas_poll_wait_aen = 0;

        instance->evt_detail = pci_alloc_consistent(pdev,
                                                    sizeof(struct
@@ -3451,6 +3747,9 @@ megasas_probe_one(struct pci_dev *pdev,
        instance->flag = 0;
        instance->unload = 1;
        instance->last_time = 0;
+       instance->disableOnlineCtrlReset = 1;
+
+       INIT_WORK(&instance->work_init, process_fw_state_change_wq);

        /*
         * Initialize MFI Firmware
@@ -3542,6 +3841,9 @@ static void megasas_flush_cache(struct m
        struct megasas_cmd *cmd;
        struct megasas_dcmd_frame *dcmd;

+       if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR)
+               return;
+
        cmd = megasas_get_cmd(instance);

        if (!cmd)
@@ -3579,6 +3881,9 @@ static void megasas_shutdown_controller(
        struct megasas_cmd *cmd;
        struct megasas_dcmd_frame *dcmd;

+       if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR)
+               return;
+
        cmd = megasas_get_cmd(instance);

        if (!cmd)
@@ -4070,6 +4375,9 @@ static int megasas_mgmt_ioctl_fw(struct
        struct megasas_iocpacket *ioc;
        struct megasas_instance *instance;
        int error;
+       int i;
+       unsigned long flags;
+       u32 wait_time = MEGASAS_RESET_WAIT_TIME;

        ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
        if (!ioc)
@@ -4086,8 +4394,8 @@ static int megasas_mgmt_ioctl_fw(struct
                goto out_kfree_ioc;
        }

-       if (instance->hw_crit_error == 1) {
-               printk(KERN_DEBUG "Controller in Crit ERROR\n");
+       if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
+               printk(KERN_ERR "Controller in crit error\n");
                error = -ENODEV;
                goto out_kfree_ioc;
        }
@@ -4104,6 +4412,35 @@ static int megasas_mgmt_ioctl_fw(struct
                error = -ERESTARTSYS;
                goto out_kfree_ioc;
        }
+
+       for (i = 0; i < wait_time; i++) {
+
+               spin_lock_irqsave(&instance->hba_lock, flags);
+               if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) {
+                       spin_unlock_irqrestore(&instance->hba_lock, flags);
+                       break;
+               }
+               spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+               if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
+                       printk(KERN_NOTICE "megasas: waiting"
+                               "for controller reset to finish\n");
+               }
+
+               msleep(1000);
+       }
+
+       spin_lock_irqsave(&instance->hba_lock, flags);
+       if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
+               spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+               printk(KERN_ERR "megaraid_sas: timed out while"
+                       "waiting for HBA to recover\n");
+               error = -ENODEV;
+               goto out_kfree_ioc;
+       }
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+
        error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc);
        up(&instance->ioctl_sem);

@@ -4117,6 +4454,9 @@ static int megasas_mgmt_ioctl_aen(struct
        struct megasas_instance *instance;
        struct megasas_aen aen;
        int error;
+       int i;
+       unsigned long flags;
+       u32 wait_time = MEGASAS_RESET_WAIT_TIME;

        if (file->private_data != file) {
                printk(KERN_DEBUG "megasas: fasync_helper was not "
@@ -4132,14 +4472,42 @@ static int megasas_mgmt_ioctl_aen(struct
        if (!instance)
                return -ENODEV;

-       if (instance->hw_crit_error == 1) {
-               error = -ENODEV;
+       if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
+               return -ENODEV;
        }

        if (instance->unload == 1) {
                return -ENODEV;
        }

+       for (i = 0; i < wait_time; i++) {
+
+               spin_lock_irqsave(&instance->hba_lock, flags);
+               if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) {
+                       spin_unlock_irqrestore(&instance->hba_lock,
+                                               flags);
+                       break;
+               }
+
+               spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+               if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
+                       printk(KERN_NOTICE "megasas: waiting for"
+                               "controller reset to finish\n");
+               }
+
+               msleep(1000);
+       }
+
+       spin_lock_irqsave(&instance->hba_lock, flags);
+       if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
+               spin_unlock_irqrestore(&instance->hba_lock, flags);
+               printk(KERN_ERR "megaraid_sas: timed out while waiting"
+                               "for HBA to recover.\n");
+               return -ENODEV;
+       }
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+
        mutex_lock(&instance->aen_mutex);
        error = megasas_register_aen(instance, aen.seq_num,
                                     aen.class_locale_word);
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h    2010-05-02 02:39:12.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h    2010-05-03 03:46:45.000000000 -0400
@@ -60,6 +60,7 @@
 #define MFI_STATE_READY                                0xB0000000
 #define MFI_STATE_OPERATIONAL                  0xC0000000
 #define MFI_STATE_FAULT                                0xF0000000
+#define  MFI_RESET_REQUIRED                    0x00000001

 #define MEGAMFI_FRAME_SIZE                     64

@@ -408,8 +409,40 @@ struct megasas_ctrl_prop {
        u16 ecc_bucket_leak_rate;
        u8 restore_hotspare_on_insertion;
        u8 expose_encl_devices;
-       u8 reserved[38];
+       u8 maintainPdFailHistory;
+       u8 disallowHostRequestReordering;
+       u8 abortCCOnError;
+       u8 loadBalanceMode;
+       u8 disableAutoDetectBackplane;

+       u8 snapVDSpace;
+
+       /*
+       * Add properties that can be controlled by
+       * a bit in the following structure.
+       */
+
+       struct {
+               u32     copyBackDisabled            : 1;
+               u32     SMARTerEnabled              : 1;
+               u32     prCorrectUnconfiguredAreas  : 1;
+               u32     useFdeOnly                  : 1;
+               u32     disableNCQ                  : 1;
+               u32     SSDSMARTerEnabled           : 1;
+               u32     SSDPatrolReadEnabled        : 1;
+               u32     enableSpinDownUnconfigured  : 1;
+               u32     autoEnhancedImport          : 1;
+               u32     enableSecretKeyControl      : 1;
+               u32     disableOnlineCtrlReset      : 1;
+               u32     allowBootWithPinnedCache    : 1;
+               u32     disableSpinDownHS           : 1;
+               u32     enableJBOD                  : 1;
+               u32     reserved                    :18;
+       } OnOffProperties;
+       u8 autoSnapVDSpace;
+       u8 viewSpace;
+       u16 spinDownTime;
+       u8  reserved[24];
 } __packed;

 /*
@@ -1265,19 +1298,24 @@ struct megasas_instance {

        struct pci_dev *pdev;
        u32 unique_id;
+       u32 fw_support_ieee;

        atomic_t fw_outstanding;
-       u32 hw_crit_error;
+       atomic_t fw_reset_no_pci_access;

        struct megasas_instance_template *instancet;
        struct tasklet_struct isr_tasklet;
+       struct work_struct work_init;

        u8 flag;
        u8 unload;
        u8 flag_ieee;
        u8 issuepend_done;
+       u8 disableOnlineCtrlReset;
        u8 adprecovery;
        unsigned long last_time;
+       u32 mfiStatus;
+       u32 last_seq_num;

        struct timer_list io_completion_timer;
        struct list_head internal_reset_pending_q;
@@ -1325,7 +1363,9 @@ struct megasas_cmd {
        u32 index;
        u8 sync_cmd;
        u8 cmd_status;
-       u16 abort_aen;
+       u8 abort_aen;
+       u8 retry_for_fw_reset;
+

        struct list_head list;
        struct scsi_cmnd *scmd;


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

* [PATCH 4/7] scsi: megaraid_sas - support devices update flag
  2010-05-06 14:42     ` [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I Yang, Bo
  2010-05-06 15:41       ` [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-II Yang, Bo
  2010-05-06 15:52       ` [PATCH 3/7] scsi: megaraid_sas - Online COntroller Reset (OCR) PART-III Yang, Bo
@ 2010-05-06 16:04       ` Yang, Bo
  2010-06-10  4:16         ` [PATCH 9/12] " Yang, Bo
  2010-05-06 16:17       ` [PATCH 5/7] scsi: megaraid_sas - Add input parameter for max_sectors Yang, Bo
                         ` (3 subsequent siblings)
  6 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-05-06 16:04 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

Driver added the Device update flag to tell LSI application driver will do the device
Update.  LSI MegaRAID SAS application will check this flag to decide if it is need to
update the Device or not. 

Signed-off-by Bo Yang<bo.yang@lsi.com>

--- 
megaraid_sas.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 03:50:44.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 05:46:37.000000000 -0400
@@ -99,6 +99,7 @@ static int megasas_poll_wait_aen;
 static DECLARE_WAIT_QUEUE_HEAD(megasas_poll_wait);
 static u32 support_poll_for_event;
 static u32 megasas_dbg_lvl;
+static u32 support_device_change;
 
 /* define lock for aen poll */
 spinlock_t poll_aen_lock;
@@ -4660,6 +4661,15 @@ megasas_sysfs_show_support_poll_for_even
 static DRIVER_ATTR(support_poll_for_event, S_IRUGO,
 			megasas_sysfs_show_support_poll_for_event, NULL);
 
+ static ssize_t
+megasas_sysfs_show_support_device_change(struct device_driver *dd, char *buf)
+{
+	return sprintf(buf, "%u\n", support_device_change);
+}
+
+static DRIVER_ATTR(support_device_change, S_IRUGO,
+			megasas_sysfs_show_support_device_change, NULL);
+
 static ssize_t
 megasas_sysfs_show_dbg_lvl(struct device_driver *dd, char *buf)
 {
@@ -4980,6 +4990,7 @@ static int __init megasas_init(void)
 	       MEGASAS_EXT_VERSION);
 
 	support_poll_for_event = 2;
+	support_device_change = 1;
 
 	memset(&megasas_mgmt_info, 0, sizeof(megasas_mgmt_info));
 
@@ -5028,8 +5039,17 @@ static int __init megasas_init(void)
 	if (rval)
 		goto err_dcf_poll_mode_io;
 
+	rval = driver_create_file(&megasas_pci_driver.driver,
+				&driver_attr_support_device_change);
+	if (rval)
+		goto err_dcf_support_device_change;
+
 	return rval;
 
+err_dcf_support_device_change:
+	driver_remove_file(&megasas_pci_driver.driver,
+		  &driver_attr_poll_mode_io);
+
 err_dcf_poll_mode_io:
 	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_dbg_lvl);
@@ -5060,6 +5080,10 @@ static void __exit megasas_exit(void)
 	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_dbg_lvl);
 	driver_remove_file(&megasas_pci_driver.driver,
+			&driver_attr_support_poll_for_event);
+	driver_remove_file(&megasas_pci_driver.driver,
+			&driver_attr_support_device_change);
+	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_release_date);
 	driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version);



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

* [PATCH 5/7] scsi: megaraid_sas - Add input parameter for max_sectors
  2010-05-06 14:42     ` [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I Yang, Bo
                         ` (2 preceding siblings ...)
  2010-05-06 16:04       ` [PATCH 4/7] scsi: megaraid_sas - support devices update flag Yang, Bo
@ 2010-05-06 16:17       ` Yang, Bo
  2010-05-06 16:34       ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
                         ` (2 subsequent siblings)
  6 siblings, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2010-05-06 16:17 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

Driver add the input parameters support for max_sectors for our gen2 chip.  Customer can
Set the max_sectors support to 1MB for gen2 chip during the driver load.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
megaraid_sas.h |    1
 2 files changed, 75 insertions(+)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 05:50:40.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 09:55:58.000000000 -0400
@@ -57,6 +57,15 @@ module_param_named(poll_mode_io, poll_mo
 MODULE_PARM_DESC(poll_mode_io,
 	"Complete cmds from IO path, (default=0)");
 
+/*
+ * Number of sectors per IO command
+ * Will be set in megasas_init_mfi if user does not provide
+ */
+static unsigned int max_sectors = 0;
+module_param_named(max_sectors, max_sectors, int, 0);
+MODULE_PARM_DESC(max_sectors,
+	"Maximum number of sectors per IO command");
+
 MODULE_LICENSE("GPL");
 MODULE_VERSION(MEGASAS_VERSION);
 MODULE_AUTHOR("megaraidlinux@lsi.com");
@@ -3566,6 +3575,32 @@ static int megasas_start_aen(struct mega
 				    class_locale.word);
 }
 
+static ssize_t
+sysfs_max_sectors_read(struct kobject *kobj, struct bin_attribute *bin_attr, 
+			char *buf, loff_t off, size_t count)
+{
+	struct device *dev = container_of(kobj, struct device, kobj);
+	
+	struct Scsi_Host *host = class_to_shost(dev);
+
+	struct megasas_instance *instance = 
+				(struct megasas_instance *)host->hostdata;
+
+	count = sprintf(buf,"%u\n", instance->max_sectors_per_req);
+
+	return count+1;
+}
+
+static struct bin_attribute sysfs_max_sectors_attr = {
+	.attr = {
+		.name = "max_sectors",
+		.mode = S_IRUSR|S_IRGRP|S_IROTH,
+		.owner = THIS_MODULE,
+	},
+	.size = 7,
+	.read = sysfs_max_sectors_read,
+};
+
 /**
  * megasas_io_attach -	Attaches this driver to SCSI mid-layer
  * @instance:		Adapter soft state
@@ -3573,6 +3608,7 @@ static int megasas_start_aen(struct mega
 static int megasas_io_attach(struct megasas_instance *instance)
 {
 	struct Scsi_Host *host = instance->host;
+	u32		error;
 
 	/*
 	 * Export parameters required by SCSI mid-layer
@@ -3588,6 +3624,27 @@ static int megasas_io_attach(struct mega
 			instance->max_fw_cmds - MEGASAS_INT_CMDS;
 	host->this_id = instance->init_id;
 	host->sg_tablesize = instance->max_num_sge;
+	/*
+	 * Check if the module parameter value for max_sectors can be used
+	 */
+	if (max_sectors && max_sectors < instance->max_sectors_per_req)
+		instance->max_sectors_per_req = max_sectors;
+	else {
+		if (max_sectors) {
+			if (((instance->pdev->device ==
+				PCI_DEVICE_ID_LSI_SAS1078GEN2) ||
+				(instance->pdev->device == 
+				PCI_DEVICE_ID_LSI_SAS0079GEN2)) && 
+				(max_sectors <= MEGASAS_MAX_SECTORS)) {
+					instance->max_sectors_per_req = max_sectors;
+			} else {
+				printk(KERN_INFO "megasas: max_sectors should be > 0 and"
+			 		"<= %d (or < 1MB for GEN2 controller)\n",
+					instance->max_sectors_per_req);
+			}
+		}
+	}
+
 	host->max_sectors = instance->max_sectors_per_req;
 	host->cmd_per_lun = 128;
 	host->max_channel = MEGASAS_MAX_CHANNELS - 1;
@@ -3604,10 +3661,27 @@ static int megasas_io_attach(struct mega
 	}
 
 	/*
+	 * Create sysfs entries for module paramaters
+	 */
+	error = sysfs_create_bin_file(&instance->host->shost_dev.kobj,
+			&sysfs_max_sectors_attr);
+	
+	if (error) {
+		printk(KERN_INFO "megasas: Error in creating the sysfs entry"
+				" max_sectors.\n");
+		goto out_remove_host;
+	}
+
+	/*
 	 * Trigger SCSI to scan our drives
 	 */
 	scsi_scan_host(host);
 	return 0;
+
+out_remove_host:
+        scsi_remove_host(host);
+        return error;
+
 }
 
 static int
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-05-03 05:50:40.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-05-03 09:56:08.000000000 -0400
@@ -706,6 +706,7 @@ struct megasas_ctrl_info {
 #define MEGASAS_MAX_LD_IDS			(MEGASAS_MAX_LD_CHANNELS * \
 						MEGASAS_MAX_DEV_PER_CHANNEL)
 
+#define MEGASAS_MAX_SECTORS                    (2*1024)
 #define MEGASAS_DBG_LVL				1
 
 #define MEGASAS_FW_BUSY				1

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

* [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset
  2010-05-06 14:42     ` [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I Yang, Bo
                         ` (3 preceding siblings ...)
  2010-05-06 16:17       ` [PATCH 5/7] scsi: megaraid_sas - Add input parameter for max_sectors Yang, Bo
@ 2010-05-06 16:34       ` Yang, Bo
  2010-05-25 16:17         ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2 Tomas Henzl
  2010-06-10  4:21         ` [PATCH 11/12] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
  2010-05-06 16:37       ` [PATCH 7/7] scsi: megaraid_sas - Version and documentation update Yang, Bo
  2010-05-26 16:25       ` [PATCH 1/7] scsi: megaraid_sas - Online Controller Reset - I: Change the Chips related functions and Add the Chip reset functions Yang, Bo
  6 siblings, 2 replies; 37+ messages in thread
From: Yang, Bo @ 2010-05-06 16:34 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-05-04 14:32:49.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-05-04 15:07:26.000000000 -0400
@@ -1569,6 +1569,28 @@ static void megasas_complete_cmd_dpc(uns
 	}
 }
 
+static void
+megasas_internal_reset_defer_cmds(struct megasas_instance *instance);
+
+static void
+process_fw_state_change_wq(struct work_struct *work);
+
+void megasas_do_ocr(struct megasas_instance *instance)
+{
+	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) ||
+	(instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) ||
+	(instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)) {
+		*instance->consumer     = MEGASAS_ADPRESET_INPROG_SIGN;
+	}
+	instance->instancet->disable_intr(instance->reg_set);
+	instance->adprecovery   = MEGASAS_ADPRESET_SM_INFAULT;
+	instance->issuepend_done = 0;
+
+	atomic_set(&instance->fw_outstanding, 0);
+	megasas_internal_reset_defer_cmds(instance);
+	process_fw_state_change_wq(&instance->work_init);
+}
+
 /**
  * megasas_wait_for_outstanding -	Wait for all outstanding cmds
  * @instance:				Adapter soft state
@@ -1586,6 +1608,8 @@ static int megasas_wait_for_outstanding(
 	unsigned long flags;
 	struct list_head clist_local;
 	struct megasas_cmd *reset_cmd;
+	u32 fw_state;
+	u8 kill_adapter_flag;
 
 	spin_lock_irqsave(&instance->hba_lock, flags);
 	adprecovery = instance->adprecovery;
@@ -1671,7 +1695,45 @@ static int megasas_wait_for_outstanding(
 		msleep(1000);
 	}
 
-	if (atomic_read(&instance->fw_outstanding)) {
+	i = 0;
+	kill_adapter_flag = 0;
+	do {
+		fw_state = instance->instancet->read_fw_status_reg(
+					instance->reg_set) & MFI_STATE_MASK;
+		if ((fw_state == MFI_STATE_FAULT) &&
+			(instance->disableOnlineCtrlReset == 0)) {
+			if (i == 3) {
+				kill_adapter_flag = 2;
+				break;
+			}
+			megasas_do_ocr(instance);
+			kill_adapter_flag = 1;
+
+			/* wait for 1 secs to let FW finish the pending cmds */
+			msleep(1000);
+		}
+		i++;
+	} while (i <= 3);
+
+	if (atomic_read(&instance->fw_outstanding) &&
+					!kill_adapter_flag) {
+		if (instance->disableOnlineCtrlReset == 0) {
+
+			megasas_do_ocr(instance);
+
+			/* wait for 5 secs to let FW finish the pending cmds */
+			for (i = 0; i < wait_time; i++) {
+				int outstanding =
+					atomic_read(&instance->fw_outstanding);
+				if (!outstanding)
+					return SUCCESS;
+				msleep(1000);
+			}
+		}
+	}
+
+	if (atomic_read(&instance->fw_outstanding) ||
+					(kill_adapter_flag == 2)) {
 		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds. 

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

* [PATCH 7/7] scsi: megaraid_sas - Version and documentation update
  2010-05-06 14:42     ` [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I Yang, Bo
                         ` (4 preceding siblings ...)
  2010-05-06 16:34       ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
@ 2010-05-06 16:37       ` Yang, Bo
  2010-06-10  4:22         ` [PATCH 12/12] " Yang, Bo
  2010-05-26 16:25       ` [PATCH 1/7] scsi: megaraid_sas - Online Controller Reset - I: Change the Chips related functions and Add the Chip reset functions Yang, Bo
  6 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-05-06 16:37 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

Update the version and documentation.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
Documentation/scsi/ChangeLog.megaraid_sas |   42 ++++++++++++++++++++++++++++++
drivers/scsi/megaraid/megaraid_sas.h      |    6 ++--
 2 files changed, 45 insertions(+), 3 deletions(-)

diff -rupN old/Documentation/scsi/ChangeLog.megaraid_sas new/Documentation/scsi/ChangeLog.megaraid_sas
--- old/Documentation/scsi/ChangeLog.megaraid_sas	2010-05-05 02:08:10.000000000 -0400
+++ new/Documentation/scsi/ChangeLog.megaraid_sas	2010-05-05 04:54:38.000000000 -0400
@@ -1,3 +1,45 @@
+1 Release Date    : Thur.  May 03, 2010 09:12:45 PST 2009 -
+			(emaild-id:megaraidlinux@lsi.com)
+			Bo Yang
+
+2 Current Version : 00.00.04.30-rc1
+3 Older Version   : 00.00.04.17.1-rc1
+
+1.	Add the Online Controller Reset (OCR) to the Driver.
+	OCR is the new feature for megaraid_sas driver which
+	will allow the fw to do the chip reset which will not
+	affact the OS hbhavious.
+
+	To add the OCR support, driver need to do: 
+		a). reset the controller chip -- Xscale and Gen2.
+		
+		b). during the reset, driver will store the pending
+		cmds to pending queue.
+		
+		c). Also in driver's timeout routine, driver will
+		report to OS as reset.
+		
+		d). in Driver's ISR routine, if driver get the FW
+		state as state change and FW in Failure status,
+		driver will start to do the controller reset.
+		
+		e). If driver goes to timeout, but driver is in
+		operational status, driver will check if fw in failed
+		status, if yes, driver will do OCR to FW upto three times.
+		
+		f). Before driver kill adapter, driver will do last chance of
+		OCR to see if driver can bring back the FW.      
+
+2.	Add the CTIO support to the driver.
+3.	Add the support update flag to the driver to tell LSI megaraid_sas
+	application which driver will support the device update.  So application
+	will not need to do the device update after application add/del the device
+	from the system.
+
+4.	Add the input parameter max_sectors to 1MB support to our GEN2 controller.
+	customer can use the input paramenter max_sectors to add 1MB support to GEN2
+	controller.
+
 1 Release Date    : Thur.  Oct 29, 2009 09:12:45 PST 2009 -
 			(emaild-id:megaraidlinux@lsi.com)
 			Bo Yang
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-05-05 01:55:42.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-05-05 02:35:16.000000000 -0400
@@ -18,9 +18,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION			"00.00.04.17.1-rc1"
-#define MEGASAS_RELDATE			"Oct. 29, 2009"
-#define MEGASAS_EXT_VERSION		"Thu. Oct. 29, 11:41:51 PST 2009"
+#define MEGASAS_VERSION			"00.00.04.30-rc1"
+#define MEGASAS_RELDATE			"May 3, 2010"
+#define MEGASAS_EXT_VERSION		"Mon. May 3, 11:41:51 PST 2010"
 
 /*
  * Device IDs

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

* Re: [PATCH 3/7] scsi: megaraid_sas - Online COntroller Reset (OCR) PART-III
  2010-05-06 15:52       ` [PATCH 3/7] scsi: megaraid_sas - Online COntroller Reset (OCR) PART-III Yang, Bo
@ 2010-05-07 12:54         ` Tomas Henzl
  2010-05-18 20:58           ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Henzl @ 2010-05-07 12:54 UTC (permalink / raw)
  To: Yang, Bo
  Cc: 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de',
	'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

On 05/06/2010 05:52 PM, Yang, Bo wrote:
> This is third part of the Online Controller Reset. In ISR routine, if driver receive the FW state change interrupt
> And the online controller reset support enabled in FW, driver will read the controller register.  Driver will issue
> Controller reset if the FW register state failure.  Also driver will back up the pending cmds for the re-fire after
> the reset finished.
>
> Also Driver added the CTIO support to this patch.
>
> Signed-off-by Bo Yang<bo.yang@lsi.com>
>
> +static void
> +process_fw_state_change_wq(struct work_struct *work)
> +{
> +       struct megasas_instance *instance =
> +               container_of(work, struct megasas_instance, work_init);
> +       u32 wait;
> +       unsigned long flags;
> +
> +       if (instance->adprecovery != MEGASAS_ADPRESET_SM_INFAULT) {
> +               printk(KERN_NOTICE "megaraid_sas: error, recovery st %x \n",
> +                               instance->adprecovery);
> +               return ;
> +       }
> +
> +       if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) {
> +               printk(KERN_NOTICE "megaraid_sas: FW detected to be in fault"
> +                                       "state, restarting it...\n");
> +
> +               instance->instancet->disable_intr(instance->reg_set);
> +               atomic_set(&instance->fw_outstanding, 0);
> +
> +               atomic_set(&instance->fw_reset_no_pci_access, 1);
> +               instance->instancet->adp_reset(instance, instance->reg_set);
> +               atomic_set(&instance->fw_reset_no_pci_access, 0 );
> +
> +               printk(KERN_NOTICE "megaraid_sas: FW restarted successfully,"
> +                                       "initiating next stage...\n");
> +
> +               printk(KERN_NOTICE "megaraid_sas: HBA recovery state machine,"
> +                                       "state 2 starting...\n");
> +
> +               /*waitting for about 20 second before start the second init*/
> +               for (wait = 0; wait < 30; wait++) {
> +                       msleep(1000);
> +               }
>   
Hi Bo,
I'm only curios - couldn't be the above loop replaced by ssleep(30); 
and have the u32 wait; removed?
+		ssleep(30); /* wait for about 30 second before second init */

I guess you wanted to have a space after the comma in the printk, if yes I think
you should do this -> printk(KERN_NOTICE "megaraid_sas: HBA recovery state machine, "

It might be a problem with my mail reader, but it seems to me that you are using 
spaces instead of tabs almost everywhere.

Tomas



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

* RE: [PATCH 3/7] scsi: megaraid_sas - Online COntroller Reset (OCR) PART-III
  2010-05-07 12:54         ` Tomas Henzl
@ 2010-05-18 20:58           ` Yang, Bo
  0 siblings, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2010-05-18 20:58 UTC (permalink / raw)
  To: Tomas Henzl
  Cc: 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de',
	'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

Tomas,

For the space, my e-mail shows tab.  Can you setup your e-mail as "plain text" to see if resolve this problem?

for (wait = 0; wait < 30; wait++) {
> +                       msleep(1000);
> +               }
>   

It can be replaced by ssleep(30);

Also change: 
> +               printk(KERN_NOTICE "megaraid_sas: HBA recovery state machine,"
To:
> +               printk(KERN_NOTICE "megaraid_sas: HBA recovery state machine, "

Thanks,

Bo Yang


-----Original Message-----
From: Tomas Henzl [mailto:thenzl@redhat.com] 
Sent: Friday, May 07, 2010 8:54 AM
To: Yang, Bo
Cc: 'James.Bottomley@HansenPartnership.com'; 'James.Bottomley@suse.de'; 'linux-scsi@vger.kernel.org'; 'akpm@osdl.org'; 'linux-kernel@vger.kernel.org'; Daftardar, Jayant
Subject: Re: [PATCH 3/7] scsi: megaraid_sas - Online COntroller Reset (OCR) PART-III

On 05/06/2010 05:52 PM, Yang, Bo wrote:
> This is third part of the Online Controller Reset. In ISR routine, if driver receive the FW state change interrupt
> And the online controller reset support enabled in FW, driver will read the controller register.  Driver will issue
> Controller reset if the FW register state failure.  Also driver will back up the pending cmds for the re-fire after
> the reset finished.
>
> Also Driver added the CTIO support to this patch.
>
> Signed-off-by Bo Yang<bo.yang@lsi.com>
>
> +static void
> +process_fw_state_change_wq(struct work_struct *work)
> +{
> +       struct megasas_instance *instance =
> +               container_of(work, struct megasas_instance, work_init);
> +       u32 wait;
> +       unsigned long flags;
> +
> +       if (instance->adprecovery != MEGASAS_ADPRESET_SM_INFAULT) {
> +               printk(KERN_NOTICE "megaraid_sas: error, recovery st %x \n",
> +                               instance->adprecovery);
> +               return ;
> +       }
> +
> +       if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) {
> +               printk(KERN_NOTICE "megaraid_sas: FW detected to be in fault"
> +                                       "state, restarting it...\n");
> +
> +               instance->instancet->disable_intr(instance->reg_set);
> +               atomic_set(&instance->fw_outstanding, 0);
> +
> +               atomic_set(&instance->fw_reset_no_pci_access, 1);
> +               instance->instancet->adp_reset(instance, instance->reg_set);
> +               atomic_set(&instance->fw_reset_no_pci_access, 0 );
> +
> +               printk(KERN_NOTICE "megaraid_sas: FW restarted successfully,"
> +                                       "initiating next stage...\n");
> +
> +               printk(KERN_NOTICE "megaraid_sas: HBA recovery state machine,"
> +                                       "state 2 starting...\n");
> +
> +               /*waitting for about 20 second before start the second init*/
> +               for (wait = 0; wait < 30; wait++) {
> +                       msleep(1000);
> +               }
>   
Hi Bo,
I'm only curios - couldn't be the above loop replaced by ssleep(30); 
and have the u32 wait; removed?
+		ssleep(30); /* wait for about 30 second before second init */

I guess you wanted to have a space after the comma in the printk, if yes I think
you should do this -> printk(KERN_NOTICE "megaraid_sas: HBA recovery state machine, "

It might be a problem with my mail reader, but it seems to me that you are using 
spaces instead of tabs almost everywhere.

Tomas



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

* [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2
  2010-05-06 16:34       ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
@ 2010-05-25 16:17         ` Tomas Henzl
  2010-05-25 17:32           ` James Bottomley
  2010-06-10  4:21         ` [PATCH 11/12] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
  1 sibling, 1 reply; 37+ messages in thread
From: Tomas Henzl @ 2010-05-25 16:17 UTC (permalink / raw)
  To: Yang, Bo
  Cc: 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de',
	'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

V2: I've cleaned up some coding style issues and removed a variable, the functionality shouldn't be changed

Tomas

If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   

Signed-off-by Bo Yang<bo.yang@lsi.com>
Signed-off-by Tomas Henzl<thenzl@redhat.com>

---
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 92e381b..0b84b3a 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -1551,6 +1551,28 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr)
 	}
 }
 
+static void
+megasas_internal_reset_defer_cmds(struct megasas_instance *instance);
+
+static void
+process_fw_state_change_wq(struct work_struct *work);
+
+void megasas_do_ocr(struct megasas_instance *instance)
+{
+	if (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R ||
+	    instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5 ||
+	    instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)
+		*instance->consumer = MEGASAS_ADPRESET_INPROG_SIGN;
+
+	instance->instancet->disable_intr(instance->reg_set);
+	instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT;
+	instance->issuepend_done = 0;
+
+	atomic_set(&instance->fw_outstanding, 0);
+	megasas_internal_reset_defer_cmds(instance);
+	process_fw_state_change_wq(&instance->work_init);
+}
+
 /**
  * megasas_wait_for_outstanding -	Wait for all outstanding cmds
  * @instance:				Adapter soft state
@@ -1568,6 +1590,9 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 	unsigned long flags;
 	struct list_head clist_local;
 	struct megasas_cmd *reset_cmd;
+	u32 fw_state;
+	u8 kill_adapter_flag;
+	int outstanding;
 
 	spin_lock_irqsave(&instance->hba_lock, flags);
 	adprecovery = instance->adprecovery;
@@ -1628,7 +1653,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 	printk(KERN_NOTICE "megaraid_sas: HBA reset handler invoked without an internal reset condition.\n");
 	for (i = 0; i < wait_time; i++) {
 
-		int outstanding = atomic_read(&instance->fw_outstanding);
+		outstanding = atomic_read(&instance->fw_outstanding);
 
 		if (!outstanding)
 			break;
@@ -1646,7 +1671,41 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 		msleep(1000);
 	}
 
-	if (atomic_read(&instance->fw_outstanding)) {
+	i = 0;
+	kill_adapter_flag = 0;
+	do {
+		fw_state = instance->instancet->read_fw_status_reg(
+					instance->reg_set) & MFI_STATE_MASK;
+		if (fw_state == MFI_STATE_FAULT &&
+		    instance->disableOnlineCtrlReset == 0) {
+			if (i == 3) {
+				kill_adapter_flag = 2;
+				break;
+			}
+			megasas_do_ocr(instance);
+			kill_adapter_flag = 1;
+
+			/* wait for 1 secs to let FW finish the pending cmds */
+			msleep(1000);
+		}
+		i++;
+	} while (i <= 3);
+
+	if (atomic_read(&instance->fw_outstanding) && !kill_adapter_flag &&
+	    instance->disableOnlineCtrlReset == 0) {
+
+		megasas_do_ocr(instance);
+
+		/* wait for 5 secs to let FW finish the pending cmds */
+		for (i = 0; i < wait_time; i++) {
+			outstanding = atomic_read(&instance->fw_outstanding);
+			if (!outstanding)
+				return SUCCESS;
+			msleep(1000);
+		}
+	}
+
+	if (atomic_read(&instance->fw_outstanding) || kill_adapter_flag == 2) {
 		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds.



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

* Re: [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2
  2010-05-25 16:17         ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2 Tomas Henzl
@ 2010-05-25 17:32           ` James Bottomley
  2010-05-26 15:48             ` Tomas Henzl
  0 siblings, 1 reply; 37+ messages in thread
From: James Bottomley @ 2010-05-25 17:32 UTC (permalink / raw)
  To: Tomas Henzl
  Cc: Yang, Bo, 'linux-scsi@vger.kernel.org',
	'akpm@osdl.org', 'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

On Tue, 2010-05-25 at 18:17 +0200, Tomas Henzl wrote:
> V2: I've cleaned up some coding style issues and removed a variable, the functionality shouldn't be changed
> 
> Tomas
> 
> If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
> Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
> Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   

So there's supposed to be a replacement for 3/7 (megaraid_sas - Online
COntroller Reset (OCR) PART-III) as well, isn't there?

Also descriptive subjects would be nice (parts I-III may do well for
Lord of the Rings ... it's less useful for SCSI patches).

James



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

* Re: [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2
  2010-05-25 17:32           ` James Bottomley
@ 2010-05-26 15:48             ` Tomas Henzl
  2010-05-26 21:08               ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Henzl @ 2010-05-26 15:48 UTC (permalink / raw)
  To: James Bottomley
  Cc: Yang, Bo, 'linux-scsi@vger.kernel.org',
	'akpm@osdl.org', 'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

On 05/25/2010 07:32 PM, James Bottomley wrote:
> On Tue, 2010-05-25 at 18:17 +0200, Tomas Henzl wrote:
>   
>> V2: I've cleaned up some coding style issues and removed a variable, the functionality shouldn't be changed
>>
>> Tomas
>>
>> If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
>> Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
>> Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   
>>     
> So there's supposed to be a replacement for 3/7 (megaraid_sas - Online
> COntroller Reset (OCR) PART-III) as well, isn't there?
>   
Yes, I think there are some issues that could be removed, on the other side
it is mostly coding style related, so I think it could be accepted as it is.
I hope I could afterwards clean something up. (The patches as they are now don't
apply correctly on my system, it's maybe an issue with my mail reader.)
 

> Also descriptive subjects would be nice (parts I-III may do well for
> Lord of the Rings ... it's less useful for SCSI patches).
>   
This is again a question for the original author. Bo?

Tomas


> James
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   


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

* [PATCH 1/7] scsi: megaraid_sas - Online Controller Reset - I: Change the Chips related functions and Add the Chip reset functions
  2010-05-06 14:42     ` [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I Yang, Bo
                         ` (5 preceding siblings ...)
  2010-05-06 16:37       ` [PATCH 7/7] scsi: megaraid_sas - Version and documentation update Yang, Bo
@ 2010-05-26 16:25       ` Yang, Bo
  6 siblings, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2010-05-26 16:25 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

RESUBMIT: Adding the detailed description for this patch:

Add the Controller reset functions to the Driver.  This is first part of the Online Controller Reset.
The driver supports XScle and Gen2 chips.  The chip related functions need to change and driver also
need to add the new chip reset functions to write the chip register do the chip reset.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |  235 +++++++++++++++++++++++++++++++++++++++++++++++++++------
megaraid_sas.h |   40 ++++++++-
 2 files changed, 248 insertions(+), 27 deletions(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c    2010-04-19 09:26:47.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c    2010-04-21 05:03:14.000000000 -0400
@@ -164,7 +164,7 @@ megasas_return_cmd(struct megasas_instan
 static inline void
 megasas_enable_intr_xscale(struct megasas_register_set __iomem * regs)
 {
-       writel(1, &(regs)->outbound_intr_mask);
+       writel(0, &(regs)->outbound_intr_mask);

        /* Dummy readl to force pci flush */
        readl(&regs->outbound_intr_mask);
@@ -200,24 +200,27 @@ static int
 megasas_clear_intr_xscale(struct megasas_register_set __iomem * regs)
 {
        u32 status;
+       u32 mfiStatus = 0;
        /*
         * Check if it is our interrupt
         */
        status = readl(&regs->outbound_intr_status);

-       if (!(status & MFI_OB_INTR_STATUS_MASK)) {
-               return 1;
-       }
+       if (status & MFI_OB_INTR_STATUS_MASK)
+               mfiStatus = MFI_INTR_FLAG_REPLY_MESSAGE;
+       if (status & MFI_XSCALE_OMR0_CHANGE_INTERRUPT)
+               mfiStatus |= MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE;

        /*
         * Clear the interrupt by writing back the same value
         */
-       writel(status, &regs->outbound_intr_status);
+       if (mfiStatus)
+               writel(status, &regs->outbound_intr_status);

        /* Dummy readl to force pci flush */
        readl(&regs->outbound_intr_status);

-       return 0;
+       return mfiStatus;
 }

 /**
@@ -232,8 +235,69 @@ megasas_fire_cmd_xscale(struct megasas_i
                u32 frame_count,
                struct megasas_register_set __iomem *regs)
 {
+       unsigned long flags;
+       spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr >> 3)|(frame_count),
               &(regs)->inbound_queue_port);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+}
+
+/**
+ * megasas_adp_reset_xscale -  For controller reset
+ * @regs:                              MFI register set
+ */
+static int
+megasas_adp_reset_xscale(struct megasas_instance *instance,
+       struct megasas_register_set __iomem *regs)
+{
+       u32 i;
+       u32 pcidata;
+       writel(MFI_ADP_RESET, &regs->inbound_doorbell);
+
+       for (i = 0; i < 3; i++)
+               msleep(1000); /* sleep for 3 secs */
+       pcidata  = 0;
+       pci_read_config_dword(instance->pdev, MFI_1068_PCSR_OFFSET, &pcidata);
+       printk(KERN_NOTICE "pcidata = %x\n", pcidata);
+       if (pcidata & 0x2) {
+               printk(KERN_NOTICE "mfi 1068 offset read=%x\n", pcidata);
+               pcidata &= ~0x2;
+               pci_write_config_dword(instance->pdev,
+                               MFI_1068_PCSR_OFFSET, pcidata);
+
+               for (i = 0; i < 2; i++)
+                       msleep(1000); /* need to wait 2 secs again */
+
+               pcidata  = 0;
+               pci_read_config_dword(instance->pdev,
+                               MFI_1068_FW_HANDSHAKE_OFFSET, &pcidata);
+               printk(KERN_NOTICE "1068 offset handshake read=%x\n", pcidata);
+               if ((pcidata & 0xffff0000) == MFI_1068_FW_READY) {
+                       printk(KERN_NOTICE "1068 offset pcidt=%x\n", pcidata);
+                       pcidata = 0;
+                       pci_write_config_dword(instance->pdev,
+                               MFI_1068_FW_HANDSHAKE_OFFSET, pcidata);
+               }
+       }
+       return 0;
+}
+
+/**
+ * megasas_check_reset_xscale -        For controller reset check
+ * @regs:                              MFI register set
+ */
+static int
+megasas_check_reset_xscale(struct megasas_instance *instance,
+               struct megasas_register_set __iomem *regs)
+{
+       u32 consumer;
+       consumer = *instance->consumer;
+
+       if ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) &&
+               (*instance->consumer == MEGASAS_ADPRESET_INPROG_SIGN)) {
+               return 1;
+       }
+       return 0;
 }

 static struct megasas_instance_template megasas_instance_template_xscale = {
@@ -243,6 +307,8 @@ static struct megasas_instance_template
        .disable_intr = megasas_disable_intr_xscale,
        .clear_intr = megasas_clear_intr_xscale,
        .read_fw_status_reg = megasas_read_fw_status_reg_xscale,
+       .adp_reset = megasas_adp_reset_xscale,
+       .check_reset = megasas_check_reset_xscale,
 };

 /**
@@ -264,7 +330,7 @@ megasas_enable_intr_ppc(struct megasas_r
 {
        writel(0xFFFFFFFF, &(regs)->outbound_doorbell_clear);

-       writel(~0x80000004, &(regs)->outbound_intr_mask);
+       writel(~0x80000000, &(regs)->outbound_intr_mask);

        /* Dummy readl to force pci flush */
        readl(&regs->outbound_intr_mask);
@@ -307,7 +373,7 @@ megasas_clear_intr_ppc(struct megasas_re
        status = readl(&regs->outbound_intr_status);

        if (!(status & MFI_REPLY_1078_MESSAGE_INTERRUPT)) {
-               return 1;
+               return 0;
        }

        /*
@@ -318,7 +384,7 @@ megasas_clear_intr_ppc(struct megasas_re
        /* Dummy readl to force pci flush */
        readl(&regs->outbound_doorbell_clear);

-       return 0;
+       return 1;
 }
 /**
  * megasas_fire_cmd_ppc -      Sends command to the FW
@@ -332,10 +398,34 @@ megasas_fire_cmd_ppc(struct megasas_inst
                u32 frame_count,
                struct megasas_register_set __iomem *regs)
 {
+       unsigned long flags;
+       spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr | (frame_count<<1))|1,
                        &(regs)->inbound_queue_port);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
 }

+/**
+ * megasas_adp_reset_ppc -     For controller reset
+ * @regs:                              MFI register set
+ */
+static int
+megasas_adp_reset_ppc(struct megasas_instance *instance,
+                       struct megasas_register_set __iomem *regs)
+{
+       return 0;
+}
+
+/**
+ * megasas_check_reset_ppc -   For controller reset check
+ * @regs:                              MFI register set
+ */
+static int
+megasas_check_reset_ppc(struct megasas_instance *instance,
+                       struct megasas_register_set __iomem *regs)
+{
+       return 0;
+}
 static struct megasas_instance_template megasas_instance_template_ppc = {

        .fire_cmd = megasas_fire_cmd_ppc,
@@ -343,6 +433,8 @@ static struct megasas_instance_template
        .disable_intr = megasas_disable_intr_ppc,
        .clear_intr = megasas_clear_intr_ppc,
        .read_fw_status_reg = megasas_read_fw_status_reg_ppc,
+       .adp_reset = megasas_adp_reset_ppc,
+       .check_reset = megasas_check_reset_ppc,
 };

 /**
@@ -397,7 +489,7 @@ megasas_clear_intr_skinny(struct megasas
        status = readl(&regs->outbound_intr_status);

        if (!(status & MFI_SKINNY_ENABLE_INTERRUPT_MASK)) {
-               return 1;
+               return 0;
        }

        /*
@@ -410,7 +502,7 @@ megasas_clear_intr_skinny(struct megasas
        */
        readl(&regs->outbound_intr_status);

-       return 0;
+       return 1;
 }

 /**
@@ -426,11 +518,33 @@ megasas_fire_cmd_skinny(struct megasas_i
                        struct megasas_register_set __iomem *regs)
 {
        unsigned long flags;
-       spin_lock_irqsave(&instance->fire_lock, flags);
+       spin_lock_irqsave(&instance->hba_lock, flags);
        writel(0, &(regs)->inbound_high_queue_port);
        writel((frame_phys_addr | (frame_count<<1))|1,
                &(regs)->inbound_low_queue_port);
-       spin_unlock_irqrestore(&instance->fire_lock, flags);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+}
+
+/**
+ * megasas_adp_reset_skinny -  For controller reset
+ * @regs:                              MFI register set
+ */
+static int
+megasas_adp_reset_skinny(struct megasas_instance *instance,
+                       struct megasas_register_set __iomem *regs)
+{
+       return 0;
+}
+
+/**
+ * megasas_check_reset_skinny -        For controller reset check
+ * @regs:                              MFI register set
+ */
+static int
+megasas_check_reset_skinny(struct megasas_instance *instance,
+                               struct megasas_register_set __iomem *regs)
+{
+       return 0;
 }

 static struct megasas_instance_template megasas_instance_template_skinny = {
@@ -440,6 +554,8 @@ static struct megasas_instance_template
        .disable_intr = megasas_disable_intr_skinny,
        .clear_intr = megasas_clear_intr_skinny,
        .read_fw_status_reg = megasas_read_fw_status_reg_skinny,
+       .adp_reset = megasas_adp_reset_skinny,
+       .check_reset = megasas_check_reset_skinny,
 };


@@ -495,23 +611,29 @@ static int
 megasas_clear_intr_gen2(struct megasas_register_set __iomem *regs)
 {
        u32 status;
+       u32 mfiStatus = 0;
        /*
         * Check if it is our interrupt
         */
        status = readl(&regs->outbound_intr_status);

-       if (!(status & MFI_GEN2_ENABLE_INTERRUPT_MASK))
-               return 1;
+       if (status & MFI_GEN2_ENABLE_INTERRUPT_MASK) {
+               mfiStatus = MFI_INTR_FLAG_REPLY_MESSAGE;
+       }
+       if (status & MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT) {
+               mfiStatus |= MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE;
+       }

        /*
         * Clear the interrupt by writing back the same value
         */
-       writel(status, &regs->outbound_doorbell_clear);
+       if (mfiStatus)
+               writel(status, &regs->outbound_doorbell_clear);

        /* Dummy readl to force pci flush */
        readl(&regs->outbound_intr_status);

-       return 0;
+       return mfiStatus;
 }
 /**
  * megasas_fire_cmd_gen2 -     Sends command to the FW
@@ -525,8 +647,74 @@ megasas_fire_cmd_gen2(struct megasas_ins
                        u32 frame_count,
                        struct megasas_register_set __iomem *regs)
 {
+       unsigned long flags;
+       spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr | (frame_count<<1))|1,
                        &(regs)->inbound_queue_port);
+       spin_unlock_irqrestore(&instance->hba_lock, flags);
+}
+
+/**
+ * megasas_adp_reset_gen2 -    For controller reset
+ * @regs:                              MFI register set
+ */
+static int
+megasas_adp_reset_gen2(struct megasas_instance *instance,
+                       struct megasas_register_set __iomem *reg_set)
+{
+       u32                     retry = 0 ;
+       u32                     HostDiag;
+
+       writel(0, &reg_set->seq_offset);
+       writel(4, &reg_set->seq_offset);
+       writel(0xb, &reg_set->seq_offset);
+       writel(2, &reg_set->seq_offset);
+       writel(7, &reg_set->seq_offset);
+       writel(0xd, &reg_set->seq_offset);
+       msleep(1000);
+
+       HostDiag = (u32)readl(&reg_set->host_diag);
+
+       while ( !( HostDiag & DIAG_WRITE_ENABLE) ) {
+               msleep(100);
+               HostDiag = (u32)readl(&reg_set->host_diag);
+               printk(KERN_NOTICE "RESETGEN2: retry=%x, hostdiag=%x\n",
+                                       retry, HostDiag);
+
+               if (retry++ >= 100)
+                       return 1;
+
+       }
+
+       printk(KERN_NOTICE "ADP_RESET_GEN2: HostDiag=%x\n", HostDiag);
+
+       writel((HostDiag | DIAG_RESET_ADAPTER), &reg_set->host_diag);
+
+       ssleep(10);
+
+       HostDiag = (u32)readl(&reg_set->host_diag);
+       while ( ( HostDiag & DIAG_RESET_ADAPTER) ) {
+               msleep(100);
+               HostDiag = (u32)readl(&reg_set->host_diag);
+               printk(KERN_NOTICE "RESET_GEN2: retry=%x, hostdiag=%x\n",
+                               retry, HostDiag);
+
+               if (retry++ >= 1000)
+                       return 1;
+
+       }
+       return 0;
+}
+
+/**
+ * megasas_check_reset_gen2 -  For controller reset check
+ * @regs:                              MFI register set
+ */
+static int
+megasas_check_reset_gen2(struct megasas_instance *instance,
+               struct megasas_register_set __iomem *regs)
+{
+       return 0;
 }

 static struct megasas_instance_template megasas_instance_template_gen2 = {
@@ -536,11 +724,13 @@ static struct megasas_instance_template
        .disable_intr = megasas_disable_intr_gen2,
        .clear_intr = megasas_clear_intr_gen2,
        .read_fw_status_reg = megasas_read_fw_status_reg_gen2,
+       .adp_reset = megasas_adp_reset_gen2,
+       .check_reset = megasas_check_reset_gen2,
 };

 /**
 *      This is the end of set of functions & definitions
-*      specific to ppc (deviceid : 0x60) controllers
+*       specific to gen2 (deviceid : 0x78, 0x79) controllers
 */

 /**
@@ -599,8 +789,7 @@ megasas_issue_blocked_cmd(struct megasas
        instance->instancet->fire_cmd(instance,
                        cmd->frame_phys_addr, 0, instance->reg_set);

-       wait_event_timeout(instance->int_cmd_wait_q, (cmd->cmd_status != ENODATA),
-               MEGASAS_INTERNAL_CMD_WAIT_TIME*HZ);
+       wait_event(instance->int_cmd_wait_q, cmd->cmd_status != ENODATA);

        return 0;
 }
@@ -648,8 +837,8 @@ megasas_issue_blocked_abort_cmd(struct m
        /*
         * Wait for this cmd to complete
         */
-       wait_event_timeout(instance->abort_cmd_wait_q, (cmd->cmd_status != 0xFF),
-               MEGASAS_INTERNAL_CMD_WAIT_TIME*HZ);
+       wait_event(instance->abort_cmd_wait_q, cmd->cmd_status != 0xFF);
+       cmd->sync_cmd = 0;

        megasas_return_cmd(instance, cmd);
        return 0;
@@ -3137,7 +3326,7 @@ megasas_probe_one(struct pci_dev *pdev,
        init_waitqueue_head(&instance->abort_cmd_wait_q);

        spin_lock_init(&instance->cmd_pool_lock);
-       spin_lock_init(&instance->fire_lock);
+       spin_lock_init(&instance->hba_lock);
        spin_lock_init(&instance->completion_lock);
        spin_lock_init(&poll_aen_lock);

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h    2010-04-19 09:26:47.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h    2010-04-21 05:00:03.000000000 -0400
@@ -73,6 +73,12 @@
  * HOTPLUG     : Resume from Hotplug
  * MFI_STOP_ADP        : Send signal to FW to stop processing
  */
+#define WRITE_SEQUENCE_OFFSET          (0x0000000FC) /* I20 */
+#define HOST_DIAGNOSTIC_OFFSET         (0x000000F8)  /* I20 */
+#define DIAG_WRITE_ENABLE                      (0x00000080)
+#define DIAG_RESET_ADAPTER                     (0x00000004)
+
+#define MFI_ADP_RESET                          0x00000040
 #define MFI_INIT_ABORT                         0x00000001
 #define MFI_INIT_READY                         0x00000002
 #define MFI_INIT_MFIMODE                       0x00000004
@@ -704,6 +710,12 @@ struct megasas_ctrl_info {
  */
 #define IS_DMA64                               (sizeof(dma_addr_t) == 8)

+#define MFI_XSCALE_OMR0_CHANGE_INTERRUPT               0x00000001
+
+#define MFI_INTR_FLAG_REPLY_MESSAGE                    0x00000001
+#define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE            0x00000002
+#define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT      0x00000004
+
 #define MFI_OB_INTR_STATUS_MASK                        0x00000002
 #define MFI_POLL_TIMEOUT_SECS                  60
 #define MEGASAS_COMPLETION_TIMER_INTERVAL      (HZ/10)
@@ -714,6 +726,9 @@ struct megasas_ctrl_info {
 #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT     0x40000000
 #define MFI_SKINNY_ENABLE_INTERRUPT_MASK       (0x00000001)

+#define MFI_1068_PCSR_OFFSET                   0x84
+#define MFI_1068_FW_HANDSHAKE_OFFSET           0x64
+#define MFI_1068_FW_READY                      0xDDDD0000
 /*
 * register set for both 1068 and 1078 controllers
 * structure extended for 1078 registers
@@ -755,8 +770,10 @@ struct megasas_register_set {
        u32     inbound_high_queue_port ;       /*00C4h*/

        u32     reserved_5;                     /*00C8h*/
-       u32     index_registers[820];           /*00CCh*/
-
+       u32     res_6[11];                      /*CCh*/
+       u32     host_diag;
+       u32     seq_offset;
+       u32     index_registers[807];           /*00CCh*/
 } __attribute__ ((packed));

 struct megasas_sge32 {
@@ -1226,11 +1243,12 @@ struct megasas_instance {

        struct megasas_cmd **cmd_list;
        struct list_head cmd_pool;
+       /* used to sync fire the cmd to fw */
        spinlock_t cmd_pool_lock;
+       /* used to sync fire the cmd to fw */
+       spinlock_t hba_lock;
        /* used to synch producer, consumer ptrs in dpc */
        spinlock_t completion_lock;
-       /* used to sync fire the cmd to fw */
-       spinlock_t fire_lock;
        struct dma_pool *frame_dma_pool;
        struct dma_pool *sense_dma_pool;

@@ -1257,11 +1275,21 @@ struct megasas_instance {
        u8 flag;
        u8 unload;
        u8 flag_ieee;
+       u8 adprecovery;
        unsigned long last_time;

        struct timer_list io_completion_timer;
 };

+enum {
+       MEGASAS_HBA_OPERATIONAL                 = 0,
+       MEGASAS_ADPRESET_SM_INFAULT             = 1,
+       MEGASAS_ADPRESET_SM_FW_RESET_SUCCESS    = 2,
+       MEGASAS_ADPRESET_SM_OPERATIONAL         = 3,
+       MEGASAS_HW_CRITICAL_ERROR               = 4,
+       MEGASAS_ADPRESET_INPROG_SIGN            = 0xDEADDEAD,
+};
+
 struct megasas_instance_template {
        void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
                u32, struct megasas_register_set __iomem *);
@@ -1272,6 +1300,10 @@ struct megasas_instance_template {
        int (*clear_intr)(struct megasas_register_set __iomem *);

        u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
+       int (*adp_reset)(struct megasas_instance *, \
+               struct megasas_register_set __iomem *);
+       int (*check_reset)(struct megasas_instance *, \
+               struct megasas_register_set __iomem *);
 };

 #define MEGASAS_IS_LOGICAL(scp)                                                \

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

* [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR)-II : Driver return RESET in timeout routine
  2010-05-06 15:41       ` [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-II Yang, Bo
@ 2010-05-26 16:35         ` Yang, Bo
  2010-06-10  3:25           ` [PATCH 4/12] scsi: megaraid_sas - Online controller Reset Support (OCR) " Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-05-26 16:35 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

RESUBMIT -- Adding the detailed description:

This is second part of the Online Controller Reset (OCR).  When driver doesn't finish to issue the pending
Cmds, driver will return BUSY to OS.  Also in driver's timeout routine, if online controller reset is going
On, driver will return RESET to OS. 

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
megaraid_sas.h |    2 +
 2 files changed, 107 insertions(+), 5 deletions(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-04-21 05:16:37.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-04-28 08:52:56.000000000 -0400
@@ -1320,14 +1320,22 @@ megasas_queue_command(struct scsi_cmnd *
 	u32 frame_count;
 	struct megasas_cmd *cmd;
 	struct megasas_instance *instance;
+	unsigned long flags;
 
 	instance = (struct megasas_instance *)
 	    scmd->device->host->hostdata;
 
-	/* Don't process if we have already declared adapter dead */
-	if (instance->hw_crit_error)
+	if (instance->issuepend_done == 0)
 		return SCSI_MLQUEUE_HOST_BUSY;
 
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
+		return SCSI_MLQUEUE_HOST_BUSY;
+	}
+
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+
 	scmd->scsi_done = done;
 	scmd->result = 0;
 
@@ -1463,6 +1471,18 @@ static int megasas_slave_alloc(struct sc
 	return 0;
 }
 
+static void megaraid_sas_kill_hba(struct megasas_instance *instance)
+{
+	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
+		(instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) {
+		writel(MFI_STOP_ADP,
+			&instance->reg_set->reserved_0[0]);
+	} else {
+		writel(MFI_STOP_ADP,
+			&instance->reg_set->inbound_doorbell);
+	}
+}
+
 /**
  * megasas_complete_cmd_dpc	 -	Returns FW's controller structure
  * @instance_addr:			Address of adapter soft state
@@ -1480,7 +1500,7 @@ static void megasas_complete_cmd_dpc(uns
 	unsigned long flags;
 
 	/* If we have already declared adapter dead, donot complete cmds */
-	if (instance->hw_crit_error)
+	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR )
 		return;
 
 	spin_lock_irqsave(&instance->completion_lock, flags);
@@ -1490,6 +1510,11 @@ static void megasas_complete_cmd_dpc(uns
 
 	while (consumer != producer) {
 		context = instance->reply_queue[consumer];
+		if (context >= instance->max_fw_cmds) {
+			printk(KERN_ERR "Unexpected context value %x\n",
+				context);
+			BUG();
+		}
 
 		cmd = instance->cmd_list[context];
 
@@ -1539,7 +1564,76 @@ static void megasas_complete_cmd_dpc(uns
 static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 {
 	int i;
+	u32 reset_index;
 	u32 wait_time = MEGASAS_RESET_WAIT_TIME;
+	u8 adprecovery;
+	unsigned long flags;
+	struct list_head clist_local;
+	struct megasas_cmd *reset_cmd;
+
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	adprecovery = instance->adprecovery;
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+	if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
+
+		INIT_LIST_HEAD(&clist_local);
+		spin_lock_irqsave(&instance->hba_lock, flags);
+		list_splice_init(&instance->internal_reset_pending_q,
+				&clist_local);
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+		printk(KERN_NOTICE "megasas: HBA reset wait ...\n");
+		for (i = 0; i < wait_time; i++) {
+			msleep(1000);
+			spin_lock_irqsave(&instance->hba_lock, flags);
+			adprecovery = instance->adprecovery;
+			spin_unlock_irqrestore(&instance->hba_lock, flags);
+			if (adprecovery == MEGASAS_HBA_OPERATIONAL)
+				break;
+		}
+
+		if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
+			printk(KERN_NOTICE "megasas: reset: Stopping HBA.\n");
+			spin_lock_irqsave(&instance->hba_lock, flags);
+			instance->adprecovery	= MEGASAS_HW_CRITICAL_ERROR;
+			spin_unlock_irqrestore(&instance->hba_lock, flags);
+			return FAILED;
+		}
+
+		reset_index	= 0;
+		while (!list_empty(&clist_local)) {
+			reset_cmd	= list_entry((&clist_local)->next,
+						struct megasas_cmd, list);
+			list_del_init(&reset_cmd->list);
+			if (reset_cmd->scmd) {
+				reset_cmd->scmd->result = DID_RESET << 16;
+				printk(KERN_NOTICE "%d:%p reset [%02x], %#lx\n",
+					reset_index, reset_cmd,
+					reset_cmd->scmd->cmnd[0],
+					reset_cmd->scmd->serial_number);
+
+				reset_cmd->scmd->scsi_done(reset_cmd->scmd);
+				megasas_return_cmd(instance, reset_cmd);
+			} else if (reset_cmd->sync_cmd) {
+				printk(KERN_NOTICE "megasas:%p synch cmds"
+						"reset queue\n",
+						reset_cmd);
+
+				reset_cmd->cmd_status = ENODATA;
+				instance->instancet->fire_cmd(instance,
+						reset_cmd->frame_phys_addr,
+						0, instance->reg_set);
+			} else {
+				printk(KERN_NOTICE "megasas: %p unexpected"
+					"cmds lst\n",
+					reset_cmd);
+			}
+			reset_index++;
+		}
+
+		return SUCCESS;
+	}
 
 	for (i = 0; i < wait_time; i++) {
 
@@ -1562,6 +1656,7 @@ static int megasas_wait_for_outstanding(
 	}
 
 	if (atomic_read(&instance->fw_outstanding)) {
+		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds.
 		* The controller will be taken offline by the OS now.
@@ -1577,10 +1672,14 @@ static int megasas_wait_for_outstanding(
 				&instance->reg_set->inbound_doorbell);
 		}
 		megasas_dump_pending_frames(instance);
-		instance->hw_crit_error = 1;
+		spin_lock_irqsave(&instance->hba_lock, flags);
+		instance->adprecovery	= MEGASAS_HW_CRITICAL_ERROR;
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
 		return FAILED;
 	}
 
+	printk(KERN_NOTICE "megaraid_sas: no pending cmds after reset\n");
+
 	return SUCCESS;
 }
 
@@ -1602,7 +1701,7 @@ static int megasas_generic_reset(struct 
 	scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x retries=%x\n",
 		 scmd->serial_number, scmd->cmnd[0], scmd->retries);
 
-	if (instance->hw_crit_error) {
+	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
 		printk(KERN_ERR "megasas: cannot recover from previous reset "
 		       "failures\n");
 		return FAILED;
@@ -3319,6 +3418,7 @@ megasas_probe_one(struct pci_dev *pdev, 
 	 * Initialize locks and queues
 	 */
 	INIT_LIST_HEAD(&instance->cmd_pool);
+	INIT_LIST_HEAD(&instance->internal_reset_pending_q);
 
 	atomic_set(&instance->fw_outstanding,0);
 
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-04-21 05:16:37.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-04-28 08:01:45.000000000 -0400
@@ -1275,10 +1275,12 @@ struct megasas_instance {
 	u8 flag;
 	u8 unload;
 	u8 flag_ieee;
+	u8 issuepend_done;
 	u8 adprecovery;
 	unsigned long last_time;
 
 	struct timer_list io_completion_timer;
+	struct list_head internal_reset_pending_q;
 };
 
 enum {

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

* RE: [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2
  2010-05-26 15:48             ` Tomas Henzl
@ 2010-05-26 21:08               ` Yang, Bo
  2010-05-28 13:31                 ` Tomas Henzl
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-05-26 21:08 UTC (permalink / raw)
  To: Tomas Henzl, James Bottomley
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2218 bytes --]

Tomas/James,

> Also descriptive subjects would be nice (parts I-III may do well for
> Lord of the Rings ... it's less useful for SCSI patches).
>   
>This is again a question for the original author. Bo?

I changed the description and resubmit them already.

Bo Yang



-----Original Message-----
From: Tomas Henzl [mailto:thenzl@redhat.com] 
Sent: Wednesday, May 26, 2010 11:48 AM
To: James Bottomley
Cc: Yang, Bo; 'linux-scsi@vger.kernel.org'; 'akpm@osdl.org'; 'linux-kernel@vger.kernel.org'; Daftardar, Jayant
Subject: Re: [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2

On 05/25/2010 07:32 PM, James Bottomley wrote:
> On Tue, 2010-05-25 at 18:17 +0200, Tomas Henzl wrote:
>   
>> V2: I've cleaned up some coding style issues and removed a variable, the functionality shouldn't be changed
>>
>> Tomas
>>
>> If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
>> Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
>> Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   
>>     
> So there's supposed to be a replacement for 3/7 (megaraid_sas - Online
> COntroller Reset (OCR) PART-III) as well, isn't there?
>   
Yes, I think there are some issues that could be removed, on the other side
it is mostly coding style related, so I think it could be accepted as it is.
I hope I could afterwards clean something up. (The patches as they are now don't
apply correctly on my system, it's maybe an issue with my mail reader.)
 

> Also descriptive subjects would be nice (parts I-III may do well for
> Lord of the Rings ... it's less useful for SCSI patches).
>   
This is again a question for the original author. Bo?

Tomas


> James
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2
  2010-05-26 21:08               ` Yang, Bo
@ 2010-05-28 13:31                 ` Tomas Henzl
  0 siblings, 0 replies; 37+ messages in thread
From: Tomas Henzl @ 2010-05-28 13:31 UTC (permalink / raw)
  To: Yang, Bo
  Cc: James Bottomley, 'linux-scsi@vger.kernel.org',
	'akpm@osdl.org', 'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

On 05/26/2010 11:08 PM, Yang, Bo wrote:
> Tomas/James,
>
>   
>> Also descriptive subjects would be nice (parts I-III may do well for
>> Lord of the Rings ... it's less useful for SCSI patches).
>>   
>> This is again a question for the original author. Bo?
>>     
> I changed the description and resubmit them already.
>   
Thanks Bo. I've noticed 
[PATCH 1/7] scsi: megaraid_sas - Online Controller Reset - I: Change the Chips related functions and Add the Chip reset functions
[PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR)-II : Driver return RESET in timeout routine

do you want for the part III to stay with the subject 'Online controller Reset'?


What is more important for me is that in Patch 1/7 you still have spaces instead 
of tabs and the patch can't be applied. The same for patch 3/7. 
You can see the spaces for example here http://www.spinics.net/lists/linux-scsi/msg43842.html

Tomas


> Bo Yang
>
>
>
> -----Original Message-----
> From: Tomas Henzl [mailto:thenzl@redhat.com] 
> Sent: Wednesday, May 26, 2010 11:48 AM
> To: James Bottomley
> Cc: Yang, Bo; 'linux-scsi@vger.kernel.org'; 'akpm@osdl.org'; 'linux-kernel@vger.kernel.org'; Daftardar, Jayant
> Subject: Re: [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2
>
> On 05/25/2010 07:32 PM, James Bottomley wrote:
>   
>> On Tue, 2010-05-25 at 18:17 +0200, Tomas Henzl wrote:
>>   
>>     
>>> V2: I've cleaned up some coding style issues and removed a variable, the functionality shouldn't be changed
>>>
>>> Tomas
>>>
>>> If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
>>> Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
>>> Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   
>>>     
>>>       
>> So there's supposed to be a replacement for 3/7 (megaraid_sas - Online
>> COntroller Reset (OCR) PART-III) as well, isn't there?
>>   
>>     
> Yes, I think there are some issues that could be removed, on the other side
> it is mostly coding style related, so I think it could be accepted as it is.
> I hope I could afterwards clean something up. (The patches as they are now don't
> apply correctly on my system, it's maybe an issue with my mail reader.)
>  
>
>   
>> Also descriptive subjects would be nice (parts I-III may do well for
>> Lord of the Rings ... it's less useful for SCSI patches).
>>   
>>     
> This is again a question for the original author. Bo?
>
> Tomas
>
>
>   
>> James
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>   
>>     
> N�����r��y���b�X��ǧv�^�)޺{.n�+����{���"�{ay�\x1dʇڙ�,j\a��f���h���z�\x1e�w���\f���j:+v���w�j�m����\a����zZ+��ݢj"��!tml=


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

* [PATCH 4/12] scsi: megaraid_sas - Online controller Reset Support (OCR) : Driver return RESET in timeout routine
  2010-05-26 16:35         ` [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR)-II : Driver return RESET in timeout routine Yang, Bo
@ 2010-06-10  3:25           ` Yang, Bo
  2010-08-05 20:16             ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-06-10  3:25 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

In this part of the Online Controller Reset (OCR).  When driver doesn't finish to issue the pending
Cmds, driver will return BUSY to OS.  Also in driver's timeout routine, if online controller reset is going
On, driver will return RESET to OS. 

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
megaraid_sas.h |    2 +
 2 files changed, 107 insertions(+), 5 deletions(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-04-21 05:16:37.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-04-28 08:52:56.000000000 -0400
@@ -1320,14 +1320,22 @@ megasas_queue_command(struct scsi_cmnd *
 	u32 frame_count;
 	struct megasas_cmd *cmd;
 	struct megasas_instance *instance;
+	unsigned long flags;
 
 	instance = (struct megasas_instance *)
 	    scmd->device->host->hostdata;
 
-	/* Don't process if we have already declared adapter dead */
-	if (instance->hw_crit_error)
+	if (instance->issuepend_done == 0)
 		return SCSI_MLQUEUE_HOST_BUSY;
 
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
+		return SCSI_MLQUEUE_HOST_BUSY;
+	}
+
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+
 	scmd->scsi_done = done;
 	scmd->result = 0;
 
@@ -1463,6 +1471,18 @@ static int megasas_slave_alloc(struct sc
 	return 0;
 }
 
+static void megaraid_sas_kill_hba(struct megasas_instance *instance)
+{
+	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
+		(instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) {
+		writel(MFI_STOP_ADP,
+			&instance->reg_set->reserved_0[0]);
+	} else {
+		writel(MFI_STOP_ADP,
+			&instance->reg_set->inbound_doorbell);
+	}
+}
+
 /**
  * megasas_complete_cmd_dpc	 -	Returns FW's controller structure
  * @instance_addr:			Address of adapter soft state
@@ -1480,7 +1500,7 @@ static void megasas_complete_cmd_dpc(uns
 	unsigned long flags;
 
 	/* If we have already declared adapter dead, donot complete cmds */
-	if (instance->hw_crit_error)
+	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR )
 		return;
 
 	spin_lock_irqsave(&instance->completion_lock, flags);
@@ -1490,6 +1510,11 @@ static void megasas_complete_cmd_dpc(uns
 
 	while (consumer != producer) {
 		context = instance->reply_queue[consumer];
+		if (context >= instance->max_fw_cmds) {
+			printk(KERN_ERR "Unexpected context value %x\n",
+				context);
+			BUG();
+		}
 
 		cmd = instance->cmd_list[context];
 
@@ -1539,7 +1564,76 @@ static void megasas_complete_cmd_dpc(uns
 static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 {
 	int i;
+	u32 reset_index;
 	u32 wait_time = MEGASAS_RESET_WAIT_TIME;
+	u8 adprecovery;
+	unsigned long flags;
+	struct list_head clist_local;
+	struct megasas_cmd *reset_cmd;
+
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	adprecovery = instance->adprecovery;
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+	if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
+
+		INIT_LIST_HEAD(&clist_local);
+		spin_lock_irqsave(&instance->hba_lock, flags);
+		list_splice_init(&instance->internal_reset_pending_q,
+				&clist_local);
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+		printk(KERN_NOTICE "megasas: HBA reset wait ...\n");
+		for (i = 0; i < wait_time; i++) {
+			msleep(1000);
+			spin_lock_irqsave(&instance->hba_lock, flags);
+			adprecovery = instance->adprecovery;
+			spin_unlock_irqrestore(&instance->hba_lock, flags);
+			if (adprecovery == MEGASAS_HBA_OPERATIONAL)
+				break;
+		}
+
+		if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
+			printk(KERN_NOTICE "megasas: reset: Stopping HBA.\n");
+			spin_lock_irqsave(&instance->hba_lock, flags);
+			instance->adprecovery	= MEGASAS_HW_CRITICAL_ERROR;
+			spin_unlock_irqrestore(&instance->hba_lock, flags);
+			return FAILED;
+		}
+
+		reset_index	= 0;
+		while (!list_empty(&clist_local)) {
+			reset_cmd	= list_entry((&clist_local)->next,
+						struct megasas_cmd, list);
+			list_del_init(&reset_cmd->list);
+			if (reset_cmd->scmd) {
+				reset_cmd->scmd->result = DID_RESET << 16;
+				printk(KERN_NOTICE "%d:%p reset [%02x], %#lx\n",
+					reset_index, reset_cmd,
+					reset_cmd->scmd->cmnd[0],
+					reset_cmd->scmd->serial_number);
+
+				reset_cmd->scmd->scsi_done(reset_cmd->scmd);
+				megasas_return_cmd(instance, reset_cmd);
+			} else if (reset_cmd->sync_cmd) {
+				printk(KERN_NOTICE "megasas:%p synch cmds"
+						"reset queue\n",
+						reset_cmd);
+
+				reset_cmd->cmd_status = ENODATA;
+				instance->instancet->fire_cmd(instance,
+						reset_cmd->frame_phys_addr,
+						0, instance->reg_set);
+			} else {
+				printk(KERN_NOTICE "megasas: %p unexpected"
+					"cmds lst\n",
+					reset_cmd);
+			}
+			reset_index++;
+		}
+
+		return SUCCESS;
+	}
 
 	for (i = 0; i < wait_time; i++) {
 
@@ -1562,6 +1656,7 @@ static int megasas_wait_for_outstanding(
 	}
 
 	if (atomic_read(&instance->fw_outstanding)) {
+		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds.
 		* The controller will be taken offline by the OS now.
@@ -1577,10 +1672,14 @@ static int megasas_wait_for_outstanding(
 				&instance->reg_set->inbound_doorbell);
 		}
 		megasas_dump_pending_frames(instance);
-		instance->hw_crit_error = 1;
+		spin_lock_irqsave(&instance->hba_lock, flags);
+		instance->adprecovery	= MEGASAS_HW_CRITICAL_ERROR;
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
 		return FAILED;
 	}
 
+	printk(KERN_NOTICE "megaraid_sas: no pending cmds after reset\n");
+
 	return SUCCESS;
 }
 
@@ -1602,7 +1701,7 @@ static int megasas_generic_reset(struct 
 	scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x retries=%x\n",
 		 scmd->serial_number, scmd->cmnd[0], scmd->retries);
 
-	if (instance->hw_crit_error) {
+	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
 		printk(KERN_ERR "megasas: cannot recover from previous reset "
 		       "failures\n");
 		return FAILED;
@@ -3319,6 +3418,7 @@ megasas_probe_one(struct pci_dev *pdev, 
 	 * Initialize locks and queues
 	 */
 	INIT_LIST_HEAD(&instance->cmd_pool);
+	INIT_LIST_HEAD(&instance->internal_reset_pending_q);
 
 	atomic_set(&instance->fw_outstanding,0);
 
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-04-21 05:16:37.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-04-28 08:01:45.000000000 -0400
@@ -1275,10 +1275,12 @@ struct megasas_instance {
 	u8 flag;
 	u8 unload;
 	u8 flag_ieee;
+	u8 issuepend_done;
 	u8 adprecovery;
 	unsigned long last_time;
 
 	struct timer_list io_completion_timer;
+	struct list_head internal_reset_pending_q;
 };
 
 enum {

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

* [PATCH 9/12] scsi: megaraid_sas - support devices update flag
  2010-05-06 16:04       ` [PATCH 4/7] scsi: megaraid_sas - support devices update flag Yang, Bo
@ 2010-06-10  4:16         ` Yang, Bo
  2010-06-18 21:05           ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-06-10  4:16 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

Driver added the Device update flag to tell LSI application driver will do the device
Update.  LSI MegaRAID SAS application will check this flag to decide if it is need to
update the Device or not. 

Signed-off-by Bo Yang<bo.yang@lsi.com>

--- 
megaraid_sas.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 03:50:44.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 05:46:37.000000000 -0400
@@ -99,6 +99,7 @@ static int megasas_poll_wait_aen;
 static DECLARE_WAIT_QUEUE_HEAD(megasas_poll_wait);
 static u32 support_poll_for_event;
 static u32 megasas_dbg_lvl;
+static u32 support_device_change;
 
 /* define lock for aen poll */
 spinlock_t poll_aen_lock;
@@ -4660,6 +4661,15 @@ megasas_sysfs_show_support_poll_for_even
 static DRIVER_ATTR(support_poll_for_event, S_IRUGO,
 			megasas_sysfs_show_support_poll_for_event, NULL);
 
+ static ssize_t
+megasas_sysfs_show_support_device_change(struct device_driver *dd, char *buf)
+{
+	return sprintf(buf, "%u\n", support_device_change);
+}
+
+static DRIVER_ATTR(support_device_change, S_IRUGO,
+			megasas_sysfs_show_support_device_change, NULL);
+
 static ssize_t
 megasas_sysfs_show_dbg_lvl(struct device_driver *dd, char *buf)
 {
@@ -4980,6 +4990,7 @@ static int __init megasas_init(void)
 	       MEGASAS_EXT_VERSION);
 
 	support_poll_for_event = 2;
+	support_device_change = 1;
 
 	memset(&megasas_mgmt_info, 0, sizeof(megasas_mgmt_info));
 
@@ -5028,8 +5039,17 @@ static int __init megasas_init(void)
 	if (rval)
 		goto err_dcf_poll_mode_io;
 
+	rval = driver_create_file(&megasas_pci_driver.driver,
+				&driver_attr_support_device_change);
+	if (rval)
+		goto err_dcf_support_device_change;
+
 	return rval;
 
+err_dcf_support_device_change:
+	driver_remove_file(&megasas_pci_driver.driver,
+		  &driver_attr_poll_mode_io);
+
 err_dcf_poll_mode_io:
 	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_dbg_lvl);
@@ -5060,6 +5080,10 @@ static void __exit megasas_exit(void)
 	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_dbg_lvl);
 	driver_remove_file(&megasas_pci_driver.driver,
+			&driver_attr_support_poll_for_event);
+	driver_remove_file(&megasas_pci_driver.driver,
+			&driver_attr_support_device_change);
+	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_release_date);
 	driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version);



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

* [PATCH 11/12] scsi: megaraid_sas - Add three times Online controller reset
  2010-05-06 16:34       ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
  2010-05-25 16:17         ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2 Tomas Henzl
@ 2010-06-10  4:21         ` Yang, Bo
  2010-06-18 21:11           ` Yang, Bo
  1 sibling, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-06-10  4:21 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-05-04 14:32:49.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-05-04 15:07:26.000000000 -0400
@@ -1569,6 +1569,28 @@ static void megasas_complete_cmd_dpc(uns
 	}
 }
 
+static void
+megasas_internal_reset_defer_cmds(struct megasas_instance *instance);
+
+static void
+process_fw_state_change_wq(struct work_struct *work);
+
+void megasas_do_ocr(struct megasas_instance *instance)
+{
+	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) ||
+	(instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) ||
+	(instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)) {
+		*instance->consumer     = MEGASAS_ADPRESET_INPROG_SIGN;
+	}
+	instance->instancet->disable_intr(instance->reg_set);
+	instance->adprecovery   = MEGASAS_ADPRESET_SM_INFAULT;
+	instance->issuepend_done = 0;
+
+	atomic_set(&instance->fw_outstanding, 0);
+	megasas_internal_reset_defer_cmds(instance);
+	process_fw_state_change_wq(&instance->work_init);
+}
+
 /**
  * megasas_wait_for_outstanding -	Wait for all outstanding cmds
  * @instance:				Adapter soft state
@@ -1586,6 +1608,8 @@ static int megasas_wait_for_outstanding(
 	unsigned long flags;
 	struct list_head clist_local;
 	struct megasas_cmd *reset_cmd;
+	u32 fw_state;
+	u8 kill_adapter_flag;
 
 	spin_lock_irqsave(&instance->hba_lock, flags);
 	adprecovery = instance->adprecovery;
@@ -1671,7 +1695,45 @@ static int megasas_wait_for_outstanding(
 		msleep(1000);
 	}
 
-	if (atomic_read(&instance->fw_outstanding)) {
+	i = 0;
+	kill_adapter_flag = 0;
+	do {
+		fw_state = instance->instancet->read_fw_status_reg(
+					instance->reg_set) & MFI_STATE_MASK;
+		if ((fw_state == MFI_STATE_FAULT) &&
+			(instance->disableOnlineCtrlReset == 0)) {
+			if (i == 3) {
+				kill_adapter_flag = 2;
+				break;
+			}
+			megasas_do_ocr(instance);
+			kill_adapter_flag = 1;
+
+			/* wait for 1 secs to let FW finish the pending cmds */
+			msleep(1000);
+		}
+		i++;
+	} while (i <= 3);
+
+	if (atomic_read(&instance->fw_outstanding) &&
+					!kill_adapter_flag) {
+		if (instance->disableOnlineCtrlReset == 0) {
+
+			megasas_do_ocr(instance);
+
+			/* wait for 5 secs to let FW finish the pending cmds */
+			for (i = 0; i < wait_time; i++) {
+				int outstanding =
+					atomic_read(&instance->fw_outstanding);
+				if (!outstanding)
+					return SUCCESS;
+				msleep(1000);
+			}
+		}
+	}
+
+	if (atomic_read(&instance->fw_outstanding) ||
+					(kill_adapter_flag == 2)) {
 		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds. 

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

* [PATCH 12/12] scsi: megaraid_sas - Version and documentation update
  2010-05-06 16:37       ` [PATCH 7/7] scsi: megaraid_sas - Version and documentation update Yang, Bo
@ 2010-06-10  4:22         ` Yang, Bo
  2010-06-18 21:13           ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-06-10  4:22 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

Update the version and documentation.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
Documentation/scsi/ChangeLog.megaraid_sas |   42 ++++++++++++++++++++++++++++++
drivers/scsi/megaraid/megaraid_sas.h      |    6 ++--
 2 files changed, 45 insertions(+), 3 deletions(-)

diff -rupN old/Documentation/scsi/ChangeLog.megaraid_sas new/Documentation/scsi/ChangeLog.megaraid_sas
--- old/Documentation/scsi/ChangeLog.megaraid_sas	2010-05-05 02:08:10.000000000 -0400
+++ new/Documentation/scsi/ChangeLog.megaraid_sas	2010-05-05 04:54:38.000000000 -0400
@@ -1,3 +1,45 @@
+1 Release Date    : Thur.  May 03, 2010 09:12:45 PST 2009 -
+			(emaild-id:megaraidlinux@lsi.com)
+			Bo Yang
+
+2 Current Version : 00.00.04.30-rc1
+3 Older Version   : 00.00.04.17.1-rc1
+
+1.	Add the Online Controller Reset (OCR) to the Driver.
+	OCR is the new feature for megaraid_sas driver which
+	will allow the fw to do the chip reset which will not
+	affact the OS hbhavious.
+
+	To add the OCR support, driver need to do: 
+		a). reset the controller chip -- Xscale and Gen2.
+		
+		b). during the reset, driver will store the pending
+		cmds to pending queue.
+		
+		c). Also in driver's timeout routine, driver will
+		report to OS as reset.
+		
+		d). in Driver's ISR routine, if driver get the FW
+		state as state change and FW in Failure status,
+		driver will start to do the controller reset.
+		
+		e). If driver goes to timeout, but driver is in
+		operational status, driver will check if fw in failed
+		status, if yes, driver will do OCR to FW upto three times.
+		
+		f). Before driver kill adapter, driver will do last chance of
+		OCR to see if driver can bring back the FW.      
+
+2.	Add the CTIO support to the driver.
+3.	Add the support update flag to the driver to tell LSI megaraid_sas
+	application which driver will support the device update.  So application
+	will not need to do the device update after application add/del the device
+	from the system.
+
+4.	Add the input parameter max_sectors to 1MB support to our GEN2 controller.
+	customer can use the input paramenter max_sectors to add 1MB support to GEN2
+	controller.
+
 1 Release Date    : Thur.  Oct 29, 2009 09:12:45 PST 2009 -
 			(emaild-id:megaraidlinux@lsi.com)
 			Bo Yang
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-05-05 01:55:42.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-05-05 02:35:16.000000000 -0400
@@ -18,9 +18,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION			"00.00.04.17.1-rc1"
-#define MEGASAS_RELDATE			"Oct. 29, 2009"
-#define MEGASAS_EXT_VERSION		"Thu. Oct. 29, 11:41:51 PST 2009"
+#define MEGASAS_VERSION			"00.00.04.30-rc1"
+#define MEGASAS_RELDATE			"May 3, 2010"
+#define MEGASAS_EXT_VERSION		"Mon. May 3, 11:41:51 PST 2010"
 
 /*
  * Device IDs

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

* [PATCH 9/12] scsi: megaraid_sas - support devices update flag
  2010-06-10  4:16         ` [PATCH 9/12] " Yang, Bo
@ 2010-06-18 21:05           ` Yang, Bo
  2010-08-05 20:28             ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-06-18 21:05 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

RESUBMIT:
Driver added the Device update flag to tell LSI application driver will do the device
Update.  LSI MegaRAID SAS application will check this flag to decide if it is need to
update the Device or not. 

Signed-off-by Bo Yang<bo.yang@lsi.com>

--- 
drivers/scsi/megaraid/megaraid_sas.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 03:50:44.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 05:46:37.000000000 -0400
@@ -99,6 +99,7 @@ static int megasas_poll_wait_aen;
 static DECLARE_WAIT_QUEUE_HEAD(megasas_poll_wait);
 static u32 support_poll_for_event;
 static u32 megasas_dbg_lvl;
+static u32 support_device_change;
 
 /* define lock for aen poll */
 spinlock_t poll_aen_lock;
@@ -4660,6 +4661,15 @@ megasas_sysfs_show_support_poll_for_even
 static DRIVER_ATTR(support_poll_for_event, S_IRUGO,
 			megasas_sysfs_show_support_poll_for_event, NULL);
 
+ static ssize_t
+megasas_sysfs_show_support_device_change(struct device_driver *dd, char *buf)
+{
+	return sprintf(buf, "%u\n", support_device_change);
+}
+
+static DRIVER_ATTR(support_device_change, S_IRUGO,
+			megasas_sysfs_show_support_device_change, NULL);
+
 static ssize_t
 megasas_sysfs_show_dbg_lvl(struct device_driver *dd, char *buf)
 {
@@ -4980,6 +4990,7 @@ static int __init megasas_init(void)
 	       MEGASAS_EXT_VERSION);
 
 	support_poll_for_event = 2;
+	support_device_change = 1;
 
 	memset(&megasas_mgmt_info, 0, sizeof(megasas_mgmt_info));
 
@@ -5028,8 +5039,17 @@ static int __init megasas_init(void)
 	if (rval)
 		goto err_dcf_poll_mode_io;
 
+	rval = driver_create_file(&megasas_pci_driver.driver,
+				&driver_attr_support_device_change);
+	if (rval)
+		goto err_dcf_support_device_change;
+
 	return rval;
 
+err_dcf_support_device_change:
+	driver_remove_file(&megasas_pci_driver.driver,
+		  &driver_attr_poll_mode_io);
+
 err_dcf_poll_mode_io:
 	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_dbg_lvl);
@@ -5060,6 +5080,10 @@ static void __exit megasas_exit(void)
 	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_dbg_lvl);
 	driver_remove_file(&megasas_pci_driver.driver,
+			&driver_attr_support_poll_for_event);
+	driver_remove_file(&megasas_pci_driver.driver,
+			&driver_attr_support_device_change);
+	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_release_date);
 	driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version);


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

* [PATCH 11/12] scsi: megaraid_sas - Add three times Online controller reset
  2010-06-10  4:21         ` [PATCH 11/12] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
@ 2010-06-18 21:11           ` Yang, Bo
  2010-08-05 20:35             ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-06-18 21:11 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

RESUBMIT:

If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
drivers/scsi/megaraid/megaraid_sas.c |   66 ++++++++++++++++++++++++++++++++++-
 1 file changed, 65 insertions(+), 1 deletion(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-06-17 07:51:23.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-06-17 09:09:07.000000000 -0400
@@ -942,6 +942,7 @@ megasas_make_sgl_skinny(struct megasas_i
 			mfi_sgl->sge_skinny[i].length = sg_dma_len(os_sgl);
 			mfi_sgl->sge_skinny[i].phys_addr =
 						sg_dma_address(os_sgl);
+			mfi_sgl->sge_skinny[i].flag = 0;
 		}
 	}
 	return sge_count;
@@ -1569,6 +1570,28 @@ static void megasas_complete_cmd_dpc(uns
 	}
 }
 
+static void
+megasas_internal_reset_defer_cmds(struct megasas_instance *instance);
+
+static void
+process_fw_state_change_wq(struct work_struct *work);
+
+void megasas_do_ocr(struct megasas_instance *instance)
+{
+	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) ||
+	(instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) ||
+	(instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)) {
+		*instance->consumer     = MEGASAS_ADPRESET_INPROG_SIGN;
+	}
+	instance->instancet->disable_intr(instance->reg_set);
+	instance->adprecovery   = MEGASAS_ADPRESET_SM_INFAULT;
+	instance->issuepend_done = 0;
+
+	atomic_set(&instance->fw_outstanding, 0);
+	megasas_internal_reset_defer_cmds(instance);
+	process_fw_state_change_wq(&instance->work_init);
+}
+
 /**
  * megasas_wait_for_outstanding -	Wait for all outstanding cmds
  * @instance:				Adapter soft state
@@ -1586,6 +1609,8 @@ static int megasas_wait_for_outstanding(
 	unsigned long flags;
 	struct list_head clist_local;
 	struct megasas_cmd *reset_cmd;
+	u32 fw_state;
+	u8 kill_adapter_flag;
 
 	spin_lock_irqsave(&instance->hba_lock, flags);
 	adprecovery = instance->adprecovery;
@@ -1671,7 +1696,45 @@ static int megasas_wait_for_outstanding(
 		msleep(1000);
 	}
 
-	if (atomic_read(&instance->fw_outstanding)) {
+	i = 0;
+	kill_adapter_flag = 0;
+	do {
+		fw_state = instance->instancet->read_fw_status_reg(
+					instance->reg_set) & MFI_STATE_MASK;
+		if ((fw_state == MFI_STATE_FAULT) &&
+			(instance->disableOnlineCtrlReset == 0)) {
+			if (i == 3) {
+				kill_adapter_flag = 2;
+				break;
+			}
+			megasas_do_ocr(instance);
+			kill_adapter_flag = 1;
+
+			/* wait for 1 secs to let FW finish the pending cmds */
+			msleep(1000);
+		}
+		i++;
+	} while (i <= 3);
+
+	if (atomic_read(&instance->fw_outstanding) &&
+					!kill_adapter_flag) {
+		if (instance->disableOnlineCtrlReset == 0) {
+
+			megasas_do_ocr(instance);
+
+			/* wait for 5 secs to let FW finish the pending cmds */
+			for (i = 0; i < wait_time; i++) {
+				int outstanding =
+					atomic_read(&instance->fw_outstanding);
+				if (!outstanding)
+					return SUCCESS;
+				msleep(1000);
+			}
+		}
+	}
+
+	if (atomic_read(&instance->fw_outstanding) ||
+					(kill_adapter_flag == 2)) {
 		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds.
@@ -2681,6 +2744,7 @@ static int megasas_create_frame_pool(str
 			return -ENOMEM;
 		}
 
+		memset(cmd->frame, 0, total_sz);
 		cmd->frame->io.context = cmd->index;
 		cmd->frame->io.pad_0 = 0;
 	}

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

* [PATCH 12/12] scsi: megaraid_sas - Version and documentation update
  2010-06-10  4:22         ` [PATCH 12/12] " Yang, Bo
@ 2010-06-18 21:13           ` Yang, Bo
  2010-08-05 20:38             ` Yang, Bo
  0 siblings, 1 reply; 37+ messages in thread
From: Yang, Bo @ 2010-06-18 21:13 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

RESUBMIT:

Update the version and documentation.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
Documentation/scsi/ChangeLog.megaraid_sas |   42 ++++++++++++++++++++++++++++++
 drivers/scsi/megaraid/megaraid_sas.h      |    6 ++--
 2 files changed, 45 insertions(+), 3 deletions(-)

diff -rupN old/Documentation/scsi/ChangeLog.megaraid_sas new/Documentation/scsi/ChangeLog.megaraid_sas
--- old/Documentation/scsi/ChangeLog.megaraid_sas	2010-06-17 07:51:22.000000000 -0400
+++ new/Documentation/scsi/ChangeLog.megaraid_sas	2010-06-17 07:51:22.000000000 -0400
@@ -1,3 +1,45 @@
+1 Release Date    : Thur.  May 03, 2010 09:12:45 PST 2009 -
+			(emaild-id:megaraidlinux@lsi.com)
+			Bo Yang
+
+2 Current Version : 00.00.04.30-rc1
+3 Older Version   : 00.00.04.17.1-rc1
+
+1.	Add the Online Controller Reset (OCR) to the Driver.
+	OCR is the new feature for megaraid_sas driver which
+	will allow the fw to do the chip reset which will not
+	affact the OS hbhavious.
+
+	To add the OCR support, driver need to do: 
+		a). reset the controller chip -- Xscale and Gen2.
+		
+		b). during the reset, driver will store the pending
+		cmds to pending queue.
+		
+		c). Also in driver's timeout routine, driver will
+		report to OS as reset.
+		
+		d). in Driver's ISR routine, if driver get the FW
+		state as state change and FW in Failure status,
+		driver will start to do the controller reset.
+		
+		e). If driver goes to timeout, but driver is in
+		operational status, driver will check if fw in failed
+		status, if yes, driver will do OCR to FW upto three times.
+		
+		f). Before driver kill adapter, driver will do last chance of
+		OCR to see if driver can bring back the FW.      
+
+2.	Add the CTIO support to the driver.
+3.	Add the support update flag to the driver to tell LSI megaraid_sas
+	application which driver will support the device update.  So application
+	will not need to do the device update after application add/del the device
+	from the system.
+
+4.	Add the input parameter max_sectors to 1MB support to our GEN2 controller.
+	customer can use the input paramenter max_sectors to add 1MB support to GEN2
+	controller.
+
 1 Release Date    : Thur.  Oct 29, 2009 09:12:45 PST 2009 -
 			(emaild-id:megaraidlinux@lsi.com)
 			Bo Yang
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-06-17 09:10:24.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-06-17 09:06:18.000000000 -0400
@@ -18,9 +18,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION			"00.00.04.17.1-rc1"
-#define MEGASAS_RELDATE			"Oct. 29, 2009"
-#define MEGASAS_EXT_VERSION		"Thu. Oct. 29, 11:41:51 PST 2009"
+#define MEGASAS_VERSION			"00.00.04.31-rc1"
+#define MEGASAS_RELDATE			"May 3, 2010"
+#define MEGASAS_EXT_VERSION		"Mon. May 3, 11:41:51 PST 2010"
 
 /*
  * Device IDs

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

* [PATCH 4/12] scsi: megaraid_sas - Online controller Reset Support (OCR) : Driver return RESET in timeout routine
  2010-06-10  3:25           ` [PATCH 4/12] scsi: megaraid_sas - Online controller Reset Support (OCR) " Yang, Bo
@ 2010-08-05 20:16             ` Yang, Bo
  0 siblings, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2010-08-05 20:16 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

Re-Submitted requested by James Bottomley.

In this part of the Online Controller Reset (OCR).  When driver doesn't finish to issue the pending
Cmds, driver will return BUSY to OS.  Also in driver's timeout routine, if online controller reset is going
On, driver will return RESET to OS. 

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
megaraid_sas.c |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
megaraid_sas.h |    2 +
 2 files changed, 107 insertions(+), 5 deletions(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-04-21 05:16:37.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-04-28 08:52:56.000000000 -0400
@@ -1320,14 +1320,22 @@ megasas_queue_command(struct scsi_cmnd *
 	u32 frame_count;
 	struct megasas_cmd *cmd;
 	struct megasas_instance *instance;
+	unsigned long flags;
 
 	instance = (struct megasas_instance *)
 	    scmd->device->host->hostdata;
 
-	/* Don't process if we have already declared adapter dead */
-	if (instance->hw_crit_error)
+	if (instance->issuepend_done == 0)
 		return SCSI_MLQUEUE_HOST_BUSY;
 
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
+		return SCSI_MLQUEUE_HOST_BUSY;
+	}
+
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+
 	scmd->scsi_done = done;
 	scmd->result = 0;
 
@@ -1463,6 +1471,18 @@ static int megasas_slave_alloc(struct sc
 	return 0;
 }
 
+static void megaraid_sas_kill_hba(struct megasas_instance *instance)
+{
+	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
+		(instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) {
+		writel(MFI_STOP_ADP,
+			&instance->reg_set->reserved_0[0]);
+	} else {
+		writel(MFI_STOP_ADP,
+			&instance->reg_set->inbound_doorbell);
+	}
+}
+
 /**
  * megasas_complete_cmd_dpc	 -	Returns FW's controller structure
  * @instance_addr:			Address of adapter soft state
@@ -1480,7 +1500,7 @@ static void megasas_complete_cmd_dpc(uns
 	unsigned long flags;
 
 	/* If we have already declared adapter dead, donot complete cmds */
-	if (instance->hw_crit_error)
+	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR )
 		return;
 
 	spin_lock_irqsave(&instance->completion_lock, flags);
@@ -1490,6 +1510,11 @@ static void megasas_complete_cmd_dpc(uns
 
 	while (consumer != producer) {
 		context = instance->reply_queue[consumer];
+		if (context >= instance->max_fw_cmds) {
+			printk(KERN_ERR "Unexpected context value %x\n",
+				context);
+			BUG();
+		}
 
 		cmd = instance->cmd_list[context];
 
@@ -1539,7 +1564,76 @@ static void megasas_complete_cmd_dpc(uns
 static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 {
 	int i;
+	u32 reset_index;
 	u32 wait_time = MEGASAS_RESET_WAIT_TIME;
+	u8 adprecovery;
+	unsigned long flags;
+	struct list_head clist_local;
+	struct megasas_cmd *reset_cmd;
+
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	adprecovery = instance->adprecovery;
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+	if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
+
+		INIT_LIST_HEAD(&clist_local);
+		spin_lock_irqsave(&instance->hba_lock, flags);
+		list_splice_init(&instance->internal_reset_pending_q,
+				&clist_local);
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
+
+		printk(KERN_NOTICE "megasas: HBA reset wait ...\n");
+		for (i = 0; i < wait_time; i++) {
+			msleep(1000);
+			spin_lock_irqsave(&instance->hba_lock, flags);
+			adprecovery = instance->adprecovery;
+			spin_unlock_irqrestore(&instance->hba_lock, flags);
+			if (adprecovery == MEGASAS_HBA_OPERATIONAL)
+				break;
+		}
+
+		if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
+			printk(KERN_NOTICE "megasas: reset: Stopping HBA.\n");
+			spin_lock_irqsave(&instance->hba_lock, flags);
+			instance->adprecovery	= MEGASAS_HW_CRITICAL_ERROR;
+			spin_unlock_irqrestore(&instance->hba_lock, flags);
+			return FAILED;
+		}
+
+		reset_index	= 0;
+		while (!list_empty(&clist_local)) {
+			reset_cmd	= list_entry((&clist_local)->next,
+						struct megasas_cmd, list);
+			list_del_init(&reset_cmd->list);
+			if (reset_cmd->scmd) {
+				reset_cmd->scmd->result = DID_RESET << 16;
+				printk(KERN_NOTICE "%d:%p reset [%02x], %#lx\n",
+					reset_index, reset_cmd,
+					reset_cmd->scmd->cmnd[0],
+					reset_cmd->scmd->serial_number);
+
+				reset_cmd->scmd->scsi_done(reset_cmd->scmd);
+				megasas_return_cmd(instance, reset_cmd);
+			} else if (reset_cmd->sync_cmd) {
+				printk(KERN_NOTICE "megasas:%p synch cmds"
+						"reset queue\n",
+						reset_cmd);
+
+				reset_cmd->cmd_status = ENODATA;
+				instance->instancet->fire_cmd(instance,
+						reset_cmd->frame_phys_addr,
+						0, instance->reg_set);
+			} else {
+				printk(KERN_NOTICE "megasas: %p unexpected"
+					"cmds lst\n",
+					reset_cmd);
+			}
+			reset_index++;
+		}
+
+		return SUCCESS;
+	}
 
 	for (i = 0; i < wait_time; i++) {
 
@@ -1562,6 +1656,7 @@ static int megasas_wait_for_outstanding(
 	}
 
 	if (atomic_read(&instance->fw_outstanding)) {
+		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds.
 		* The controller will be taken offline by the OS now.
@@ -1577,10 +1672,14 @@ static int megasas_wait_for_outstanding(
 				&instance->reg_set->inbound_doorbell);
 		}
 		megasas_dump_pending_frames(instance);
-		instance->hw_crit_error = 1;
+		spin_lock_irqsave(&instance->hba_lock, flags);
+		instance->adprecovery	= MEGASAS_HW_CRITICAL_ERROR;
+		spin_unlock_irqrestore(&instance->hba_lock, flags);
 		return FAILED;
 	}
 
+	printk(KERN_NOTICE "megaraid_sas: no pending cmds after reset\n");
+
 	return SUCCESS;
 }
 
@@ -1602,7 +1701,7 @@ static int megasas_generic_reset(struct 
 	scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x retries=%x\n",
 		 scmd->serial_number, scmd->cmnd[0], scmd->retries);
 
-	if (instance->hw_crit_error) {
+	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
 		printk(KERN_ERR "megasas: cannot recover from previous reset "
 		       "failures\n");
 		return FAILED;
@@ -3319,6 +3418,7 @@ megasas_probe_one(struct pci_dev *pdev, 
 	 * Initialize locks and queues
 	 */
 	INIT_LIST_HEAD(&instance->cmd_pool);
+	INIT_LIST_HEAD(&instance->internal_reset_pending_q);
 
 	atomic_set(&instance->fw_outstanding,0);
 
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-04-21 05:16:37.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-04-28 08:01:45.000000000 -0400
@@ -1275,10 +1275,12 @@ struct megasas_instance {
 	u8 flag;
 	u8 unload;
 	u8 flag_ieee;
+	u8 issuepend_done;
 	u8 adprecovery;
 	unsigned long last_time;
 
 	struct timer_list io_completion_timer;
+	struct list_head internal_reset_pending_q;
 };
 
 enum {

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

* [PATCH 9/12] scsi: megaraid_sas - support devices update flag
  2010-06-18 21:05           ` Yang, Bo
@ 2010-08-05 20:28             ` Yang, Bo
  0 siblings, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2010-08-05 20:28 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

RESUBMIT requested by James Bottomley:

Driver added the Device update flag to tell LSI application driver will do the device
Update.  LSI MegaRAID SAS application will check this flag to decide if it is need to
update the Device or not. 

Signed-off-by Bo Yang<bo.yang@lsi.com>

--- 
drivers/scsi/megaraid/megaraid_sas.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 03:50:44.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-05-03 05:46:37.000000000 -0400
@@ -99,6 +99,7 @@ static int megasas_poll_wait_aen;
 static DECLARE_WAIT_QUEUE_HEAD(megasas_poll_wait);
 static u32 support_poll_for_event;
 static u32 megasas_dbg_lvl;
+static u32 support_device_change;
 
 /* define lock for aen poll */
 spinlock_t poll_aen_lock;
@@ -4660,6 +4661,15 @@ megasas_sysfs_show_support_poll_for_even
 static DRIVER_ATTR(support_poll_for_event, S_IRUGO,
 			megasas_sysfs_show_support_poll_for_event, NULL);
 
+ static ssize_t
+megasas_sysfs_show_support_device_change(struct device_driver *dd, char *buf)
+{
+	return sprintf(buf, "%u\n", support_device_change);
+}
+
+static DRIVER_ATTR(support_device_change, S_IRUGO,
+			megasas_sysfs_show_support_device_change, NULL);
+
 static ssize_t
 megasas_sysfs_show_dbg_lvl(struct device_driver *dd, char *buf)
 {
@@ -4980,6 +4990,7 @@ static int __init megasas_init(void)
 	       MEGASAS_EXT_VERSION);
 
 	support_poll_for_event = 2;
+	support_device_change = 1;
 
 	memset(&megasas_mgmt_info, 0, sizeof(megasas_mgmt_info));
 
@@ -5028,8 +5039,17 @@ static int __init megasas_init(void)
 	if (rval)
 		goto err_dcf_poll_mode_io;
 
+	rval = driver_create_file(&megasas_pci_driver.driver,
+				&driver_attr_support_device_change);
+	if (rval)
+		goto err_dcf_support_device_change;
+
 	return rval;
 
+err_dcf_support_device_change:
+	driver_remove_file(&megasas_pci_driver.driver,
+		  &driver_attr_poll_mode_io);
+
 err_dcf_poll_mode_io:
 	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_dbg_lvl);
@@ -5060,6 +5080,10 @@ static void __exit megasas_exit(void)
 	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_dbg_lvl);
 	driver_remove_file(&megasas_pci_driver.driver,
+			&driver_attr_support_poll_for_event);
+	driver_remove_file(&megasas_pci_driver.driver,
+			&driver_attr_support_device_change);
+	driver_remove_file(&megasas_pci_driver.driver,
 			   &driver_attr_release_date);
 	driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version);


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

* [PATCH 11/12] scsi: megaraid_sas - Add three times Online controller reset
  2010-06-18 21:11           ` Yang, Bo
@ 2010-08-05 20:35             ` Yang, Bo
  0 siblings, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2010-08-05 20:35 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

RESUBMIT requested by James Bottomley:

If fw didn't raise the interrupt with the fw state change to driver and fw goes to failure state, driver
Will check the FW state in driver's timeout routine and issue the reset if need.  Driver will do the OCR upto three
Times until kill adapter.  Also driver will issue OCR before driver kill adapter even if fw in operational state.   

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
drivers/scsi/megaraid/megaraid_sas.c |   70 ++++++++++++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff -rupN old/drivers/scsi/megaraid/megaraid_sas.c new/drivers/scsi/megaraid/megaraid_sas.c
--- old/drivers/scsi/megaraid/megaraid_sas.c	2010-08-04 07:43:30.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.c	2010-08-04 07:44:48.000000000 -0400
@@ -730,6 +730,10 @@ static int
 megasas_check_reset_gen2(struct megasas_instance *instance,
 		struct megasas_register_set __iomem *regs)
 {
+	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
+		return 1;
+	}
+
 	return 0;
 }
 
@@ -942,6 +946,7 @@ megasas_make_sgl_skinny(struct megasas_i
 			mfi_sgl->sge_skinny[i].length = sg_dma_len(os_sgl);
 			mfi_sgl->sge_skinny[i].phys_addr =
 						sg_dma_address(os_sgl);
+			mfi_sgl->sge_skinny[i].flag = 0;
 		}
 	}
 	return sge_count;
@@ -1569,6 +1574,28 @@ static void megasas_complete_cmd_dpc(uns
 	}
 }
 
+static void
+megasas_internal_reset_defer_cmds(struct megasas_instance *instance);
+
+static void
+process_fw_state_change_wq(struct work_struct *work);
+
+void megasas_do_ocr(struct megasas_instance *instance)
+{
+	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) ||
+	(instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) ||
+	(instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)) {
+		*instance->consumer     = MEGASAS_ADPRESET_INPROG_SIGN;
+	}
+	instance->instancet->disable_intr(instance->reg_set);
+	instance->adprecovery   = MEGASAS_ADPRESET_SM_INFAULT;
+	instance->issuepend_done = 0;
+
+	atomic_set(&instance->fw_outstanding, 0);
+	megasas_internal_reset_defer_cmds(instance);
+	process_fw_state_change_wq(&instance->work_init);
+}
+
 /**
  * megasas_wait_for_outstanding -	Wait for all outstanding cmds
  * @instance:				Adapter soft state
@@ -1586,6 +1613,8 @@ static int megasas_wait_for_outstanding(
 	unsigned long flags;
 	struct list_head clist_local;
 	struct megasas_cmd *reset_cmd;
+	u32 fw_state;
+	u8 kill_adapter_flag;
 
 	spin_lock_irqsave(&instance->hba_lock, flags);
 	adprecovery = instance->adprecovery;
@@ -1671,7 +1700,45 @@ static int megasas_wait_for_outstanding(
 		msleep(1000);
 	}
 
-	if (atomic_read(&instance->fw_outstanding)) {
+	i = 0;
+	kill_adapter_flag = 0;
+	do {
+		fw_state = instance->instancet->read_fw_status_reg(
+					instance->reg_set) & MFI_STATE_MASK;
+		if ((fw_state == MFI_STATE_FAULT) &&
+			(instance->disableOnlineCtrlReset == 0)) {
+			if (i == 3) {
+				kill_adapter_flag = 2;
+				break;
+			}
+			megasas_do_ocr(instance);
+			kill_adapter_flag = 1;
+
+			/* wait for 1 secs to let FW finish the pending cmds */
+			msleep(1000);
+		}
+		i++;
+	} while (i <= 3);
+
+	if (atomic_read(&instance->fw_outstanding) &&
+					!kill_adapter_flag) {
+		if (instance->disableOnlineCtrlReset == 0) {
+
+			megasas_do_ocr(instance);
+
+			/* wait for 5 secs to let FW finish the pending cmds */
+			for (i = 0; i < wait_time; i++) {
+				int outstanding =
+					atomic_read(&instance->fw_outstanding);
+				if (!outstanding)
+					return SUCCESS;
+				msleep(1000);
+			}
+		}
+	}
+
+	if (atomic_read(&instance->fw_outstanding) ||
+					(kill_adapter_flag == 2)) {
 		printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
 		/*
 		* Send signal to FW to stop processing any pending cmds.
@@ -2681,6 +2748,7 @@ static int megasas_create_frame_pool(str
 			return -ENOMEM;
 		}
 
+		memset(cmd->frame, 0, total_sz);
 		cmd->frame->io.context = cmd->index;
 		cmd->frame->io.pad_0 = 0;
 	}

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

* [PATCH 12/12] scsi: megaraid_sas - Version and documentation update
  2010-06-18 21:13           ` Yang, Bo
@ 2010-08-05 20:38             ` Yang, Bo
  0 siblings, 0 replies; 37+ messages in thread
From: Yang, Bo @ 2010-08-05 20:38 UTC (permalink / raw)
  To: Yang, Bo, 'James.Bottomley@HansenPartnership.com',
	'James.Bottomley@suse.de'
  Cc: 'linux-scsi@vger.kernel.org', 'akpm@osdl.org',
	'linux-kernel@vger.kernel.org',
	Daftardar, Jayant

RESUBMIT requested by James Bottomley:

Update the version and documentation.

Signed-off-by Bo Yang<bo.yang@lsi.com>

---
Documentation/scsi/ChangeLog.megaraid_sas |   46 ++++++++++++++++++++++++++++++
 drivers/scsi/megaraid/megaraid_sas.h      |    6 +--
 2 files changed, 49 insertions(+), 3 deletions(-)

diff -rupN old/Documentation/scsi/ChangeLog.megaraid_sas new/Documentation/scsi/ChangeLog.megaraid_sas
--- old/Documentation/scsi/ChangeLog.megaraid_sas	2010-08-04 07:48:32.000000000 -0400
+++ new/Documentation/scsi/ChangeLog.megaraid_sas	2010-08-04 07:58:50.000000000 -0400
@@ -1,3 +1,49 @@
+1 Release Date    : Thur.  May 03, 2010 09:12:45 PST 2009 -
+			(emaild-id:megaraidlinux@lsi.com)
+			Bo Yang
+
+2 Current Version : 00.00.04.31-rc1
+3 Older Version   : 00.00.04.17.1-rc1
+
+1.	Add the Online Controller Reset (OCR) to the Driver.
+	OCR is the new feature for megaraid_sas driver which
+	will allow the fw to do the chip reset which will not
+	affact the OS behavious.
+
+	To add the OCR support, driver need to do: 
+		a). reset the controller chips -- Xscale and Gen2 which
+		will change the function calls and add the reset function
+		related to this two chips.
+		
+		b). during the reset, driver will store the pending cmds
+		which not returned by FW to driver's pending queue.  Driver
+		will re-issue those pending cmds again to FW after the OCR
+		finished.
+		
+		c). In driver's timeout routine, driver will report to
+		OS as reset. Also driver's queue routine will block the
+		cmds until the OCR finished.
+		
+		d). in Driver's ISR routine, if driver get the FW state as
+		state change, FW in Failure status and FW support online controller
+		reset (OCR), driver will start to do the controller reset.
+		
+		e). In driver's IOCTL routine, the application cmds will wait for the
+		OCR to finish, then issue the cmds to FW.
+		 
+		f). Before driver kill adapter, driver will do last chance of
+		OCR to see if driver can bring back the FW.      
+
+2.	Add the CTIO support to the driver.
+3.	Add the support update flag to the driver to tell LSI megaraid_sas
+	application which driver will support the device update.  So application
+	will not need to do the device update after application add/del the device
+	from the system.
+
+4.	Add the input parameter max_sectors to 1MB support to our GEN2 controller.
+	customer can use the input paramenter max_sectors to add 1MB support to GEN2
+	controller.
+
 1 Release Date    : Thur.  Oct 29, 2009 09:12:45 PST 2009 -
 			(emaild-id:megaraidlinux@lsi.com)
 			Bo Yang
diff -rupN old/drivers/scsi/megaraid/megaraid_sas.h new/drivers/scsi/megaraid/megaraid_sas.h
--- old/drivers/scsi/megaraid/megaraid_sas.h	2010-08-04 07:52:09.000000000 -0400
+++ new/drivers/scsi/megaraid/megaraid_sas.h	2010-08-04 07:48:32.000000000 -0400
@@ -18,9 +18,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION			"00.00.04.17.1-rc1"
-#define MEGASAS_RELDATE			"Oct. 29, 2009"
-#define MEGASAS_EXT_VERSION		"Thu. Oct. 29, 11:41:51 PST 2009"
+#define MEGASAS_VERSION			"00.00.04.31-rc1"
+#define MEGASAS_RELDATE			"May 3, 2010"
+#define MEGASAS_EXT_VERSION		"Mon. May 3, 11:41:51 PST 2010"
 
 /*
  * Device IDs

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

end of thread, other threads:[~2010-08-05 20:38 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-21  2:21 [PATCH 1/12] scsi: megaraid_sas - tape drive support fix Yang, Bo
2009-09-21  3:40 ` Daniel Walker
2009-09-21 15:22   ` Yang, Bo
2009-09-21 15:57     ` Daniel Walker
2009-09-21 16:04       ` Yang, Bo
2009-10-06 20:12 ` Yang, Bo
2009-12-06 15:24   ` [PATCH 1/4] scsi: megaraid_sas - Zero pad_0 in mfi structure Yang, Bo
2009-12-06 15:30     ` [PATCH 2/4] scsi: megaraid_sas - add the ld list to driver Yang, Bo
2009-12-06 15:39       ` [PATCH 3/4] scsi: megaraid_sas - driver fixed the device update issue Yang, Bo
2009-12-06 15:42       ` [PATCH 4/4] scsi: megaraid_sas - version and documentation update Yang, Bo
     [not found]   ` <3A916D859199814BBB666188F96EB165013979165E@cosmail02.lsi.com>
2010-05-06 14:42     ` [PATCH 1/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-I Yang, Bo
2010-05-06 15:41       ` [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR) PART-II Yang, Bo
2010-05-26 16:35         ` [PATCH 2/7] scsi: megaraid_sas - Online controller Reset Support (OCR)-II : Driver return RESET in timeout routine Yang, Bo
2010-06-10  3:25           ` [PATCH 4/12] scsi: megaraid_sas - Online controller Reset Support (OCR) " Yang, Bo
2010-08-05 20:16             ` Yang, Bo
2010-05-06 15:52       ` [PATCH 3/7] scsi: megaraid_sas - Online COntroller Reset (OCR) PART-III Yang, Bo
2010-05-07 12:54         ` Tomas Henzl
2010-05-18 20:58           ` Yang, Bo
2010-05-06 16:04       ` [PATCH 4/7] scsi: megaraid_sas - support devices update flag Yang, Bo
2010-06-10  4:16         ` [PATCH 9/12] " Yang, Bo
2010-06-18 21:05           ` Yang, Bo
2010-08-05 20:28             ` Yang, Bo
2010-05-06 16:17       ` [PATCH 5/7] scsi: megaraid_sas - Add input parameter for max_sectors Yang, Bo
2010-05-06 16:34       ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
2010-05-25 16:17         ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2 Tomas Henzl
2010-05-25 17:32           ` James Bottomley
2010-05-26 15:48             ` Tomas Henzl
2010-05-26 21:08               ` Yang, Bo
2010-05-28 13:31                 ` Tomas Henzl
2010-06-10  4:21         ` [PATCH 11/12] scsi: megaraid_sas - Add three times Online controller reset Yang, Bo
2010-06-18 21:11           ` Yang, Bo
2010-08-05 20:35             ` Yang, Bo
2010-05-06 16:37       ` [PATCH 7/7] scsi: megaraid_sas - Version and documentation update Yang, Bo
2010-06-10  4:22         ` [PATCH 12/12] " Yang, Bo
2010-06-18 21:13           ` Yang, Bo
2010-08-05 20:38             ` Yang, Bo
2010-05-26 16:25       ` [PATCH 1/7] scsi: megaraid_sas - Online Controller Reset - I: Change the Chips related functions and Add the Chip reset functions Yang, Bo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).