Re: [PATCH v2 5/5] r8152: Block future register access if register access fails
From: Simon Horman
Date: Thu Oct 05 2023 - 11:47:35 EST
On Wed, Oct 04, 2023 at 12:24:42PM -0700, Douglas Anderson wrote:
...
> @@ -9784,7 +9904,29 @@ static int rtl8152_probe(struct usb_interface *intf,
> else
> device_set_wakeup_enable(&udev->dev, false);
>
> - netif_info(tp, probe, netdev, "%s\n", DRIVER_VERSION);
> + mutex_lock(&tp->control);
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
> + /* If the device is marked inaccessible before probe even
> + * finished then one of two things happened. Either we got a
> + * USB error during probe or the user already unplugged the
> + * device.
> + *
> + * If we got a USB error during probe then we skipped doing a
> + * reset in r8152_control_msg() and deferred it to here. This
> + * is because the queued reset will give up after 1 second
> + * (see usb_lock_device_for_reset()) and we want to make sure
> + * that we queue things up right before probe finishes.
> + *
> + * If the user already unplugged the device then the USB
> + * farmework will call unbind right away for us. The extra
Hi Douglas,
As you are planning to re-spin anyway: farmework -> framework
> + * reset we queue up here will be harmless.
> + */
> + usb_queue_reset_device(tp->intf);
> + } else {
> + set_bit(PROBED_WITH_NO_ERRORS, &tp->flags);
> + netif_info(tp, probe, netdev, "%s\n", DRIVER_VERSION);
> + }
> + mutex_unlock(&tp->control);
>
> return 0;
>
> --
> 2.42.0.582.g8ccd20d70d-goog
>