All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Lorenzo Bianconi <lorenzo@kernel.org>,
	Kalle Valo <kvalo@codeaurora.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.4 41/53] mt7601u: do not schedule rx_tasklet when the device has been disconnected
Date: Mon, 15 Jul 2019 10:45:23 -0400	[thread overview]
Message-ID: <20190715144535.11636-41-sashal@kernel.org> (raw)
In-Reply-To: <20190715144535.11636-1-sashal@kernel.org>

From: Lorenzo Bianconi <lorenzo@kernel.org>

[ Upstream commit 4079e8ccabc3b6d1b503f2376123cb515d14921f ]

Do not schedule rx_tasklet when the usb dongle is disconnected.
Moreover do not grub rx_lock in mt7601u_kill_rx since usb_poison_urb
can run concurrently with urb completion and we can unlink urbs from rx
ring in any order.
This patch fixes the common kernel warning reported when
the device is removed.

[   24.921354] usb 3-14: USB disconnect, device number 7
[   24.921593] ------------[ cut here ]------------
[   24.921594] RX urb mismatch
[   24.921675] WARNING: CPU: 4 PID: 163 at drivers/net/wireless/mediatek/mt7601u/dma.c:200 mt7601u_complete_rx+0xcb/0xd0 [mt7601u]
[   24.921769] CPU: 4 PID: 163 Comm: kworker/4:2 Tainted: G           OE     4.19.31-041931-generic #201903231635
[   24.921770] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./Z97 Extreme4, BIOS P1.30 05/23/2014
[   24.921782] Workqueue: usb_hub_wq hub_event
[   24.921797] RIP: 0010:mt7601u_complete_rx+0xcb/0xd0 [mt7601u]
[   24.921800] RSP: 0018:ffff9bd9cfd03d08 EFLAGS: 00010086
[   24.921802] RAX: 0000000000000000 RBX: ffff9bd9bf043540 RCX: 0000000000000006
[   24.921803] RDX: 0000000000000007 RSI: 0000000000000096 RDI: ffff9bd9cfd16420
[   24.921804] RBP: ffff9bd9cfd03d28 R08: 0000000000000002 R09: 00000000000003a8
[   24.921805] R10: 0000002f485fca34 R11: 0000000000000000 R12: ffff9bd9bf043c1c
[   24.921806] R13: ffff9bd9c62fa3c0 R14: 0000000000000082 R15: 0000000000000000
[   24.921807] FS:  0000000000000000(0000) GS:ffff9bd9cfd00000(0000) knlGS:0000000000000000
[   24.921808] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   24.921808] CR2: 00007fb2648b0000 CR3: 0000000142c0a004 CR4: 00000000001606e0
[   24.921809] Call Trace:
[   24.921812]  <IRQ>
[   24.921819]  __usb_hcd_giveback_urb+0x8b/0x140
[   24.921821]  usb_hcd_giveback_urb+0xca/0xe0
[   24.921828]  xhci_giveback_urb_in_irq.isra.42+0x82/0xf0
[   24.921834]  handle_cmd_completion+0xe02/0x10d0
[   24.921837]  xhci_irq+0x274/0x4a0
[   24.921838]  xhci_msi_irq+0x11/0x20
[   24.921851]  __handle_irq_event_percpu+0x44/0x190
[   24.921856]  handle_irq_event_percpu+0x32/0x80
[   24.921861]  handle_irq_event+0x3b/0x5a
[   24.921867]  handle_edge_irq+0x80/0x190
[   24.921874]  handle_irq+0x20/0x30
[   24.921889]  do_IRQ+0x4e/0xe0
[   24.921891]  common_interrupt+0xf/0xf
[   24.921892]  </IRQ>
[   24.921900] RIP: 0010:usb_hcd_flush_endpoint+0x78/0x180
[   24.921354] usb 3-14: USB disconnect, device number 7

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/wireless/mediatek/mt7601u/dma.c | 33 +++++++++++----------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c
index 57a80cfa39b1..6ba30129a3d8 100644
--- a/drivers/net/wireless/mediatek/mt7601u/dma.c
+++ b/drivers/net/wireless/mediatek/mt7601u/dma.c
@@ -193,10 +193,23 @@ static void mt7601u_complete_rx(struct urb *urb)
 	struct mt7601u_rx_queue *q = &dev->rx_q;
 	unsigned long flags;
 
-	spin_lock_irqsave(&dev->rx_lock, flags);
+	/* do no schedule rx tasklet if urb has been unlinked
+	 * or the device has been removed
+	 */
+	switch (urb->status) {
+	case -ECONNRESET:
+	case -ESHUTDOWN:
+	case -ENOENT:
+		return;
+	default:
+		dev_err_ratelimited(dev->dev, "rx urb failed: %d\n",
+				    urb->status);
+		/* fall through */
+	case 0:
+		break;
+	}
 
-	if (mt7601u_urb_has_error(urb))
-		dev_err(dev->dev, "Error: RX urb failed:%d\n", urb->status);
+	spin_lock_irqsave(&dev->rx_lock, flags);
 	if (WARN_ONCE(q->e[q->end].urb != urb, "RX urb mismatch"))
 		goto out;
 
@@ -363,19 +376,9 @@ int mt7601u_dma_enqueue_tx(struct mt7601u_dev *dev, struct sk_buff *skb,
 static void mt7601u_kill_rx(struct mt7601u_dev *dev)
 {
 	int i;
-	unsigned long flags;
 
-	spin_lock_irqsave(&dev->rx_lock, flags);
-
-	for (i = 0; i < dev->rx_q.entries; i++) {
-		int next = dev->rx_q.end;
-
-		spin_unlock_irqrestore(&dev->rx_lock, flags);
-		usb_poison_urb(dev->rx_q.e[next].urb);
-		spin_lock_irqsave(&dev->rx_lock, flags);
-	}
-
-	spin_unlock_irqrestore(&dev->rx_lock, flags);
+	for (i = 0; i < dev->rx_q.entries; i++)
+		usb_poison_urb(dev->rx_q.e[i].urb);
 }
 
 static int mt7601u_submit_rx_buf(struct mt7601u_dev *dev,
-- 
2.20.1


  parent reply	other threads:[~2019-07-15 14:48 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 14:44 [PATCH AUTOSEL 4.4 01/53] ath10k: Do not send probe response template for mesh Sasha Levin
2019-07-15 14:44 ` Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 02/53] ath9k: Check for errors when reading SREV register Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 03/53] ath6kl: add some bounds checking Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 04/53] ath: DFS JP domain W56 fixed pulse type 3 RADAR detection Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 05/53] batman-adv: fix for leaked TVLV handler Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 06/53] media: dvb: usb: fix use after free in dvb_usb_device_exit Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 07/53] crypto: talitos - fix skcipher failure due to wrong output IV Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 08/53] media: marvell-ccic: fix DMA s/g desc number calculation Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 09/53] media: vpss: fix a potential NULL pointer dereference Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 10/53] net: stmmac: dwmac1000: Clear unused address entries Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 11/53] signal/pid_namespace: Fix reboot_pid_ns to use send_sig not force_sig Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 12/53] signal/cifs: Fix cifs_put_tcp_session to call send_sig instead of force_sig Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 13/53] af_key: fix leaks in key_pol_get_resp and dump_sp Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 14/53] xfrm: Fix xfrm sel prefix length validation Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 15/53] e1000e: start network tx queue only when link is up Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 16/53] media: staging: media: davinci_vpfe: - Fix for memory leak if decoder initialization fails Sasha Levin
2019-07-15 14:44   ` Sasha Levin
2019-07-15 14:44 ` [PATCH AUTOSEL 4.4 17/53] net: phy: Check against net_device being NULL Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 18/53] tua6100: Avoid build warnings Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 19/53] locking/lockdep: Fix merging of hlocks with non-zero references Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 20/53] media: wl128x: Fix some error handling in fm_v4l2_init_video_device() Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 21/53] cpupower : frequency-set -r option misses the last cpu in related cpu list Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 22/53] net: fec: Do not use netdev messages too early Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 23/53] net: axienet: Fix race condition causing TX hang Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 24/53] s390/qdio: handle PENDING state for QEBSM devices Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 25/53] perf test 6: Fix missing kvm module load for s390 Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 26/53] gpio: omap: fix lack of irqstatus_raw0 for OMAP4 Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 27/53] gpio: omap: ensure irq is enabled before wakeup Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 28/53] regmap: fix bulk writes on paged registers Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 29/53] bpf: silence warning messages in core Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 30/53] rcu: Force inlining of rcu_read_lock() Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 31/53] xfrm: fix sa selector validation Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 32/53] perf evsel: Make perf_evsel__name() accept a NULL argument Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 33/53] vhost_net: disable zerocopy by default Sasha Levin
2019-07-15 14:45   ` Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 34/53] EDAC/sysfs: Fix memory leak when creating a csrow object Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 35/53] media: i2c: fix warning same module names Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 36/53] ntp: Limit TAI-UTC offset Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 37/53] timer_list: Guard procfs specific code Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 38/53] acpi/arm64: ignore 5.1 FADTs that are reported as 5.0 Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 39/53] media: coda: fix mpeg2 sequence number handling Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 40/53] media: coda: increment sequence offset for the last returned frame Sasha Levin
2019-07-15 14:45 ` Sasha Levin [this message]
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 42/53] x86/build: Add 'set -e' to mkcapflags.sh to delete broken capflags.c Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 43/53] mt7601u: fix possible memory leak when the device is disconnected Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 44/53] ath10k: fix PCIE device wake up failed Sasha Levin
2019-07-15 14:45   ` Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 45/53] rslib: Fix decoding of shortened codes Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 46/53] rslib: Fix handling of of caller provided syndrome Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 47/53] ixgbe: Check DDM existence in transceiver before access Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 48/53] EDAC: Fix global-out-of-bounds write when setting edac_mc_poll_msec Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 49/53] bcache: check c->gc_thread by IS_ERR_OR_NULL in cache_set_flush() Sasha Levin
2019-07-15 14:45   ` Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 50/53] Bluetooth: hci_bcsp: Fix memory leak in rx_skb Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 51/53] Bluetooth: 6lowpan: search for destination address in all peers Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 52/53] Bluetooth: Check state in l2cap_disconnect_rsp Sasha Levin
2019-07-15 14:45 ` [PATCH AUTOSEL 4.4 53/53] Bluetooth: validate BLE connection interval updates Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190715144535.11636-41-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.