public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
To: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org
Cc: David.Carroll@microsemi.com, Gana.Sridaran@microsemi.com,
	Scott.Benesh@microsemi.com, Prasad.Munirathnam@microsemi.com
Subject: [PATCH 11/19] aacraid: Add periodic checks to see IOP reset status
Date: Sun, 7 May 2017 06:34:16 -0700	[thread overview]
Message-ID: <1494164064-17715-12-git-send-email-RaghavaAditya.Renukunta@microsemi.com> (raw)
In-Reply-To: <1494164064-17715-1-git-send-email-RaghavaAditya.Renukunta@microsemi.com>

Added function that waits with a timeout for the ctrl to be up and running
after triggering an IOP reset. Also removed 30 sec sleep as it is not
needed.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aacraid.h |  1 +
 drivers/scsi/aacraid/src.c     | 45 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 993f134..829f3d8 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -2519,6 +2519,7 @@ struct aac_hba_info {
 
 #define	SELF_TEST_FAILED		0x00000004
 #define	MONITOR_PANIC			0x00000020
+#define	KERNEL_BOOTING			0x00000040
 #define	KERNEL_UP_AND_RUNNING		0x00000080
 #define	KERNEL_PANIC			0x00000100
 #define	FLASH_UPD_PENDING		0x00002000
diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
index e8e9178..67185eb 100644
--- a/drivers/scsi/aacraid/src.c
+++ b/drivers/scsi/aacraid/src.c
@@ -694,6 +694,37 @@ static void aac_dump_fw_fib_iop_reset(struct aac_dev *dev)
 			0, 0, 0,  0, 0, 0, NULL, NULL, NULL, NULL, NULL);
 }
 
+static bool aac_is_ctrl_up_and_running(struct aac_dev *dev)
+{
+	bool ctrl_up = true;
+	unsigned long status, start;
+	bool is_up = false;
+
+	start = jiffies;
+	do {
+		schedule();
+		status = src_readl(dev, MUnit.OMR);
+
+		if (status == 0xffffffff)
+			status = 0;
+
+		if (status & KERNEL_BOOTING) {
+			start = jiffies;
+			continue;
+		}
+
+		if (time_after(jiffies, start+HZ*SOFT_RESET_TIME)) {
+			ctrl_up = false;
+			break;
+		}
+
+		is_up = status & KERNEL_UP_AND_RUNNING;
+
+	} while (!is_up);
+
+	return ctrl_up;
+}
+
 static void aac_notify_fw_of_iop_reset(struct aac_dev *dev)
 {
 	aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS, 0, 0, 0, 0, 0, 0, NULL,
@@ -709,8 +740,6 @@ static void aac_send_iop_reset(struct aac_dev *dev)
 	aac_set_intx_mode(dev);
 
 	src_writel(dev, MUnit.IDR, IOP_SRC_RESET_MASK);
-
-	msleep(30000);
 }
 
 static void aac_send_hardware_soft_reset(struct aac_dev *dev)
@@ -726,6 +755,7 @@ static void aac_send_hardware_soft_reset(struct aac_dev *dev)
 static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type)
 {
 	unsigned long status, start;
+	bool is_ctrl_up;
 
 	if (bled < 0)
 		goto invalid_out;
@@ -745,6 +775,16 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type)
 	switch (reset_type) {
 	case IOP_HWSOFT_RESET:
 		aac_send_iop_reset(dev);
+
+		/*
+		 * Creates a delay or wait till up and running comes thru
+		 */
+		is_ctrl_up = aac_is_ctrl_up_and_running(dev);
+		if (!is_ctrl_up)
+			dev_err(&dev->pdev->dev, "IOP reset failed\n");
+		else
+			goto set_startup;
+
 		/*
 		 * Check to see if KERNEL_UP_AND_RUNNING
 		 * Wait for the adapter to be up and running.
@@ -780,6 +820,7 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type)
 	if (src_readl(dev, MUnit.OMR) & KERNEL_PANIC)
 		return -ENODEV;
 
+set_startup:
 	if (startup_timeout < 300)
 		startup_timeout = 300;
 
-- 
2.7.4

  parent reply	other threads:[~2017-05-07 21:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-07 13:34 [PATCH 00/19] aacraid: Patchset with reset rework and misc fixes Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 01/19] aacraid: Remove GFP_DMA for raw srb memory Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 02/19] aacraid: Fix DMAR issues with iommu=pt Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 03/19] aacraid: Added 32 and 64 queue depth for arc natives Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 04/19] aacraid: Set correct Queue Depth for HBA1000 RAW disks Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 05/19] aacraid: Remove reset support from check_health Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 06/19] aacraid: Change wait time for fib completion Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 07/19] aacraid: Log count info of scsi cmds before reset Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 08/19] aacraid: Print ctrl status before eh reset Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 09/19] aacraid: Using single reset mask for IOP reset Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 10/19] aacraid: Rework " Raghava Aditya Renukunta
2017-05-07 13:34 ` Raghava Aditya Renukunta [this message]
2017-05-07 13:34 ` [PATCH 12/19] aacraid: Rework SOFT reset code Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 13/19] aacraid: Rework aac_src_restart Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 14/19] aacraid: Use correct function to get ctrl health Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 15/19] aacraid: Make sure ioctl returns on controller reset Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 16/19] aacraid: Enable ctrl reset for both hba and arc Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 17/19] aacraid : Add reset debugging statements Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 18/19] aacraid: Remove reference to Series-9 Raghava Aditya Renukunta
2017-05-07 13:34 ` [PATCH 19/19] aacraid: Update driver version to 50834 Raghava Aditya Renukunta
2017-05-08 21:16 ` [PATCH 00/19] aacraid: Patchset with reset rework and misc fixes Raghava Aditya Renukunta
  -- strict thread matches above, loose matches on Subject: below --
2017-05-07 11:26 Raghava Aditya Renukunta
2017-05-07 11:26 ` [PATCH 11/19] aacraid: Add periodic checks to see IOP reset status Raghava Aditya Renukunta

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=1494164064-17715-12-git-send-email-RaghavaAditya.Renukunta@microsemi.com \
    --to=raghavaaditya.renukunta@microsemi.com \
    --cc=David.Carroll@microsemi.com \
    --cc=Gana.Sridaran@microsemi.com \
    --cc=Prasad.Munirathnam@microsemi.com \
    --cc=Scott.Benesh@microsemi.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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