13 Dec, 2020

1 commit

  • To better describe what the pm_genpd_syscore_poweroff|poweron() functions
    actually do, let's rename them to dev_pm_genpd_suspend|resume() and update
    the rather few callers of them accordingly (a couple of clocksource
    drivers).

    Moreover, let's take the opportunity to add some documentation of these
    exported functions, as that is currently missing.

    Cc: Daniel Lezcano
    Cc: Thomas Gleixner
    Signed-off-by: Ulf Hansson
    (cherry picked from commit fc51989062138744b56e47190915ce68484e73f3 git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git)
    Bug: 175076037
    Change-Id: I8b59f0ca12e63b39f2a39528eb566232c78172c9
    Signed-off-by: Lina Iyer

    Ulf Hansson
     

23 Jul, 2020

1 commit


06 Jan, 2020

1 commit


07 Oct, 2019

2 commits

  • Old early platform device support is now sh-specific. Before moving on
    to implementing new early platform framework based on real platform
    devices, prefix all early platform symbols with 'sh_'.

    Signed-off-by: Bartosz Golaszewski
    Cc: Rich Felker
    Link: https://lore.kernel.org/r/20191003092913.10731-3-brgl@bgdev.pl
    Signed-off-by: Greg Kroah-Hartman

    Bartosz Golaszewski
     
  • SuperH is the only user of the current implementation of early platform
    device support. We want to introduce a more robust approach to early
    probing. As the first step - move all the current early platform code
    to arch/sh.

    In order not to export internal drivers/base functions to arch code for
    this temporary solution - copy the two needed routines for driver
    matching from drivers/base/platform.c to arch/sh/drivers/platform_early.c.

    Also: call early_platform_cleanup() from subsys_initcall() so that it's
    called after all early devices are probed.

    Signed-off-by: Bartosz Golaszewski
    Cc: Rich Felker
    Link: https://lore.kernel.org/r/20191003092913.10731-2-brgl@bgdev.pl
    Signed-off-by: Greg Kroah-Hartman

    Bartosz Golaszewski
     

27 Aug, 2019

3 commits

  • Update the CMT driver to mark "renesas,cmt-48" as deprecated.

    Instead of documenting a theoretical hardware device based on current software
    support level, define DT bindings top-down based on available data sheet
    information and make use of part numbers in the DT compat string.

    In case of the only in-tree users r8a7740 and sh73a0 the compat strings
    "renesas,r8a7740-cmt1" and "renesas,sh73a0-cmt1" may be used instead.

    Signed-off-by: Magnus Damm
    Reviewed-by: Simon Horman
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Magnus Damm
     
  • Add SoC-specific matching for CMT1 on r8a7740 and sh73a0.

    This allows us to move away from the old DT bindings such as
    - "renesas,cmt-48-sh73a0"
    - "renesas,cmt-48-r8a7740"
    - "renesas,cmt-48"
    in favour for the now commonly used format "renesas,-"

    Signed-off-by: Magnus Damm
    Reviewed-by: Simon Horman
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Magnus Damm
     
  • We don't need dev_err() messages when platform_get_irq() fails now that
    platform_get_irq() prints an error message itself when something goes
    wrong. Let's remove these prints with a simple semantic patch.

    //
    @@
    expression ret;
    struct platform_device *E;
    @@

    ret =
    (
    platform_get_irq(E, ...)
    |
    platform_get_irq_byname(E, ...)
    );

    if ( \( ret < 0 \| ret

    While we're here, remove braces on if statements that only have one
    statement (manually).

    Cc: Greg Kroah-Hartman
    Cc: Daniel Lezcano
    Cc: Thomas Gleixner
    Signed-off-by: Stephen Boyd
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Stephen Boyd
     

03 Oct, 2018

5 commits

  • Add support for the R-Car gen3 CMT types 0/1 -- they seem to be the same
    CMT types 0/1 as in R-Car gen2 SoCs.

    Signed-off-by: Sergei Shtylyov
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Sergei Shtylyov
     
  • There's no good reason for the sh_cmt_of_table[] initializer to
    violate the 80-column limit, especially after the commit 8d50e9476bb4
    ("clocksource/drivers/sh_cmt: Mark "renesas,cmt-48-gen2" deprecated")
    partially fixed it -- fix the R-Car gen2 related entries as well.

    Signed-off-by: Sergei Shtylyov
    Reviewed-by: Chris Paterson
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Sergei Shtylyov
     
  • The driver seems to abuse *unsigned long* not only for the (32-bit)
    register values but also for the 'sh_cmt_channel::total_cycles' which
    needs to always be 64-bit -- as a result, the clocksource's mask is
    needlessly clamped down to 32-bits on the 32-bit machines...

    Fixes: 19bdc9d061bc ("clocksource: sh_cmt clocksource support")
    Reported-by: Geert Uytterhoeven
    Signed-off-by: Sergei Shtylyov
    Reviewed-by: Simon Horman
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Sergei Shtylyov
     
  • When trying to use CMT for clockevents on R-Car gen3 SoCs, I noticed
    that 'max_delta_ns' for the broadcast timer (CMT) was shown as 1000 in
    /proc/timer_list. It turned out that when calculating it, the driver did
    1 << 32 (causing what I think was undefined behavior) resulting in a zero
    delta, later clamped to 1000 by cev_delta2ns(). The root cause turned out
    to be that the driver abused *unsigned long* for the CMT register values
    (which are 16/32-bit), so that the calculation of 'ch->max_match_value'
    in sh_cmt_setup_channel() used the wrong branch. Using more proper 'u32'
    instead fixed 'max_delta_ns' and even fixed the switching an active
    clocksource to CMT (which caused the system to turn non-interactive
    before).

    Signed-off-by: Sergei Shtylyov
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Sergei Shtylyov
     
  • This patch updates license to use SPDX-License-Identifier instead of verbose
    license text.

    Signed-off-by: Kuninori Morimoto
    Reviewed-by: Simon Horman
    Signed-off-by: Daniel Lezcano

    Kuninori Morimoto
     

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
     

20 Oct, 2017

6 commits

  • Use the existing of_device_get_match_data() helper instead of
    open-coding its functionality.

    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Daniel Lezcano

    Geert Uytterhoeven
     
  • The in-driver channel configuration in sh_cmt_info.channels_mask is now
    always set for all CMT devices instantiated from DT.

    Hence the "renesas,channels-mask" property is no longer checked, and its
    handling can be removed, cfr. commit 4e18111ff38f0664 ("devicetree:
    bindings: Remove deprecated properties").

    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Daniel Lezcano

    Geert Uytterhoeven
     
  • Document in the driver that "renesas,cmt-48-gen2" is deprecated, but
    still supported for backward compatibility with old DTBs, cfr. commit
    4e18111ff38f0664 ("devicetree: bindings: Remove deprecated
    properties").

    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Daniel Lezcano

    Geert Uytterhoeven
     
  • Remove driver matching support for the unused "renesas,cmt-32" and
    "renesas,cmt-32-fast" compatible values, cfr. commit 203bb3479958c48a
    ("devicetree: bindings: Remove unused 32-bit CMT bindings").

    As this removes the last user of SH_CMT_32BIT_FAST, all support for this
    variant is removed from the driver.

    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Daniel Lezcano

    Geert Uytterhoeven
     
  • Add support for the new R-Car Gen2 CMT0 and CMT1 bindings. Support
    for the old DT binding is still kept around, however devices using
    such binding will be treated as a low-feature CMT0 device. If users
    want to make use of CMT1-specific features then they need to update
    their DTBs. No special CMT1-specific features are however implemented
    by his patch, only DT bindings are redone as groundwork for future
    feature patches.

    Signed-off-by: Magnus Damm
    Acked-by: Laurent Pinchart
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Magnus Damm
     
  • Always use 0x3f as channel mask for the SH_CMT_48BIT type of devices.
    Once this patch is applied the "renesas,channels-mask" property will
    be ignored by the driver for older devices matching SH_CMT_48BIT. In
    the future when all CMT types store channel mask in the driver then
    we will be able to deprecate and remove "renesas,channels-mask" from DTS.

    Signed-off-by: Magnus Damm
    Acked-by: Laurent Pinchart
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano

    Magnus Damm
     

15 Apr, 2017

1 commit

  • In preparation for making the clockevents core NTP correction aware,
    all clockevent device drivers must set ->min_delta_ticks and
    ->max_delta_ticks rather than ->min_delta_ns and ->max_delta_ns: a
    clockevent device's rate is going to change dynamically and thus, the
    ratio of ns to ticks ceases to stay invariant.

    Make the sh_cmt clockevent driver initialize these fields properly.

    This patch alone doesn't introduce any change in functionality as the
    clockevents core still looks exclusively at the (untouched) ->min_delta_ns
    and ->max_delta_ns. As soon as this has changed, a followup patch will
    purge the initialization of ->min_delta_ns and ->max_delta_ns from this
    driver.

    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Daniel Lezcano
    Cc: Richard Cochran
    Cc: Prarit Bhargava
    Cc: Stephen Boyd
    Acked-by: Daniel Lezcano
    Signed-off-by: Nicolai Stange
    Signed-off-by: John Stultz

    Nicolai Stange
     

24 Mar, 2017

1 commit

  • With the upcoming NTP correction related rate adjustments to be implemented
    in the clockevents core, the latter needs to get informed about every rate
    change of a clockevent device made after its registration.

    Currently, sh_cmt violates this requirement in that it registers its
    clockevent device with a dummy rate and sets its final ->mult and ->shift
    values from its ->set_state_oneshot() and ->set_state_periodic() functions
    respectively.

    This patch moves the setting of the clockevent device's ->mult and ->shift
    values to before its registration.

    Note that there has been some back and forth regarding this question with
    respect to the clocksource also provided by this driver:
    commit f4d7c3565c16 ("clocksource: sh_cmt: compute mult and shift before
    registration")
    moves the rate determination from the clocksource's ->enable() function to
    before its registration. OTOH, the later
    commit 3593f5fe40a1 ("clocksource: sh_cmt: __clocksource_updatefreq_hz()
    update")
    basically reverts this, saying
    "Without this patch the old code uses clocksource_register() together
    with a hack that assumes a never changing clock rate."

    However, I checked all current sh_cmt users in arch/sh as well as in
    arch/arm/mach-shmobile carefully and right now, none of them changes any
    rate in any clock tree relevant to sh_cmt after their respective
    time_init(). Since all sh_cmt instances are created after time_init(), none
    of them should ever observe any clock rate changes.

    What's more, both, a clocksource as well as a clockevent device, can
    immediately get selected for use at their registration and thus, enabled
    at this point already. So it's probably safer to assume a "never changing
    clock rate" here.

    - Move the struct sh_cmt_channel's ->rate member to struct sh_cmt_device:
    it's a property of the underlying clock which is in turn specific to
    the sh_cmt_device.
    - Determine the ->rate value in sh_cmt_setup() at device probing rather
    than at first usage.
    - Set the clockevent device's ->mult and ->shift values right before its
    registration.
    - Although not strictly necessary for the upcoming clockevent core changes,
    set the clocksource's rate at its registration for consistency.

    Signed-off-by: Nicolai Stange
    Signed-off-by: John Stultz

    Nicolai Stange
     

25 Dec, 2016

1 commit


15 Oct, 2015

1 commit


02 Sep, 2015

1 commit

  • Pull timer updates from Thomas Gleixner:
    "Rather large, but nothing exiting:

    - new range check for settimeofday() to prevent that boot time
    becomes negative.
    - fix for file time rounding
    - a few simplifications of the hrtimer code
    - fix for the proc/timerlist code so the output of clock realtime
    timers is accurate
    - more y2038 work
    - tree wide conversion of clockevent drivers to the new callbacks"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (88 commits)
    hrtimer: Handle failure of tick_init_highres() gracefully
    hrtimer: Unconfuse switch_hrtimer_base() a bit
    hrtimer: Simplify get_target_base() by returning current base
    hrtimer: Drop return code of hrtimer_switch_to_hres()
    time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64()
    time: Introduce current_kernel_time64()
    time: Introduce struct itimerspec64
    time: Add the common weak version of update_persistent_clock()
    time: Always make sure wall_to_monotonic isn't positive
    time: Fix nanosecond file time rounding in timespec_trunc()
    timer_list: Add the base offset so remaining nsecs are accurate for non monotonic timers
    cris/time: Migrate to new 'set-state' interface
    kernel: broadcast-hrtimer: Migrate to new 'set-state' interface
    xtensa/time: Migrate to new 'set-state' interface
    unicore/time: Migrate to new 'set-state' interface
    um/time: Migrate to new 'set-state' interface
    sparc/time: Migrate to new 'set-state' interface
    sh/localtimer: Migrate to new 'set-state' interface
    score/time: Migrate to new 'set-state' interface
    s390/time: Migrate to new 'set-state' interface
    ...

    Linus Torvalds
     

10 Aug, 2015

4 commits


08 Aug, 2015

1 commit

  • Currently the sh_cmt clocksource timer is disabled or enabled
    unconditionally on clocksource suspend resp. resume, even if a
    better clocksource is present (e.g. arch_sys_counter) and the
    sh_cmt clocksource is not enabled.

    As sh_cmt is a syscore device when its timer is enabled, this
    may lead to a genpd.prepared_count imbalance in the presence of
    PM Domains, which may cause a lock-up during reboot after s2ram.

    During suspend:
    - pm_genpd_prepare() is called for all non-syscore devices (incl.
    sh_cmt), increasing genpd.prepared_count for each device,
    - clocksource.suspend() is called for all clocksource devices,
    - sh_cmt_clocksource_suspend() calls sh_cmt_stop(), which is a no-op
    as the clocksource was not enabled.

    During resume:
    - clocksource.resume() is called for all clocksource devices,
    - sh_cmt_clocksource_resume() calls sh_cmt_start(), which enables the
    clocksource timer, and turns sh_cmt into a syscore device,
    - pm_genpd_complete() is called for all non-syscore devices (excl.
    sh_cmt now!), decreasing genpd.prepared_count for each device but
    sh_cmt.

    Now genpd.prepared_count of the PM Domain containing sh_cmt is
    still 1 instead of zero. On subsequent suspend/resume cycles,
    sh_cmt is still a syscore device, hence it's skipped for
    pm_genpd_{prepare,complete}(), keeping the imbalance of
    genpd.prepared_count at 1.

    During reboot:

    - platform_drv_shutdown() is called for any platform device that has
    a driver with a .shutdown() method (only rcar-dmac on R-Car Gen2),

    - platform_drv_shutdown() calls dev_pm_domain_detach(), which
    calls genpd_dev_pm_detach(),

    - genpd_dev_pm_detach() keeps calling pm_genpd_remove_device() until
    it doesn't return -EAGAIN[*],

    - If the device is part of the same PM Domain as sh_cmt,
    pm_genpd_remove_device() always fails with -EAGAIN due to
    genpd.prepared_count > 0.

    - Infinite loop in genpd_dev_pm_detach()[*].

    [*] Commit 93af5e9354432828 ("PM / Domains: Avoid infinite loops in
    attach/detach code") already limited the number of loop iterations,
    avoiding the lock-up.

    To fix this, only disable or enable the clocksource timer on
    clocksource suspend resp. resume if the clocksource was enabled.

    This was tested on r8a7791/koelsch with the CPG Clock Domain:

    - using arch_sys_counter as the clocksource, which is the default, and
    which showed the problem,

    - using sh_cmt as a clocksource ("echo ffca0000.timer > \
    /sys/devices/system/clocksource/clocksource0/current_clocksource"),
    which behaves the same as before.

    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Daniel Lezcano
    Acked-by: Laurent Pinchart
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1438875126-12596-2-git-send-email-daniel.lezcano@linaro.org
    Signed-off-by: Ingo Molnar

    Geert Uytterhoeven
     

13 Mar, 2015

1 commit

  • Ingo requested this function be renamed to improve readability,
    so I've renamed __clocksource_updatefreq_scale() as well as the
    __clocksource_updatefreq_hz/khz() functions to avoid
    squishedtogethernames.

    This touches some of the sh clocksources, which I've not tested.

    The arch/arm/plat-omap change is just a comment change for
    consistency.

    Signed-off-by: John Stultz
    Cc: Daniel Lezcano
    Cc: Dave Jones
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Stephen Boyd
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1426133800-29329-13-git-send-email-john.stultz@linaro.org
    Signed-off-by: Ingo Molnar

    John Stultz
     

04 Jul, 2014

1 commit


02 Jul, 2014

2 commits


23 May, 2014

1 commit


16 Apr, 2014

5 commits

  • Clock sources don't need an IRQ, request the IRQ only for channels used
    as clock event devices.

    Signed-off-by: Laurent Pinchart

    Laurent Pinchart
     
  • This helps locating duplicates and inserting new headers.

    Signed-off-by: Laurent Pinchart

    Laurent Pinchart
     
  • Do not include the paragraph about writing to the Free Software
    Foundation's mailing address from the sample GPL notice. The FSF has
    changed addresses in the past, and may do so again. Linux already
    includes a copy of the GPL.

    Signed-off-by: Laurent Pinchart

    Laurent Pinchart
     
  • The sh_cmt driver gets the CMT functional clock using a connection ID of
    "cmt_fck". While all SH SoCs create clock lookup entries with a NULL
    device ID and a "cmt_fck" connection ID, the ARM SoCs use the device ID
    only with a NULL connection ID. This works on legacy platforms but will
    break on ARM with DT boot.

    Fix the situation by using a connection ID of "fck" in the non-legacy
    platform data case. Clock lookup entries will be renamed to use the
    device ID as well as the connection ID as platforms get moved to new
    platform data. The legacy code will eventually be dropped, leaving us
    with device ID based clock lookup, compatible with DT boot.

    Signed-off-by: Laurent Pinchart

    Laurent Pinchart
     
  • CMT hardware devices can support multiple channels, with global
    registers and per-channel registers. The sh_cmt driver currently models
    the hardware with one Linux device per channel. This model makes it
    difficult to handle global registers in a clean way.

    Add support for a new model that uses one Linux device per timer with
    multiple channels per device. This requires changes to platform data,
    add new channel configuration fields.

    Support for the legacy model is kept and will be removed after all
    platforms switch to the new model.

    Signed-off-by: Laurent Pinchart

    Laurent Pinchart