Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the standard inquiry response additional length field. #1349

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

iabdalkader
Copy link
Contributor

@iabdalkader iabdalkader commented Feb 25, 2022

Describe the PR
The standard inquiry response additional length field needs to be set to the length in bytes of the remaining standard inquiry data (i.e. N - 5), otherwise the kernel driver issues a warning about short inquiry response.

Additional context
On Linux I see the following warning, it seems the driver assumes the response is the minimum 36 bytes:

[53564.998251] usb-storage 4-2:1.2: USB Mass Storage device detected
[53564.998424] scsi host0: usb-storage 4-2:1.2
[53566.008111] scsi host0: scsi scan: INQUIRY result too short (5), using 36

This warning is gone after setting the additional length field.

See section 3.6.2 Standard INQUIRY data in Seagate SCSI reference manual (PDF link).

Tested using sg_inq, without this patch (note the length=5):

> sudo sg_inq --only /dev/sda
standard INQUIRY:
  PQual=0  PDT=0  RMB=1  LU_CONG=0  hot_pluggable=0  version=0x02  [SCSI-2]
  [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=0  Resp_data_format=2
  SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=0  [BQue=0]
  EncServ=0  MultiP=0  [MChngr=0]  [ACKREQQ=0]  Addr16=0
  [RelAdr=0]  WBus16=0  Sync=0  [Linked=0]  [TranDis=0]  CmdQue=0
    length=5 (0x5)
  [for SCSI>=2, len>=36 is expected]   Peripheral device type: disk
Inquiry response length=5, no vendor, product or revision data

With this patch (the expected 36 bytes length):

> sudo sg_inq --only /dev/sda
standard INQUIRY:
  PQual=0  PDT=0  RMB=1  LU_CONG=0  hot_pluggable=0  version=0x02  [SCSI-2]
  [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=0  Resp_data_format=2
  SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=0  [BQue=0]
  EncServ=0  MultiP=0  [MChngr=0]  [ACKREQQ=0]  Addr16=0
  [RelAdr=0]  WBus16=0  Sync=0  [Linked=0]  [TranDis=0]  CmdQue=0
    length=36 (0x24)   Peripheral device type: disk
 Vendor identification: Micropy
 Product identification: Mass Storage
 Product revision level: 1.0

* The standard inquiry response additional length field needs to be set to
the length in bytes of the remaining standard inquiry data (i.e. N - 5),
otherwise the kernel driver issues a warning about short inquiry response..
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just tested, work great. additional_length is length until end of response. I guess the spec (N-4) where N = 35, scsi specs is known to be quite confusing. Thanks dpgeorge for reviewing.

@hathach hathach merged commit 13a4582 into hathach:master Feb 25, 2022
@iabdalkader iabdalkader deleted the fix_inquiry_data branch February 25, 2022 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants