Launch a custom script at reboot before system recognises USB devices

  • I own an external USB 3.0 enclosure with the chip Asmedia ASM1051E that reports lots of error to syslogs:


    Code
    sd 8:0:0:0: [sdi] tag#1 uas_eh_abort_handler 0 uas-tag 2 inflight: CMD 
    sd 8:0:0:0: [sdi] tag#1 CDB: Write(10) 2a 00 48 c0 81 00 00 00 01 00
    scsi host8: uas_eh_device_reset_handler start
    usb 2-1: reset SuperSpeed USB device number 2 using xhci_hcd
    scsi host8: uas_eh_device_reset_handler success
    usb 2-1: Disable of device-initiated U1 failed.
    usb 2-1: Disable of device-initiated U2 failed.
    sd 8:0:0:0: [sdi] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD IN 
    sd 8:0:0:0: [sdi] tag#0 CDB: ATA command pass through(16) 85 09 0e 00 00 00 01 00 11 00 00 00 00 00 2f 00
    xhci_hcd 0000:00:14.0: ERROR Unknown event condition 199 for slot 4 ep 3 , HC probably busted


    I have done some research about it, and I found that the chip itself has broken support under UAS mode and that the best option is to run it as regular USB storage mode.


    Blacklisting the vendor_id:product_id with the following command resolves the incompatibility problem:



    Code
    echo "174c:55aa:u" >/sys/module/usb_storage/parameters/quirks


    But it has to be done at each reboot, before the system recognises the external USB enclosure.


    I have tried to do a scheduled job at reboot executed with root but it gets launched after the system detects the external USB enclosure and therefore it uses UAS for it. So I have to turn the external drive off, relaunch the script and turn it on again each time the system reboots.


    Is there any way to execute a custom script at a "lower level", before the system recognises the USB devices attached to it? Maybe at /etc/init.d/ or /etc/rc.local?


    Thanks in advance.

    omv 5.5.23-1 usul arm64

    omv 5.5.23-1 usul x64


  • Is there any way to execute a custom script at a "lower level", before the system recognises the USB devices attached to it? Maybe at /etc/init.d/ or /etc/rc.local?

    Why not solving your problem instead. Quick web search for 'debian blacklist uas' ends up here: https://unix.stackexchange.com…n-usb3-hdd-uas-i-o-errors (if you run on x86 then follow the last answer and not how I prepared it with Armbian)

  • Why not solving your problem instead. Quick web search for 'debian blacklist uas' ends up here: https://unix.stackexchange.com…n-usb3-hdd-uas-i-o-errors (if you run on x86 then follow the last answer and not how I prepared it with Armbian)

    I tried the latest solution but it does not prevent the UAS from being loaded:

    Code
    echo "options usb-storage quirks=174c:55aa:u" >> /etc/modprobe.d/usb-storage-quirks.conf
    update-initramfs -u

    It generates a usb-storage-quirks.conf in modprobe correctly, but when doing a lsusb -t:

    Code
    /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 5000M
        |__ Port 1: Dev 3, If 0, Class=Mass Storage, Driver=uas, 5000M
        |__ Port 9: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
        |__ Port 4: Dev 2, If 0, Class=Human Interface Device, Driver=usbfs, 12M
        |__ Port 6: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 480M

    The Bus 02-Port 1-Dev 3 is the external enclosure (which should be "Driver=usb-storage"). The Bus 02-Port 9-Dev 2 is the cache SSD.


    With the UAS driver it gests lots of device resets, SMART warnings and I/O errors in syslog.


    What I need to do is prevent the system from loading UAS for that vendor ID (blacklist definitely, I would prefer not to disable UAS for other devices as my cache SSD uses it correctly) since the boot sequence, as if it gets loaded, no matter what I do it does not change the driver until i turn it off/on or unplug/plug the cable.

    omv 5.5.23-1 usul arm64

    omv 5.5.23-1 usul x64


  • Just to be sure: Did you reboot in between?

    Oh right, after a reboot it loads it as usb-storage, thank you a lot.


    The weird part is that it seems to have disabled completely uas because my cache SSD has changed from uas to usb-storage too. I have rechecked the vendor_id and product_id chain for my external enclosure in the quirks file.


    I prefer not having issues with the external drive to have a minimal boost on the cache disk so I will leave it as is now.


    Code
    /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 5000M
        |__ Port 1: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
        |__ Port 9: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
        |__ Port 4: Dev 2, If 0, Class=Human Interface Device, Driver=usbfs, 12M
        |__ Port 6: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 480M

    Thank you again!

    omv 5.5.23-1 usul arm64

    omv 5.5.23-1 usul x64


  • Hmm... unlikely but without knowing the contents of /etc/modprobe.d/usb-storage-quirks.conf and output of lsusb I can't tell anything... you might also watch dmesg output for informative messages...

    Here they go:
    cat /etc/modprobe.d/usb-storage-quirks.conf

    Code
    options usb-storage quirks=174c:55aa:u

    lusb

    Code
    Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 003: ID 8564:1000 Transcend Information, Inc. JetFlash
    Bus 001 Device 002: ID 051d:0003 American Power Conversion UPS
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    lsusb -t  (without the external hdd attached)

    Code
    /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 5000M
        |__ Port 9: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
        |__ Port 4: Dev 2, If 0, Class=Human Interface Device, Driver=usbfs, 12M
        |__ Port 6: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 480M

    lsusb -t (with the external hdd attached)

    Code
    /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 5000M
        |__ Port 1: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
        |__ Port 9: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
        |__ Port 4: Dev 2, If 0, Class=Human Interface Device, Driver=usbfs, 12M
        |__ Port 6: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 480M

    dmesg (since the moment I attached the external drive)

    Thanks again.


    I am ok with this, I do not think I will miss any real performance between uas and usb-storage driver on the cache drive.

    omv 5.5.23-1 usul arm64

    omv 5.5.23-1 usul x64


  • I do not think I will miss any real performance between uas and usb-storage driver on the cache drive

    UAS or the old and anachronistic mass storage mode can make a huge difference wrt random IO. And I was a bit unclear about what could be interesting before: it's not about the external disk but your cache SSD that seems to be missing on most outputs you posted directly above.


    Anyway: one problem with ASMedia's chipsets is that the vendor reused product IDs for different chips so proper detection gets tricky. Which kernel version are you running with (uname -a)?

  • UAS or the old and anachronistic mass storage mode can make a huge difference wrt random IO. And I was a bit unclear about what could be interesting before: it's not about the external disk but your cache SSD that seems to be missing on most outputs you posted directly above.
    Anyway: one problem with ASMedia's chipsets is that the vendor reused product IDs for different chips so proper detection gets tricky. Which kernel version are you running with (uname -a)?

    uname -a

    Code
    Linux olmos13nas 4.16.0-0.bpo.2-amd64 #1 SMP Debian 4.16.12-1~bpo9+1 (2018-06-03) x86_64 GNU/Linux

    omv 5.5.23-1 usul arm64

    omv 5.5.23-1 usul x64


Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!