Commit 5a717f4f authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by David S. Miller

netdevice: fix sparse warning for HARD_TX_LOCK

sparse warns about context imbalance in any code
that uses HARD_TX_LOCK/UNLOCK - this is because it's
unable to determine that flags don't change so
lock and unlock are paired.

Seems easy enough to fix by adding __acquire/__release
calls.

With this patch af_packet.c is now sparse-clean,
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 42895116
...@@ -3462,6 +3462,17 @@ static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu) ...@@ -3462,6 +3462,17 @@ static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
txq->xmit_lock_owner = cpu; txq->xmit_lock_owner = cpu;
} }
static inline bool __netif_tx_acquire(struct netdev_queue *txq)
{
__acquire(&txq->_xmit_lock);
return true;
}
static inline void __netif_tx_release(struct netdev_queue *txq)
{
__release(&txq->_xmit_lock);
}
static inline void __netif_tx_lock_bh(struct netdev_queue *txq) static inline void __netif_tx_lock_bh(struct netdev_queue *txq)
{ {
spin_lock_bh(&txq->_xmit_lock); spin_lock_bh(&txq->_xmit_lock);
...@@ -3563,17 +3574,21 @@ static inline void netif_tx_unlock_bh(struct net_device *dev) ...@@ -3563,17 +3574,21 @@ static inline void netif_tx_unlock_bh(struct net_device *dev)
#define HARD_TX_LOCK(dev, txq, cpu) { \ #define HARD_TX_LOCK(dev, txq, cpu) { \
if ((dev->features & NETIF_F_LLTX) == 0) { \ if ((dev->features & NETIF_F_LLTX) == 0) { \
__netif_tx_lock(txq, cpu); \ __netif_tx_lock(txq, cpu); \
} else { \
__netif_tx_acquire(txq); \
} \ } \
} }
#define HARD_TX_TRYLOCK(dev, txq) \ #define HARD_TX_TRYLOCK(dev, txq) \
(((dev->features & NETIF_F_LLTX) == 0) ? \ (((dev->features & NETIF_F_LLTX) == 0) ? \
__netif_tx_trylock(txq) : \ __netif_tx_trylock(txq) : \
true ) __netif_tx_acquire(txq))
#define HARD_TX_UNLOCK(dev, txq) { \ #define HARD_TX_UNLOCK(dev, txq) { \
if ((dev->features & NETIF_F_LLTX) == 0) { \ if ((dev->features & NETIF_F_LLTX) == 0) { \
__netif_tx_unlock(txq); \ __netif_tx_unlock(txq); \
} else { \
__netif_tx_release(txq); \
} \ } \
} }
......
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