Received: by 10.223.185.116 with SMTP id b49csp5059488wrg; Tue, 27 Feb 2018 07:11:49 -0800 (PST) X-Google-Smtp-Source: AH8x227pgpDybeh7aYFUmry0leySk1WAuoLsL38njOOPgpPTXzBLPr9ijV2pYMHsckulSByuyWdv X-Received: by 2002:a17:902:a610:: with SMTP id u16-v6mr13947762plq.293.1519744309662; Tue, 27 Feb 2018 07:11:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519744309; cv=none; d=google.com; s=arc-20160816; b=Te7AtX6efd6mwj1EOE/oI/TlionzuREL2UI+JRpLasMCLC8i827bG9EFtPLXBoEFfr Ml4BhIuD8GbnUdLrdPHNQdCgtZqAMNpZwfDV2fSdlq/FvtkUORBz3WCgbcIs7tzxJkZS oKQY78hwBJjVC2Q2rcnrLs4SHYI3kFZSmTNDvxHe6gHqNkkJo0LEl7fOWAxLRfYYyRUX LcXK9M97OTiOgq6zB2ZAI0VfhYwGCirYBU8yjoY5GdA9OvxSwibs/EjzCp4wizbu5/Lp aBWJ4fCJtzbBBniSmov2x23ZNQDhRCcB85YAOiQ2VRtsupf6dp6dXd2Fnyp8LazGmEYt YZQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=xnsPC1guSpaRnXXvTsF7/UMqvvSlJTig9TywjQ+Y2dc=; b=cFbOp7y5c4PTD4iCaCbZHZX1wlRfvrU5EzFFY3rK3aFlVq7LXP2XS1sIslNstD9+LB o+GpW6q3MU95cZ4zwEqMbE8lfeuTlQlFBkjRARHskq2AhZGTcEs7GJvWSuwybcEZ7Taz WX0YmOmd43Cm2xHqFjsGc8QYhHPAeN/ACFJ1fFdgiJ5ojbOdREBvAuyWSTtC0gy0PSI4 QWL91meexZo2KTARd4/foF2gP6E2IIZcPzZuVZ5++cc6/gOChy7ZkZnXvHjJdT7H0p84 PpKNDc/dVvIYPEJ5lv0+KNvMb1W9lMuSwPANxiFN/ZSwgeGsu50dGPTH5M+mUB7UkmWz Mluw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fi/K+P5K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s25si7137448pgv.479.2018.02.27.07.11.33; Tue, 27 Feb 2018 07:11:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fi/K+P5K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754050AbeB0PJc (ORCPT + 99 others); Tue, 27 Feb 2018 10:09:32 -0500 Received: from mail-pl0-f49.google.com ([209.85.160.49]:41303 "EHLO mail-pl0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753167AbeB0PJa (ORCPT ); Tue, 27 Feb 2018 10:09:30 -0500 Received: by mail-pl0-f49.google.com with SMTP id k8so11518525pli.8; Tue, 27 Feb 2018 07:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=xnsPC1guSpaRnXXvTsF7/UMqvvSlJTig9TywjQ+Y2dc=; b=fi/K+P5K6p9MXSrSl9Y17oE9Ga+lplhi1cMh7qGbM9Yu+kmd6vN9XwfXHOMHCPzHMj AgBV7y9CX1Bnv+eERUKw3T63D8otFM5ydZRBaGsgoYRrBTvbqqX6i/AS38NqmMFM981t S1tbYTFG6SAyPt/RWgkWD5Lu8WfkVlFag0EO+Go0jOn5fq5WYuCtWWo7IpVKPGDEDLz8 jMLWOflhZPi33TriKfQHff4uFK31FOR/K1XhYH6oTlP53cOX+yIZXgXVg1nOsjpj56go /rpxiOwn5WqQYHxDzhax2geM3jqh0X1zd63bvYdXYINwTBI5yM9Kh8MjV6qTyBYpIVNF Pn9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=xnsPC1guSpaRnXXvTsF7/UMqvvSlJTig9TywjQ+Y2dc=; b=n9g5/qtAW/aEAQYwaVn/ksbaOvu2zgOK6T7NeJsewU4TyHVlVECccNiD1gRSA3UqyS 6FZ/M5gfbFzKoUDMGczV4pYKrk1b1oJvztTM/q7EortNjURwyKfSQyCJQHfiFLpptP42 r6sXUI6l0QF83Ue2Seapq/Cm0+9sSYg6kTHGtQukuEvlKESxQp04RsJziNOW4Y6Obyi3 wmHFXg2aFt2ml2JsCxpFjbN4uyv62id7iv+yM8e72OdrYr5MBzP35s5RVgqqfXPZE6th C7Tn712N9X3Epj0PXB14qpJJWWaAEkoPkjU82s0HJfwxeojodonMCyn7CVUjJ3x1pOtc 8hFQ== X-Gm-Message-State: APf1xPBsypq8HTMQdUhhy35LAfxAEW+KwhxjG/+wH6URzmUOr4mW4NJ3 uZUbdPWzK3fC+X7FhlkIRaQ= X-Received: by 2002:a17:902:a50b:: with SMTP id s11-v6mr14452426plq.440.1519744169785; Tue, 27 Feb 2018 07:09:29 -0800 (PST) Received: from edumazet-glaptop3.lan (c-67-180-167-114.hsd1.ca.comcast.net. [67.180.167.114]) by smtp.googlemail.com with ESMTPSA id p79sm22441780pfi.115.2018.02.27.07.09.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Feb 2018 07:09:28 -0800 (PST) Message-ID: <1519744167.7296.8.camel@gmail.com> Subject: Re: inconsistent lock state with usbnet/asix usb ethernet and xhci From: Eric Dumazet To: Marek Szyprowski , netdev@vger.kernel.org, Linux USB Mailing List , LKML , 'Linux Samsung SOC' Cc: Dean Jenkins , Oliver Neukum Date: Tue, 27 Feb 2018 07:09:27 -0800 In-Reply-To: References: <1519740421.7296.6.camel@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-02-27 at 15:42 +0100, Marek Szyprowski wrote: > Hi Eric, > > On 2018-02-27 15:07, Eric Dumazet wrote: > > On Tue, 2018-02-27 at 08:26 +0100, Marek Szyprowski wrote: > > > I've noticed that USBnet/ASIX AX88772B USB driver produces deplock kernel > > > warning ("inconsistent lock state") on Chromebook2 Peach-PIT board. No > > > special activity is needed to reproduce this issue, it happens almost > > > on every boot. ASIX USB ethernet is connected to XHCI USB host controller > > > on that board. Is it a known issue? Frankly I have no idea where to look > > > to fix it. The same adapter connected to EHCI ports on other boards based > > > on the same SoC works fine without any warnings. > > > > > > Here are some more information from that board: > > > # lsusb > > > Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub > > > Bus 005 Device 002: ID 0b95:772b ASIX Electronics Corp. AX88772B > > > Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub > > > Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub > > > Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub > > > Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub > > > Bus 001 Device 002: ID 2232:1056 Silicon Motion > > > Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub > > > > > > # lsusb -t > > > /:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M > > > /:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M > > >     |__ Port 1: Dev 2, If 0, Class=Vendor Specific Class, Driver=asix, 480M > > > /:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M > > > /:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M > > > /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=exynos-ohci/3p, 12M > > > /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=exynos-ehci/3p, 480M > > >     |__ Port 1: Dev 2, If 0, Class=Video, Driver=, 480M > > >     |__ Port 1: Dev 2, If 1, Class=Video, Driver=, 480M > > > > > > > > > And the log with mentioned warning: > > > > > > [   17.768040] ================================ > > > [   17.772239] WARNING: inconsistent lock state > > > [   17.776511] 4.16.0-rc3-next-20180227-00007-g876c53a7493c #453 Not tainted > > > [   17.783329] -------------------------------- > > > [   17.787580] inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. > > > [   17.793607] swapper/0/0 [HC0[0]:SC1[1]:HE1:SE0] takes: > > > [   17.798751]  (&syncp->seq#5){?.-.}, at: [<9b22e5f0>] > > > asix_rx_fixup_internal+0x188/0x288 > > > [   17.806790] {IN-HARDIRQ-W} state was registered at: > > > [   17.811677]   tx_complete+0x100/0x208 > > > [   17.815319]   __usb_hcd_giveback_urb+0x60/0xf0 > > > [   17.819770]   xhci_giveback_urb_in_irq+0xa8/0x240 > > > [   17.824469]   xhci_td_cleanup+0xf4/0x16c > > > [   17.828367]   xhci_irq+0xe74/0x2240 > > > [   17.831827]   usb_hcd_irq+0x24/0x38 > > > [   17.835343]   __handle_irq_event_percpu+0x98/0x510 > > > [   17.840111]   handle_irq_event_percpu+0x1c/0x58 > > > [   17.844623]   handle_irq_event+0x38/0x5c > > > [   17.848519]   handle_fasteoi_irq+0xa4/0x138 > > > [   17.852681]   generic_handle_irq+0x18/0x28 > > > [   17.856760]   __handle_domain_irq+0x6c/0xe4 > > > [   17.860941]   gic_handle_irq+0x54/0xa0 > > > [   17.864666]   __irq_svc+0x70/0xb0 > > > [   17.867964]   arch_cpu_idle+0x20/0x3c > > > [   17.871578]   arch_cpu_idle+0x20/0x3c > > > [   17.875190]   do_idle+0x144/0x218 > > > [   17.878468]   cpu_startup_entry+0x18/0x1c > > > [   17.882454]   start_kernel+0x394/0x400 > > > [   17.886177] irq event stamp: 161912 > > > [   17.889616] hardirqs last  enabled at (161912): [<7bedfacf>] > > > __netdev_alloc_skb+0xcc/0x140 > > > [   17.897893] hardirqs last disabled at (161911): [] > > > __netdev_alloc_skb+0x94/0x140 > > > [   17.904903] exynos5-hsi2c 12ca0000.i2c: tx timeout > > > [   17.906116] softirqs last  enabled at (161904): [<387102ff>] > > > irq_enter+0x78/0x80 > > > [   17.906123] softirqs last disabled at (161905): [] > > > irq_exit+0x134/0x158 > > > [   17.925722]. > > > [   17.925722] other info that might help us debug this: > > > [   17.933435]  Possible unsafe locking scenario: > > > [   17.933435]. > > > [   17.940331]        CPU0 > > > [   17.942488]        ---- > > > [   17.944894]   lock(&syncp->seq#5); > > > [   17.948274]   > > > [   17.950847]     lock(&syncp->seq#5); > > > [   17.954386]. > > > [   17.954386]  *** DEADLOCK *** > > > [   17.954386]. > > > [   17.962422] no locks held by swapper/0/0. > > > [   17.966011]. > > > [   17.966011] stack backtrace: > > > [   17.971333] CPU: 0 PID: 0 Comm: swapper/0 Not tainted > > > 4.16.0-rc3-next-20180227-00007-g876c53a7493c #453 > > > [   17.980312] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) > > > [   17.986380] [] (unwind_backtrace) from [] > > > (show_stack+0x10/0x14) > > > [   17.994128] [] (show_stack) from [] > > > (dump_stack+0x90/0xc8) > > > [   18.001339] [] (dump_stack) from [] > > > (print_usage_bug+0x25c/0x2cc) > > > [   18.009161] [] (print_usage_bug) from [] > > > (mark_lock+0x290/0x698) > > > [   18.014952] exynos5-hsi2c 12ca0000.i2c: tx timeout > > > [   18.016899] [] (mark_lock) from [] > > > (__lock_acquire+0x454/0x1850) > > > [   18.029449] [] (__lock_acquire) from [] > > > (lock_acquire+0xc8/0x2b8) > > > [   18.037272] [] (lock_acquire) from [] > > > (usbnet_skb_return+0x7c/0x1a0) > > > [   18.045356] [] (usbnet_skb_return) from [] > > > (asix_rx_fixup_internal+0x188/0x288) > > > [   18.054420] [] (asix_rx_fixup_internal) from [] > > > (usbnet_bh+0xf8/0x2e4) > > > [   18.062694] [] (usbnet_bh) from [] > > > (tasklet_action+0x8c/0x13c) > > > [   18.070259] [] (tasklet_action) from [] > > > (__do_softirq+0xd4/0x6d4) > > > [   18.078089] [] (__do_softirq) from [] > > > (irq_exit+0x134/0x158) > > > [   18.085480] [] (irq_exit) from [] > > > (__handle_domain_irq+0x70/0xe4) > > > [   18.093314] [] (__handle_domain_irq) from [] > > > (gic_handle_irq+0x54/0xa0) > > > [   18.101670] [] (gic_handle_irq) from [] > > > (__irq_svc+0x70/0xb0) > > > [   18.109163] Exception stack(0xc0f01eb8 to 0xc0f01f00) > > > [   18.114202] 1ea0: 00000001 00000001 > > > [   18.122397] 1ec0: 00000000 c0f0ba80 eef3a540 eef3a540 ee8d2700 > > > c0f088b4 00000402 c09d23e0 > > > [   18.124980] exynos5-hsi2c 12ca0000.i2c: tx timeout > > > [   18.130611] 1ee0: c0f0ba80 c0f01f4c 00000000 c0f01f08 c017ea54 > > > c09d92d4 20000013 ffffffff > > > [   18.135504] cpu cpu0: _set_opp_voltage: failed to set voltage > > > (1250000 1250000 1250000 mV): -110 > > > [   18.143690] [] (__irq_svc) from [] > > > (_raw_spin_unlock_irq+0x28/0x5c) > > > [   18.152671] cpufreq: __target_index: Failed to change cpu frequency: -110 > > > [   18.160683] [] (_raw_spin_unlock_irq) from [] > > > (finish_task_switch+0xb4/0x254) > > > [   18.160696] [] (finish_task_switch) from [] > > > (__schedule+0x290/0xb10) > > > [   18.160704] [] (__schedule) from [] > > > (schedule_idle+0x2c/0x78) > > > [   18.160711] [] (schedule_idle) from [] > > > (cpu_startup_entry+0x18/0x1c) > > > [   18.200726] [] (cpu_startup_entry) from [] > > > (start_kernel+0x394/0x400) > > > > > > Best regards > > > > Please try the attached patch, thanks. > > Thanks for the patch. It fixes the deplock warning. However IMHO the same > fix should be also applied to complete_tx function for modifying stats64 > there: > > diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c > index 7f5bda0ec9e8..d9eea8cfe6cb 100644 > --- a/drivers/net/usb/usbnet.c > +++ b/drivers/net/usb/usbnet.c > @@ -1249,11 +1249,12 @@ static void tx_complete (struct urb *urb) > >         if (urb->status == 0) { >                 struct pcpu_sw_netstats *stats64 = > this_cpu_ptr(dev->stats64); > +               unsigned long flags; > > -               u64_stats_update_begin(&stats64->syncp); > +               flags = u64_stats_update_begin_irqsave(&stats64->syncp); >                 stats64->tx_packets += entry->packets; >                 stats64->tx_bytes += entry->length; > -               u64_stats_update_end(&stats64->syncp); > + u64_stats_update_end_irqrestore(&stats64->syncp, flags); >         } else { >                 dev->net->stats.tx_errors++; > > > I've did that and it also works fine without deplock warning. Note that for this one, it seems we also could perform stats updates in BH context, since skb is queued via defer_bh() But simplicity wins I guess. I'll send a formal patch including your change in tx_complete(), thanks !