scsi: do not fill the LUN in the second CDB byte
authorNeil Armstrong <neil.armstrong@linaro.org>
Fri, 24 Jan 2025 02:01:48 +0000 (03:01 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 31 Jan 2025 17:28:55 +0000 (11:28 -0600)
commit664a25777728074a82a8e3e492aa7bcb53e8247e
tree58cba2fe9cbcd1a08d73d541025fb5aee283e714
parent058ed281faed1bac6005d3ebc126fae825309158
scsi: do not fill the LUN in the second CDB byte

The SCSI specification originally required that the second
Command Data Byte contain the LUN value in its high-order bits,
but this field has been marked as reserved since the SCSI-3 spec
from 1996.

Some vendors uses this byte to pass vendor specific data,
and specifying the LUN can trigger strange behaviors.
For the record, this happened on an UFS device where LUN0 was
working perfectly and reading the other LUNs would get the last
buffer data that was read for LUN0, making this issue very very
hard to debug.

It's sane to assume U-Boot will probably never encounter
an SCSI-2 multi-LUN device, if somehow it happens the enquiry
command would need to get the SCSI level to handle this case.

The Linux fix was added in [1] to fix the exact same issue.

[1] https://lore.kernel.org/all/Pine.LNX.4.44L0.1409021108380.2308-100000@iolanthe.rowland.org/

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
drivers/scsi/scsi.c