Skip to contentSkip to conversation

qla4xxx: Wait for device to come online.

PATCH In review Ravi Anand 1 participant 1 message Jan 30, 2010

Subsystems (2)
lore
Share & tools
lore

Ravi Anand

author
#0 lore raw

PATCH 1/11 qla4xxx: Wait for device to come online.

From: Vikas Chaudhary <[email protected]>

Wait upto 10s for device to come online otherwise indicate an error condition.

---
 drivers/scsi/qla4xxx/ql4_def.h |    1 +
 drivers/scsi/qla4xxx/ql4_mbx.c |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
drivers/scsi/qla4xxx/ql4_def.h +1 -0
index 81b5f29..38e261d 100644
@@ -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
drivers/scsi/qla4xxx/ql4_mbx.c +22 -0
index 09d6d4b..37c8fcb 100644
@@ -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("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
 	 */
Signature · 1 line
1.6.0.2