Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8602315ybi; Thu, 6 Jun 2019 15:38:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpj1mJOz9CqnqeP/hIRc+NPXE/kagYUk6FPmfbACKesTu5atKzoybVFgFX1C6lB1tFe3lP X-Received: by 2002:aa7:8d85:: with SMTP id i5mr54138040pfr.242.1559860736926; Thu, 06 Jun 2019 15:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559860736; cv=none; d=google.com; s=arc-20160816; b=lNFH7HntAeTLCyq0CQT7yc3jlebOYHqC3bWBM+p2omlJJCRts2aWzoGIfN0OTPzH57 nGIwWnVHhTEdwL8wKRoutoMwQ5YZAO8fpzkX88WKmMjYRm/6xaYkvg9JAKD/W6Ow5gz5 MWO7DM+ySVS/3SKX5RzwahDyCQNg9lSProZYeNvtuWcAuTQ3N34gsWCIZlu/LoJNoiCE B/0dOSpv1Y+0yNJJZkhENNUtkBUCpLM41MlNnVCQ1WzqWv4i/5c0IfdFup/RpOYdD8YJ JbbZ+zWN/S4sli02jb9lvye+ckV2PLSH1+/7STuBUSkW/GnejY7syZZOQRAP4JyuGxRb RojQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=2GQajOm2MtdM8ShQ34Lw/zEW2c4tCO7hvWkmg9UltbQ=; b=XHNd5tFgoIn6GCF5admrQ9ag30AM+U+TqSShldTY/F9tmWil6uaAMAVkbIAWmTcoKz ZhIDriTku0WYydKJ2lLek5GA4N4lq7JLQ+Ze08Hzeh6w8SK327p4ArbzLcxzL6GM+GMd 6Lq7gkldViDsILPsqKytereEMcxvl55b6mwa1WaGjoLiIMKTkpUbufMGdvaMZ4Lfp74u qlXsV88TT5fyrKVQRxYlcZyR+r8OcyeVsQeYkHatQHPdS+W68nFEtG/bZIx3OnwISj7N Ou7ipiJBi+2EMc3ULD4FN6PXMebXulvN9h9fKRryDPT1ahHNaNzH7Fmf0/06lszbbvCO zdVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g22si292350pgb.107.2019.06.06.15.38.41; Thu, 06 Jun 2019 15:38:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727824AbfFFWAE (ORCPT + 99 others); Thu, 6 Jun 2019 18:00:04 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:37636 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbfFFWAE (ORCPT ); Thu, 6 Jun 2019 18:00:04 -0400 Received: by mail-io1-f67.google.com with SMTP id e5so1449270iok.4 for ; Thu, 06 Jun 2019 15:00:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2GQajOm2MtdM8ShQ34Lw/zEW2c4tCO7hvWkmg9UltbQ=; b=gCmwWrGFeVtC/F8Zr6k7LLf3Bj/kkVl6S3waNq+rhKSq4DZJyljVlW07y9bi6LrQSk aSH3Hksybl/+NROCyNFOqGgZoU2gS+8gIImfHH8BsbCKfufJnjdYm4pYHLEFcXRp87Xu GAkgkzfTpJni/dSUB0btrMepSGX9kTqPBBGrT2dOMCBZTycfX6gn9E98Tt3Uz+DZIqJ+ Th4J8qBF4Eb2tXjQahDPyimaAsCJFlCjmQgWQizHQyuORZphQ/5fpvX2ADWIigWzvRRy WOHFZllZxwEjLzpTU2YoTe3vMqYn/jz0yTeTHl8qxqbHCbuQ3ffEhuTLCKsMRXoVVyFZ +HUw== X-Gm-Message-State: APjAAAXXR+WbvSUU99+NL2sU4jJebe3N3JCoCIH9zQaMvZIkBN0X8LOT 9yiNozbY1ceacXGB+uT3Klf4fb5PwAwpYQWphsaGleMDmog= X-Received: by 2002:a05:6602:2006:: with SMTP id y6mr29193586iod.218.1559858403149; Thu, 06 Jun 2019 15:00:03 -0700 (PDT) MIME-Version: 1.0 References: <20190606114228.7a0ba115@cakuba.netronome.com> <20190606142622.7e5f11de@cakuba.netronome.com> In-Reply-To: <20190606142622.7e5f11de@cakuba.netronome.com> From: Lorenzo Bianconi Date: Thu, 6 Jun 2019 23:59:52 +0200 Message-ID: Subject: Re: [PATCH] mt7601u: do not schedule rx_tasklet when the device has been disconnected To: Jakub Kicinski Cc: Lorenzo Bianconi , linux-wireless Content-Type: text/plain; charset="UTF-8" Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org > > On Thu, 6 Jun 2019 23:02:08 +0200, Lorenzo Bianconi wrote: > > > On Thu, 6 Jun 2019 14:26:12 +0200, Lorenzo Bianconi wrote: > > Hi Jakub, > > > > thx for the fast review :) > > I guess I'm used to the 24h "review timeout" on netdev :) > :-) > > > Is this a new thing? I def tested unplugging the dongle under > > > traffic, but that must had been in 3.19 days :S > > > > I do not know if the issue has been introduced in recent kernel, I am > > able to trigger it in a vm running > > wireless-drivers-next and it has been reported here: > > https://bugzilla.kernel.org/show_bug.cgi?id=203249 > > I see. I'm just worried that we make a mistake here and it will get > backported all the way back to very old kernels because of the fixes > tag. If old kernels worked perhaps it's not worth disturbing them. > > > > > Fixes: c869f77d6abb ("add mt7601u driver") > > > > Signed-off-by: Lorenzo Bianconi > > > > --- > > > > I will post a patch to fix tx side as well > > > > --- > > > > drivers/net/wireless/mediatek/mt7601u/dma.c | 33 ++++++++++----------- > > > > 1 file changed, 16 insertions(+), 17 deletions(-) > > > > > > > > diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c > > > > index f7edeffb2b19..e7703990b291 100644 > > > > --- a/drivers/net/wireless/mediatek/mt7601u/dma.c > > > > +++ b/drivers/net/wireless/mediatek/mt7601u/dma.c > > > > @@ -193,10 +193,20 @@ 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); > > > > + switch (urb->status) { > > > > + case -ECONNRESET: > > > > + case -ESHUTDOWN: > > > > + case -ENOENT: > > > > + return; > > > > > > So we assume this is non-recoverable? Everything will fail after? > > > Because pending is incremented linearly :S That's why there is a > > > warning here. > > > > AFAIK -ECONNRESET/-ENOENT are related to urb unlink/kill while > > -ESHUTDOWN is related to device disconnection. > > I guess we can assume the device has been removed if we get these errors > > Makes sense. A bit of an implicit assumption, USB subsystem may break > this for us. Let's at least put a comment here so we can go back and > know that at the time of committing we did double check? > ack, I will put a comment in v2 > > > > + 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 +373,10 @@ 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); > > > > - } > > > > > > Why is there no need to take the lock? Admittedly it's not clear what > > > this lock is protecting here :P Perhaps a separate patch to remove the > > > unnecessary locking with an explanation? > > > > usb_poison_urb() can run concurrently with urb completion so I guess > > we do not need locks here. > > I guess we need to maintain this chunk in the same patch since now > > when the device is disconnected > > we do not increment dev->rx_q.end. What do you think? > > Ah, I see! The completion used to run in between the unlock/lock! > Now we just poison out of order, because completion doesn't care about > ordering for errored URBs. Perhaps worth putting in the commit message? ack, I will put a comment in v2 Regards, Lorenzo