-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
I have a few drives in an enclosure (mediasonic pro box) connected via USB using a Jmicron USB bridge (ID 152d:0567 JMicron Technology Corp.). I am not able to create the desired names (ata-<model>-<serial>) for these devices in /dev/disk/by-id because ata_id is unable to retrieve the ATA device identity information for these drives.
I did some root causing and found where the problem lies. The ATA Pass Through command sets the check condition flag (CK_COND=1). In the response it expects and checks for sense data.
It seems the JMicron USB bridge successfully responds to the ATA IDENTIFY DEVICE command but it does not return any sense data along with it and therefore the disk_identify_command() function returns EIO even though the command was successful and we got all that we needed. I checked by removing this condition and the ata_id output was found to be accurate.
The behavior implemented by ata_id seems to be correct strictly speaking as per the SAT draft. It seems the Jmicron USB hardware does not comply with the standard. Here is an excerpt from page 123 of the SAT draft I found by googling.
-----snip-----
The CK_COND (Check Condition) bit may be used to request the SATL to return a copy of ATA register information in the sense data upon command completion. If the CK_COND bit is set to one the SATL shall return a status of CHECK CONDITION when the ATA command completes, even if the command completes successfully, and return the ATA Normal Output fields (see ATA8-ACS) in the sense data using the ATA Return descriptor (see 12.2.6). If the CK_COND bit is set to zero, then the SATL shall terminate the command with CHECK CONDITION status only if an error occurs in processing the command. See clause 11 for a description of ATA error conditions.
-----snip-----
I have a fix for this problem. The fix is to set CK_COND bit to zero in the command and use the SG IO hdr status fields to check for errors. This seems to be the way smartctl also works for SAT devices and that's why smartctl works without any problems for my JMicron as well. The fix is working fine for all my ATA devices including several internal drives and a couple of external USB/eSATA boxes.
I will send a PR with the fix for a look.