Re: [PATCH v3] staging: most: dim2: drop volatile from state counters
From: Greg KH
Date: Fri Nov 20 2026 - 02:15:13 EST
On Wed, Nov 18, 2026 at 10:24:41AM -0800, Maximo Manriquez Lizarraga via B4 Relay wrote:
> From: Maximo Manriquez Lizarraga <DelaySystem@xxxxxxxxx>
>
> The request_counter/service_counter pair is shared between the AHB
> hard-IRQ handler and the threaded-IRQ service path, but every access
> already runs under dim_lock with local interrupts disabled:
> dim2_ahb_isr() holds it across dim_service_ahb_int_irq(),
> dim2_task_irq() across dim_service_channel(), and configure_channel()
> across the dim_init_*() calls that zero the counters. The spinlock
> provides both the mutual exclusion and the memory barriers, so the
> volatile qualifier adds nothing and wrongly suggests lockless
> cross-context sharing (see
> Documentation/process/volatile-considered-harmful.rst).
>
> Converting to atomic_t is the wrong tool here: the service-side
> check-and-increment cannot be a single atomic step when done as
> separate atomic_read() calls, as Dan Carpenter pointed out on the
> atomic_t attempt, and a lockless scheme would still need dim_lock for
> the sibling channel state (level, indices, done-buffer count, MBO
> lists) anyway.
>
> Drop the qualifier and document the actual protection in place. No
> functional change intended.
>
> Compile-tested only (MOST=m, MOST_DIM2=m build clean); I don't have
> this hardware, so testing on real hardware would be appreciated.
I'll only take stuff like this if you can test it on real hardware,
sorry.
thanks,
gre gk-h