public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tomas Henzl <thenzl@redhat.com>
To: "Yang, Bo" <Bo.Yang@lsi.com>
Cc: "'James.Bottomley@HansenPartnership.com'" 
	<James.Bottomley@HansenPartnership.com>,
	"'James.Bottomley@suse.de'" <James.Bottomley@suse.de>,
	"'linux-scsi@vger.kernel.org'" <linux-scsi@vger.kernel.org>,
	"'akpm@osdl.org'" <akpm@osdl.org>,
	"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>,
	"Daftardar, Jayant" <Jayant.Daftardar@lsi.com>
Subject: [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2
Date: Tue, 25 May 2010 18:17:24 +0200	[thread overview]
Message-ID: <4BFBF814.5040202@redhat.com> (raw)
In-Reply-To: <4B6A08C587958942AA3002690DD4F8C3CDB80C32@cosmail02.lsi.com>

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.



  reply	other threads:[~2010-05-25 16:18 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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         ` Tomas Henzl [this message]
2010-05-25 17:32           ` [PATCH 6/7] scsi: megaraid_sas - Add three times Online controller reset - V2 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BFBF814.5040202@redhat.com \
    --to=thenzl@redhat.com \
    --cc=Bo.Yang@lsi.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=James.Bottomley@suse.de \
    --cc=Jayant.Daftardar@lsi.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox