]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
scsi: Retry inquiry 3 times to overcome Unit Attention condition
authorFaiz Abbas <faiz_abbas@ti.com>
Tue, 15 Oct 2019 12:54:34 +0000 (18:24 +0530)
committerTom Rini <trini@konsulko.com>
Thu, 24 Oct 2019 00:47:12 +0000 (20:47 -0400)
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

index e55bb256a9db70c41015a38ef7c976f0f2c69130..0639eb6b310f7d17b2be8c92271068277482e061 100644 (file)
@@ -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;