[haiku-bugs] [Haiku] #10043: usb_disk fails to handle USB stick, panic KDL when trying to boot from it

  • From: "jua" <trac@xxxxxxxxxxxx>
  • Date: Mon, 30 Sep 2013 23:06:26 -0000

#10043: usb_disk fails to handle USB stick, panic KDL when trying to boot from 
 Reporter:  jua                                |        Owner:  mmlr
     Type:  bug                                |       Status:  new
 Priority:  normal                             |    Milestone:  R1
Component:  Drivers/USB                        |      Version:
 Keywords:  usb_disk usb stick boot kdl panic  |  R1/Development
 Blocking:                                     |   Blocked By:
 Platform:  x86                                |  Has a Patch:  0
 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

 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.

Ticket URL: <http://dev.haiku-os.org/ticket/10043>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: