23 Feb, 2019

1 commit

  • If the clock tree is not fully populated when the timer-sun5i init code
    is called, attempts to get the clock rate for the timer would fail and
    return 0.

    Make the init code for both clock events and clocksource check the
    returned clock rate and fail gracefully if the result is 0, instead of
    causing a divide by 0 exception later on.

    Fixes: 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")
    Signed-off-by: Chen-Yu Tsai
    Acked-by: Maxime Ripard
    Signed-off-by: Daniel Lezcano

    Chen-Yu Tsai
     

22 Feb, 2018

1 commit

  • On lkml suggestions were made to split up such trivial typo fixes into per subsystem
    patches:

    --- a/arch/x86/boot/compressed/eboot.c
    +++ b/arch/x86/boot/compressed/eboot.c
    @@ -439,7 +439,7 @@ setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
    struct efi_uga_draw_protocol *uga = NULL, *first_uga;
    efi_guid_t uga_proto = EFI_UGA_PROTOCOL_GUID;
    unsigned long nr_ugas;
    - u32 *handles = (u32 *)uga_handle;;
    + u32 *handles = (u32 *)uga_handle;
    efi_status_t status = EFI_INVALID_PARAMETER;
    int i;

    This patch is the result of the following script:

    $ sed -i 's/;;$/;/g' $(git grep -E ';;$' | grep "\.[ch]:" | grep -vwE 'for|ia64' | cut -d: -f1 | sort | uniq)

    ... followed by manual review to make sure it's all good.

    Splitting this up is just crazy talk, let's get over with this and just do it.

    Reported-by: Pavel Machek
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

21 Jun, 2017

1 commit


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
     

13 Jun, 2017

1 commit

  • The kbuild test robot reported errors in these files when doing an ia64
    allmodconfig build.

    drivers/clocksource/timer-sun5i.c:52:21: error: field 'clksrc' has incomplete type
    struct clocksource clksrc;
    ^~~~~~
    drivers/clocksource/cadence_ttc_timer.c:92:21: error: field 'cs' has incomplete type
    struct clocksource cs;
    ^~

    (and many more errors for these files)

    Cc: Michal Simek
    Cc: "Sören Brinkmann"
    Cc: Daniel Lezcano
    Cc: Thomas Gleixner
    Cc: Maxime Ripard
    Cc: Chen-Yu Tsai
    Reported-by: kbuild test robot
    Signed-off-by: Stephen Rothwell
    Acked-by: Michal Simek
    Signed-off-by: Daniel Lezcano

    Stephen Rothwell
     

07 Apr, 2017

1 commit


25 Dec, 2016

1 commit


21 Oct, 2016

1 commit

  • struct clocksource is also used by the clk notifier callback, to
    unregister and re-register the clocksource with a different clock rate.
    clocksource_mmio_init does not pass back a pointer to the struct used,
    and the clk notifier callback assumes that the struct clocksource in
    struct sun5i_timer_clksrc is valid. This results in a kernel NULL
    pointer dereference when the hstimer clock is changed:

    Unable to handle kernel NULL pointer dereference at virtual address 00000004
    [] (clocksource_unbind) from [] (clocksource_unregister+0x2c/0x44)
    [] (clocksource_unregister) from [] (sun5i_rate_cb_clksrc+0x34/0x3c)
    [] (sun5i_rate_cb_clksrc) from [] (notifier_call_chain+0x44/0x84)
    [] (notifier_call_chain) from [] (__srcu_notifier_call_chain+0x44/0x60)
    [] (__srcu_notifier_call_chain) from [] (srcu_notifier_call_chain+0x18/0x20)
    [] (srcu_notifier_call_chain) from [] (__clk_notify+0x70/0x7c)
    [] (__clk_notify) from [] (clk_propagate_rate_change+0xa4/0xc4)
    [] (clk_propagate_rate_change) from [] (clk_propagate_rate_change+0x6c/0xc4)

    Revert the commit for now. clocksource_mmio_init can be made to pass back
    a pointer, but the code churn and usage of an inner struct might not be
    worth it.

    Fixes: 157dfadef832 ("clocksource/drivers/timer_sun5i: Replace code by clocksource_mmio_init")
    Reported-by: Maxime Ripard
    Signed-off-by: Chen-Yu Tsai
    Cc: linux-sunxi@googlegroups.com
    Cc: Daniel Lezcano
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lkml.kernel.org/r/20161018054918.26855-1-wens@csie.org
    Signed-off-by: Thomas Gleixner

    Chen-Yu Tsai
     

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

    Daniel Lezcano
     

15 Dec, 2015

1 commit


10 Aug, 2015

1 commit

  • Migrate sun5i 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 Ripard
    Signed-off-by: Viresh Kumar
    Signed-off-by: Daniel Lezcano
    Acked-by: Maxime Ripard

    Viresh Kumar
     

05 May, 2015

1 commit

  • of_io_request_and map returns an error pointer, but the current code assumes
    that on error the returned pointer will be NULL.

    Obviously, that makes the check completely useless. Change the test to actually
    check for the proper error code.

    Signed-off-by: Maxime Ripard
    Cc: Daniel Lezcano
    Link: http://lkml.kernel.org/r/1430579006-32702-6-git-send-email-maxime.ripard@free-electrons.com
    Signed-off-by: Thomas Gleixner

    Maxime Ripard
     

31 Mar, 2015

4 commits

  • The parent clock of the sun5i timer is the AHB clock, which rate
    might change because of other devices requirements.

    This is for example the case on the Allwinner A31, where the DMA
    controller needs a minimum rate higher than the default, that is
    enforced after the timer driver has probed.

    Add clock notifiers to make sure we reflect the clock rate
    changes in the timer rates.

    Signed-off-by: Maxime Ripard
    Signed-off-by: Daniel Lezcano
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lkml.kernel.org/r/1427796746-373-5-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Maxime Ripard
     
  • Refactor the code in order to remove the global variables and
    split the clock source and clock events registration in order to
    ease the addition of the clock notifiers needed to handle the
    parent clock rate changes.

    Signed-off-by: Maxime Ripard
    Signed-off-by: Daniel Lezcano
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lkml.kernel.org/r/1427796746-373-4-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Maxime Ripard
     
  • of_iomap doesn't do a request_mem_region() on the memory area
    defined in the DT it maps. Switch to of_io_request_and_map() to
    make sure we're the only users.

    Signed-off-by: Maxime Ripard
    Signed-off-by: Daniel Lezcano
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lkml.kernel.org/r/1427796746-373-3-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Maxime Ripard
     
  • The current code uses setup_irq(), while it could perfectly use
    the much simpler request_irq(). Switch to that.

    Signed-off-by: Maxime Ripard
    Signed-off-by: Daniel Lezcano
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lkml.kernel.org/r/1427796746-373-2-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Maxime Ripard
     

26 Mar, 2015

1 commit

  • The sun5i timer is used as the sched-clock on certain systems, and ever
    since we started using cpufreq, the cpu clock (that is one of the
    timer's clock indirect parent) now changes as well, along with the
    actual sched_clock() rate.

    This is not accurate and not desirable.

    We can safely remove the sun5i sched-clock on those systems, since we
    have other reliable sched_clock() sources in the system.

    Tested-by: Hans de Goede
    Signed-off-by: Maxime Ripard
    Signed-off-by: Daniel Lezcano
    [ Improved the changelog. ]
    Cc: richard@nod.at
    Link: http://lkml.kernel.org/r/1427362029-6511-4-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Maxime Ripard
     

05 Mar, 2015

1 commit

  • The interrupt is enabled before the handler is set. Even this bug
    did not appear, it is potentially dangerous as it can lead to a
    NULL pointer dereference.

    Fix the error by enabling the interrupt after
    clockevents_config_and_register() is called.

    Cc: stable@vger.kernel.org
    Signed-off-by: Yongbae Park
    Signed-off-by: Daniel Lezcano

    Yongbae Park
     

22 Apr, 2014

1 commit


19 Jan, 2014

1 commit

  • The 32-bit sched_clock() interface supports 64 bits since
    3.13-rc1. Upgrade to the 64-bit function to allow us to remove
    the 32-bit registration interface.

    Signed-off-by: Stephen Boyd
    Acked-by: Daniel Lezcano
    Cc: Maxime Ripard
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lkml.kernel.org/r/1389922686-6249-1-git-send-email-sboyd@codeaurora.org
    Signed-off-by: Ingo Molnar

    Stephen Boyd
     

11 Dec, 2013

1 commit

  • Most of the Allwinner SoCs (at this time, all but the A10) also have a
    High Speed timers that are not using the 24MHz oscillator as a source
    but rather the AHB clock running much faster.

    The IP is slightly different between the A10s/A13 and the one used in
    the A20/A31, since the latter have 4 timers available, while the former
    have only 2 of them.

    [dlezcano] : Fixed conflict with b788beda "Order Kconfig options
    alphabetically"

    Signed-off-by: Maxime Ripard
    Tested-by: Emilio López
    Signed-off-by: Daniel Lezcano

    Maxime Ripard