Skip to content

Commit cee43db

Browse files
fancerdlezcano
authored andcommitted
clocksource: dw_apb_timer: Make CPU-affiliation being optional
Currently the DW APB Timer driver binds each clockevent timers to a particular CPU. This isn't good for multiple reasons. First of all seeing the device is placed on APB bus (which makes it accessible from any CPU core), accessible over MMIO and having the DYNIRQ flag set we can be sure that manually binding the timer to any CPU just isn't correct. By doing so we just set an extra limitation on device usage. This also doesn't reflect the device actual capability, since by setting the IRQ affinity we can make it virtually local to any CPU. Secondly imagine if you had a real CPU-local timer with the same rating and the same CPU-affinity. In this case if DW APB timer was registered first, then due to the clockevent framework tick-timer selection procedure we'll end up with the real CPU-local timer being left unselected for clock-events tracking. But on most of the platforms (MIPS/ARM/etc) such timers are normally embedded into the CPU core and are accessible with much better performance then devices placed on APB. For instance in MIPS architectures there is r4k-timer, which is CPU-local, assigned with the same rating, and normally its clockevent device is registered after the platform-specific one. So in order to fix all of these issues let's make the DW APB Timer CPU affinity being optional and deactivated by passing a negative CPU id, which will effectively set the DW APB clockevent timer cpumask to 'cpu_possible_mask'. Signed-off-by: Serge Semin <[email protected]> Cc: Alexey Malahov <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Paul Burton <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Rob Herring <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e69bc89 commit cee43db

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/clocksource/dw_apb_timer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ static int apbt_next_event(unsigned long delta,
222222
/**
223223
* dw_apb_clockevent_init() - use an APB timer as a clock_event_device
224224
*
225-
* @cpu: The CPU the events will be targeted at.
225+
* @cpu: The CPU the events will be targeted at or -1 if CPU affiliation
226+
* isn't required.
226227
* @name: The name used for the timer and the IRQ for it.
227228
* @rating: The rating to give the timer.
228229
* @base: I/O base for the timer registers.
@@ -257,7 +258,7 @@ dw_apb_clockevent_init(int cpu, const char *name, unsigned rating,
257258
dw_ced->ced.max_delta_ticks = 0x7fffffff;
258259
dw_ced->ced.min_delta_ns = clockevent_delta2ns(5000, &dw_ced->ced);
259260
dw_ced->ced.min_delta_ticks = 5000;
260-
dw_ced->ced.cpumask = cpumask_of(cpu);
261+
dw_ced->ced.cpumask = cpu < 0 ? cpu_possible_mask : cpumask_of(cpu);
261262
dw_ced->ced.features = CLOCK_EVT_FEAT_PERIODIC |
262263
CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_DYNIRQ;
263264
dw_ced->ced.set_state_shutdown = apbt_shutdown;

0 commit comments

Comments
 (0)