2022-10-08 05:22:58

by David Tomaschik

[permalink] [raw]
Subject: rtl8187 triggers usb device reset on kernel driver disconnect

Hi all,

It seems that any time the rtl8187 driver is detached from an rtl8187
interface, a USB device reset is triggered. This is not a problem in
the general case, but when working with libusb, calling
libusb_detach_kernel_driver
(https://libusb.sourceforge.io/api-1.0/group__libusb__dev.html#ga5e0cc1d666097e915748593effdc634a)
results in the device reset, which then causes the kernel driver to
re-attach to the device. This prevents, for example, forwarding the
device into a VM using QEMU/KVM. This seems to be due to
rtl8187_disconnect calling usb_reset_device.

The 8187 driver seems to be the only realtek driver unconditionally
resetting on disconnect -- is this technically necessary? I'm not
sure I would call this a bug, but it's definitely behavior that was
very puzzling to me and I only understood after enough debugging to
start reading kernel source.

David

--
David Tomaschik
https://systemoverlord.com
[email protected]
7FD5 8D9A 196D CEEE AD67 1F94 F4D7 A791 5DEA 789B


2022-10-10 01:32:37

by Larry Finger

[permalink] [raw]
Subject: Re: rtl8187 triggers usb device reset on kernel driver disconnect

On 10/7/22 23:33, David Tomaschik wrote:
> Hi all,
>
> It seems that any time the rtl8187 driver is detached from an rtl8187
> interface, a USB device reset is triggered. This is not a problem in
> the general case, but when working with libusb, calling
> libusb_detach_kernel_driver
> (https://libusb.sourceforge.io/api-1.0/group__libusb__dev.html#ga5e0cc1d666097e915748593effdc634a)
> results in the device reset, which then causes the kernel driver to
> re-attach to the device. This prevents, for example, forwarding the
> device into a VM using QEMU/KVM. This seems to be due to
> rtl8187_disconnect calling usb_reset_device.
>
> The 8187 driver seems to be the only realtek driver unconditionally
> resetting on disconnect -- is this technically necessary? I'm not
> sure I would call this a bug, but it's definitely behavior that was
> very puzzling to me and I only understood after enough debugging to
> start reading kernel source.

David,

This behavior certainly is a bug. If one tries to attach the RTL8187 to a VM, it
crashes. I will be looking into this issue.

Larry