Skip to content

Commit bc1e64d

Browse files
committed
Merge branch 'net-use-netdev-lock-to-protect-napi'
Jakub Kicinski says: ==================== net: use netdev->lock to protect NAPI We recently added a lock member to struct net_device, with a vague plan to start using it to protect netdev-local state, removing the need to take rtnl_lock for new configuration APIs. Lay some groundwork and use this lock for protecting NAPI APIs. v1: https://lore.kernel.org/20250114035118.110297-1-kuba@kernel.org ==================== Link: https://patch.msgid.link/20250115035319.559603-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 0b6f659 + 062e789 commit bc1e64d

File tree

11 files changed

+420
-121
lines changed

11 files changed

+420
-121
lines changed

drivers/net/ethernet/amd/pcnet32.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ static void pcnet32_netif_start(struct net_device *dev)
462462
val = lp->a->read_csr(ioaddr, CSR3);
463463
val &= 0x00ff;
464464
lp->a->write_csr(ioaddr, CSR3, val);
465-
napi_enable(&lp->napi);
465+
napi_enable_locked(&lp->napi);
466466
}
467467

468468
/*
@@ -889,6 +889,7 @@ static int pcnet32_set_ringparam(struct net_device *dev,
889889
if (netif_running(dev))
890890
pcnet32_netif_stop(dev);
891891

892+
netdev_lock(dev);
892893
spin_lock_irqsave(&lp->lock, flags);
893894
lp->a->write_csr(ioaddr, CSR0, CSR0_STOP); /* stop the chip */
894895

@@ -920,6 +921,7 @@ static int pcnet32_set_ringparam(struct net_device *dev,
920921
}
921922

922923
spin_unlock_irqrestore(&lp->lock, flags);
924+
netdev_unlock(dev);
923925

924926
netif_info(lp, drv, dev, "Ring Param Settings: RX: %d, TX: %d\n",
925927
lp->rx_ring_size, lp->tx_ring_size);
@@ -985,6 +987,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
985987
if (netif_running(dev))
986988
pcnet32_netif_stop(dev);
987989

990+
netdev_lock(dev);
988991
spin_lock_irqsave(&lp->lock, flags);
989992
lp->a->write_csr(ioaddr, CSR0, CSR0_STOP); /* stop the chip */
990993

@@ -1122,6 +1125,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
11221125
lp->a->write_bcr(ioaddr, 20, 4); /* return to 16bit mode */
11231126
}
11241127
spin_unlock_irqrestore(&lp->lock, flags);
1128+
netdev_unlock(dev);
11251129

11261130
return rc;
11271131
} /* end pcnet32_loopback_test */
@@ -2101,6 +2105,7 @@ static int pcnet32_open(struct net_device *dev)
21012105
return -EAGAIN;
21022106
}
21032107

2108+
netdev_lock(dev);
21042109
spin_lock_irqsave(&lp->lock, flags);
21052110
/* Check for a valid station address */
21062111
if (!is_valid_ether_addr(dev->dev_addr)) {
@@ -2266,7 +2271,7 @@ static int pcnet32_open(struct net_device *dev)
22662271
goto err_free_ring;
22672272
}
22682273

2269-
napi_enable(&lp->napi);
2274+
napi_enable_locked(&lp->napi);
22702275

22712276
/* Re-initialize the PCNET32, and start it when done. */
22722277
lp->a->write_csr(ioaddr, 1, (lp->init_dma_addr & 0xffff));
@@ -2300,6 +2305,7 @@ static int pcnet32_open(struct net_device *dev)
23002305
lp->a->read_csr(ioaddr, CSR0));
23012306

23022307
spin_unlock_irqrestore(&lp->lock, flags);
2308+
netdev_unlock(dev);
23032309

23042310
return 0; /* Always succeed */
23052311

@@ -2315,6 +2321,7 @@ static int pcnet32_open(struct net_device *dev)
23152321

23162322
err_free_irq:
23172323
spin_unlock_irqrestore(&lp->lock, flags);
2324+
netdev_unlock(dev);
23182325
free_irq(dev->irq, dev);
23192326
return rc;
23202327
}

0 commit comments

Comments
 (0)