Opened 12 years ago

Closed 11 years ago

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

Change History (27)

comment:1 by markh, 12 years ago

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

by markh, 11 years ago

Attachment: usb_disk_retry.patch added

Fix for devices that don't respond immediately

comment:2 by markh, 11 years ago

patch: 01

comment:3 by markh, 11 years ago

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 by korli, 11 years ago

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

comment:5 by markh, 11 years ago

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

comment:6 by korli, 11 years ago

Resolution: fixed
Status: newclosed

Thanks for the feedback!

comment:7 by diger, 11 years ago

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.

Version 0, edited 11 years ago by diger (next)

by diger, 11 years ago

Attachment: shot1.jpg added

by diger, 11 years ago

Attachment: shot2.jpg added

comment:8 by markh, 11 years ago

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 by korli, 11 years ago

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.

by markh, 11 years ago

Attachment: syslog_wd_elements.log added

Snippet of syslog when attaching WD Elements USB drive

comment:10 by markh, 11 years ago

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 by korli, 11 years ago

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.

by diger, 11 years ago

Attachment: syslog added

syslog with SD card reader

comment:12 by markh, 11 years ago

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

comment:13 by mmlr, 11 years ago

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 by markh, 11 years ago

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.

by markh, 11 years ago

Attachment: usb_disk_retry_2.patch added

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

comment:15 by markh, 11 years ago

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 by korli, 11 years ago

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 by korli, 11 years ago

Please check with hrev46099. Thanks!

comment:18 by markh, 11 years ago

That revision still works with my WD Elements drive.

comment:19 by diger, 11 years ago

That revision boot ok with SD card reader

comment:20 by korli, 11 years ago

Resolution: fixed
Status: reopenedclosed

Thanks both for the feedback! Closing as fixed.

comment:21 by anevilyak, 11 years ago

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.