Skip to content

Commit 448b448

Browse files
lunndavem330
authored andcommitted
net: dsa: Add lockdep class to tx queues to avoid lockdep splat
DSA stacks an Ethernet device on top of an Ethernet device. This can cause false positive lockdep splats for the transmit queue: Acked-by: Florian Fainelli <[email protected]> ============================================= [ INFO: possible recursive locking detected ] 4.0.0-rc7-01838-g70621a215fc7 torvalds#386 Not tainted --------------------------------------------- kworker/0:0/4 is trying to acquire lock: (_xmit_ETHER#2){+.-...}, at: [<c040e95c>] sch_direct_xmit+0xa8/0x1fc but task is already holding lock: (_xmit_ETHER#2){+.-...}, at: [<c03f4208>] __dev_queue_xmit+0x4d4/0x56c other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(_xmit_ETHER#2); lock(_xmit_ETHER#2); To avoid this, walk the tq queues of the dsa slaves and set a lockdep class. Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 16fe24f commit 448b448

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

net/dsa/slave.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,12 +810,19 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
810810
return 0;
811811
}
812812

813+
static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
814+
static void dsa_slave_set_lockdep_class_one(struct net_device *dev,
815+
struct netdev_queue *txq,
816+
void *_unused)
817+
{
818+
lockdep_set_class(&txq->_xmit_lock,
819+
&dsa_slave_netdev_xmit_lock_key);
820+
}
821+
813822
int dsa_slave_suspend(struct net_device *slave_dev)
814823
{
815824
struct dsa_slave_priv *p = netdev_priv(slave_dev);
816825

817-
netif_device_detach(slave_dev);
818-
819826
if (p->phy) {
820827
phy_stop(p->phy);
821828
p->old_pause = -1;
@@ -861,6 +868,9 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
861868
slave_dev->netdev_ops = &dsa_slave_netdev_ops;
862869
slave_dev->swdev_ops = &dsa_slave_swdev_ops;
863870

871+
netdev_for_each_tx_queue(slave_dev, dsa_slave_set_lockdep_class_one,
872+
NULL);
873+
864874
SET_NETDEV_DEV(slave_dev, parent);
865875
slave_dev->dev.of_node = ds->pd->port_dn[port];
866876
slave_dev->vlan_features = master->vlan_features;

0 commit comments

Comments
 (0)