Opened 11 years ago
Closed 11 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 | |
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)
Change History (16)
by , 11 years ago
Attachment: | retry-on-asc-0x2800.patch added |
---|
comment:1 by , 11 years ago
patch: | 0 → 1 |
---|
comment:2 by , 11 years ago
As a test-hack, I overrode it by just setting
lun->write_protected
always totrue
Correction: I meant write false
there.
comment:3 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Looks ok to me. I'm seeing this issue as well. Going to test the patch and commit it.
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
applied in hrev46154. Works for me. Thanks!
comment:5 by , 11 years ago
This would need to be tested with a USB CD-ROM device and checked for no regression. Thanks!
comment:6 by , 11 years ago
Just tested it with a USB CD/DVD drive: booting from it still works fine with the patch.
comment:7 by , 11 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 , 11 years ago
Attachment: | 0001-usb_disk-accept-B_DEV_MEDIA_CHANGED-as-a-ready-unit.patch added |
---|
accept B_DEV_MEDIA_CHANGED
comment:8 by , 11 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:9 by , 11 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 , 11 years ago
ok jua. kallisti5, feel free to try the second patch if you can reproduce.
comment:11 by , 11 years ago
Blocking: | 10155 added |
---|
comment:12 by , 11 years ago
Blocking: | 10174 added |
---|
comment:13 by , 11 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 , 11 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Applied in hrev46380. Thanks for the feedback! Please reopen if needed.
Proposed patch