18 Oct, 2019

1 commit

  • As platform_get_irq_by_name() now prints an error when the interrupt
    does not exist, looping over possibly non-existing interrupts causes the
    printing of scary messages like:

    sh_mtu2 fcff0000.timer: IRQ tgi1a not found
    sh_mtu2 fcff0000.timer: IRQ tgi2a not found

    Fix this by using the platform_irq_count() helper, to avoid touching
    non-existent interrupts. Limit the returned number of interrupts to the
    maximum number of channels currently supported by the driver in a
    future-proof way, i.e. using ARRAY_SIZE() instead of a hardcoded number.

    Fixes: 7723f4c5ecdb8d83 ("driver core: platform: Add an error message to platform_get_irq*()")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/20191016143003.28561-1-geert+renesas@glider.be

    Geert Uytterhoeven
     

03 Oct, 2018

1 commit


13 Jun, 2018

1 commit

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

28 Oct, 2015

1 commit

  • On the r7s72100 Genmai board the MTU2 driver currently triggers a common
    clock framework WARN_ON(enable_count) when disabling the clock due to
    the MTU2 driver after recent callback rework may call ->set_state_shutdown()
    multiple times. A similar issue was spotted for the TMU driver and fixed in:
    452b132 clocksource/drivers/sh_tmu: Fix traceback spotted in -next

    On r7s72100 Genmai v4.3-rc7 built with shmobile_defconfig spits out the
    following during boot:

    sh_mtu2 fcff0000.timer: ch0: used for clock events
    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:675 clk_core_disable+0x2c/0x6c()
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.3.0-rc7 #1
    Hardware name: Generic R7S72100 (Flattened Device Tree)
    Backtrace:
    [] (dump_backtrace) from [] (show_stack+0x18/0x1c)
    [] (show_stack) from [] (dump_stack+0x74/0x90)
    [] (dump_stack) from [] (warn_slowpath_common+0x88/0xb4)
    [] (warn_slowpath_common) from [] (warn_slowpath_null+0x24/0x2c)
    [] (warn_slowpath_null) from [] (clk_core_disable+0x2c/0x6c)
    [] (clk_core_disable) from [] (clk_disable+0x40/0x4c)
    [] (clk_disable) from [] (sh_mtu2_disable+0x24/0x50)
    [] (sh_mtu2_disable) from [] (sh_mtu2_clock_event_shutdown+0x14/0x1c)
    [] (sh_mtu2_clock_event_shutdown) from [] (clockevents_switch_state+0xc8/0x114)
    [] (clockevents_switch_state) from [] (clockevents_shutdown+0x18/0x28)
    [] (clockevents_shutdown) from [] (clockevents_exchange_device+0x70/0x78)
    [] (clockevents_exchange_device) from [] (tick_check_new_device+0x88/0xe0)
    [] (tick_check_new_device) from [] (clockevents_register_device+0xac/0x120)
    [] (clockevents_register_device) from [] (sh_mtu2_probe+0x230/0x350)
    [] (sh_mtu2_probe) from [] (platform_drv_probe+0x50/0x98)

    Reported-by: Chris Brandt
    Fixes: 19a9ffb ("clockevents/drivers/sh_mtu2: Migrate to new 'set-state' interface")
    Cc: Viresh Kumar
    Cc: Laurent Pinchart
    Signed-off-by: Magnus Damm
    Signed-off-by: Daniel Lezcano
    Reviewed-by: Viresh Kumar

    Magnus Damm
     

10 Aug, 2015

1 commit

  • Migrate sh_mtu2 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: Magnus Damm
    Cc: Laurent Pinchart
    Cc: Paul Mundt
    Signed-off-by: Viresh Kumar
    Signed-off-by: Daniel Lezcano
    Acked-by: Laurent Pinchart

    Viresh Kumar
     

04 Jul, 2014

1 commit


02 Jul, 2014

2 commits


23 May, 2014

1 commit


16 Apr, 2014

17 commits


14 Jan, 2014

1 commit

  • Pull clocksource/clockevent updates from Daniel Lezcano:

    * Axel Lin removed an unused structure defining the ids for the
    bcm kona driver.

    * Ezequiel Garcia enabled the timer divider only when the 25MHz
    timer is not used for the armada 370 XP.

    * Jingoo Han removed a pointless platform data initialization for
    the sh_mtu and sh_mtu2.

    * Laurent Pinchart added the clk_prepare/clk_unprepare for sh_cmt.

    * Linus Walleij added a useful warning in clk_of when no clocks
    are found while the old behavior was to silently hang at boot time.

    * Maxime Ripard added the high speed timer drivers for the
    Allwinner SoCs (A10, A13, A20). He increased the rating, shared the
    irq across all available cpus and fixed the clockevent's irq
    initialization for the sun4i.

    * Michael Opdenacker removed the usage of the IRQF_DISABLED for the
    all the timers driver located in drivers/clocksource.

    * Stephen Boyd switched to sched_clock_register for the
    arm_global_timer, cadence_ttc, sun4i and orion timers.

    Conflicts:
    drivers/clocksource/clksrc-of.c

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

11 Dec, 2013

2 commits


21 Nov, 2013

2 commits


13 Mar, 2013

1 commit

  • The reason for this is to ensure that MTU2 is probed earlier
    than with its previous initcall level, module init.

    This came up as a problem with using CMT as a clock source kzm9g-reference
    which does not make use of early timers or devices. In that scenario
    initialisation of SDHI and MMCIF both stall on msleep() calls due to the
    absence of a initialised clock source.

    The purpose of this change is to keep the MTU2 code in sync with the CMT code
    which has been modified in a similar manner..

    Compile tested only using se7206_defconfig.
    I do not believe I have any boards that support the MTU2.

    Signed-off-by: Simon Horman

    Simon Horman
     

04 Jan, 2013

1 commit

  • CONFIG_HOTPLUG is going away as an option. As a result, the __dev*
    markings need to be removed.

    This change removes the use of __devinit, __devexit_p, __devinitdata,
    __devinitconst, and __devexit from these drivers.

    Based on patches originally written by Bill Pemberton, but redone by me
    in order to handle some of the coding style issues better, by hand.

    Cc: Bill Pemberton
    Cc: John Stultz
    Cc: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

04 Sep, 2012

4 commits

  • Modify the SH MTU2 clock event device driver to support runtime PM at
    a basic level (i.e. device clocks can be disabled and enabled, but
    domain power must be on, because the device has to be marked as
    "irq safe").

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Magnus Damm

    Rafael J. Wysocki
     
  • The syscore device PM flag is used to mark the devices (belonging to
    a PM domain) that should never be turned off, except for the system
    core (syscore) suspend/hibernation and resume stages. That flag is
    stored in the device's struct pm_subsys_data object whose address is
    available from struct device. However, in some situations it may be
    convenient to set that flag before the device is added to a PM
    domain, so it is better to move it directly to the "power" member of
    struct device. Then, it can be checked by the routines in
    drivers/base/power/runtime.c and drivers/base/power/main.c, which is
    more straightforward.

    This also reduces the number of dev_gpd_data() invocations in the
    generic PM domains framework, so the overhead related to the syscore
    flag is slightly smaller.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Magnus Damm

    Rafael J. Wysocki
     
  • The always_on device flag is used to mark the devices (belonging to
    a PM domain) that should never be turned off, except for the system
    core (syscore) suspend/hibernation and resume stages. Change name
    of that flag to "syscore" to better reflect its purpose.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Magnus Damm

    Rafael J. Wysocki
     
  • Introduce suspend/resume routines for SH MTU2 clock event devices
    such that if those devices belong to a PM domain, the generic PM
    domains framework will be notified that the given domain may be
    turned off (during system suspend) or that it has to be turned on
    (during system resume).

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Magnus Damm

    Rafael J. Wysocki
     

11 Jun, 2012

1 commit


17 Mar, 2012

1 commit


01 Nov, 2011

1 commit