Bug 105931

Summary: libata does not report for simple_tags in INQUIRY simulation
Product: IO/Storage Reporter: Tom Yan (tom.ty89)
Component: Serial ATAAssignee: Tejun Heo (tj)
Status: RESOLVED CODE_FIX    
Severity: normal CC: szg00000
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.2.2 Subsystem:
Regression: No Bisected commit-id:

Description Tom Yan 2015-10-13 19:54:17 UTC
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c8b09f6fb67df7fc1b51ced1037fa9b677428149

Since this commit the simple_tags (hence the reported queue_type in sysfs) is set according to the scsi_level and a field in the enquiry result. However in this commit no change has been done in the INQUIRY simulation of libata, so it reports "none" in queue_type ever after.

Compare the libata simulation with an USB-SATA adapter I have:

[tom@localhost ~]$ grep . /sys/block/sd{a,b}/device/queue_*
/sys/block/sda/device/queue_depth:31
/sys/block/sda/device/queue_ramp_up_period:120000
/sys/block/sda/device/queue_type:none
/sys/block/sdb/device/queue_depth:30
/sys/block/sdb/device/queue_type:simple

You can see that eighth field (inq_result[7]) in output of sda is 0x00, while in that of sdb it is 0x02:

[tom@localhost ~]$ sudo sg_inq -H /dev/sda
 00     00 00 05 02 5b 00 00 00  41 54 41 20 20 20 20 20    ....[...ATA     
 10     49 4e 54 45 4c 20 53 53  44 53 43 32 42 57 32 34    INTEL SSDSC2BW24
 20     44 43 33 32 00 00 00 00  00 00 00 00 00 00 00 00    DC32............
 30     00 00 00 00 00 00 00 00  00 00 00 60 03 20 02 60    ...........`. .`
 40     00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00    ................
 50     00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00    ................
[tom@localhost ~]$ sudo sg_inq -H /dev/sdb
 00     00 00 06 02 47 00 00 02  41 53 4d 54 20 20 20 20    ....G...ASMT    
 10     32 31 31 35 20 20 20 20  20 20 20 20 20 20 20 20    2115            
 20     30 20 20 20 00 00 00 00  00 00 00 00 00 00 00 00    0   ............
 30     00 00 00 00 00 00 00 00  00 00 04 c0 17 47 04 60    .............G.`
 40     00 00 00 00 00 00 00 00  00 00 00 00                ............

Also the difference of "CmdQue" in the decoded version:

[tom@localhost ~]$ sudo sg_inq /dev/sda
standard INQUIRY:
  PQual=0  Device_type=0  RMB=0  LU_CONG=0  version=0x05  [SPC-3]
  [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
  [SPI: Clocking=0x0  QAS=0  IUS=0]
    length=96 (0x60)   Peripheral device type: disk
 Vendor identification: ATA     
 Product identification: INTEL SSDSC2BW24
 Product revision level: DC32
 Unit serial number: CVDA339603M02403GN  
[tom@localhost ~]$ sudo sg_inq /dev/sdb
standard INQUIRY:
  PQual=0  Device_type=0  RMB=0  LU_CONG=0  version=0x06  [SPC-4]
  [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=1
  [SPI: Clocking=0x0  QAS=0  IUS=0]
    length=76 (0x4c)   Peripheral device type: disk
 Vendor identification: ASMT    
 Product identification: 2115            
 Product revision level: 0   
 Unit serial number: 514987654321
Comment 1 Tom Yan 2015-10-31 03:20:51 UTC
It should only report CmdQue=1 when NCQ is enabled though.
Comment 2 Tom Yan 2016-07-19 11:38:53 UTC
Commit 415ffdde1555 ("
libata-scsi: set CmdQue bit in standard INQUIRY data to 1") applied to libata/for-4.8

P.S. Actually there is no obvious reason that we should relate the bit with the state/availability of ATA NCQ, thus it's statically set to 1 in the patch.