]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: eth: be defensive in rteth_confirm_and_disable_irqs()
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Mon, 23 Feb 2026 17:44:25 +0000 (18:44 +0100)
committerRobert Marko <robimarko@gmail.com>
Fri, 27 Feb 2026 17:24:25 +0000 (18:24 +0100)
With latest refactoring irq activation and deactivation is side-by-side
in the code. This makes it easier to align these functions. Current
assumption is, that the ethernet irq is only called on one cpu and
napi handling does not interfere. So it should be totally fine to
run irq disabling (called from interrupt handler) without locks.
Nevertheless be defensive and add a lock(). So in the case the ethernet
irq is fired twice on two cpus (e.g. RTL931x) the code is on the
safe side.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22156
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c

index 1e43cefbff4564ede02b1739dc610a9700e691a7..779aa6fac6b1d0d2e99e12e759d1d6f0ff0d74cd 100644 (file)
@@ -211,12 +211,15 @@ static inline void rteth_confirm_and_disable_irqs(struct rteth_ctrl *ctrl,
        u32 mask = GENMASK(ctrl->r->rx_rings - 1, 0);
        u32 shift = ctrl->r->rx_rings % 32;
        u32 reg = ctrl->r->rx_rings / 32;
+       unsigned long flags;
        u32 active;
 
        /* get all irqs, disable only rx (on RTL839x this keeps L2), confirm all */
+       spin_lock_irqsave(&ctrl->lock, flags);
        active = sw_r32(ctrl->r->dma_if_intr_sts + reg * 4);
        sw_w32_mask(active & (mask << shift), 0, ctrl->r->dma_if_intr_msk + reg * 4);
        sw_w32(active, ctrl->r->dma_if_intr_sts + reg * 4);
+       spin_unlock_irqrestore(&ctrl->lock, flags);
 
        /* ~mask filters out RTL93xx devices */
        *l2 = !!(active & ~mask & RTL839X_DMA_IF_INTR_NOTIFY_MASK);