Hung tasks after disconnecting SD card reader from the bus while mounted
When powering the USB hub down while the SD card is mounted, the kernel becomes very unhappy. I'd expect it to react gracefully, no different than when unplugging a mounted pendrive on a PC.
[50023.332263] INFO: task kworker/0:2:5069 blocked for more than 120 seconds.
[50023.339527] Tainted: G C 5.15.0-1-librem5 #1
[50023.345784] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[50023.353677] task:kworker/0:2 state:D stack: 0 pid: 5069 ppid: 2 flags:0x00000008
[50023.353749] Workqueue: usb_hub_wq hub_event [usbcore]
[50023.354427] Call trace:
[50023.354436] __switch_to+0x134/0x1f0
[50023.354533] __schedule+0x30c/0x878
[50023.354587] schedule+0x78/0x110
[50023.354600] __submit_bio+0xe4/0x280
[50023.354646] submit_bio_noacct+0x1ec/0x228
[50023.354665] submit_bio+0x58/0x198
[50023.354676] submit_bio_wait+0x64/0xd0
[50023.354715] blkdev_issue_flush+0x80/0xa8
[50023.354743] ext4_sync_fs+0x178/0x218
[50023.354781] sync_filesystem+0x94/0xb8
[50023.354830] fsync_bdev+0x2c/0x70
[50023.354847] delete_partition+0x20/0x88
[50023.354873] blk_drop_partitions+0x54/0x90
[50023.354883] del_gendisk+0x70/0x228
[50023.354919] sd_remove+0x58/0xd0
[50023.354959] device_release_driver_internal+0x1f4/0x1f8
[50023.355001] device_release_driver+0x20/0x30
[50023.355016] bus_remove_device+0xdc/0x168
[50023.355031] device_del+0x184/0x3c0
[50023.355079] __scsi_remove_device+0x114/0x148
[50023.355117] scsi_forget_host+0x80/0xb8
[50023.355134] scsi_remove_host+0x7c/0x138
[50023.355176] usb_stor_disconnect+0x54/0xf8 [usb_storage]
[50023.355293] usb_unbind_interface+0x78/0x228 [usbcore]
[50023.355399] device_release_driver_internal+0x1f4/0x1f8
[50023.355413] device_release_driver+0x20/0x30
[50023.355424] bus_remove_device+0xdc/0x168
[50023.355436] device_del+0x184/0x3c0
[50023.355449] usb_disable_device+0xb0/0x1f8 [usbcore]
[50023.355552] usb_disconnect+0xc8/0x2f0 [usbcore]
[50023.355677] usb_disconnect+0xac/0x2f0 [usbcore]
[50023.355779] hub_event+0x440/0x1590 [usbcore]
[50023.355882] process_one_work+0x214/0x4d0
[50023.355923] worker_thread+0x50/0x480
[50023.355937] kthread+0x158/0x168
[50023.355971] ret_from_fork+0x10/0x20
While in this state, lsusb
just hangs.
To test, mount the SD card and do:
echo 0 | sudo tee /sys/class/leds/hub_nreset/brightness