Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9589 closed bug (fixed)

WD Elements USB drive not found

Reported by: markh Owned by: mmlr
Priority: normal Milestone: R1
Component: Drivers/USB Version: R1/alpha4.1
Keywords: Cc:
Blocked By: Blocking: #10010
Has a Patch: yes Platform: All

Description

I have a WD Elements 500GB external USB drive. If I attach it to the computer, Haiku writes the following in the syslog, but doesn't do anything else with it:

KERN: usb hub 83: KERN: port 1: new device connected KERN: usb_disk: device reports a lun count of 1 KERN: usb_disk: vendor_identification "WD " KERN: usb_disk: product_identification "Elements 1042 " KERN: usb_disk: product_revision_level "1019" KERN: usb_disk: unhandled ioctl 24

I can attach an USB stick and that is recognized fine. I am using it to boot Haiku from the stick.

Attachments (6)

usb_disk_retry.patch (605 bytes) - added by markh 6 years ago.
Fix for devices that don't respond immediately
shot1.jpg (1.1 MB) - added by diger 6 years ago.
shot2.jpg (1.2 MB) - added by diger 6 years ago.
syslog_wd_elements.log (3.4 KB) - added by markh 6 years ago.
Snippet of syslog when attaching WD Elements USB drive
syslog (350.3 KB) - added by diger 6 years ago.
syslog with SD card reader
usb_disk_retry_2.patch (910 bytes) - added by markh 6 years ago.
This patch should work for both the WD Elements drive and the SD card reader

Change History (27)

comment:1 Changed 6 years ago by markh

With a nightly build (href45525) I get something different. It now reports the following in the syslog:

KERN: usb hub 83: KERN: port 2: new device connected KERN: usb_disk: device reports a lun count of 1 KERN: usb_disk: vendor_identification "WD " KERN: usb_disk: product_identification "Elements 1042 " KERN: usb_disk: product_revision_level "1019" KERN: usb_disk: got device name "WD Elements 1042 1019": No error KERN: fs_mount - EXIT, result code is No error

It now also shows in DriveSetup, but I can't create a partition on it. Trying to mount it produces the following error:

Could not mount partition "".

Error: Invalid Argument

Changed 6 years ago by markh

Attachment: usb_disk_retry.patch added

Fix for devices that don't respond immediately

comment:2 Changed 6 years ago by markh

Has a Patch: set

comment:3 Changed 6 years ago by markh

I looked into the code and it seems to be going wrong when it tries to read the status from the drive. It fails with "request_sense: device not ready", but it does not return an errror. I changed the code to return an error, so it will retry until the device is ready.

comment:4 Changed 6 years ago by korli

Please check with hrev46058 or newer. I hopefully understood your patch right. Thanks!

comment:5 Changed 6 years ago by markh

Yes, this works fine. I can now mount the drive with this revision.

comment:6 Changed 6 years ago by korli

Resolution: fixed
Status: newclosed

Thanks for the feedback!

comment:7 Changed 6 years ago by diger

Resolution: fixed
Status: closedreopened

Unfortunately this modification forces system to boot paused for about 4 minutes in case my SD card reader is plugged in during boot. See attached onscreen debug screenshot for details. Last "paragraph" repeated every minute. If the reader is removed - system boots properly.

Last edited 6 years ago by diger (previous) (diff)

Changed 6 years ago by diger

Attachment: shot1.jpg added

Changed 6 years ago by diger

Attachment: shot2.jpg added

comment:8 Changed 6 years ago by markh

Sorry about that. I tested the change with a few usb devices and none had any problems. It could be that your system is slowing down, because it gets a timeout as there is no SD card inserted in the reader. Could you try it with a card inserted and see what happens?

If so, then it seems that my drive and your card reader go through the same part of the code for different reasons. I will look at the code again to see if I can understand why this happens.

comment:9 Changed 6 years ago by korli

Hi Mark and diger, could you please post a syslog with TRACE_USB_DISK activated? This TRACE should give an hint on whether a retry is needed or not.

Changed 6 years ago by markh

Attachment: syslog_wd_elements.log added

Snippet of syslog when attaching WD Elements USB drive

comment:10 Changed 6 years ago by markh

I attached a small part of the syslog that shows what happens when the WD Elements drive is attached with TRACE_USB_DISK enabled. I did some further digging and I think I know where the problem is. The sense data contains additional data and this data clarifies exactly why the device is not responding (see https://en.wikipedia.org/wiki/Key_Code_Qualifier for the list). The WD Elements drive returns 04 01 as the response as can be seen in the log. I suspect the card reader returns something like 3A 00. If so, then we need to add code to interpret this additional data.

comment:11 Changed 6 years ago by korli

I agree. For reference the official list is at http://www.t10.org/lists/asc-num.txt This could be an idea to generate an header based on this list, and display sense information.

Changed 6 years ago by diger

Attachment: syslog added

syslog with SD card reader

comment:12 Changed 6 years ago by markh

The SD card syslog indeed shows 3A 00 for the additional information. korli: What do you want to do?

comment:13 Changed 6 years ago by mmlr

But that's what the code already checks for in the case above the changed one. It's just that that one falls through, so now also gets the changed error code. Please just un-fall-through the case above or return the old return code for unit attention.

comment:14 Changed 6 years ago by markh

I see now what the code was doing, but according to the wikipedia article I linked to the combination of SCSI_SENSE_KEY_UNIT_ATTENTION and SCSI_ASC_MEDIUM_NOT_PRESENT cannot occur. Your list however does not indicate a limitation on this part. It might be interesting to see which sense key the SD card reader is sending, but I will change the code so it works either way.

Changed 6 years ago by markh

Attachment: usb_disk_retry_2.patch added

This patch should work for both the WD Elements drive and the SD card reader

comment:15 Changed 6 years ago by markh

The patch still doesn't take into account all the options that the list supplies, but that might be best left for some other time.

comment:16 Changed 6 years ago by korli

I'm willing to switch usb_disk to a comprehensive SCSI ASC list, common with scsi_periph. It would provide a message, a defined action and a status return code. We could then merge and update the error sense handling code in scsi_periph as well. I should tackle this very soon and let you know when something can be tested.

comment:17 Changed 6 years ago by korli

Please check with hrev46099. Thanks!

comment:18 Changed 6 years ago by markh

That revision still works with my WD Elements drive.

comment:19 Changed 6 years ago by diger

That revision boot ok with SD card reader

comment:20 Changed 6 years ago by korli

Resolution: fixed
Status: reopenedclosed

Thanks both for the feedback! Closing as fixed.

comment:21 Changed 6 years ago by anevilyak

Blocking: 10010 added

(In #10010) It should be noted that that change hasn't yet been merged into the PM branch.

Note: See TracTickets for help on using tickets.