28 Oct, 2015

1 commit

  • Measure latency does by itself contribute to an increased latency, thus we
    should avoid it when it isn't needed.

    By merging the latency measurements for the ->save_state() and the
    ->stop() callbacks, we get one measurement instead of two and we get one
    value to store instead of two. Let's also apply the likewise change for
    the ->start() and ->restore_state() callbacks.

    Signed-off-by: Ulf Hansson
    Reviewed-by: Lina Iyer
    Acked-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

13 Oct, 2015

3 commits

  • Once genpd could be configured to be built with CONFIG_PM_RUNTIME unset
    (nowadays CONFIG_PM), the pm_genpd_poweron() API served a purpose, since
    it allowed users to power on a PM domain.

    As such configuration no longer is supported, users shall solely rely on
    using some of the runtime PM APIs to power on a PM domain.

    Signed-off-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     
  • As the last user of the pm_genpd_poweroff_unused() API has moved into
    relying on genpd to deal with this internally from a late_initcall, let's
    remove the API.

    Signed-off-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     
  • Commit ba2bbfbf6307 ("PM / Domains: Remove intermediate states..") changed
    the power off sequence (pm_genpd_poweroff()), which from locking point of
    view means the genpd mutex is held throughout the sequence.

    The above change means the in_progress counter can't be updated while
    pm_genpd_poweroff() is executing, which allows us to remove the counter.

    Instead we inform pm_genpd_poweroff() via a bool parameter, to indicate
    whether we call it from the scheduled work or from the ->runtime_suspend()
    callback, since that all that matters.

    Signed-off-by: Ulf Hansson
    Reviewed-by: Lina Iyer
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

26 Sep, 2015

2 commits

  • The power domains code allows to tie a cpuidle state with a power domain.

    Preventing the cpuidle framework to enter a specific idle state by disabling
    from the power domain framework is a good idea. Unfortunately, the current
    implementation has some gaps with a SMP system and a complex cpuidle
    implementation. Enabling a power domain wakes up all the cpus even if a cpu
    does not belong to the power domain.

    There is some work to do a logical representation with the power domains of
    the hardware dependencies (eg. a cpu belongs to a power domains, these power
    domains belong to a higher power domain for a cluster, etc ...). A new code
    relying on the genpd hierarchy to disable the idle states would make more
    sense.

    As the unique user of this code has been removed, let's wipe out this code
    to prevent new user and to have a clean place to put a new implementation.

    Signed-off-by: Daniel Lezcano
    Acked-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Daniel Lezcano
     
  • As all users of the named based APIs now have converted to the non-named
    based APIs, the time has come to remove them.

    Signed-off-by: Ulf Hansson
    Acked-by: Geert Uytterhoeven
    Acked-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

29 Aug, 2015

1 commit

  • The governor dummies for the !CONFIG_PM_GENERIC_DOMAINS case are
    unusable, as a governors is always referred to by taking its address,
    which you can't do with a literal NULL pointer.

    I.e.

    pm_genpd_init(genpd, &simple_qos_governor, false);

    fails to compile with:

    error: lvalue required as unary '&' operand

    Hence just remove the governor dummies.

    Signed-off-by: Geert Uytterhoeven
    Acked-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Geert Uytterhoeven
     

01 Aug, 2015

1 commit

  • Genpd's ->runtime_suspend() (assigned to pm_genpd_runtime_suspend())
    doesn't immediately walk the hierarchy of ->runtime_suspend() callbacks.
    Instead, pm_genpd_runtime_suspend() calls pm_genpd_poweroff() which
    postpones that until *all* the devices in the genpd are runtime suspended.

    When pm_genpd_poweroff() discovers that the last device in the genpd is
    about to be runtime suspended, it calls __pm_genpd_save_device() for *all*
    the devices in the genpd sequentially. Furthermore,
    __pm_genpd_save_device() invokes the ->start() callback, walks the
    hierarchy of the ->runtime_suspend() callbacks and invokes the ->stop()
    callback. This causes a "thundering herd" problem.

    Let's address this issue by having pm_genpd_runtime_suspend() immediately
    walk the hierarchy of the ->runtime_suspend() callbacks, instead of
    postponing that to the power off sequence via pm_genpd_poweroff(). If the
    selected ->runtime_suspend() callback doesn't return an error code, call
    pm_genpd_poweroff() to see if it's feasible to also power off the PM
    domain.

    Adopting this change enables us to simplify parts of the code in genpd,
    for example the locking mechanism. Additionally, it gives some positive
    side effects, as described below.

    i)
    One device's ->runtime_resume() latency is no longer affected by other
    devices' latencies in a genpd.

    The complexity genpd has to support the option to abort the power off
    sequence suffers from latency issues. More precisely, a device that is
    requested to be runtime resumed, may end up waiting for
    __pm_genpd_save_device() to complete its operations for *another* device.
    That's because pm_genpd_poweroff() can't confirm an abort request while it
    waits for __pm_genpd_save_device() to return.

    As this patch removes the intermediate states in pm_genpd_poweroff() while
    powering off the PM domain, we no longer need the ability to abort that
    sequence.

    ii)
    Make pm_runtime[_status]_suspended() reliable when used with genpd.

    Until the last device in a genpd becomes idle, pm_genpd_runtime_suspend()
    will return 0 without actually walking the hierarchy of the
    ->runtime_suspend() callbacks. However, by returning 0 the runtime PM core
    considers the device as runtime_suspended, so
    pm_runtime[_status]_suspended() will return true, even though the device
    isn't (yet) runtime suspended.

    After this patch, since pm_genpd_runtime_suspend() immediately walks the
    hierarchy of the ->runtime_suspend() callbacks,
    pm_runtime[_status]_suspended() will accurately reflect the status of the
    device.

    iii)
    Enable fine-grained PM through runtime PM callbacks in drivers/subsystems.

    There are currently cases were drivers/subsystems implements runtime PM
    callbacks to deploy fine-grained PM (e.g. gate clocks, move pinctrl to
    power-save state, etc.). While using the genpd, pm_genpd_runtime_suspend()
    postpones invoking these callbacks until *all* the devices in the genpd
    are runtime suspended. In essence, one runtime resumed device prevents
    fine-grained PM for other devices within the same genpd.

    After this patch, since pm_genpd_runtime_suspend() immediately walks the
    hierarchy of the ->runtime_suspend() callbacks, fine-grained PM is enabled
    throughout all the levels of runtime PM callbacks.

    iiii)
    Enable fine-grained PM for IRQ safe devices

    Per the definition for an IRQ safe device, its runtime PM callbacks must
    be able to execute in atomic context. In the path while genpd walks the
    hierarchy of the ->runtime_suspend() callbacks for the device, it uses a
    mutex. Therefore, genpd prevents that path to be executed for IRQ safe
    devices.

    As this patch changes pm_genpd_runtime_suspend() to immediately walk the
    hierarchy of the ->runtime_suspend() callbacks and without needing to use
    a mutex, fine-grained PM is enabled throughout all the levels of runtime
    PM callbacks for IRQ safe devices.

    Unfortunately this patch also comes with a drawback, as described in the
    summary below.

    Driver's/subsystem's runtime PM callbacks may be invoked even when the
    genpd hasn't actually powered off the PM domain, potentially introducing
    unnecessary latency.

    However, in most cases, saving/restoring register contexts for devices are
    typically fast operations or can be optimized in device specific ways
    (e.g. shadow copies of register contents in memory, device-specific checks
    to see if context has been lost before restoring context, etc.).

    Still, in some cases the driver/subsystem may suffer from latency if
    runtime PM is used in a very fine-grained manner (e.g. for each IO request
    or xfer). To prevent that extra overhead, the driver/subsystem may deploy
    the runtime PM autosuspend feature.

    Signed-off-by: Ulf Hansson
    Reviewed-by: Kevin Hilman
    Tested-by: Geert Uytterhoeven
    Tested-by: Lina Iyer
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

23 Mar, 2015

1 commit

  • The PM domain code contains two methods to get the generic PM domain
    for a struct device. One is dev_to_genpd() which is only safe when
    we know for certain that the device has a generic PM domain attached.
    The other is coded into genpd_dev_pm_detach() which ensures that the
    PM domain in the struct device is a generic PM domain (and so is safer).

    This commit factors out the safer version, documents it, and hides the
    unsafe dev_to_genpd().

    Signed-off-by: Russell King
    Signed-off-by: Rafael J. Wysocki

    Russell King
     

04 Feb, 2015

2 commits

  • While adding devices to their PM domains, dev_pm_qos_add_notifier() was
    invoked while allocating the generic_pm_domain_data for the device.

    Since the generic_pm_domain_data's device pointer will be assigned
    after allocation, the ->genpd_dev_pm_qos_notifier() callback could be
    called prior having a valid pointer to the device. Similar scenario
    existed while removing a device from a genpd.

    To cope with these scenarios a mutex was used to protect the pointer to
    the device.

    By re-order the sequence for when dev_pm_qos_add|remove_notifier() are
    invoked, we make sure the ->genpd_dev_pm_qos_notifier() callback are
    always called with a valid device pointer available.

    In this way, we eliminate the need for protecting the pointer and thus
    we can remove the mutex from the struct generic_pm_domain_data.

    Signed-off-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     
  • The reference counting was needed when genpd supported PM domain device
    callbacks. Since this option has been removed, let's also remove the
    reference counting of the struct generic_pm_domain_data.

    Signed-off-by: Ulf Hansson
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

24 Jan, 2015

1 commit

  • There are currently no users of this API, let's remove it.

    Additionally, if such feature would be needed future wise, a better
    option is likely use pm_runtime_set_active|suspended() in some form.

    Signed-off-by: Ulf Hansson
    Acked-by: Geert Uytterhoeven
    Acked-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

30 Dec, 2014

1 commit


17 Dec, 2014

1 commit


09 Dec, 2014

1 commit

  • * pm-runtime: (25 commits)
    i2c-omap / PM: Drop CONFIG_PM_RUNTIME from i2c-omap.c
    dmaengine / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    drivers: sh / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    e1000e / igb / PM: Eliminate CONFIG_PM_RUNTIME
    MMC / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    MFD / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    misc / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    media / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    input / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    iio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    hsi / OMAP / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    i2c-hid / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    drm / exynos / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    gpio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    hwrandom / exynos / PM: Use CONFIG_PM in #ifdef
    block / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM
    USB / PM: Drop CONFIG_PM_RUNTIME from the USB core
    PM: Merge the SET*_RUNTIME_PM_OPS() macros
    PM / Kconfig: Do not select PM directly from Kconfig files
    PCI / PM: Drop CONFIG_PM_RUNTIME from the PCI core
    ...

    Rafael J. Wysocki
     

04 Dec, 2014

2 commits

  • After commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if PM_SLEEP is
    selected) PM_RUNTIME is always set if PM is set, so quite a few
    depend on CONFIG_PM or even may be dropped entirely in some cases.

    Replace CONFIG_PM_RUNTIME with CONFIG_PM in the PM core code.

    Reviewed-by: Ulf Hansson
    Acked-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • It's quite common for PM domains to use PM clocks. Typically from SOC
    specific code, the per device PM clock list is created and
    pm_clk_suspend|resume() are invoked to handle clock gating/ungating.

    A step towards consolidation is to integrate PM clock support into
    genpd, which is what this patch does.

    In this initial step, the calls to the pm_clk_suspend|resume() are
    handled within genpd, but the per device PM clock list still needs to
    be created from SOC specific code. It seems reasonable to have gendp to
    handle that as well, but that left to future patches to address.

    It's not every users of genpd that are keen on using PM clocks, thus we
    need to provide this a configuration option for genpd. Therefore let's
    add flag field in the genpd struct to keep this information and define
    a new GENDP_FLAG_PM_CLK bit for it.

    Signed-off-by: Ulf Hansson
    Acked-by: Geert Uytterhoeven
    Acked-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

18 Nov, 2014

2 commits


12 Nov, 2014

1 commit

  • The initial state of the device's need_restore flag should'nt depend on
    the current state of the PM domain. For example it should be perfectly
    valid to attach an inactive device to a powered PM domain.

    The pm_genpd_dev_need_restore() API allow us to update the need_restore
    flag to somewhat cope with such scenarios. Typically that should have
    been done from drivers/buses ->probe() since it's those that put the
    requirements on the value of the need_restore flag.

    Until recently, the Exynos SOCs were the only user of the
    pm_genpd_dev_need_restore() API, though invoking it from a centralized
    location while adding devices to their PM domains.

    Due to that Exynos now have swithed to the generic OF-based PM domain
    look-up, it's no longer possible to invoke the API from a centralized
    location. The reason is because devices are now added to their PM
    domains during the probe sequence.

    Commit "ARM: exynos: Move to generic PM domain DT bindings"
    did the switch for Exynos to the generic OF-based PM domain look-up,
    but it also removed the call to pm_genpd_dev_need_restore(). This
    caused a regression for some of the Exynos drivers.

    To handle things more properly in the generic PM domain, let's change
    the default initial value of the need_restore flag to reflect that the
    state is unknown. As soon as some of the runtime PM callbacks gets
    invoked, update the initial value accordingly.

    Moreover, since the generic PM domain is verifying that all devices
    are both runtime PM enabled and suspended, using pm_runtime_suspended()
    while pm_genpd_poweroff() is invoked from the scheduled work, we can be
    sure of that the PM domain won't be powering off while having active
    devices.

    Do note that, the generic PM domain can still only know about active
    devices which has been activated through invoking its runtime PM resume
    callback. In other words, buses/drivers using pm_runtime_set_active()
    during ->probe() will still suffer from a race condition, potentially
    probing a device without having its PM domain being powered. That issue
    will have to be solved using a different approach.

    This a log from the boot regression for Exynos5, which is being fixed in
    this patch.

    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 308 at ../drivers/clk/clk.c:851 clk_disable+0x24/0x30()
    Modules linked in:
    CPU: 0 PID: 308 Comm: kworker/0:1 Not tainted 3.18.0-rc3-00569-gbd9449f-dirty #10
    Workqueue: pm pm_runtime_work
    [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
    [] (show_stack) from [] (dump_stack+0x70/0xbc)
    [] (dump_stack) from [] (warn_slowpath_common+0x64/0x88)
    [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24)
    [] (warn_slowpath_null) from [] (clk_disable+0x24/0x30)
    [] (clk_disable) from [] (gsc_runtime_suspend+0x128/0x160)
    [] (gsc_runtime_suspend) from [] (pm_generic_runtime_suspend+0x2c/0x38)
    [] (pm_generic_runtime_suspend) from [] (pm_genpd_default_save_state+0x2c/0x8c)
    [] (pm_genpd_default_save_state) from [] (pm_genpd_poweroff+0x224/0x3ec)
    [] (pm_genpd_poweroff) from [] (pm_genpd_runtime_suspend+0x9c/0xcc)
    [] (pm_genpd_runtime_suspend) from [] (__rpm_callback+0x2c/0x60)
    [] (__rpm_callback) from [] (rpm_callback+0x20/0x74)
    [] (rpm_callback) from [] (rpm_suspend+0xd4/0x43c)
    [] (rpm_suspend) from [] (pm_runtime_work+0x80/0x90)
    [] (pm_runtime_work) from [] (process_one_work+0x12c/0x314)
    [] (process_one_work) from [] (worker_thread+0x3c/0x4b0)
    [] (worker_thread) from [] (kthread+0xcc/0xe8)
    [] (kthread) from [] (ret_from_fork+0x14/0x3c)
    ---[ end trace 40cd58bcd6988f12 ]---

    Fixes: a4a8c2c4962bb655 (ARM: exynos: Move to generic PM domain DT bindings)
    Reported-and-tested0by: Sylwester Nawrocki
    Reviewed-by: Sylwester Nawrocki
    Reviewed-by: Kevin Hilman
    Signed-off-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

08 Nov, 2014

1 commit

  • Convert the prototypes to return an int in order to support error
    handling in these callbacks.

    Also, as suggested by Dmitry Torokhov, pass the domain pointer for use
    inside the callbacks, and so that they match the existing
    power_on/power_off callbacks which currently take the domain pointer.

    Acked-by: Dmitry Torokhov
    Acked-by: Geert Uytterhoeven
    Signed-off-by: Ulf Hansson
    [ khilman: added domain as parameter to callbacks, as suggested by Dmitry ]
    Signed-off-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

03 Oct, 2014

1 commit

  • The "cpu_data" are defined for some archs and thus conflicting with the
    "cpu_data" member in the struct gpd_cpu_data. This causes a compiler
    error for those archs.

    Let's fix it by rename the member to cpuidle_data. In this context it
    also seems appropriate to rename the struct to gpd_cpuidle_data to
    better reflect its use.

    Fixes: f48c767ce895 (PM / Domains: Move dev_pm_domain_attach|detach() to pm_domain.h)
    Signed-off-by: Ulf Hansson
    Acked-by: Geert Uytterhoeven
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

30 Sep, 2014

1 commit

  • The commit 46420dd73b80 (PM / Domains: Add APIs to attach/detach a PM
    domain for a device) started using errno values in pm.h header file.
    It also failed to include the header for these, thus it caused
    compiler errors.

    Instead of including the errno header to pm.h, let's move the functions
    to pm_domain.h, since it's a better match.

    Fixes: 46420dd73b80 (PM / Domains: Add APIs to attach/detach a PM domain for a device)
    Signed-off-by: Ulf Hansson
    Acked-by: Geert Uytterhoeven
    Acked-by: Wolfram Sang
    Acked-by: Mark Brown
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

26 Sep, 2014

2 commits

  • There are no active clients of the legacy API and we now also have a
    better way to handle genpd DT support. So let's remove the legacy API.

    Signed-off-by: Ulf Hansson
    Acked-by: Geert Uytterhoeven
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     
  • While a PM domain can enable PM runtime management of its devices' module
    clocks by setting

    genpd->dev_ops.stop = pm_clk_suspend;
    genpd->dev_ops.start = pm_clk_resume;

    this also requires registering the clocks with the pm_clk subsystem.
    In the legacy case, this is handled by the platform code, after
    attaching the device to its PM domain.

    When the devices are instantiated from DT, devices are attached to their
    PM domains by generic code, leaving no method for the platform-specific
    PM domain code to register their clocks.

    Add two callbacks, allowing a PM domain to perform platform-specific
    tasks when a device is attached to or detached from a PM domain.

    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Geert Uytterhoeven
     

22 Sep, 2014

1 commit

  • This patch introduces generic code to perform PM domain look-up using
    device tree and automatically bind devices to their PM domains.

    Generic device tree bindings are introduced to specify PM domains of
    devices in their device tree nodes.

    Backwards compatibility with legacy Samsung-specific PM domain bindings
    is provided, but for now the new code is not compiled when
    CONFIG_ARCH_EXYNOS is selected to avoid collision with legacy code.
    This will change as soon as the Exynos PM domain code gets converted to
    use the generic framework in further patch.

    This patch was originally submitted by Tomasz Figa when he was employed
    by Samsung.

    Link: http://marc.info/?l=linux-pm&m=139955349702152&w=2
    Signed-off-by: Ulf Hansson
    Acked-by: Rob Herring
    Tested-by: Philipp Zabel
    Reviewed-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Tomasz Figa
     

09 Sep, 2014

8 commits


03 Sep, 2014

1 commit


04 Sep, 2012

5 commits

  • Make it possible to use domain names in operations connecting cpuidle
    to and disconnecting it from a PM domain. This is useful on
    platforms where PM domain objects are organized in such a way that
    the names of the domains are easier to use than the addresses of
    those objects.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • The names of the cpuidle-related functions in
    drivers/base/power/domain.c are inconsistent with the names of the
    other exported functions in that file (the "pm_" prefix is missing
    from them) and they are missing kerneldoc comments.

    Fix that by adding the missing "pm_" prefix to the names of those
    functions and add kerneldoc comments documenting them.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • It sometimes is necessary to turn on a given PM domain when only
    the name of it is known and the domain pointer is not readily
    available. For this reason, add a new helper function,
    pm_genpd_name_poweron(), allowing the caller to turn on a PM domain
    using its name for identification. To avoid code duplication,
    move the domain lookup code to a separate function.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Add a new helper function, pm_genpd_add_subdomain_names(), allowing
    the caller to add a subdomain to a generic PM domain using names for
    domain identification (both domains have to be initialized before).

    This function is useful for adding subdomains to PM domains whose
    representations are stored in tables, when the caller doesn't know
    the indices of the domain to add the subdomain to and of the
    subdomain itself, but it knows the domains' names.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Add a new helper function __pm_genpd_name_add_device() allowing
    a device to be added to a (registered) generic PM domain identified
    by name. Add a wrapper around it, pm_genpd_name_add_device(),
    passing NULL as the last argument and reorganize pm_domains.h for the
    new functions to be defined consistently with the existing ones.

    These functions are useful for adding devices to PM domains whose
    representations are stored in tables, when the caller doesn't know
    the index of the domain to add the device to, but it knows the
    domain's name.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki