net: xilinx: axienet: Fix race in axienet_stop
authorSean Anderson <sean.anderson@linux.dev>
Tue, 3 Sep 2024 17:51:41 +0000 (13:51 -0400)
committerJakub Kicinski <kuba@kernel.org>
Thu, 5 Sep 2024 00:07:12 +0000 (17:07 -0700)
commit858430db28a5f5a11f8faa3a6fa805438e6f0851
treea4c546bdcc0fa06324929d4f915874992ea19824
parentbee2ef946d3184e99077be526567d791c473036f
net: xilinx: axienet: Fix race in axienet_stop

axienet_dma_err_handler can race with axienet_stop in the following
manner:

CPU 1                       CPU 2
======================      ==================
axienet_stop()
    napi_disable()
    axienet_dma_stop()
                            axienet_dma_err_handler()
                                napi_disable()
                                axienet_dma_stop()
                                axienet_dma_start()
                                napi_enable()
    cancel_work_sync()
    free_irq()

Fix this by setting a flag in axienet_stop telling
axienet_dma_err_handler not to bother doing anything. I chose not to use
disable_work_sync to allow for easier backporting.

Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Fixes: 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")
Link: https://patch.msgid.link/20240903175141.4132898-1-sean.anderson@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/xilinx/xilinx_axienet.h
drivers/net/ethernet/xilinx/xilinx_axienet_main.c