Message ID | 20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid |
---|---|
State | Superseded |
Headers | show |
Series | [net,v3,1/5] r8152: Hold the rtnl_lock for all of reset | expand |
Douglas Anderson <dianders@chromium.org> > Sent: Thursday, November 30, 2023 5:25 AM [...] > > Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set > so that they don't delay too long if the device becomes > inaccessible. Add the break to the loop in r8153_aldps_en(). > > Fixes: 4214cc550bf9 ("r8152: check if disabling ALDPS is finished") > Reviewed-by: Grant Grundler <grundler@chromium.org> > Signed-off-by: Douglas Anderson <dianders@chromium.org> Acked-by: Hayes Wang <hayeswang@realtek.com> Best Regards, Hayes
Hello: This series was applied to netdev/net.git (main) by David S. Miller <davem@davemloft.net>: On Wed, 29 Nov 2023 13:25:20 -0800 you wrote: > As of commit d9962b0d4202 ("r8152: Block future register access if > register access fails") there is a race condition that can happen > between the USB device reset thread and napi_enable() (not) getting > called during rtl8152_open(). Specifically: > * While rtl8152_open() is running we get a register access error > that's _not_ -ENODEV and queue up a USB reset. > * rtl8152_open() exits before calling napi_enable() due to any reason > (including usb_submit_urb() returning an error). > > [...] Here is the summary with links: - [net,v3,1/5] r8152: Hold the rtnl_lock for all of reset https://git.kernel.org/netdev/net/c/e62adaeecdc6 - [net,v3,2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops https://git.kernel.org/netdev/net/c/32a574c7e268 - [net,v3,3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash() https://git.kernel.org/netdev/net/c/8a67b47fced9 - [net,v3,4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1() https://git.kernel.org/netdev/net/c/8c53a7bd7065 - [net,v3,5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en() https://git.kernel.org/netdev/net/c/79321a793945 You are awesome, thank you!
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 2c5c1e91ded6..d6edf0254599 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -8397,6 +8397,8 @@ static int rtl8152_pre_reset(struct usb_interface *intf) struct r8152 *tp = usb_get_intfdata(intf); struct net_device *netdev; + rtnl_lock(); + if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) return 0; @@ -8428,20 +8430,17 @@ static int rtl8152_post_reset(struct usb_interface *intf) struct sockaddr sa; if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) - return 0; + goto exit; rtl_set_accessible(tp); /* reset the MAC address in case of policy change */ - if (determine_ethernet_addr(tp, &sa) >= 0) { - rtnl_lock(); + if (determine_ethernet_addr(tp, &sa) >= 0) dev_set_mac_address (tp->netdev, &sa, NULL); - rtnl_unlock(); - } netdev = tp->netdev; if (!netif_running(netdev)) - return 0; + goto exit; set_bit(WORK_ENABLE, &tp->flags); if (netif_carrier_ok(netdev)) { @@ -8460,6 +8459,8 @@ static int rtl8152_post_reset(struct usb_interface *intf) if (!list_empty(&tp->rx_done)) napi_schedule(&tp->napi); +exit: + rtnl_unlock(); return 0; }