1. 15 11月, 2012 1 次提交
  2. 23 10月, 2012 1 次提交
  3. 25 9月, 2012 1 次提交
  4. 23 9月, 2012 1 次提交
    • K
      PM / Runtime: let rpm_resume() succeed if RPM_ACTIVE, even when disabled, v2 · 6f3c77b0
      Kevin Hilman 提交于
      There are several drivers where the return value of
      pm_runtime_get_sync() is used to decide whether or not it is safe to
      access hardware and that don't provide .suspend() callbacks for system
      suspend (but may use late/noirq callbacks.)  If such a driver happens
      to call pm_runtime_get_sync() during system suspend, after the core
      has disabled runtime PM, it will get the error code and will decide
      that the hardware should not be accessed, although this may be a wrong
      conclusion, depending on the state of the device when runtime PM was
      disabled.
      
      Drivers might work around this problem by using a test like:
      
         ret = pm_runtime_get_sync(dev);
         if (!ret || (ret == -EACCES && driver_private_data(dev)->suspended)) {
            /* access hardware */
         }
      
      where driver_private_data(dev)->suspended is a flag set by the
      driver's .suspend() method (that would have to be added for this
      purpose).  However, that potentially would need to be done by multiple
      drivers which means quite a lot of duplicated code and bloat.
      
      To avoid that we can use the observation that the core sets
      dev->power.is_suspended before disabling runtime PM and use that
      instead of the driver's private flag.  Still, potentially many drivers
      would need to repeat that same check in quite a few places, so it's
      better to let the core do it.
      
      Then we can be a bit smarter and check whether or not runtime PM was
      disabled by the core only (disable_depth == 1) or by someone else in
      addition to the core (disable_depth > 1).  In the former case
      rpm_resume() can return 1 if the runtime PM status is RPM_ACTIVE,
      because it means the device was active when the core disabled runtime
      PM.  In the latter case it should still return -EACCES, because it
      isn't clear why runtime PM has been disabled.
      
      Tested on AM3730/Beagle-xM where a wakeup IRQ firing during the late
      suspend phase triggers runtime PM activity in the I2C driver since the
      wakeup IRQ is on an I2C-connected PMIC.
      
      [rjw: Modified whitespace to follow the file's convention.]
      Signed-off-by: NKevin Hilman <khilman@ti.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      6f3c77b0
  5. 20 9月, 2012 1 次提交
    • A
      PM: Prevent runtime suspend during system resume · 88d26136
      Alan Stern 提交于
      This patch (as1591) moves the pm_runtime_get_noresume() and
      pm_runtime_put_sync() calls from __device_suspend() and
      device_resume() to device_prepare() and device_complete() in the PM
      core.
      
      The reason for doing this is to make sure that parent devices remain
      at full power (i.e., don't go into runtime suspend) while their
      children are being resumed from a system sleep.
      
      The PCI core already contained equivalent code to serve the same
      purpose.  The patch removes the duplicated code, since it is no longer
      needed.  One of the comments from the PCI core gets moved into the PM
      core, and a second comment is added to explain whe the _get_noresume
      and _put_sync calls are present.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      88d26136
  6. 19 9月, 2012 2 次提交
  7. 10 9月, 2012 1 次提交
  8. 07 9月, 2012 2 次提交
  9. 04 9月, 2012 13 次提交
    • R
      PM / Domains: Operations related to cpuidle using domain names · 74a2799a
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rjw@sisk.pl>
      74a2799a
    • R
      PM / Domains: Document cpuidle-related functions and change their names · 40114447
      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: NRafael J. Wysocki <rjw@sisk.pl>
      40114447
    • R
      PM / Domains: Add power-on function using names to identify domains · 8bc0251d
      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: NRafael J. Wysocki <rjw@sisk.pl>
      8bc0251d
    • R
      PM / Domains: Make it possible to use names when adding subdomains · fb7268be
      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: NRafael J. Wysocki <rjw@sisk.pl>
      fb7268be
    • R
      PM / Domains: Make it possible to use domain names when adding devices · b5abb085
      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: NRafael J. Wysocki <rjw@sisk.pl>
      b5abb085
    • R
      PM: Do not use the syscore flag for runtime PM · feb70af0
      Rafael J. Wysocki 提交于
      The syscore device PM flag used to mark the devices (belonging to
      PM domains) that should never be turned off, except for the system
      core (syscore) suspend/hibernation and resume stages, need not be
      accessed by the runtime PM core functions, because all of the devices
      it is set for need to be marked as "irq safe" anyway and are
      protected from being turned off by runtime PM by ensuring that their
      usage counters are always set.
      
      For this reason, make the syscore flag system-wide PM-specific
      and simplify the code used for manipulating it, because it need not
      acquire the device's power.lock any more.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      feb70af0
    • R
      PM / Domains: Do not measure start time for "irq safe" devices · e2e3e4e5
      Rafael J. Wysocki 提交于
      The genpd_start_dev() routine used by pm_genpd_runtime_resume()
      to put "irq safe" devices into the full power state measures the
      time necessary to "start" the device and updates its PM QoS timing
      data if necessary.  This may lead to a deadlock if the given device
      is a clock source and genpd_start_dev() is invoked from within the
      clock source's .enable() routine, which will happen if that routine
      uses pm_runtime_get_sync(), for example, to ensure that the device
      is operational.
      
      For this reason, introduce a special routine analogous to
      genpd_start_dev(), called genpd_start_dev_no_timing(), that doesn't
      carry out the time measurement, and make pm_genpd_runtime_resume()
      use it instead of genpd_start_dev() to power up "irq safe" devices.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      e2e3e4e5
    • R
      PM / Domains: Move syscore flag from subsys data to struct device · dbf37414
      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: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NMagnus Damm <damm@opensource.se>
      dbf37414
    • R
      PM / Domains: Rename the always_on device flag to syscore · 6fb28bad
      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: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NMagnus Damm <damm@opensource.se>
      6fb28bad
    • R
      PM / Runtime: Allow helpers to be called by early platform drivers · bed2b42d
      Rafael J. Wysocki 提交于
      Runtime PM helper functions, like pm_runtime_get_sync(), cannot be
      called by early platform device drivers, because the devices' power
      management locks are not initialized at that time.  This is quite
      inconvenient, so modify early_platform_add_devices() to initialize
      the devices power management locks as appropriate and make sure that
      they won't be initialized more than once if an early platform
      device is going to be used as a regular one later.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      bed2b42d
    • R
      PM: Reorganize device PM initialization · e91c11b1
      Rafael J. Wysocki 提交于
      Make the device power management initialization more straightforward
      by moving the initialization of common (i.e. used by both runtime PM
      and system suspend) fields to a separate routine.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      e91c11b1
    • R
      PM / Domains: Add power off/on function for system core suspend stage · 77f827de
      Rafael J. Wysocki 提交于
      Introduce function pm_genpd_syscore_switch() and two wrappers around
      it, pm_genpd_syscore_poweroff() and pm_genpd_syscore_poweron(),
      allowing the callers to let the generic PM domains framework know
      that the given device is not necessary any more and its PM domain
      can be turned off (the former) or that the given device will be
      required immediately, so its PM domain has to be turned on (the
      latter) during the system core (syscore) stage of system suspend
      (or hibernation) and resume.
      
      These functions will be used for handling devices registered as
      clock sources and clock event devices that belong to PM domains.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      77f827de
    • R
      PM / Domains: Introduce simplified power on routine for system resume · 802d8b49
      Rafael J. Wysocki 提交于
      Introduce function pm_genpd_sync_poweron() for restoring domain power
      during resume from system suspend and hibernation.  It can be much
      simpler than pm_genpd_poweron(), because it doesn't have to care
      about locking and it can skip many checks done by the latter.
      
      Modify pm_genpd_resume_noirq() and pm_genpd_restore_noirq() to use
      the new function.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      802d8b49
  10. 18 8月, 2012 4 次提交
    • T
      PM / Sleep: Print name of wakeup source that aborts suspend · a938da06
      Todd Poynor 提交于
      A driver or app may repeatedly request a wakeup source while the system
      is attempting to enter suspend, which may indicate a bug or at least
      point out a highly active system component that is responsible for
      decreased battery life on a mobile device.  Even when the incidence
      of suspend abort is not severe, identifying wakeup sources that
      frequently abort suspend can be a useful clue for power management
      analysis.
      
      In some cases the existing stats can point out the offender where there is
      an unexpectedly high activation count that stands out from the others, but
      in other cases the wakeup source frequently taken just after the rest of
      the system thinks its time to suspend might not stand out in the overall
      stats.
      
      It is also often useful to have information about what's been happening
      recently, rather than totals of all activity for the system boot.
      
      It's suggested to dump a line about which wakeup source
      aborted suspend to aid analysis of these situations.
      Signed-off-by: NTodd Poynor <toddpoynor@google.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      a938da06
    • R
      PM / Runtime: Check device PM QoS setting before "no callbacks" check · 55d7ec45
      Rafael J. Wysocki 提交于
      If __dev_pm_qos_read_value(dev) returns a negative value,
      rpm_suspend() should return -EPERM for dev even if its
      power.no_callbacks flag is set.  For this to happen, the device's
      power.no_callbacks flag has to be checked after the PM QoS check,
      so move the PM QoS check to rpm_check_suspend_allowed() (this will
      make it cover idle notifications as well as runtime suspend too).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      55d7ec45
    • R
      PM / Runtime: Clear power.deferred_resume on success in rpm_suspend() · 58a34de7
      Rafael J. Wysocki 提交于
      The power.deferred_resume can only be set if the runtime PM status
      of device is RPM_SUSPENDING and it should be cleared after its
      status has been changed, regardless of whether or not the runtime
      suspend has been successful.  However, it only is cleared on
      suspend failure, while it may remain set on successful suspend and
      is happily leaked to rpm_resume() executed in that case.
      
      That shouldn't happen, so if power.deferred_resume is set in
      rpm_suspend() after the status has been changed to RPM_SUSPENDED,
      clear it before calling rpm_resume().  Then, it doesn't need to be
      cleared before changing the status to RPM_SUSPENDING any more,
      because it's always cleared after the status has been changed to
      either RPM_SUSPENDED (on success) or RPM_ACTIVE (on failure).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      58a34de7
    • R
      PM / Runtime: Fix rpm_resume() return value for power.no_callbacks set · 7f321c26
      Rafael J. Wysocki 提交于
      For devices whose power.no_callbacks flag is set, rpm_resume()
      should return 1 if the device's parent is already active, so that
      the callers of pm_runtime_get() don't think that they have to wait
      for the device to resume (asynchronously) in that case (the core
      won't queue up an asynchronous resume in that case, so there's
      nothing to wait for anyway).
      
      Modify the code accordingly (and make sure that an idle notification
      will be queued up on success, even if 1 is to be returned).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      7f321c26
  11. 17 8月, 2012 1 次提交
  12. 09 8月, 2012 1 次提交
  13. 19 7月, 2012 3 次提交
  14. 13 7月, 2012 2 次提交
  15. 11 7月, 2012 3 次提交
    • S
      PM / Domains: Replace plain integer with NULL pointer in domain.c file · db79e53d
      Sachin Kamat 提交于
      Fixes the following sparse warning:
      drivers/base/power/domain.c:1679:55: warning: Using plain integer as NULL pointer
      Signed-off-by: NSachin Kamat <sachin.kamat@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      db79e53d
    • S
      PM / Domains: Add missing static storage class specifier in domain.c file · 8951ef02
      Sachin Kamat 提交于
      Fixes the folloiwng sparse warning:
      drivers/base/power/domain.c:149:5:
      warning: symbol '__pm_genpd_poweron' was not declared. Should it be static?
      Signed-off-by: NSachin Kamat <sachin.kamat@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      8951ef02
    • P
      PM / cpuidle: System resume hang fix with cpuidle · 8651f97b
      Preeti U Murthy 提交于
      On certain bios, resume hangs if cpus are allowed to enter idle states
      during suspend [1].
      
      This was fixed in apci idle driver [2].But intel_idle driver does not
      have this fix. Thus instead of replicating the fix in both the idle
      drivers, or in more platform specific idle drivers if needed, the
      more general cpuidle infrastructure could handle this.
      
      A suspend callback in cpuidle_driver could handle this fix. But
      a cpuidle_driver provides only basic functionalities like platform idle
      state detection capability and mechanisms to support entry and exit
      into CPU idle states. All other cpuidle functions are found in the
      cpuidle generic infrastructure for good reason that all cpuidle
      drivers, irrepective of their platforms will support these functions.
      
      One option therefore would be to register a suspend callback in cpuidle
      which handles this fix. This could be called through a PM_SUSPEND_PREPARE
      notifier. But this is too generic a notfier for a driver to handle.
      
      Also, ideally the job of cpuidle is not to handle side effects of suspend.
      It should expose the interfaces which "handle cpuidle 'during' suspend"
      or any other operation, which the subsystems call during that respective
      operation.
      
      The fix demands that during suspend, no cpus should be allowed to enter
      deep C-states. The interface cpuidle_uninstall_idle_handler() in cpuidle
      ensures that. Not just that it also kicks all the cpus which are already
      in idle out of their idle states which was being done during cpu hotplug
      through a CPU_DYING_FROZEN callbacks.
      
      Now the question arises about when during suspend should
      cpuidle_uninstall_idle_handler() be called. Since we are dealing with
      drivers it seems best to call this function during dpm_suspend().
      Delaying the call till dpm_suspend_noirq() does no harm, as long as it is
      before cpu_hotplug_begin() to avoid race conditions with cpu hotpulg
      operations. In dpm_suspend_noirq(), it would be wise to place this call
      before suspend_device_irqs() to avoid ugly interactions with the same.
      
      Ananlogously, during resume.
      
      References:
      [1] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/674075.
      [2] http://marc.info/?l=linux-pm&m=133958534231884&w=2Reported-and-tested-by: NDave Hansen <dave@linux.vnet.ibm.com>
      Signed-off-by: NPreeti U Murthy <preeti@linux.vnet.ibm.com>
      Reviewed-by: NSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      8651f97b
  16. 06 7月, 2012 2 次提交
    • R
      PM / Domains: Allow device callbacks to be added at any time · 62d44902
      Rafael J. Wysocki 提交于
      Make it possible to modify device callbacks used by the generic PM
      domains core code at any time, not only after the device has been
      added to a domain.  This will allow device drivers to provide their
      own device PM domain callbacks even if they are registered before
      adding the devices to PM domains.
      
      For this purpose, use the observation that the struct
      generic_pm_domain_data object containing the relevant callback
      pointers may be allocated by pm_genpd_add_callbacks() and the
      callbacks may be set before __pm_genpd_add_device() is run for
      the given device.  This object will then be used by
      __pm_genpd_add_device(), but it has to be protected from
      premature removal by reference counting.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      62d44902
    • R
      PM / Domains: Add device domain data reference counter · 1d5fcfec
      Rafael J. Wysocki 提交于
      Add a mechanism for counting references to the
      struct generic_pm_domain_data object pointed to by
      dev->power.subsys_data->domain_data if the device in question
      belongs to a generic PM domain.
      
      This change is necessary for a subsequent patch making it possible to
      allocate that object from within pm_genpd_add_callbacks(), so that
      drivers can attach their PM domain device callbacks to devices before
      those devices are added to PM domains.
      
      This patch has been tested on the SH7372 Mackerel board.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      1d5fcfec
  17. 04 7月, 2012 1 次提交
    • R
      PM / Domains: Add preliminary support for cpuidle, v2 · cbc9ef02
      Rafael J. Wysocki 提交于
      On some systems there are CPU cores located in the same power
      domains as I/O devices.  Then, power can only be removed from the
      domain if all I/O devices in it are not in use and the CPU core
      is idle.  Add preliminary support for that to the generic PM domains
      framework.
      
      First, the platform is expected to provide a cpuidle driver with one
      extra state designated for use with the generic PM domains code.
      This state should be initially disabled and its exit_latency value
      should be set to whatever time is needed to bring up the CPU core
      itself after restoring power to it, not including the domain's
      power on latency.  Its .enter() callback should point to a procedure
      that will remove power from the domain containing the CPU core at
      the end of the CPU power transition.
      
      The remaining characteristics of the extra cpuidle state, referred to
      as the "domain" cpuidle state below, (e.g. power usage, target
      residency) should be populated in accordance with the properties of
      the hardware.
      
      Next, the platform should execute genpd_attach_cpuidle() on the PM
      domain containing the CPU core.  That will cause the generic PM
      domains framework to treat that domain in a special way such that:
      
       * When all devices in the domain have been suspended and it is about
         to be turned off, the states of the devices will be saved, but
         power will not be removed from the domain.  Instead, the "domain"
         cpuidle state will be enabled so that power can be removed from
         the domain when the CPU core is idle and the state has been chosen
         as the target by the cpuidle governor.
      
       * When the first I/O device in the domain is resumed and
         __pm_genpd_poweron(() is called for the first time after
         power has been removed from the domain, the "domain" cpuidle
         state will be disabled to avoid subsequent surprise power removals
         via cpuidle.
      
      The effective exit_latency value of the "domain" cpuidle state
      depends on the time needed to bring up the CPU core itself after
      restoring power to it as well as on the power on latency of the
      domain containing the CPU core.  Thus the "domain" cpuidle state's
      exit_latency has to be recomputed every time the domain's power on
      latency is updated, which may happen every time power is restored
      to the domain, if the measured power on latency is greater than
      the latency stored in the corresponding generic_pm_domain structure.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: NKevin Hilman <khilman@ti.com>
      cbc9ef02