From: Jiri Slaby Subject: Re: Hangs in r8152 connected to power management in kernels at least up v4.17-rc4 Date: Fri, 25 May 2018 10:41:37 +0200 Message-ID: References: <1526388188.2724.5.camel@suse.com> <0835B3720019904CB8F7AA43166CEEB2D2E47ABE@RTITMBSV06.realtek.com.tw> <1526459203.25281.2.camel@suse.com> <0835B3720019904CB8F7AA43166CEEB2D2E47EB4@RTITMBSV06.realtek.com.tw> <1526465391.25281.7.camel@suse.com> <0835B3720019904CB8F7AA43166CEEB2D2E47F8B@RTITMBSV06.realtek.com.tw> <60052c70-ae38-7be8-5f70-5598104a13bd@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "netdev@vger.kernel.org" To: Hayes Wang , Oliver Neukum Return-path: Received: from mail-wm0-f65.google.com ([74.125.82.65]:50905 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965116AbeEYIll (ORCPT ); Fri, 25 May 2018 04:41:41 -0400 Received: by mail-wm0-f65.google.com with SMTP id t11-v6so12231683wmt.0 for ; Fri, 25 May 2018 01:41:40 -0700 (PDT) In-Reply-To: Content-Language: en-GB Sender: netdev-owner@vger.kernel.org List-ID: On 05/16/2018, 03:36 PM, Jiri Slaby wrote: > So I assume it must be a problem of making usb->disconnect without prior > ndo->close (or alike). So according to my debug messages, I think this should workaround the problem: --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -3962,7 +3962,8 @@ static int rtl8152_close(struct net_device *netdev) #ifdef CONFIG_PM_SLEEP unregister_pm_notifier(&tp->pm_notifier); #endif - napi_disable(&tp->napi); + if (!test_bit(RTL8152_UNPLUG, &tp->flags)) + napi_disable(&tp->napi); clear_bit(WORK_ENABLE, &tp->flags); usb_kill_urb(tp->intr_urb); cancel_delayed_work_sync(&tp->schedule); napi is deleted in usb->disconnect, then unregister_netdev is called which invokes netdev->ndo_stop, i.e. rtl8152_close above. And rtl8152_close tries to napi_disable, but that is already deleted. The patch does not solve the race between disconnect and ndo_stop AFAICS. It needs locking, IMO. I am not familiar enough with the code, but it looks like ->disconnect can happen any time while ->stop is in progress. thanks, -- js suse labs