Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support USB 3.0 UAS Drives #121

Closed
MaximumWaffle opened this issue Dec 22, 2021 · 14 comments
Closed

Support USB 3.0 UAS Drives #121

MaximumWaffle opened this issue Dec 22, 2021 · 14 comments

Comments

@MaximumWaffle
Copy link

Please consider adding uas to the default modules list to support booting from USB 3.0 storage devices that use UAS instead of UMS.

anatol added a commit that referenced this issue Dec 22, 2021
@anatol
Copy link
Owner

anatol commented Dec 22, 2021

Sounds reasonable. I pushed the change to wip branch. Please test it and let me know if it works for you as expected.

@MaximumWaffle
Copy link
Author

Thanks for getting to this so quickly! I was able to do a quick test this morning - I can now boot when I have booster build a universal image, but not when I remove universal from the config.

I added busybox to the image and lowered the timeout in order to take a look at what's happening. For some reason usb_storage and uas are not automatically loaded (even though they are present). I can insmod usb_storage and uas to get my drive to appear in /dev and I can see it load in dmesg. I'm not sure if I'll have time to take a closer look until next week, but I'll try to dig into this a bit more whenever I have a chance.

@anatol
Copy link
Owner

anatol commented Dec 22, 2021

Thanks for the feedback.

Kernel modules (including uas) are loaded when an OS enumerates devices and finds a matching modalias. I wonder if the required modalias was not added to the non-universal booster image.

Let's debug the non-universal image:

  • To confirm that this module was properly added to the image please run booster ls YOURIMAGE.img and post it here.
  • Also please post output of booster build --verbose booster.img it will tell what device aliases you have at your machine.
  • And the last item please post output of the filtered modalias booster cat booster-linux.img usr/lib/modules/booster.alias

@anatol
Copy link
Owner

anatol commented Dec 22, 2021

And for the reference here is a list of modaliases 5.15.10 uses for uas module:

$ grep -w uas /usr/lib/modules/5.15.10-arch1-1/modules.alias
alias usb:v*p*d*dc*dsc*dp*ic08isc06ip62in* uas
alias usb:v*p*d*dc*dsc*dp*ic08isc06ip50in* uas
alias usb:v4971p8024d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v4971p8017d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v4971p1012d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v357Dp7788d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v2537p1068d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v2109p0711d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v154BpF00Dd*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v154BpF00Bd*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v152Dp0578d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v152Dp0567d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v152Dp0539d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v13FDp3940d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v0BC2p331Ad*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v0984p0301d0128dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v059Fp1061d*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v059Fp105Fd*dc*dsc*dp*ic*isc*ip*in* uas
alias usb:v054Cp087Dd*dc*dsc*dp*ic*isc*ip*in* uas

@MaximumWaffle
Copy link
Author

It appears that the device needs two modalias entries to fully enumerate.

When plugging in the device, udevadm monitor -p shows two uevents with different modalias properties:

KERNEL[2240.300811] add      /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
PRODUCT=174c/235c/100
TYPE=0/0/0
INTERFACE=8/6/80
MODALIAS=usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00
SEQNUM=3656
KERNEL[2240.326083] bind     /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 (usb)
ACTION=bind
DEVPATH=/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
DRIVER=uas
PRODUCT=174c/235c/100
TYPE=0/0/0
INTERFACE=8/6/98
MODALIAS=usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip62in00
SEQNUM=3660

The second modalias is the only one present in /sys, so that's the only entry present in booster.alias.

To test this, I extracted booster-linux.img, added the first modalias to booster.alias and recreated the booster-linux.img file. The resulting image was able to successfully boot.

@anatol
Copy link
Owner

anatol commented Dec 26, 2021

Thanks for the response. I just double-checked the aliases and they indeed match uas:

$ modprobe -qaR 'usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00'
uas
usb_storage
$ modprobe -qaR 'usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip62in00'
uas

Why the first alias is not present under /sys is a good question and worth clarifying. But even in this case the second alias should match uas module and load it (+usb_storage which is a dependency of uas). Does it mean your boot system never really receives a udev event for the second modalias?

Could you please add booster.log=debug to the kernel parameter and boot booster with your fixed image. Then in your journalctl there will be a bunch on information related to udev events. What usb/uas udev events do you see there?

@MaximumWaffle
Copy link
Author

Does it mean your boot system never really receives a udev event for the second modalias?

It seems as though second modalias event only happens if the first event successfully matches the driver.

Here's a sample of the log when booting the image that doesn't work. It fails to match the modalias and the system continues loading other drivers, eventually timing out while waiting for the rootfs since the second modalias event never occurs.

[    3.154198] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Subsystem:usb Seqnum:1642 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/     0000:02:00.0/usb2/2-3/2-3:1.0 DEVTYPE:usb_interface INTERFACE:8/6/80 MODALIAS:usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00 PRODUCT:174c/235c/100 SEQNUM:1642 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.154230] booster: udev event {Header:bind@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Action:bind Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Subsystem:usb Seqnum:1643 Vars:map[ACTION:bind BUSNUM:002 DEVNAME:bus/usb/002/002 DEVNUM:002 DEVPATH:     /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 DEVTYPE:usb_device DRIVER:usb MAJOR:189 MINOR:129 PRODUCT:174c/235c/100 SEQNUM:1643 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.154335] booster: no match found for alias usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00 
[    3.353612] usb 1-4.2: new low-speed USB device number 3 using xhci_hcd
[    3.608775] usb 1-4.2: New USB device found, idVendor=046d, idProduct=c31c, bcdDevice=64.00
[    3.608781] usb 1-4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    3.608783] usb 1-4.2: Product: USB Keyboard
[    3.608785] usb 1-4.2: Manufacturer: Logitech
[    3.609096] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2 Subsystem:usb Seqnum:1644 Vars:map[ACTION:add BUSNUM:001 DEVNAME:bus/usb/001/003 DEVNUM:003      DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2 DEVTYPE:usb_device MAJOR:189 MINOR:2 PRODUCT:46d/c31c/6400 SEQNUM:1644 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.623990] booster: udev event {Header:change@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2 Action:change Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2 Subsystem:usb Seqnum:1645 Vars:map[ACTION:change BUSNUM:001 DEVNAME:bus/usb/001/003 D     EVNUM:003 DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2 DEVTYPE:usb_device DRIVER:usb MAJOR:189 MINOR:2 PRODUCT:46d/c31c/6400 SEQNUM:1645 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.647602] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2/1-4.2:1.0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2/1-4.2:1.0 Subsystem:usb Seqnum:1646 Vars:map[ACTION:add DEVPATH:/devices/pci0000:     00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4.2/1-4.2:1.0 DEVTYPE:usb_interface INTERFACE:3/1/1 MODALIAS:usb:v046DpC31Cd6400dc00dsc00dp00ic03isc01ip01in00 PRODUCT:46d/c31c/6400 SEQNUM:1646 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.647670] booster: modalias usb:v046DpC31Cd6400dc00dsc00dp00ic03isc01ip01in00 matched module usbhid
[    3.647715] booster: loading module usbhid
...
[    7.514064] booster: Timeout waiting for root filesystem

Here's a sample of the log from the modified image. It shows that the first modalias matches, the second modalias matches, then the block device appears and booster executes switch_root with the systemd init.

[    3.150552] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Subsystem:usb Seqnum:1640 Vars:map[ACTION:add BUSNUM:002 DEVNAME:bus/usb/002/002 DEVNUM:002 DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 DEVTYPE:usb_device MAJOR:189 MINOR:129 PRODUCT:174c/235c/100 SEQNUM:1640 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.159424] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Subsystem:usb Seqnum:1641 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 DEVTYPE:usb_interface INTERFACE:8/6/80 MODALIAS:usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00 PRODUCT:174c/235c/100 SEQNUM:1641 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.159466] booster: udev event {Header:bind@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Action:bind Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Subsystem:usb Seqnum:1642 Vars:map[ACTION:bind BUSNUM:002 DEVNAME:bus/usb/002/002 DEVNUM:002 DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 DEVTYPE:usb_device DRIVER:usb MAJOR:189 MINOR:129 PRODUCT:174c/235c/100 SEQNUM:1642 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.159551] booster: modalias usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00 matched module uas
[    3.159590] booster: loading module usb_storage
[    3.163836] usbcore: registered new interface driver usb-storage
[    3.163884] booster: udev event {Header:add@/bus/usb/drivers/usb-storage Action:add Devpath:/bus/usb/drivers/usb-storage Subsystem:drivers Seqnum:1643 Vars:map[ACTION:add DEVPATH:/bus/usb/drivers/usb-storage SEQNUM:1643 SUBSYSTEM:drivers]}
[    3.163901] booster: udev event {Header:add@/module/usb_storage Action:add Devpath:/module/usb_storage Subsystem:module Seqnum:1644 Vars:map[ACTION:add DEVPATH:/module/usb_storage SEQNUM:1644 SUBSYSTEM:module]}
[    3.163929] booster: loading module uas
[    3.184171] booster: udev event {Header:add@/devices/virtual/workqueue/scsi_tmf_9 Action:add Devpath:/devices/virtual/workqueue/scsi_tmf_9 Subsystem:workqueue Seqnum:1645 Vars:map[ACTION:add DEVPATH:/devices/virtual/workqueue/scsi_tmf_9 SEQNUM:1645 SUBSYSTEM:workqueue]}
[    3.187957] scsi host9: uas
[    3.188026] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9 Subsystem:scsi Seqnum:1646 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9 DEVTYPE:scsi_host SEQNUM:1646 SUBSYSTEM:scsi]}
[    3.188032] usbcore: registered new interface driver uas
[    3.188039] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/scsi_host/host9 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/scsi_host/host9 Subsystem:scsi_host Seqnum:1647 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/scsi_host/host9 SEQNUM:1647 SUBSYSTEM:scsi_host]}
[    3.188059] booster: udev event {Header:bind@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Action:bind Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Subsystem:usb Seqnum:1648 Vars:map[ACTION:bind DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 DEVTYPE:usb_interface DRIVER:uas INTERFACE:8/6/98 MODALIAS:usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip62in00 PRODUCT:174c/235c/100 SEQNUM:1648 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.188081] booster: udev event {Header:add@/bus/usb/drivers/uas Action:add Devpath:/bus/usb/drivers/uas Subsystem:drivers Seqnum:1649 Vars:map[ACTION:add DEVPATH:/bus/usb/drivers/uas SEQNUM:1649 SUBSYSTEM:drivers]}
[    3.188092] booster: udev event {Header:add@/module/uas Action:add Devpath:/module/uas Subsystem:module Seqnum:1650 Vars:map[ACTION:add DEVPATH:/module/uas SEQNUM:1650 SUBSYSTEM:module]}
[    3.188098] booster: modalias usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip62in00 matched module uas
[    3.188266] scsi 9:0:0:0: Direct-Access     SanDisk  SDSSDP128G       0    PQ: 0 ANSI: 6
[    3.188684] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0 Subsystem:scsi Seqnum:1651 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0 DEVTYPE:scsi_target SEQNUM:1651 SUBSYSTEM:scsi]}
[    3.188705] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0 Subsystem:scsi Seqnum:1652 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0 DEVTYPE:scsi_device MODALIAS:scsi:t-0x00 SEQNUM:1652 SUBSYSTEM:scsi]}
[    3.188720] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/scsi_device/9:0:0:0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/scsi_device/9:0:0:0 Subsystem:scsi_device Seqnum:1653 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/scsi_device/9:0:0:0 SEQNUM:1653 SUBSYSTEM:scsi_device]}
[    3.188743] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/bsg/9:0:0:0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/bsg/9:0:0:0 Subsystem:bsg Seqnum:1654 Vars:map[ACTION:add DEVNAME:bsg/9:0:0:0 DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/bsg/9:0:0:0 MAJOR:242 MINOR:4 SEQNUM:1654 SUBSYSTEM:bsg]}
[    3.188751] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/scsi_disk/9:0:0:0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/scsi_disk/9:0:0:0 Subsystem:scsi_disk Seqnum:1655 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0/scsi_disk/9:0:0:0 SEQNUM:1655 SUBSYSTEM:scsi_disk]}
[    3.189221] sd 9:0:0:0: [sde] 246162672 512-byte logical blocks: (126 GB/117 GiB)
...
[    3.276212] booster: mounting /dev/sde2->/booster.root, fs=ext4, flags=0x0, options=
[    3.295044] sd 9:0:0:0: [sde] Attached SCSI disk
[    3.295114] booster: udev event {Header:bind@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0 Action:bind Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0 Subsystem:scsi Seqnum:1665 Vars:map[ACTION:bind DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/target9:0:0/9:0:0:0 DEVTYPE:scsi_device DRIVER:sd MODALIAS:scsi:t-0x00 SEQNUM:1665 SUBSYSTEM:scsi]}
[    3.297253] EXT4-fs (sde2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[    3.314902] booster: Switching to the new userspace now. Да пабачэння!
[    3.355880] usb 1-4.2: new low-speed USB device number 3 using xhci_hcd
[    3.498093] random: crng init done
[    3.498103] systemd[1]: Successfully credited entropy passed from boot loader.
[    3.499292] systemd[1]: systemd 249.7-2-arch running in system mode (+PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified)

anatol added a commit that referenced this issue Dec 27, 2021
@anatol
Copy link
Owner

anatol commented Dec 28, 2021

Interesting...

So in the second case (booster boots successfully) the first modalias (usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00) matches uas and usb_storage modules. Booster loads the drivers. This triggers uas device enumeration and it in turn reports another modailias for the same device but different USB interface.

So the first alias is the important one and booster should add it to the image. But for some reason it does not see it at the image generation time. Which is wrong. Booster should have a way to enumerate all the UAS devices + its modaliases.

To double-check do you see any of the 2 above modailiases when you run find /sys/devices -name modalias -exec cat {} \;?

@anatol
Copy link
Owner

anatol commented Dec 28, 2021

Also at this point the correct workaround to load the uas driver is to add following config option modules_force_load: uas

@MaximumWaffle
Copy link
Author

I did a bit more digging...

My understanding is that USB devices have one device descriptor, but can have multiple configurations (these seem to be referred to as alternate settings in the driver). Configurations can in turn have multiple interfaces.

Breaking down the device ID shows that the device first specifies its interface as USB_PR_BULK (ip = 0x50 in the modalias). Both usb_storage and uas register for devices with interface class USB_CLASS_MASS_STORAGE, interface subclass USB_SC_SCSI and interface USB_PR_BULK so each driver's probe function will be called.

During storage_probe() in the usb_storage driver, it will check if the UAS driver is enabled, and if so it will iterate through the alternate settings checking for a profile that's UAS capable ((interface class == USB_CLASS_MASS_STORAGE) && (interface subclasss == USB_SC_SCSI) && (interface == USB_PR_UAS)). If it finds a UAS capable alternate setting it will ignore the device by returning -ENXIO (no such device).

In the meantime, the UAS driver will also match the first modalias and in uas_probe() it will check if one of the interfaces in an alternate configuration supports UAS. If it finds a UAS-capable interface it calls uas_switch_interface(). This in turn calls usb_set_interface() to switch to the USB_PR_UAS alternate configuration, which I believe disables the USB_PR_BULK interface since I think only one interface can be active for an endpoint (I'm not very familiar with USB terminology so this may not be totally accurate). I'm not sure, but I'm guessing that disabling and enabling the endpoint when switching interfaces may trigger the second event with the new modalias.

I suspect the device is presenting USB_PR_BULK first for backwards compatibility - systems without any idea of what a UAS interface is would simply ignore the device if it presented USB_PR_UAS first.

The second modalias is the only one present on my system. The first modalias is absent because there is only one active interface for the device.

$ find /sys/devices -name modalias | xargs grep -e v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00 -e v174Cp235Cd0100dc00dsc00dp00ic08isc06ip62in00
/sys/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/modalias:usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip62in00

Also at this point the correct workaround to load the uas driver is to add following config option modules_force_load: uas

Sounds good! That's what I've been doing so I'm glad to know that's the right approach for now.

I haven't looked yet, but I'm guessing other initramfs generators include all modalias entries for each driver present in the initramfs.

@anatol
Copy link
Owner

anatol commented Dec 28, 2021

cc @oneukum who is an active uas kernel driver developer and might have some ideas about it.

@anatol
Copy link
Owner

anatol commented Dec 30, 2021

Breaking down the device ID shows that the device first specifies its interface as USB_PR_BULK (ip = 0x50 in the modalias). 

I suspect the device is presenting USB_PR_BULK first for backwards compatibility - systems without any idea of what a UAS interface is would simply ignore the device if it presented USB_PR_UAS first.

The device relies on the USB_PR_BULK modalias, provides USB_PR_BULK interface but it does not report it anywhere at sysfs. For me it sounds like a bug. The device should either report USB_PR_BULK on sysfs or USB_PR_UAS interface should send a udev event during enumeration without relying on existence of usb_storage module.

As a workaround at booster side we can add a module quirk - if uas module is loaded at a usersystem then all its modaliases should be included to the image.

anatol added a commit that referenced this issue Jan 4, 2022
anatol added a commit that referenced this issue Jan 12, 2022
Introduce an idea of quirks for modaliases. Some modules do not report
aliases they use. So we just add all registered modaliases to the
booster image.

Closes #121
@anatol
Copy link
Owner

anatol commented Jan 12, 2022

As there are any comments on this issue from the upstream developer then I am going to implement the "quirk" solution. Booster will add all uas modaliases to the image. This should help to detect the module without any additional user configuration.

@MaximumWaffle Please check wip branch and let me know if it works for you without the config workaround.

anatol added a commit that referenced this issue Jan 12, 2022
Introduce an idea of quirks for modaliases. Some modules do not report
aliases they use. So we just add all registered modaliases to the
booster image.

Closes #121
@MaximumWaffle
Copy link
Author

Looks great, thanks!

$ booster cat /boot/booster-linux.img usr/lib/modules/booster.alias | sort
acpi*:MSFT0101:* tpm_crb
acpi*:MSFT0101:* tpm_tis
cpu:type:x86,ven*fam*mod*:feature:*0081* crc32_pclmul
cpu:type:x86,ven*fam*mod*:feature:*0081* crct10dif_pclmul
cpu:type:x86,ven*fam*mod*:feature:*0081* ghash_clmulni_intel
cpu:type:x86,ven*fam*mod*:feature:*0094* crc32c_intel
cpu:type:x86,ven*fam*mod*:feature:*0099* aesni_intel
pci:v*d*sv*sd*bc0Csc03i30* xhci_pci
usb:v*p*d*dc*dsc*dp*ic03isc*ip*in* usbhid
usb:v*p*d*dc*dsc*dp*ic08isc06ip50in* uas
usb:v*p*d*dc*dsc*dp*ic08isc06ip62in* uas
usb:v054Cp087Dd*dc*dsc*dp*ic*isc*ip*in* uas
usb:v059Fp105Fd*dc*dsc*dp*ic*isc*ip*in* uas
usb:v059Fp1061d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v0984p0301d0128dc*dsc*dp*ic*isc*ip*in* uas
usb:v0BC2p331Ad*dc*dsc*dp*ic*isc*ip*in* uas
usb:v13FDp3940d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v152Dp0539d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v152Dp0567d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v152Dp0578d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v154BpF00Bd*dc*dsc*dp*ic*isc*ip*in* uas
usb:v154BpF00Dd*dc*dsc*dp*ic*isc*ip*in* uas
usb:v2109p0711d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v2537p1068d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v357Dp7788d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v4971p1012d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v4971p8017d*dc*dsc*dp*ic*isc*ip*in* uas
usb:v4971p8024d*dc*dsc*dp*ic*isc*ip*in* uas
[    3.093083] usb 2-3: new SuperSpeed USB device number 2 using xhci_hcd
[    3.121790] usb 2-3: New USB device found, idVendor=174c, idProduct=235c, bcdDevice= 1.00
[    3.121796] usb 2-3: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[    3.121798] usb 2-3: Product: Ugreen Storage Device
[    3.121799] usb 2-3: Manufacturer: Ugreen
[    3.121800] usb 2-3: SerialNumber: 20D11E80C210
[    3.122117] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Subsystem:usb Seqnum:1640 Vars:map[ACTION:add BUSNUM:002 DEVNAME:bus/usb/002/002 DEVNUM:002 DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 DEVTYPE:usb_device MAJOR:189 MINOR:129 PRODUCT:174c/235c/100 SEQNUM:1640 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.133489] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Subsystem:usb Seqnum:1641 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 DEVTYPE:usb_interface INTERFACE:8/6/80 MODALIAS:usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00 PRODUCT:174c/235c/100 SEQNUM:1641 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.133516] booster: udev event {Header:bind@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Action:bind Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 Subsystem:usb Seqnum:1642 Vars:map[ACTION:bind BUSNUM:002 DEVNAME:bus/usb/002/002 DEVNUM:002 DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3 DEVTYPE:usb_device DRIVER:usb MAJOR:189 MINOR:129 PRODUCT:174c/235c/100 SEQNUM:1642 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.133607] booster: modalias usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip50in00 matched module uas
[    3.133654] booster: loading module usb_storage
[    3.137951] usbcore: registered new interface driver usb-storage
[    3.137982] booster: udev event {Header:add@/bus/usb/drivers/usb-storage Action:add Devpath:/bus/usb/drivers/usb-storage Subsystem:drivers Seqnum:1643 Vars:map[ACTION:add DEVPATH:/bus/usb/drivers/usb-storage SEQNUM:1643 SUBSYSTEM:drivers]}
[    3.138000] booster: udev event {Header:add@/module/usb_storage Action:add Devpath:/module/usb_storage Subsystem:module Seqnum:1644 Vars:map[ACTION:add DEVPATH:/module/usb_storage SEQNUM:1644 SUBSYSTEM:module]}
[    3.138056] booster: loading module uas
[    3.161855] booster: udev event {Header:add@/devices/virtual/workqueue/scsi_tmf_9 Action:add Devpath:/devices/virtual/workqueue/scsi_tmf_9 Subsystem:workqueue Seqnum:1645 Vars:map[ACTION:add DEVPATH:/devices/virtual/workqueue/scsi_tmf_9 SEQNUM:1645 SUBSYSTEM:workqueue]}
[    3.165919] scsi host9: uas
[    3.165999] usbcore: registered new interface driver uas
[    3.166161] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9 Subsystem:scsi Seqnum:1646 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9 DEVTYPE:scsi_host SEQNUM:1646 SUBSYSTEM:scsi]}
[    3.166175] booster: udev event {Header:add@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/scsi_host/host9 Action:add Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/scsi_host/host9 Subsystem:scsi_host Seqnum:1647 Vars:map[ACTION:add DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0/host9/scsi_host/host9 SEQNUM:1647 SUBSYSTEM:scsi_host]}
[    3.166202] booster: udev event {Header:bind@/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Action:bind Devpath:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 Subsystem:usb Seqnum:1648 Vars:map[ACTION:bind DEVPATH:/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-3/2-3:1.0 DEVTYPE:usb_interface DRIVER:uas INTERFACE:8/6/98 MODALIAS:usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip62in00 PRODUCT:174c/235c/100 SEQNUM:1648 SUBSYSTEM:usb TYPE:0/0/0]}
[    3.166218] booster: udev event {Header:add@/bus/usb/drivers/uas Action:add Devpath:/bus/usb/drivers/uas Subsystem:drivers Seqnum:1649 Vars:map[ACTION:add DEVPATH:/bus/usb/drivers/uas SEQNUM:1649 SUBSYSTEM:drivers]}
[    3.166227] booster: udev event {Header:add@/module/uas Action:add Devpath:/module/uas Subsystem:module Seqnum:1650 Vars:map[ACTION:add DEVPATH:/module/uas SEQNUM:1650 SUBSYSTEM:module]}
[    3.166299] booster: modalias usb:v174Cp235Cd0100dc00dsc00dp00ic08isc06ip62in00 matched module uas
[    3.166484] scsi 9:0:0:0: Direct-Access     SanDisk  SDSSDP128G       0    PQ: 0 ANSI: 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants