public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Ravi Anand <ravi.anand@qlogic.com>
To: James Bottomley <james.bottomley@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>,
	Linux-SCSI Mailing List <linux-scsi@vger.kernel.org>,
	Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Subject: [PATCH 01/12] qla4xxx: wait for device to come online in reset_lun
Date: Tue, 6 Apr 2010 03:13:33 -0700	[thread overview]
Message-ID: <20100406101333.GH22922@linux-qf4p> (raw)


From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>

wait upto 10s for device to come online otherwise indicating
an error condition.

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Signed-off-by: Ravi Anand <ravi.anand@qlogic.com>
---
 drivers/scsi/qla4xxx/ql4_def.h |    1 +
 drivers/scsi/qla4xxx/ql4_mbx.c |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 81b5f29..38e261d 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -146,6 +146,7 @@
 #define ISNS_DEREG_TOV			5
 
 #define MAX_RESET_HA_RETRIES		2
+#define DEVICE_ONLINE_TOV		10
 
 /*
  * SCSI Request Block structure	 (srb)	that is placed
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 09d6d4b..4d8b3cb 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -679,11 +679,33 @@ int qla4xxx_reset_lun(struct scsi_qla_host * ha, struct ddb_entry * ddb_entry,
 	uint32_t mbox_cmd[MBOX_REG_COUNT];
 	uint32_t mbox_sts[MBOX_REG_COUNT];
 	int status = QLA_SUCCESS;
+	unsigned long wait_online;
 
 	DEBUG2(printk("scsi%ld:%d:%d: lun reset issued\n", ha->host_no,
 		      ddb_entry->os_target_id, lun));
 
 	/*
+	 * If device is not online wait for 10 sec for device to come online.
+	 * else return error
+	 */
+	if (atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) {
+		wait_online = jiffies + (DEVICE_ONLINE_TOV * HZ);
+		while (time_before(jiffies, wait_online)) {
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ);
+			if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE)
+				break;
+		}
+
+		if (atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) {
+			DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Unable to "
+					"reset lun. Device is not online.\n",
+					ha->host_no, __func__));
+			return QLA_ERROR;
+		}
+	}
+
+	/*
 	 * Send lun reset command to ISP, so that the ISP will return all
 	 * outstanding requests with RESET status
 	 */
-- 
1.6.0.2

----- End forwarded message -----

             reply	other threads:[~2010-04-06 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-06 10:13 Ravi Anand [this message]
2010-04-07  3:35 ` [PATCH 01/12] qla4xxx: wait for device to come online in reset_lun Mike Christie

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=20100406101333.GH22922@linux-qf4p \
    --to=ravi.anand@qlogic.com \
    --cc=james.bottomley@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    --cc=vikas.chaudhary@qlogic.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