mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Finn Thain <fthain@linux-m68k.org>
To: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Hannes Reinecke <hare@suse.com>,
	Michael Schmitz <schmitzmic@gmail.com>,
	Ondrej Zary <linux@zary.sk>, Stan Johnson <userm57@yahoo.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 07/11] scsi: NCR5380: Handle BSY signal loss during information transfer phases
Date: Wed, 07 Aug 2024 13:36:28 +1000	[thread overview]
Message-ID: <d253dddaf4d9bc17b8ee02ea2b731d92f25b16f1.1723001788.git.fthain@linux-m68k.org> (raw)
In-Reply-To: <cover.1723001788.git.fthain@linux-m68k.org>

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 <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
---
 drivers/scsi/NCR5380.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 4fcb73b727aa..8a9df2ab9569 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -1244,8 +1244,6 @@ static bool NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
  * is in same phase.
  *
  * Also, *phase, *count, *data are modified in place.
- *
- * XXX Note : handling for bus free may be useful.
  */
 
 /*
@@ -1277,8 +1275,8 @@ static int NCR5380_transfer_pio(struct Scsi_Host *instance,
 		 * valid
 		 */
 
-		if (NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ,
-					  HZ * can_sleep) < 0)
+		if (NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ | SR_BSY,
+					  SR_REQ | SR_BSY, HZ * can_sleep) < 0)
 			break;
 
 		dsprintk(NDEBUG_HANDSHAKE, instance, "REQ asserted\n");
@@ -1666,9 +1664,6 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance,
  * Side effects : SCSI things happen, the disconnected queue will be
  * modified if a command disconnects, *instance->connected will
  * change.
- *
- * XXX Note : we need to watch for bus free or a reset condition here
- * to recover from an unexpected bus free condition.
  */
 
 static void NCR5380_information_transfer(struct Scsi_Host *instance)
@@ -2009,9 +2004,20 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
 				NCR5380_dprint(NDEBUG_ANY, instance);
 			} /* switch(phase) */
 		} else {
+			int err;
+
 			spin_unlock_irq(&hostdata->lock);
-			NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ, HZ);
+			err = NCR5380_poll_politely(hostdata, STATUS_REG,
+						    SR_REQ, SR_REQ, HZ);
 			spin_lock_irq(&hostdata->lock);
+
+			if (err < 0 && hostdata->connected &&
+			    !(NCR5380_read(STATUS_REG) & SR_BSY)) {
+				scmd_printk(KERN_ERR, hostdata->connected,
+					    "BSY signal lost\n");
+				do_reset(instance);
+				bus_reset_cleanup(instance);
+			}
 		}
 	}
 }
-- 
2.39.5


  parent reply	other threads:[~2024-08-07  3:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  3:36 [PATCH 00/11] NCR5380: Bug fixes and other improvements Finn Thain
2024-08-07  3:36 ` [PATCH 01/11] scsi: mac_scsi: Revise printk(KERN_DEBUG ...) messages Finn Thain
2024-08-07  3:36 ` [PATCH 09/11] scsi: NCR5380: Remove redundant result calculation from NCR5380_transfer_pio() Finn Thain
2024-08-07  3:36 ` [PATCH 06/11] scsi: NCR5380: Initialize buffer for MSG IN and STATUS transfers Finn Thain
2024-08-07  3:36 ` [PATCH 02/11] scsi: mac_scsi: Refactor polling loop Finn Thain
2024-08-07  3:36 ` Finn Thain [this message]
2024-08-07  3:36 ` [PATCH 04/11] scsi: NCR5380: Check for phase match during PDMA fixup Finn Thain
2024-08-07  3:36 ` [PATCH 08/11] scsi: NCR5380: Drop redundant member from struct NCR5380_cmd Finn Thain
2024-08-07  3:36 ` [PATCH 11/11] scsi: NCR5380: Clean up indentation Finn Thain
2024-08-07  3:36 ` [PATCH 10/11] scsi: NCR5380: Remove obsolete comment Finn Thain
2024-08-07  3:36 ` [PATCH 05/11] scsi: mac_scsi: Enable scatter/gather by default Finn Thain
2024-08-07  3:36 ` [PATCH 03/11] scsi: mac_scsi: Disallow bus errors during PDMA send Finn Thain
2024-08-13  2:07 ` [PATCH 00/11] NCR5380: Bug fixes and other improvements Martin K. Petersen
2024-08-17  1:34 ` Martin K. Petersen

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=d253dddaf4d9bc17b8ee02ea2b731d92f25b16f1.1723001788.git.fthain@linux-m68k.org \
    --to=fthain@linux-m68k.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=hare@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@zary.sk \
    --cc=martin.petersen@oracle.com \
    --cc=schmitzmic@gmail.com \
    --cc=userm57@yahoo.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

all inboxes | Powered by JetHome®