Re: [PATCH v2 4/5] clocksource: mips-gic-timer: Set next GIC event on the correct VP

From: Benoît Monin

Date: Tue Sep 01 2026 - 12:42:24 EST


On Thursday, 20 August 2026 at 10:41:29 CEST, Thomas Gleixner wrote:
> > gic_next_event() programs the next event on the clock_event_device's target
> > CPU. When that CPU is not the current one, the compare register is reached
> > through the GIC VO (other/redirect) window, which is first pointed at the
> > target VP with write_gic_vl_other().
> >
> > On a multi-cluster system each cluster has its own GIC. The VO window of
> > the local GIC is what write_gic_vl_other() redirects, so when the target
> > CPU belongs to another cluster, write_gic_vo_compare() lands in the
> > wrong GIC, overwriting the COMPARE register of a VP in the local cluster.
>
> The MIPS GIC clockevent device is strictly registered per CPU with the
> cpumask of that CPU. See gic_clockevent_cpu_init().
>
> The set_next_event() callback of a per CPU clockevent device is _always_
> invoked on that CPU and cannot be invoked on a different CPU.
>
> So I completely fail to understand what this cluster and non-current CPU
> voodoo is about.
>
Going through the log, here is what I found:

The commit 414408d0eedd ("MIPS: allow GIC clockevent device config
from other CPUs") was merged in v3.16, its intent was to make the GIC
clockevent usable as a tick broadcast device.

Also in v3.16, the commit 0467811e9bdb ("MIPS: mark GIC clockevent device
with CLOCK_EVT_FEAT_C3STOP") sets the C3STOP flag. With this flag, as
I understand it, the GIC clockevent cannot be used as a tick broadcast
device. So the set_next_event() callback is always invoked on the CPU
of the event.

The `if/else` was added later in v4.15 by commit f16ff2bdb135
("clocksource/drivers/mips-gic-timer: Add fastpath for local timer
updates"). But the `else` path was never called.

I am going to drop the `else` path, should I also add the
CLOCK_EVT_FEAT_PERCPU flag, or is C3STOP and the cpumask enough?

Thanks for the review,

Benoît.