Commit 7edff82d authored by Andrew Vasquez's avatar Andrew Vasquez Committed by James Bottomley

[PATCH] [15/18] qla2xxx: SRB handling cleanup and fixes

  Cleanup qla2x00_eh_wait_on_command() srb_t handling.
Signed-off-by: default avatarAndrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 16c3992f
...@@ -2267,7 +2267,8 @@ typedef struct scsi_qla_host { ...@@ -2267,7 +2267,8 @@ typedef struct scsi_qla_host {
mbx_cmd_t *mcp; mbx_cmd_t *mcp;
unsigned long mbx_cmd_flags; unsigned long mbx_cmd_flags;
#define MBX_INTERRUPT 1 #define MBX_INTERRUPT 1
#define MBX_INTR_WAIT 2 #define MBX_INTR_WAIT 2
#define MBX_UPDATE_FLASH_ACTIVE 3
spinlock_t mbx_reg_lock; /* Mbx Cmd Register Lock */ spinlock_t mbx_reg_lock; /* Mbx Cmd Register Lock */
......
...@@ -882,38 +882,38 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)) ...@@ -882,38 +882,38 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
static int static int
qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd) qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd)
{ {
#define ABORT_WAIT_TIME 10 /* seconds */ #define ABORT_POLLING_PERIOD HZ
#define ABORT_WAIT_TIME ((10 * HZ) / (ABORT_POLLING_PERIOD))
int found = 0; int found = 0;
int done = 0; int done = 0;
srb_t *rp; srb_t *rp = NULL;
struct list_head *list, *temp; struct list_head *list, *temp;
u_long max_wait_time = ABORT_WAIT_TIME; u_long max_wait_time = ABORT_WAIT_TIME;
do { do {
/* Check on done queue */ /* Check on done queue */
if (!found) { spin_lock(&ha->list_lock);
spin_lock(&ha->list_lock); list_for_each_safe(list, temp, &ha->done_queue) {
list_for_each_safe(list, temp, &ha->done_queue) { rp = list_entry(list, srb_t, list);
rp = list_entry(list, srb_t, list);
/* /*
* Found command. Just exit and wait for the * Found command. Just exit and wait for the cmd sent
* cmd sent to OS. * to OS.
*/ */
if (cmd == rp->cmd) { if (cmd == rp->cmd) {
found++; found++;
DEBUG3(printk("%s: found in done " DEBUG3(printk("%s: found in done queue.\n",
"queue.\n", __func__);) __func__);)
break; break;
}
} }
spin_unlock(&ha->list_lock);
} }
spin_unlock(&ha->list_lock);
/* Checking to see if its returned to OS */ /* Complete the cmd right away. */
rp = (srb_t *) CMD_SP(cmd); if (found) {
if (rp == NULL ) { qla2x00_delete_from_done_queue(ha, rp);
sp_put(ha, rp);
done++; done++;
break; break;
} }
...@@ -921,20 +921,14 @@ qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd) ...@@ -921,20 +921,14 @@ qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd)
spin_unlock_irq(ha->host->host_lock); spin_unlock_irq(ha->host->host_lock);
set_current_state(TASK_UNINTERRUPTIBLE); set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(2*HZ); schedule_timeout(ABORT_POLLING_PERIOD);
spin_lock_irq(ha->host->host_lock); spin_lock_irq(ha->host->host_lock);
} while ((max_wait_time--)); } while ((max_wait_time--));
if (done) { if (done)
DEBUG2(printk(KERN_INFO "%s: found cmd=%p.\n", __func__, cmd)); DEBUG2(printk(KERN_INFO "%s: found cmd=%p.\n", __func__, cmd));
} else if (found) {
/* Immediately return command to the mid-layer */
qla2x00_delete_from_done_queue(ha, rp);
sp_put(ha, rp);
done++;
}
return (done); return (done);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment