Opened 5 years ago

Last modified 5 months ago

#10222 assigned bug

SD card reader fails to work with usb_disk

Reported by: pulkomandy Owned by: korli
Priority: normal Milestone: R1
Component: Drivers/Disk/USB Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: yes Platform: All

Description (last modified by pulkomandy)

My Thinkpad X200 has an internal SD card reader. This doesn't work in Haiku. Relevant syslog message:

KERN: usb error ehci -1: qtd (0xa349b80) error: 0x00088d40
KERN: usb_disk: operation 0x25 failed at the SCSI level
KERN: usb_disk: failed to update capacity: Device media changed
bš™y@

Listusb:

[Device /dev/bus/usb/7/5]
    Class .................. 0x00 (Per-interface classes)
    Subclass ............... 0x00
    Protocol ............... 0x00
    Max Endpoint 0 Packet .. 64
    USB Version ............ 0x0200
    Vendor ID .............. 0x05ca (Ricoh Co., Ltd)
    Product ID ............. 0x1880
    Product Version ........ 0x0001
    Manufacturer String .... "RICOH             "
    Product String ......... "USB2.0-FLASH Media    "
    Serial Number .......... "R5U880-00003"
    [Configuration 0]
        Configuration String . ""
        [Interface 0]
            [Alternate 0 active]
                Class .............. 0x08 (Mass storage)
                Subclass ........... 0x06
                Protocol ........... 0x50
                Interface String ... ""
                [Endpoint 0]
                    MaxPacketSize .... 512
                    Interval ......... 0
                    Type ............. Bulk
                    Direction ........ Input
                [Endpoint 1]
                    MaxPacketSize .... 512
                    Interval ......... 0
                    Type ............. Bulk
                    Direction ........ Output

This used to work with hrev46154, but doesn't anymore with the final patch from #10043.

Removing the card and inserting it again seems to work.

Attachments (1)

0001-usb_disk-update_capacity-now-retries-until-success.patch (1.4 KB) - added by korli 5 years ago.
patch

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by pulkomandy

Description: modified (diff)

comment:2 Changed 5 years ago by korli

Component: - GeneralDrivers/Disk
Owner: changed from nobody to korli
Status: newassigned

comment:3 Changed 5 years ago by korli

Has a Patch: set

comment:4 Changed 5 years ago by korli

Please try this patch. The action checks might simply be superfluous.

comment:5 Changed 5 years ago by pulkomandy

No, same error.

I noticed that the device is connected to USB only when I insert a card, and removed when I remove it. Seems like the card detection switch powers on the USB logic. So, I expect a "media change" event immediately on first access to the device, but retrying should get past that, and we shoundn't get any other "media change" event, as removing the card will cut power to the device before it can send it anyway.

I have seen other devices sending media change on first connection as well. Maybe we should ignore that only the first time ?

comment:6 Changed 5 years ago by korli

OK a bit clearer. Though ReadCapacity should be the third command sent to the device (after inquiry and TUR). The init sequence might need to be tweaked indeed. Could you attach a log with TRACE_USB_DISK enabled? I thought ReadCapacity would be retried, and that's what the code did before hrev46099.

comment:7 Changed 5 years ago by pulkomandy

Here is a log (with the patch applied + TRACE_USB_DISK):

KERN: usb hub 37: KERN: port 5: new device connected
KERN: usb_disk: init_hardware()
KERN: usb_disk: init_driver()
KERN: usb_disk: trying module bus_managers/usb/v3
KERN: usb_disk: device_added(0x0000002b)
KERN: usb_disk: device reports a lun count of 1
KERN: usb_disk: operation: lun: 0; op: 18; oplen: 6; lba: 0; tlen: 36; data: 0x81a07c60; dlen: 0x81a07c58 (36); in: y
KERN: usb_disk: peripherial_device_type  0x00
KERN: usb_disk: peripherial_qualifier    0x00
KERN: usb_disk: removable_medium         yes
KERN: usb_disk: version                  0x02
KERN: usb_disk: response_data_format     0x02
KERN: usb_disk: vendor_identification    "RICOH   "
KERN: usb_disk: product_identification   "R5U880FlashMedia"
KERN: usb_disk: product_revision_level   "0000"
KERN: usb_disk: usb lun 0 inquiry attempt 0 begin
KERN: usb_disk: operation: lun: 0; op: 0; oplen: 6; lba: 0; tlen: 0; data: 0x00000000; dlen: 0x00000000 (0); in: y
KERN: usb_disk: operation: lun: 0; op: 3; oplen: 6; lba: 0; tlen: 18; data: 0x81a07b90; dlen: 0x81a07b8c (18); in: y
KERN: usb_disk: usb lun 0 ready. write protected = n
KERN: usb_disk: new device: 0x0xd266e508
KERN: usb_disk: publish_devices()
KERN: usb_disk: find_device()
KERN: ahci: ahci_supports_device
KERN: Last message repeated 3 times.
KERN: usb_disk: open(disk/usb/0/0/raw)
KERN: usb_disk: opening raw device disk/usb/0/0/raw for disk/usb/0/0/raw
KERN: usb_disk: operation: lun: 0; op: 0; oplen: 6; lba: 0; tlen: 0; data: 0x00000000; dlen: 0x00000000 (0); in: y
KERN: usb_disk: operation: lun: 0; op: 3; oplen: 6; lba: 0; tlen: 18; data: 0x826aeaf0; dlen: 0x826aeaec (18); in: y
KERN: usb_disk: B_GET_MEDIA_STATUS: 0x8000a00d
KERN: usb_disk: operation: lun: 0; op: 37; oplen: 10; lba: 0; tlen: 0; data: 0x826aebe4; dlen: 0x826aebec (8); in: y
KERN: usb error ehci -1: qtd (0xa34db80) error: 0x00088d40
KERN: usb_disk: stall while transfering data
KERN: usb_disk: operation 0x25 failed at the SCSI level
KERN: usb_disk: operation: lun: 0; op: 3; oplen: 6; lba: 0; tlen: 18; data: 0x826aeb00; dlen: 0x826aeafc (18); in: y
KERN: usb_disk: operation: lun: 0; op: 37; oplen: 10; lba: 0; tlen: 0; data: 0x826aebe4; dlen: 0x826aebec (0); in: y
KERN: usb_disk: operation 0x25 failed at the SCSI level
KERN: usb_disk: operation: lun: 0; op: 3; oplen: 6; lba: 0; tlen: 18; data: 0x826aeb00; dlen: 0x826aeafc (18); in: y
KERN: usb_disk: operation: lun: 0; op: 37; oplen: 10; lba: 0; tlen: 0; data: 0x826aebe4; dlen: 0x826aebec (0); in: y
KERN: usb_disk: operation 0x25 failed at the SCSI level
KERN: usb_disk: operation: lun: 0; op: 3; oplen: 6; lba: 0; tlen: 18; data: 0x826aeb00; dlen: 0x826aeafc (18); in: y
KERN: usb_disk: failed to update capacity: Device media changed
KERN: usb_disk: close()
KERN: usb_disk: free()

comment:8 Changed 5 months ago by pulkomandy

Component: Drivers/DiskDrivers/Disk/USB
Note: See TracTickets for help on using tickets.