Skip to content

Commit 086c480

Browse files
fthainmartinkpetersen
authored andcommitted
scsi: NCR5380: Handle BSY signal loss during information transfer phases
Improve robustness by checking for a lost BSY signal during the information transfer loop. The status register is being polled anyway, so a BSY check costs nothing. BSY signal loss could be caused by a target error or a kicked plug etc. A bus reset is another possibility but that is already handled and hostdata->connected would be NULL. Tested-by: Stan Johnson <[email protected]> Signed-off-by: Finn Thain <[email protected]> Link: https://lore.kernel.org/r/d253dddaf4d9bc17b8ee02ea2b731d92f25b16f1.1723001788.git.fthain@linux-m68k.org Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 1c71065 commit 086c480

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

drivers/scsi/NCR5380.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,6 @@ static bool NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
12441244
* is in same phase.
12451245
*
12461246
* Also, *phase, *count, *data are modified in place.
1247-
*
1248-
* XXX Note : handling for bus free may be useful.
12491247
*/
12501248

12511249
/*
@@ -1277,8 +1275,8 @@ static int NCR5380_transfer_pio(struct Scsi_Host *instance,
12771275
* valid
12781276
*/
12791277

1280-
if (NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ,
1281-
HZ * can_sleep) < 0)
1278+
if (NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ | SR_BSY,
1279+
SR_REQ | SR_BSY, HZ * can_sleep) < 0)
12821280
break;
12831281

12841282
dsprintk(NDEBUG_HANDSHAKE, instance, "REQ asserted\n");
@@ -1666,9 +1664,6 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance,
16661664
* Side effects : SCSI things happen, the disconnected queue will be
16671665
* modified if a command disconnects, *instance->connected will
16681666
* change.
1669-
*
1670-
* XXX Note : we need to watch for bus free or a reset condition here
1671-
* to recover from an unexpected bus free condition.
16721667
*/
16731668

16741669
static void NCR5380_information_transfer(struct Scsi_Host *instance)
@@ -2009,9 +2004,20 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
20092004
NCR5380_dprint(NDEBUG_ANY, instance);
20102005
} /* switch(phase) */
20112006
} else {
2007+
int err;
2008+
20122009
spin_unlock_irq(&hostdata->lock);
2013-
NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ, HZ);
2010+
err = NCR5380_poll_politely(hostdata, STATUS_REG,
2011+
SR_REQ, SR_REQ, HZ);
20142012
spin_lock_irq(&hostdata->lock);
2013+
2014+
if (err < 0 && hostdata->connected &&
2015+
!(NCR5380_read(STATUS_REG) & SR_BSY)) {
2016+
scmd_printk(KERN_ERR, hostdata->connected,
2017+
"BSY signal lost\n");
2018+
do_reset(instance);
2019+
bus_reset_cleanup(instance);
2020+
}
20152021
}
20162022
}
20172023
}

0 commit comments

Comments
 (0)