24 Feb, 2020

1 commit

  • [ Upstream commit 2052d032c06761330bca4944bb7858b00960e868 ]

    Currently when setup_irq fails the error exit path will leak the
    recently allocated timer structure. Originally the code would
    throw a panic but a later commit changed the behaviour to return
    via the err_iounmap path and hence we now have a memory leak. Fix
    this by adding a err_timer_free error path that kfree's timer.

    Addresses-Coverity: ("Resource Leak")
    Fixes: 524a7f08983d ("clocksource/drivers/bcm2835_timer: Convert init function to return error")
    Signed-off-by: Colin Ian King
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/20191219213246.34437-1-colin.king@canonical.com
    Signed-off-by: Sasha Levin

    Colin Ian King
     

19 Dec, 2018

1 commit


25 Oct, 2017

1 commit

  • …READ_ONCE()/WRITE_ONCE()

    Please do not apply this to mainline directly, instead please re-run the
    coccinelle script shown below and apply its output.

    For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
    preference to ACCESS_ONCE(), and new code is expected to use one of the
    former. So far, there's been no reason to change most existing uses of
    ACCESS_ONCE(), as these aren't harmful, and changing them results in
    churn.

    However, for some features, the read/write distinction is critical to
    correct operation. To distinguish these cases, separate read/write
    accessors must be used. This patch migrates (most) remaining
    ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
    coccinelle script:

    ----
    // Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
    // WRITE_ONCE()

    // $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch

    virtual patch

    @ depends on patch @
    expression E1, E2;
    @@

    - ACCESS_ONCE(E1) = E2
    + WRITE_ONCE(E1, E2)

    @ depends on patch @
    expression E;
    @@

    - ACCESS_ONCE(E)
    + READ_ONCE(E)
    ----

    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: davem@davemloft.net
    Cc: linux-arch@vger.kernel.org
    Cc: mpe@ellerman.id.au
    Cc: shuah@kernel.org
    Cc: snitzer@redhat.com
    Cc: thor.thayer@linux.intel.com
    Cc: tj@kernel.org
    Cc: viro@zeniv.linux.org.uk
    Cc: will.deacon@arm.com
    Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>

    Mark Rutland
     

29 Aug, 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
     

07 Apr, 2017

1 commit


22 Nov, 2016

1 commit


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: Eric Anholt

    Daniel Lezcano
     

06 Aug, 2015

1 commit

  • Migrate bcm2835 driver to the new 'set-state' interface provided by
    the 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.

    We weren't doing anything in the ->set_mode() callback. So, this patch
    doesn't provide any set-state callbacks.

    Acked-by: Daniel Lezcano
    Tested-by: Stephen Warren
    Cc: Stephen Warren
    Cc: Lee Jones
    Signed-off-by: Viresh Kumar
    Signed-off-by: Daniel Lezcano

    Viresh Kumar
     

31 Jul, 2013

1 commit


13 Jun, 2013

1 commit


11 Mar, 2013

1 commit

  • In cases where we have multiple nodes of the same type, we may need the
    node pointer to know which node was matched. Passing the node pointer
    also keeps the init function from having to match the node a 2nd time.

    Update bcm2835, vt8500, and tegra20 init functions for the new function
    prototype. Further tegra20 clean-ups are in follow-up commit.

    Signed-off-by: Rob Herring
    Cc: John Stultz
    Cc: Thomas Gleixner
    Reviewed-by: Stephen Warren
    Tested-by: Stephen Warren
    Acked-by: Arnd Bergmann
    Acked-by: Tony Prisk
    Tested-by: Michal Simek

    Rob Herring
     

15 Jan, 2013

1 commit


25 Dec, 2012

1 commit

  • Now that the only field in struct sys_timer is .init, delete the struct,
    and replace the machine descriptor .timer field with the initialization
    function itself.

    This will enable moving timer drivers into drivers/clocksource without
    having to place a public prototype of each struct sys_timer object into
    include/linux; the intent is to create a single of_clocksource_init()
    function that determines which timer driver to initialize by scanning
    the device dtree, much like the proposed irqchip_init() at:
    http://www.spinics.net/lists/arm-kernel/msg203686.html

    Includes mach-omap2 fixes from Igor Grinberg.

    Tested-by: Robert Jarzmik
    Signed-off-by: Stephen Warren

    Stephen Warren
     

20 Sep, 2012

1 commit

  • The System Timer peripheral provides four 32-bit timer channels and a
    single 64-bit free running counter. Each channel has an output compare
    register, which is compared against the 32 least significant bits of the
    free running counter values, and generates an interrupt.

    Timer 3 is used as the Linux timer.

    The BCM2835 also contains an SP804-based timer module. However, it
    apparently has significant differences from the standard SP804 IP block,
    and Broadcom's documentation recommends using the system timer instead.

    This patch was extracted from git://github.com/lp0/linux.git branch
    rpi-split as of 2012/09/08, and modified as follows:

    * s/bcm2708/bcm2835/.
    * Modified device tree vendor prefix.
    * Moved to drivers/clocksource/. This looks like the desired location for
    such code now.
    * Added DT binding docs.
    * Moved struct sys_timer bcm2835_timer into time.c to encapsulate it more.
    * Simplified bcm2835_time_init() to find one matching node and operate on
    it, rather than looping over all matching nodes. This seems more
    consistent with other clocksource code.
    * Simplified bcm2835_time_init() using of_iomap().
    * Renamed struct bcm2835_timer.index to match_mask to better represent its
    purpose.
    * s/printk(PR_INFO/pr_info(/

    Signed-off-by: Chris Boot
    Signed-off-by: Simon Arlott
    Signed-off-by: Dom Cobley
    Signed-off-by: Dom Cobley
    Signed-off-by: Stephen Warren
    Acked-by: Arnd Bergmann

    Simon Arlott