diff mbox series

[U-Boot,v2,03/11] scsi: Retry inquiry 3 times to overcome Unit Attention condition

Message ID 20191015125442.1786-4-faiz_abbas@ti.com
State Accepted
Commit d48f00ed11d04eb76d4510b3db1d7f36f758d4e9
Delegated to: Tom Rini
Headers show
Series Add Support for UFS subsystem for TI's J721e | expand

Commit Message

Faiz Abbas Oct. 15, 2019, 12:54 p.m. UTC
The UFS SCSI device LUNs are observed to return failure the first time a
unit ready inquiry is sent and pass on the second try. Send this
inquiry 3 times to make sure device is ready.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
---
 drivers/scsi/scsi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Tom Rini Oct. 24, 2019, 6:52 p.m. UTC | #1
On Tue, Oct 15, 2019 at 06:24:34PM +0530, Faiz Abbas wrote:

> The UFS SCSI device LUNs are observed to return failure the first time a
> unit ready inquiry is sent and pass on the second try. Send this
> inquiry 3 times to make sure device is ready.
> 
> Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 0bce22a51a..1256e22a52 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -479,6 +479,7 @@  static int scsi_detect_dev(struct udevice *dev, int target, int lun,
 	lbaint_t capacity;
 	unsigned long blksz;
 	struct scsi_cmd *pccb = (struct scsi_cmd *)&tempccb;
+	int count, err;
 
 	pccb->target = target;
 	pccb->lun = lun;
@@ -514,9 +515,14 @@  static int scsi_detect_dev(struct udevice *dev, int target, int lun,
 	dev_desc->target = pccb->target;
 	dev_desc->lun = pccb->lun;
 
-	pccb->datalen = 0;
-	scsi_setup_test_unit_ready(pccb);
-	if (scsi_exec(dev, pccb)) {
+	for (count = 0; count < 3; count++) {
+		pccb->datalen = 0;
+		scsi_setup_test_unit_ready(pccb);
+		err = scsi_exec(dev, pccb);
+		if (!err)
+			break;
+	}
+	if (err) {
 		if (dev_desc->removable) {
 			dev_desc->type = perq;
 			goto removable;