Subject: Re: [PATCH net-next v2] net: dlink: add synchronization for stats update

From: Jakub Kicinski <[email-masked]>
Date: Mon, 5 May 2025 18:49:45 -0700

On Sat, 3 May 2025 08:50:49 +0900 Moon Yeounsu wrote:
> Also, I believe that `spin_lock_irq()` in `get_stats()` should be
> changed to `spin_lock_irqsave()` since `get_stats()` can be called
> from IRQ context (via `rio_interrupt()` -> `rio_error()` ->
> `get_stats()`).  In my view, calling `spin_unlock_irq()` in this
> context could be risky, as it would re-enable local IRQs via
> local_irq_enable().
> 
> There are two ways to lock the `get_stats()` function: either add a
> new parameter to check whether it's in IRQ context, or simply use
> `spin_lock_irqsave()`. I found that `rio_free_tx()` behaves like the
> first case. I'd appreciate your opinion on which approach would be
> preferable here.

If there's a call path from the IRQ I'd go with spin_lock_irqsave()