Opened 6 years ago

Closed 6 years ago

#10043 closed bug (fixed)

usb_disk fails to handle USB stick, panic KDL when trying to boot from it

Reported by: jua Owned by: kallisti5
Priority: normal Milestone: R1
Component: Drivers/USB Version: R1/Development
Keywords: usb_disk usb stick boot kdl panic Cc:
Blocked By: Blocking: #10155, #10174
Has a Patch: yes Platform: x86

Description

The changes to usb_disk driver in hrev46099 broke booting an anyboot-image from one of my USB sticks for me. When the disk icon lights up in the boot splash, it shows a KDL "PANIC: could not mount boot device". (With a different USB stick it stills works fine...)

Here's what I found out:

The updated usb_disk driver wrongly detects the USB stick as read-only device (the KPartition::Dump printed to the serial console while booting shows the boot partition flags as 0xa... while with the usb_disk driver from hrev46098 it is the correct 0x2). This later leads to failed mounting.

The problem has its roots in usb_disk_device_added(), in the part starting at line 795. For some reason, the problematic USB stick responds to the 'unit ready'-inquiry with ASC 0x2800: "Not ready to ready change, medium may have changed" (maybe a device quirk?). In scsi_sense.h this is associated with err_act_fail, so it will drop out of the loop without retrying... lun->write_protected doesn't get set to false and it will then wrongly assume a read-only medium.

As a test-hack, I overrode it by just setting lun->write_protected always to true. It then works, boots fine, without any further changes.

A better fix would be to set the entry for 0x2800 in sSCSISenseAscTable to err_act_retry. This fixes the problem, it will retry the command on the stick and the second time it succeeds and can mount the boot volume. Attaching a patch which does this. I'm not sure whether this is the correct solution though.

Attachments (2)

retry-on-asc-0x2800.patch (1.6 KB ) - added by jua 6 years ago.
Proposed patch
0001-usb_disk-accept-B_DEV_MEDIA_CHANGED-as-a-ready-unit.patch (3.0 KB ) - added by korli 6 years ago.
accept B_DEV_MEDIA_CHANGED

Download all attachments as: .zip

Change History (16)

by jua, 6 years ago

Attachment: retry-on-asc-0x2800.patch added

Proposed patch

comment:1 by jua, 6 years ago

Has a Patch: set

comment:2 by jua, 6 years ago

As a test-hack, I overrode it by just setting lun->write_protected always to true

Correction: I meant write false there.

comment:3 by kallisti5, 6 years ago

Owner: changed from mmlr to kallisti5
Status: newassigned

Looks ok to me. I'm seeing this issue as well. Going to test the patch and commit it.

comment:4 by kallisti5, 6 years ago

Resolution: fixed
Status: assignedclosed

applied in hrev46154. Works for me. Thanks!

comment:5 by korli, 6 years ago

This would need to be tested with a USB CD-ROM device and checked for no regression. Thanks!

comment:6 by jua, 6 years ago

Just tested it with a USB CD/DVD drive: booting from it still works fine with the patch.

comment:7 by korli, 6 years ago

Just tested here with a USB CD/DVD device, the media change isn't detected anymore for me. I suppose the fix isn't that good. Could you try with the following patch? Thanks!

by korli, 6 years ago

accept B_DEV_MEDIA_CHANGED

comment:8 by korli, 6 years ago

Resolution: fixed
Status: closedreopened

Reverted hrev46154 for now in hrev46261, reopened the bug.

comment:9 by jua, 6 years ago

Sorry, I had only tested it with booting from CD, didn't test media changing...

I will try with the new patch as soon as I find time.

comment:10 by korli, 6 years ago

ok jua. kallisti5, feel free to try the second patch if you can reproduce.

comment:11 by bonefish, 6 years ago

Blocking: 10155 added

(In #10155) So, to sum it up, the Corsair stick works and always did, and booting off the Transcend stick broke between hrev46255 and hrev46263. This supports jua's theory. Closing as duplicate of #10043.

comment:12 by jua, 6 years ago

Blocking: 10174 added

(In #10174) Thanks for reporting. Most probably duplicate of #10043.

comment:13 by x-ist, 6 years ago

The second patch seems to be working for me! Tested successfully with an SD card and three different USB sticks. Patch was applied to hrev46378. Sorry for the noise on the ML!

comment:14 by korli, 6 years ago

Resolution: fixed
Status: reopenedclosed

Applied in hrev46380. Thanks for the feedback! Please reopen if needed.

Note: See TracTickets for help on using tickets.