netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Reinhard Speyerer <rspmn@arcor.de>
To: "Bjørn Mork" <bjorn@mork.no>
Cc: Daniele Palmas <dnlplm@gmail.com>,
	netdev@vger.kernel.org, rspmn@arcor.de
Subject: [PATCH 3/4] qmi_wwan: avoid RCU stalls on device disconnect when in QMAP mode
Date: Wed, 12 Jun 2019 19:03:15 +0200	[thread overview]
Message-ID: <fbb0cab5f36550668dd4dc6ecdb5eafa90a6e655.1560287477.git.rspmn@arcor.de> (raw)
In-Reply-To: <cover.1560287477.git.rspmn@arcor.de>

Switch qmimux_unregister_device() and qmi_wwan_disconnect() to
use unregister_netdevice_queue() and unregister_netdevice_many()
instead of unregister_netdevice(). This avoids RCU stalls which
have been observed on device disconnect in certain setups otherwise.

Fixes: c6adf77953bc ("net: usb: qmi_wwan: add qmap mux protocol support")
Cc: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: Reinhard Speyerer <rspmn@arcor.de>
---
 drivers/net/usb/qmi_wwan.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index b0a96459621f..c6fbc2a2a785 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -312,14 +312,15 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
 	return err;
 }
 
-static void qmimux_unregister_device(struct net_device *dev)
+static void qmimux_unregister_device(struct net_device *dev,
+				     struct list_head *head)
 {
 	struct qmimux_priv *priv = netdev_priv(dev);
 	struct net_device *real_dev = priv->real_dev;
 
 	free_percpu(priv->stats64);
 	netdev_upper_dev_unlink(real_dev, dev);
-	unregister_netdevice(dev);
+	unregister_netdevice_queue(dev, head);
 
 	/* Get rid of the reference to real_dev */
 	dev_put(real_dev);
@@ -490,7 +491,7 @@ static ssize_t del_mux_store(struct device *d,  struct device_attribute *attr, c
 		ret = -EINVAL;
 		goto err;
 	}
-	qmimux_unregister_device(del_dev);
+	qmimux_unregister_device(del_dev, NULL);
 
 	if (!qmimux_has_slaves(dev))
 		info->flags &= ~QMI_WWAN_FLAG_MUX;
@@ -1500,6 +1501,7 @@ static void qmi_wwan_disconnect(struct usb_interface *intf)
 	struct qmi_wwan_state *info;
 	struct list_head *iter;
 	struct net_device *ldev;
+	LIST_HEAD(list);
 
 	/* called twice if separate control and data intf */
 	if (!dev)
@@ -1512,8 +1514,9 @@ static void qmi_wwan_disconnect(struct usb_interface *intf)
 		}
 		rcu_read_lock();
 		netdev_for_each_upper_dev_rcu(dev->net, ldev, iter)
-			qmimux_unregister_device(ldev);
+			qmimux_unregister_device(ldev, &list);
 		rcu_read_unlock();
+		unregister_netdevice_many(&list);
 		rtnl_unlock();
 		info->flags &= ~QMI_WWAN_FLAG_MUX;
 	}
-- 
2.11.0


  parent reply	other threads:[~2019-06-12 17:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 17:01 [PATCH 0/4] qmi_wwan: fix QMAP handling Reinhard Speyerer
2019-06-12 17:02 ` [PATCH 1/4] qmi_wwan: add support for QMAP padding in the RX path Reinhard Speyerer
2019-06-12 17:02 ` [PATCH 2/4] qmi_wwan: add network device usage statistics for qmimux devices Reinhard Speyerer
2019-06-12 17:03 ` Reinhard Speyerer [this message]
2019-06-12 17:03 ` [PATCH 4/4] qmi_wwan: extend permitted QMAP mux_id value range Reinhard Speyerer
2019-06-13 15:14 ` [PATCH 0/4] qmi_wwan: fix QMAP handling Daniele Palmas
2019-06-13 17:54 ` Bjørn Mork
2019-06-15  2:06   ` David Miller

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=fbb0cab5f36550668dd4dc6ecdb5eafa90a6e655.1560287477.git.rspmn@arcor.de \
    --to=rspmn@arcor.de \
    --cc=bjorn@mork.no \
    --cc=dnlplm@gmail.com \
    --cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).