From: Faiz Abbas Date: Mon, 9 Sep 2019 13:49:52 +0530 Subject: [U-Boot] [PATCH 03/10] scsi: Retry inquiry 3 times to overcome Unit Attention condition In-Reply-To: <20190909081959.16173-1-faiz_abbas@ti.com> References: <20190909081959.16173-1-faiz_abbas@ti.com> Message-ID: <20190909081959.16173-4-faiz_abbas@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- drivers/scsi/scsi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index fd1b4b776d..7b7d388557 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -478,6 +478,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; @@ -513,9 +514,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; -- 2.19.2