Re: kernel crash/disc errors when unbinding USB devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/23/22 12:59, Helge Deller wrote:
> On 1/23/22 12:07, Greg Kroah-Hartman wrote:
>> On Sun, Jan 23, 2022 at 11:40:01AM +0100, Helge Deller wrote:
>>> On all kernels 5.15.x and 5.16.x I noticed that resetting
>>> the USB devices with this shell script:
>>>
>>>        for i in $(ls /sys/bus/pci/drivers/ahci/|grep :)
>>>          do
>>>          echo $i
>>>          echo $i >/sys/bus/pci/drivers/ahci/unbind
>>>          sleep 1
>>>          echo $i >/sys/bus/pci/drivers/ahci/bind
>>>         done
>>
>> That is dangerous to do, why do this?  All of your block devices might
>> have disappeard.
>>
>>>         # reseting USB3 ports (if there none you'll get errors)
>>>         for i in $(ls /sys/bus/pci/drivers/xhci_hcd/|grep :)
>>>          do
>>>          echo $i
>>>          echo $i >/sys/bus/pci/drivers/xhci_hcd/unbind
>>>          sleep 1
>>>          echo $i >/sys/bus/pci/drivers/xhci_hcd/bind
>>>         done
>>
>> Again, why do this at all?
>
> I need to reset some of the USB devices after a suspend/resume cycle.
> The problem is, that some of the USB devices are
> handed over into a running VirtualBox VM and after
> the suspend/resume they need to be virtually plugged out/in
> so that the running Windows VM will reconnect them.
>
> If you search in the internet, you will find many places
> where this unbind/bind process is mentioned, e.g.:
> https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line
> This procedure did worked in the past.
>
> I think the main problem is, that it's somehow unexpected that
> the SATA controllers are logically attached to the USB
> controllers.
> So, if you believe to unbind "just" the USB devices you
> suddenly unbind SATA controllers too.
>
>>> immediately leads to a non-functional system, because the discs
>>> face I/O errors and will switch to read-only mode.
>>
>> Sure, the disks are gone, this is expected.
>
> Ok.
>
>>> Effectively I have to reboot the machine.
>>
>> I'm amazed it keeps working at all.
>
> :-)
>
>>> It's reproduceable for me on two completely different x86 machines with
>>> different USB devices.
>>
>> What do you expect this to do instead?  You just disabled all block
>> controllers in your system, followed by all USB controllers.  And then
>> attempted to add them back, but given that the old devices still had
>> userspace references on them, the devices will come back with different
>> names and so you need to mount them again.
>>
>> So this looks like it is working as intended.  Just don't do this :)
>
> Ok, sure, but I think it's unexpected that the SATA ports are listed
> beneath the USB controllers, beside USB devices.
> If I run "lsusb", the SATA controllers don't show up either.
> They are listed when I run "lspci".
> Shouldn't they maybe show up somewhere else, e.g.
> /sys/bus/pci/drivers/sata/*

Ignore this.
AHCI = SATA...

Sorry for the noise.

Helge




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux