31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    license terms gnu general public license gpl version 2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 161 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Alexios Zavras
    Reviewed-by: Steve Winslow
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190528170027.447718015@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

13 Jun, 2018

1 commit

  • Return an error code on failure.

    Problem found using Coccinelle.

    Signed-off-by: Julia Lawall
    Signed-off-by: Thomas Gleixner
    Cc: Daniel Lezcano
    Cc: kernel-janitors@vger.kernel.org
    Cc: Maxime Coquelin
    Cc: Alexandre Torgue
    Cc: linux-arm-kernel@lists.infradead.org
    Link: https://lkml.kernel.org/r1528640655-18948-3-git-send-email-Julia.Lawall@lip6.fr

    Julia Lawall
     

09 Jan, 2018

10 commits

  • As we have a lot of timers on this platform, we can have potentially all the
    timers enabled in the DT, so we don't want to start the timer for every probe
    otherwise they will be running for nothing as only one will be used.

    Start the timer only when setting the mode or when the clocksource is
    enabled.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-20-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Daniel Lezcano
     
  • Add the timer delay callback, that saves us ~90ms of boot time.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-19-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Daniel Lezcano
     
  • The scene is set for the clocksource functionality, let's add it for this driver.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-18-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Benjamin Gaignard
     
  • In order to prepare the clocksource code, let's factor out the clockevent
    code, split the prescaler and timer width code into separate functions.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-17-git-send-email-daniel.lezcano@linaro.org
    [ Small edits. ]
    Signed-off-by: Ingo Molnar

    Daniel Lezcano
     
  • The stm32 timer block is able to have a counter and a comparator.

    Instead of using the auto-reload register for periodic events, we switch
    to oneshot mode by using the comparator register.

    The timer is able to generate an interrupt when the counter overflows but
    we don't want that as this counter will be use as a clocksource in the next
    patches. So it is disabled by the UDIS bit of the control register.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-16-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Benjamin Gaignard
     
  • The prescaler value is arbitrarily set to 1024 without any regard to the
    timer frequency. For 32-bit timers, there is no need to set a prescaler
    value as they wrap in an acceptable interval and give the opportunity to
    have precise timers on this platform. However, for 16-bit timers a prescaler
    value is needed if we don't want to wrap too often per second which is
    inefficient and adds more and more error margin. With a targeted clock
    of 10MHz, the 16 bits are precise enough whatever the timer frequency is
    as we will compute the prescaler.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-15-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Benjamin Gaignard
     
  • In order to clarify and encapsulate the code for upcoming changes, move the
    timer width check into a function and add some documentation.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-14-git-send-email-daniel.lezcano@linaro.org
    [ Spelling fixes. ]
    Signed-off-by: Ingo Molnar

    Daniel Lezcano
     
  • As there are different timers on the stm32, use the node name for the timer
    name in order to give the indication of which timer the kernel is using.

    /proc/timer_list gives all the information with the right name, otherwise
    we end up digging in the kernel log and /proc/interrupt to do the connection
    between the used timer.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-13-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Daniel Lezcano
     
  • Convert the driver to use the timer_of() helpers. This allows the removal of
    a custom private structure, factors out and simplifies the code.

    [Daniel Lezcano]: Respin against the critical fix patch and massaged the changelog.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1515418139-23276-12-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Benjamin Gaignard
     
  • The current code hides a couple of bugs:

    - The global variable 'clock_event_ddata' is overwritten each time the
    init function is invoked.

    This is fixed with a kmemdup() instead of assigning the global variable. That
    prevents a memory corruption when several timers are defined in the DT.

    - The clockevent's event_handler is NULL if the time framework does
    not select the clockevent when registering it, this is fine but the init
    code generates in any case an interrupt leading to dereference this
    NULL pointer.

    The stm32 timer works with shadow registers, a mechanism to cache the
    registers. When a change is done in one buffered register, we need to
    artificially generate an event to force the timer to copy the content
    of the register to the shadowed register.

    The auto-reload register (ARR) is one of the shadowed register as well as
    the prescaler register (PSC), so in order to force the copy, we issue an
    event which in turn leads to an interrupt and the NULL dereference.

    This is fixed by inverting two lines where we clear the status register
    before enabling the update event interrupt.

    As this kernel crash is resulting from the combination of these two bugs,
    the fixes are grouped into a single patch.

    Tested-by: Benjamin Gaignard
    Signed-off-by: Daniel Lezcano
    Acked-by: Benjamin Gaignard
    Cc: Alexandre Torgue
    Cc: Linus Torvalds
    Cc: Maxime Coquelin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: stable@vger.kernel.org
    Link: http://lkml.kernel.org/r/1515418139-23276-11-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Daniel Lezcano
     

31 Aug, 2017

1 commit

  • Now that we have a custom printf format specifier, convert users of
    full_name to use %pOF instead. This is preparation to remove storing
    of the full path string for each node.

    Signed-off-by: Rob Herring
    Cc: Daniel Lezcano
    Cc: Thomas Gleixner
    Cc: Marc Gonzalez
    Cc: Maxime Coquelin
    Cc: Alexandre Torgue
    Cc: linux-arm-kernel@lists.infradead.org
    Acked-by: Marc Gonzalez
    Acked-by: Alexandre TORGUE
    Signed-off-by: Daniel Lezcano

    Rob Herring
     

14 Jun, 2017

1 commit

  • The CLOCKSOURCE_OF_DECLARE macro is used widely for the timers to declare the
    clocksource at early stage. However, this macro is also used to initialize
    the clockevent if any, or the clockevent only.

    It was originally suggested to declare another macro to initialize a
    clockevent, so in order to separate the two entities even they belong to the
    same IP. This was not accepted because of the impact on the DT where splitting
    a clocksource/clockevent definition does not make sense as it is a Linux
    concept not a hardware description.

    On the other side, the clocksource has not interrupt declared while the
    clockevent has, so it is easy from the driver to know if the description is
    for a clockevent or a clocksource, IOW it could be implemented at the driver
    level.

    So instead of dealing with a named clocksource macro, let's use a more generic
    one: TIMER_OF_DECLARE.

    The patch has not functional changes.

    Signed-off-by: Daniel Lezcano
    Acked-by: Heiko Stuebner
    Acked-by: Neil Armstrong
    Acked-by: Arnd Bergmann
    Acked-by: Matthias Brugger
    Reviewed-by: Linus Walleij

    Daniel Lezcano
     

28 Jun, 2016

2 commits

  • All the clocksource drivers's init function are now converted to return
    an error code. CLOCKSOURCE_OF_DECLARE is no longer used as well as the
    clksrc-of table.

    Let's convert back the names:
    - CLOCKSOURCE_OF_DECLARE_RET => CLOCKSOURCE_OF_DECLARE
    - clksrc-of-ret => clksrc-of

    Signed-off-by: Daniel Lezcano

    For exynos_mct and samsung_pwm_timer:
    Acked-by: Krzysztof Kozlowski

    For arch/arc:
    Acked-by: Vineet Gupta

    For mediatek driver:
    Acked-by: Matthias Brugger

    For the Rockchip-part
    Acked-by: Heiko Stuebner

    For STi :
    Acked-by: Patrice Chotard

    For the mps2-timer.c and versatile.c changes:
    Acked-by: Liviu Dudau

    For the OXNAS part :
    Acked-by: Neil Armstrong

    For LPC32xx driver:
    Acked-by: Sylvain Lemieux

    For Broadcom Kona timer change:
    Acked-by: Ray Jui

    For Sun4i and Sun5i:
    Acked-by: Chen-Yu Tsai

    For Meson6:
    Acked-by: Carlo Caione

    For Keystone:
    Acked-by: Santosh Shilimkar

    For NPS:
    Acked-by: Noam Camus

    For bcm2835:
    Acked-by: Eric Anholt

    Daniel Lezcano
     
  • The init functions do not return any error. They behave as the following:

    - panic, thus leading to a kernel crash while another timer may work and
    make the system boot up correctly

    or

    - print an error and let the caller unaware if the state of the system

    Change that by converting the init functions to return an error conforming
    to the CLOCKSOURCE_OF_RET prototype.

    Proper error handling (rollback, errno value) will be changed later case
    by case, thus this change just return back an error or success in the init
    function.

    Signed-off-by: Daniel Lezcano
    Acked-by: Maxime Coquelin

    Daniel Lezcano
     

10 Aug, 2015

1 commit

  • Migrate stm32 driver to the new 'set-state' interface provided by
    clockevents core, the earlier 'set-mode' interface is marked obsolete
    now.

    This also enables us to implement callbacks for new states of clockevent
    devices, for example: ONESHOT_STOPPED.

    Cc: Maxime Coquelin
    Signed-off-by: Viresh Kumar
    Signed-off-by: Daniel Lezcano
    Tested-by: Maxime Coquelin
    Acked-by: Maxime Coquelin

    Viresh Kumar
     

02 Jun, 2015

2 commits

  • This patch fixes below warning spotted by kbuild test robot when building
    with ARCH=powerpc:

    drivers/clocksource/timer-stm32.c: In function 'stm32_clockevent_init':
    >> drivers/clocksource/timer-stm32.c:140:9: warning: large integer implicitly
    truncated to unsigned type [-Woverflow]

    writel_relaxed(~0UL, data->base + TIM_ARR);

    The fix consists in using 0U instead of 0UL.

    Reported-by: kbuild test robot
    Signed-off-by: Maxime Coquelin
    Signed-off-by: Daniel Lezcano

    Maxime Coquelin
     
  • STM32 MCUs feature 16 and 32 bits general purpose timers with prescalers.
    The drivers detects whether the time is 16 or 32 bits, and applies a
    1024 prescaler value if it is 16 bits.

    Reviewed-by: Linus Walleij
    Tested-by: Chanwoo Choi
    Signed-off-by: Maxime Coquelin
    Signed-off-by: Daniel Lezcano

    Maxime Coquelin