]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
scsi: set dma direction to NONE for TEST UNIT READY
authorNikita Yushchenko <nikita.yoush@cogentembedded.com>
Mon, 13 Nov 2023 05:51:02 +0000 (11:51 +0600)
committerTom Rini <trini@konsulko.com>
Mon, 20 Nov 2023 13:34:08 +0000 (08:34 -0500)
SCSI device scan code was executing TEST UNIT READY command without
explicitly setting dma direction in struct scsi_cmd to NONE, so command
was passed to driver with dma direction set to DMA_FROM_DEVICE,
inherited from older usage.

With WDC SDINDDH6-64G ufs device, that caused TEST UNIT READY to
return error.

Fix that, by explicitly setting dma direction to NONE for
TEST UNIT READY, and restoring it back DMA_FROM_DEVICE for the
following READ CAPACITY.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Reviewed-by: Marek Vasut <marex@denx.de>
drivers/scsi/scsi.c

index b76aadb0653deb82303887b80aaa526cc3ea7e32..1330482c167402cb0f49d3d1dd2e48a3f6ea8501 100644 (file)
@@ -374,6 +374,7 @@ static int scsi_read_capacity(struct udevice *dev, struct scsi_cmd *pccb,
        pccb->cmd[0] = SCSI_RD_CAPAC10;
        pccb->cmd[1] = pccb->lun << 5;
        pccb->cmdlen = 10;
+       pccb->dma_dir = DMA_FROM_DEVICE;
        pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */
 
        pccb->datalen = 8;
@@ -538,6 +539,7 @@ static int scsi_detect_dev(struct udevice *dev, int target, int lun,
 
        for (count = 0; count < 3; count++) {
                pccb->datalen = 0;
+               pccb->dma_dir = DMA_NONE;
                scsi_setup_test_unit_ready(pccb);
                err = scsi_exec(dev, pccb);
                if (!err)