Skip to contentSkip to conversation

scsi: Adjust SCSI inquiry command data length

PATCH Superseded Macpaul Lin 2 participants 6 messages Feb 11 – Mar 3 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: Adjust SCSI inquiry command data length

Adjust the data length of the SCSI inquiry command to accommodate various UFS device vendors. This prevents SCSI detection failures on Longsys UFS devices. Verified with Hynix, SD, and Longsys UFS devices.

---
 drivers/scsi/scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi.c +1 -1
index 8fe6b38a8c74..116b696b08dd 100644
@@ -513,7 +513,7 @@ static int scsi_detect_dev(struct udevice *dev, int target, int lun,
 	pccb->target = target;
 	pccb->lun = lun;
 	pccb->pdata = tempbuff;
-	pccb->datalen = 512;
+	pccb->datalen = 36;
 	pccb->dma_dir = DMA_FROM_DEVICE;
 	scsi_setup_inquiry(pccb);
 	if (scsi_exec(dev, pccb)) {
Signature · 1 line
2.45.2
#1 lore raw
Quoted 3 lines · Macpaul Lin

Adjust the data length of the SCSI inquiry command to accommodate various UFS device vendors. This prevents SCSI detection failures on Longsys UFS devices. Verified with Hynix, SD, and Longsys UFS devices.

Can this be quirked using some vendor/device ID match , so only the problematic devices suffer the consequences ? Thank you

#2 lore raw
Quoted 5 lines · Marek Vasut

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 8 lines
Quoted 5 lines · Macpaul Lin

Adjust the data length of the SCSI inquiry command to accommodate various
UFS device vendors. This prevents SCSI detection failures on Longsys UFS
devices. Verified with Hynix, SD, and Longsys UFS devices.

Can this be quirked using some vendor/device ID match , so only the problematic devices suffer the consequences ? Thank you

During the patch reviewing last time, Eric (HT Lin) commented the length of 512 bytes is not follow the specification of UFS storage; it should be 36 bytes. So these are not problematic devices actually. However, I'm wondering how the parameter should apply to the traditional SCSI devices like harddrive or USB disk.

I'll double check it with Eric then update new patch around the end of February.

Thanks!
Macpaul Lin

#3 lore raw
Quoted 15 lines · Macpaul Lin (林智斌)
Quoted 5 lines · Marek Vasut

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 8 lines
Quoted 5 lines · Macpaul Lin

Adjust the data length of the SCSI inquiry command to accommodate various
UFS device vendors. This prevents SCSI detection failures on Longsys UFS
devices. Verified with Hynix, SD, and Longsys UFS devices.

Can this be quirked using some vendor/device ID match , so only the problematic devices suffer the consequences ? Thank you

Quoted 8 lines

During the patch reviewing last time, Eric (HT Lin) commented the length of 512 bytes is not follow the specification of UFS storage; it should be 36 bytes. So these are not problematic devices actually. However, I'm wondering how the parameter should apply to the traditional SCSI devices like harddrive or USB disk.

I'll double check it with Eric then update new patch around the end of February.

Thank you, and yes, I was about to point out that this is a scsi core code, this applies to SCSI, USB and such devices.

#4 lore raw
Quoted 32 lines · Marek Vasut

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 26 lines · Macpaul Lin (林智斌)
Quoted 13 lines · Marek Vasut

External email : Please do not click links or open attachments until
you have verified the sender or the content.

Quoted 6 lines · Macpaul Lin

Adjust the data length of the SCSI inquiry command to accommodate
various
UFS device vendors. This prevents SCSI detection failures on Longsys UFS
devices. Verified with Hynix, SD, and Longsys UFS devices.

Quoted 3 lines

Can this be quirked using some vendor/device ID match , so only the
problematic devices suffer the consequences ? Thank you

During the patch reviewing last time, Eric (HT Lin) commented the length of 512 bytes is not follow the specification of UFS storage;
it should be 36 bytes. So these are not problematic devices actually.
However, I'm wondering how the parameter should apply to the traditional SCSI devices like harddrive  or USB disk.

Quoted 5 lines
Quoted 3 lines

I'll double check it with Eric then update new patch around the end of
February.

Thank you, and yes, I was about to point out that this is a scsi core code, this applies to SCSI, USB and such devices.

After re-visit the specification of SCSI SPC-4, we have confirmed the standard inquiry (and the 1st) should not "less than" 36 bytes.

https://www.t10.org/members/w_spc4.htm
(A summary of SCSI-1 could be found here in html format
https://www.staff.uni-mainz.de/tacke/scsi/SCSI2-08.html#8.2.5 )

Compare the logic with the Linux's implementation in these sections:
https://elixir.bootlin.com/linux/v6.19.3/source/drivers/scsi/scsi_scan.c#L690

https://elixir.bootlin.com/linux/v6.19.3/source/drivers/scsi/scsi_scan.c#L801
https://elixir.bootlin.com/linux/v6.19.3/source/drivers/scsi/scsi_scan.c#L757

Unless the inquiry length has been assigned by the device, Linux use 36 bytes as the default standard inquiry length.

Is it possible to update the implementation in u-boot to use 36 bytes as default standard inquiry lenght aligned with Linux, other devices should apply vendor specific inquiry length with quirk settings. Would it be okay? Looking forward for the further suggestions.

Thanks
Macpaul Lin

#5 lore raw
Quoted 16 lines · Macpaul Lin (林智斌)
Quoted 2 lines

Thank you, and yes, I was about to point out that this is a scsi core code, this applies to SCSI, USB and such devices.

After re-visit the specification of SCSI SPC-4, we have confirmed the standard inquiry (and the 1st) should not "less than" 36 bytes.

https://www.t10.org/members/w_spc4.htm
(A summary of SCSI-1 could be found here in html format
https://www.staff.uni-mainz.de/tacke/scsi/SCSI2-08.html#8.2.5 )

Compare the logic with the Linux's implementation in these sections:
https://elixir.bootlin.com/linux/v6.19.3/source/drivers/scsi/scsi_scan.c#L690

https://elixir.bootlin.com/linux/v6.19.3/source/drivers/scsi/scsi_scan.c#L801
https://elixir.bootlin.com/linux/v6.19.3/source/drivers/scsi/scsi_scan.c#L757

Quoted 7 lines

Unless the inquiry length has been assigned by the device, Linux use 36 bytes as the default standard inquiry length.

Is it possible to update the implementation in u-boot to use 36 bytes as default standard inquiry lenght aligned with Linux, other devices should apply vendor specific inquiry length with quirk settings. Would it be okay? Looking forward for the further suggestions.

This would be OK, yes. Please update the commit message and send a V2. Thank you for investigating this.