aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaiz Abbas2019-10-15 18:24:34 +0530
committerTom Rini2019-10-23 20:47:12 -0400
commitd48f00ed11d04eb76d4510b3db1d7f36f758d4e9 (patch)
tree95b6c6860d7c74934c14c2a1a0d1976ed413b144
parent4ff572830eb1ae95fa85f8ab585521ccc1d86845 (diff)
scsi: Retry inquiry 3 times to overcome Unit Attention condition
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>
-rw-r--r--drivers/scsi/scsi.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index e55bb256a9d..0639eb6b310 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -481,6 +481,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;
@@ -516,9 +517,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;