Commit 382719d4 authored by Reinhard Speyerer's avatar Reinhard Speyerer Committed by Greg Kroah-Hartman

qmi_wwan: avoid RCU stalls on device disconnect when in QMAP mode

[ Upstream commit a8fdde1c ]

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: c6adf779 ("net: usb: qmi_wwan: add qmap mux protocol support")
Cc: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: default avatarReinhard Speyerer <rspmn@arcor.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 4bd6849a
...@@ -247,13 +247,14 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id) ...@@ -247,13 +247,14 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
return err; 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 qmimux_priv *priv = netdev_priv(dev);
struct net_device *real_dev = priv->real_dev; struct net_device *real_dev = priv->real_dev;
netdev_upper_dev_unlink(real_dev, dev); netdev_upper_dev_unlink(real_dev, dev);
unregister_netdevice(dev); unregister_netdevice_queue(dev, head);
/* Get rid of the reference to real_dev */ /* Get rid of the reference to real_dev */
dev_put(real_dev); dev_put(real_dev);
...@@ -424,7 +425,7 @@ static ssize_t del_mux_store(struct device *d, struct device_attribute *attr, c ...@@ -424,7 +425,7 @@ static ssize_t del_mux_store(struct device *d, struct device_attribute *attr, c
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
qmimux_unregister_device(del_dev); qmimux_unregister_device(del_dev, NULL);
if (!qmimux_has_slaves(dev)) if (!qmimux_has_slaves(dev))
info->flags &= ~QMI_WWAN_FLAG_MUX; info->flags &= ~QMI_WWAN_FLAG_MUX;
...@@ -1434,6 +1435,7 @@ static void qmi_wwan_disconnect(struct usb_interface *intf) ...@@ -1434,6 +1435,7 @@ static void qmi_wwan_disconnect(struct usb_interface *intf)
struct qmi_wwan_state *info; struct qmi_wwan_state *info;
struct list_head *iter; struct list_head *iter;
struct net_device *ldev; struct net_device *ldev;
LIST_HEAD(list);
/* called twice if separate control and data intf */ /* called twice if separate control and data intf */
if (!dev) if (!dev)
...@@ -1446,8 +1448,9 @@ static void qmi_wwan_disconnect(struct usb_interface *intf) ...@@ -1446,8 +1448,9 @@ static void qmi_wwan_disconnect(struct usb_interface *intf)
} }
rcu_read_lock(); rcu_read_lock();
netdev_for_each_upper_dev_rcu(dev->net, ldev, iter) netdev_for_each_upper_dev_rcu(dev->net, ldev, iter)
qmimux_unregister_device(ldev); qmimux_unregister_device(ldev, &list);
rcu_read_unlock(); rcu_read_unlock();
unregister_netdevice_many(&list);
rtnl_unlock(); rtnl_unlock();
info->flags &= ~QMI_WWAN_FLAG_MUX; info->flags &= ~QMI_WWAN_FLAG_MUX;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment