• Serge Semin's avatar
    clocksource: dw_apb_timer: Make CPU-affiliation being optional · cee43dbf
    Serge Semin authored
    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: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
    Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
    Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Cc: Paul Burton <paulburton@kernel.org>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: Alessandro Zummo <a.zummo@towertech.it>
    Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Rob Herring <robh+dt@kernel.org>
    Cc: linux-mips@vger.kernel.org
    Cc: linux-rtc@vger.kernel.org
    Cc: devicetree@vger.kernel.org
    Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
    Link: https://lore.kernel.org/r/20200521204818.25436-5-Sergey.Semin@baikalelectronics.ru
    cee43dbf
dw_apb_timer.c 11.7 KB