Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: xilinx: axienet: Schedule NAPI in two steps

As advised by Documentation/networking/napi.rst, masking IRQs after
calling napi_schedule can be racy. Avoid this by only masking/scheduling
if napi_schedule_prep returns true.

Fixes: 9e2bc267e780 ("net: axienet: Use NAPI for TX completion path")
Fixes: cc37610caaf8 ("net: axienet: implement NAPI and GRO receive")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20240913145711.2284295-1-sean.anderson@linux.dev
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Sean Anderson and committed by
Paolo Abeni
ba0da2dc 194ef9d0

+8 -6
+8 -6
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 1282 1282 u32 cr = lp->tx_dma_cr; 1283 1283 1284 1284 cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK); 1285 - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); 1286 - 1287 - napi_schedule(&lp->napi_tx); 1285 + if (napi_schedule_prep(&lp->napi_tx)) { 1286 + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); 1287 + __napi_schedule(&lp->napi_tx); 1288 + } 1288 1289 } 1289 1290 1290 1291 return IRQ_HANDLED; ··· 1327 1326 u32 cr = lp->rx_dma_cr; 1328 1327 1329 1328 cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK); 1330 - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); 1331 - 1332 - napi_schedule(&lp->napi_rx); 1329 + if (napi_schedule_prep(&lp->napi_rx)) { 1330 + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); 1331 + __napi_schedule(&lp->napi_rx); 1332 + } 1333 1333 } 1334 1334 1335 1335 return IRQ_HANDLED;