1. 01 7月, 2012 2 次提交
    • R
      PM / Domains: Do not stop devices after restoring their states · 80de3d7f
      Rafael J. Wysocki 提交于
      While resuming a device belonging to a PM domain,
      pm_genpd_runtime_resume() calls __pm_genpd_restore_device() to
      restore its state, if necessary.  The latter starts the device,
      using genpd_start_dev(), restores its state, using
      genpd_restore_dev(), and then stops it, using genpd_stop_dev().
      However, this last operation is not necessary, because the
      device is supposed to be operational after pm_genpd_runtime_resume()
      has returned and because of it pm_genpd_runtime_resume() has to
      call genpd_start_dev() once again for the "restored" device, which
      is inefficient.
      
      To make things more efficient, remove the call to genpd_stop_dev()
      from __pm_genpd_restore_device() and the direct call to
      genpd_start_dev() from pm_genpd_runtime_resume().  [Of course,
      genpd_start_dev() still has to be called by it for devices with the
      power.irq_safe flag set, because __pm_genpd_restore_device() is not
      executed for them.]
      
      This change has been tested on the SH7372 Mackerel board.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      80de3d7f
    • R
      PM / Domains: Use subsystem runtime suspend/resume callbacks by default · 0b589741
      Rafael J. Wysocki 提交于
      Currently, the default "save state" and "restore state" routines
      for generic PM domains, pm_genpd_default_save_state() and
      pm_genpd_default_restore_state(), respectively, only use runtime PM
      callbacks provided by device drivers, but in general those callbacks
      need not provide the entire necessary functionality.  Namely, in
      general it may be necessary to execute subsystem (i.e. device type,
      device class or bus type) callbacks that will carry out all of the
      necessary operations.
      
      For this reason, modify pm_genpd_default_save_state() and
      pm_genpd_default_restore_state() to execute subsystem callbacks,
      if they are provided, and fall back to driver callbacks otherwise.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0b589741
  2. 25 6月, 2012 1 次提交
  3. 19 5月, 2012 1 次提交
    • R
      PM / Domains: Make it possible to add devices to inactive domains · ca1d72f0
      Rafael J. Wysocki 提交于
      The generic PM domains core code currently requires domains to be in
      the "power on" state for adding devices to them, but this limitation
      turns out to be inconvenient in some situations, so remove it.
      
      For this purpose, make __pm_genpd_add_device() set the device's
      need_restore flag if the domain is in the "power off" state, so that
      the device's "restore state" (usually .runtime_resume()) callback
      is executed when it is resumed after the domain has been turned on.
      If the domain is in the "power on" state, the device's need_restore
      flag will be cleared by __pm_genpd_add_device(), so that its "save
      state" (usually .runtime_suspend()) callback is executed when the
      domain is about to be turned off.  However, since that default
      behavior need not be always desirable, add a helper function
      pm_genpd_dev_need_restore() allowing a device's need_restore flag
      to be set/unset at any time.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      ca1d72f0
  4. 12 5月, 2012 2 次提交
    • R
      PM / Domains: Fix computation of maximum domain off time · b723b0eb
      Rafael J. Wysocki 提交于
      The default domain power off governor function for generic PM
      domains, default_power_down_ok(), may violate subdomain maximum
      off time limit by allowing the master domain to be off for too
      long.  Namely, it only finds the minium of all device maximum
      off times over the domain's devices and uses that to compute the
      domain's maximum off time, but it should do the same for the
      subdomains.
      
      Fix this problem by modifying default_power_down_ok() to compute
      the given domain's maximum off time as the difference between the
      minimum off time over all devices and subdomains in the domain and
      its power on latency.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      b723b0eb
    • H
      PM / Domains: Fix link checking when add subdomain · 4fcac10d
      Huang Ying 提交于
      Current pm_genpd_add_subdomain() will allow duplicated link between
      master and slave domain.  This patch fixed it.
      
      Because when current pm_genpd_add_subdomain() checks whether the link
      between the master and slave generic PM domain already exists,
      slave_links instead of master_links of master domain is used.
      Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      4fcac10d
  5. 06 5月, 2012 2 次提交
    • R
      PM / Domains: Cache device stop and domain power off governor results, v3 · 6ff7bb0d
      Rafael J. Wysocki 提交于
      The results of the default device stop and domain power off governor
      functions for generic PM domains, default_stop_ok() and
      default_power_down_ok(), depend only on the timing data of devices,
      which are static, and on their PM QoS constraints.  Thus, in theory,
      these functions only need to carry out their computations, which may
      be time consuming in general, when it is known that the PM QoS
      constraint of at least one of the devices in question has changed.
      
      Use the PM QoS notifiers of devices to implement that.  First,
      introduce new fields, constraint_changed and max_off_time_changed,
      into struct gpd_timing_data and struct generic_pm_domain,
      respectively, and register a PM QoS notifier function when adding
      a device into a domain that will set those fields to 'true' whenever
      the device's PM QoS constraint is modified.  Second, make
      default_stop_ok() and default_power_down_ok() use those fields to
      decide whether or not to carry out their computations from scratch.
      
      The device and PM domain hierarchies are taken into account in that
      and the expense is that the changes of PM QoS constraints of
      suspended devices will not be taken into account immediately, which
      isn't guaranteed anyway in general.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      6ff7bb0d
    • R
      PM / Domains: Make device removal more straightforward · efa69025
      Rafael J. Wysocki 提交于
      The removal of a device from a PM domain doesn't have to browse
      the domain's device list, because it can check directly if the
      device belongs to the given domain.  Moreover, it should clear
      the domain_data pointer in dev->power.subsys_data, because
      dev_pm_put_subsys_data(dev) may not remove dev->power.subsys_data
      and the stale domain data pointer may cause problems to happen.
      
      Rework pm_genpd_remove_device() taking the above observations into
      account.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      efa69025
  6. 02 5月, 2012 11 次提交
    • R
      PM / QoS: Create device constraints objects on notifier registration · 23e0fc5a
      Rafael J. Wysocki 提交于
      The current behavior of dev_pm_qos_add_notifier() makes device PM QoS
      notifiers less than useful.  Namely, it silently returns success when
      called before any PM QoS constraints are added for the device, so the
      caller will assume that the notifier has been registered, but when
      someone actually adds some nontrivial constraints for the device
      eventually, the previous callers of dev_pm_qos_add_notifier()
      will not know about that and their notifier routines will not be
      executed (contrary to their expectations).
      
      To address this problem make dev_pm_qos_add_notifier() create the
      constraints object for the device if it is not present when the
      routine is called.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by : markgross <markgross@thegnar.org>
      23e0fc5a
    • R
      PM / Runtime: Remove device fields related to suspend time, v2 · 76e267d8
      Rafael J. Wysocki 提交于
      After the previous changes in default_stop_ok() and
      default_power_down_ok() for PM domains, there are two fields in
      struct dev_pm_info that aren't necessary any more,  suspend_time
      and max_time_suspended_ns.
      
      Remove those fields along with all of the code that accesses them,
      which simplifies the runtime PM framework quite a bit.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      76e267d8
    • R
      PM / Domains: Rework default domain power off governor function, v2 · dd8683e9
      Rafael J. Wysocki 提交于
      The existing default domain power down governor function for PM
      domains, default_power_down_ok(), is supposed to check whether or not
      the PM QoS latency constraints of the devices in the domain will be
      violated if the domain is turned off by pm_genpd_poweroff().
      However, the computations carried out by it don't reflect the
      definition of the PM QoS latency constrait in
      Documentation/ABI/testing/sysfs-devices-power.
      
      Make default_power_down_ok() follow the definition of the PM QoS
      latency constrait.  In particular, make it only take latencies into
      account, because it doesn't matter how much time has elapsed since
      the domain's devices were suspended for the computation.
      
      Remove the break_even_ns and power_off_time fields from
      struct generic_pm_domain, because they are not necessary any more.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      dd8683e9
    • R
      PM / Domains: Rework default device stop governor function, v2 · a5bef810
      Rafael J. Wysocki 提交于
      The existing default device stop governor function for PM domains,
      default_stop_ok(), is supposed to check whether or not the device's
      PM QoS latency constraint will be violated if the device is stopped
      by pm_genpd_runtime_suspend().  However, the computations carried out
      by it don't reflect the definition of the PM QoS latency constrait in
      Documentation/ABI/testing/sysfs-devices-power.
      
      Make default_stop_ok() follow the definition of the PM QoS latency
      constrait.  In particular, make it take the device's start and stop
      latencies correctly.
      
      Add a new field, effective_constraint_ns, to struct gpd_timing_data
      and use it to store the difference between the device's PM QoS
      constraint and its resume latency for use by the device's parent
      (the effective_constraint_ns values for the children are used for
      computing the parent's one along with its PM QoS constraint).
      
      Remove the break_even_ns field from struct gpd_timing_data, because
      it's not used any more.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      a5bef810
    • R
      PM / Sleep: Add user space interface for manipulating wakeup sources, v3 · b86ff982
      Rafael J. Wysocki 提交于
      Android allows user space to manipulate wakelocks using two
      sysfs file located in /sys/power/, wake_lock and wake_unlock.
      Writing a wakelock name and optionally a timeout to the wake_lock
      file causes the wakelock whose name was written to be acquired (it
      is created before is necessary), optionally with the given timeout.
      Writing the name of a wakelock to wake_unlock causes that wakelock
      to be released.
      
      Implement an analogous interface for user space using wakeup sources.
      Add the /sys/power/wake_lock and /sys/power/wake_unlock files
      allowing user space to create, activate and deactivate wakeup
      sources, such that writing a name and optionally a timeout to
      wake_lock causes the wakeup source of that name to be activated,
      optionally with the given timeout.  If that wakeup source doesn't
      exist, it will be created and then activated.  Writing a name to
      wake_unlock causes the wakeup source of that name, if there is one,
      to be deactivated.  Wakeup sources created with the help of
      wake_lock that haven't been used for more than 5 minutes are garbage
      collected and destroyed.  Moreover, there can be only WL_NUMBER_LIMIT
      wakeup sources created with the help of wake_lock present at a time.
      
      The data type used to track wakeup sources created by user space is
      called "struct wakelock" to indicate the origins of this feature.
      
      This version of the patch includes an rbtree manipulation fix from John Stultz.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NNeilBrown <neilb@suse.de>
      b86ff982
    • R
      PM / Sleep: Add "prevent autosleep time" statistics to wakeup sources · 55850945
      Rafael J. Wysocki 提交于
      Android uses one wakelock statistics that is only necessary for
      opportunistic sleep.  Namely, the prevent_suspend_time field
      accumulates the total time the given wakelock has been locked
      while "automatic suspend" was enabled.  Add an analogous field,
      prevent_sleep_time, to wakeup sources and make it behave in a similar
      way.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55850945
    • R
      PM / Sleep: Implement opportunistic sleep, v2 · 7483b4a4
      Rafael J. Wysocki 提交于
      Introduce a mechanism by which the kernel can trigger global
      transitions to a sleep state chosen by user space if there are no
      active wakeup sources.
      
      It consists of a new sysfs attribute, /sys/power/autosleep, that
      can be written one of the strings returned by reads from
      /sys/power/state, an ordered workqueue and a work item carrying out
      the "suspend" operations.  If a string representing the system's
      sleep state is written to /sys/power/autosleep, the work item
      triggering transitions to that state is queued up and it requeues
      itself after every execution until user space writes "off" to
      /sys/power/autosleep.
      
      That work item enables the detection of wakeup events using the
      functions already defined in drivers/base/power/wakeup.c (with one
      small modification) and calls either pm_suspend(), or hibernate() to
      put the system into a sleep state.  If a wakeup event is reported
      while the transition is in progress, it will abort the transition and
      the "system suspend" work item will be queued up again.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NNeilBrown <neilb@suse.de>
      7483b4a4
    • A
      PM / Sleep: Add wakeup_source_activate and wakeup_source_deactivate tracepoints · 6791e36c
      Arve Hjønnevåg 提交于
      Add tracepoints to wakeup_source_activate and wakeup_source_deactivate.
      Useful for checking that specific wakeup sources overlap as expected.
      Signed-off-by: NArve Hjønnevåg <arve@android.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      6791e36c
    • R
      PM / Sleep: Change wakeup source statistics to follow Android · 30e3ce6d
      Rafael J. Wysocki 提交于
      Wakeup statistics used by Android are slightly different from what we
      have in wakeup sources at the moment and there aren't any known
      users of those statistics other than Android, so modify them to make
      it easier for Android to switch to wakeup sources.
      
      This removes the struct wakeup_source's hit_cout field, which is very
      rough and therefore not very useful, and adds two new fields,
      wakeup_count and expire_count.  The first one tracks how many times
      the wakeup source is activated with events_check_enabled set (which
      roughly corresponds to the situations when a system power transition
      to a sleep state is in progress and would be aborted by this wakeup
      source if it were the only active one at that time) and the second
      one is the number of times the wakeup source has been activated with
      a timeout that expired.
      
      Additionally, the last_time field is now updated when the wakeup
      source is deactivated too (previously it was only updated during
      the wakeup source's activation), which seems to be what Android does
      with the analogous counter for wakelocks.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      30e3ce6d
    • R
      PM / Sleep: Use wait queue to signal "no wakeup events in progress" · 60af1066
      Rafael J. Wysocki 提交于
      The current wakeup source deactivation code doesn't do anything when
      the counter of wakeup events in progress goes down to zero, which
      requires pm_get_wakeup_count() to poll that counter periodically.
      Although this reduces the average time it takes to deactivate a
      wakeup source, it also may lead to a substantial amount of unnecessary
      polling if there are extended periods of wakeup activity.  Thus it
      seems reasonable to use a wait queue for signaling the "no wakeup
      events in progress" condition and remove the polling.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: Nmark gross <markgross@thegnar.org>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60af1066
    • R
      PM / Sleep: Look for wakeup events in later stages of device suspend · 52d136cc
      Rafael J. Wysocki 提交于
      Currently, the device suspend code in drivers/base/power/main.c
      only checks if there have been any wakeup events, and therefore the
      ongoing system transition to a sleep state should be aborted, during
      the first (i.e. "suspend") device suspend phase.  However, wakeup
      events may be reported later as well, so it's reasonable to look for
      them in the in the subsequent (i.e. "late suspend" and "suspend
      noirq") phases.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52d136cc
  7. 27 3月, 2012 1 次提交
    • A
      PM / Runtime: don't forget to wake up waitqueue on failure · f2791d73
      Alan Stern 提交于
      This patch (as1535) fixes a bug in the runtime PM core.  When a
      runtime suspend attempt completes, whether successfully or not, the
      device's power.wait_queue is supposed to be signalled.  But this
      doesn't happen in the failure pathway of rpm_suspend() when another
      autosuspend attempt is rescheduled.  As a result, a task can get stuck
      indefinitely on the wait queue (I have seen this happen in testing).
      
      The patch fixes the problem by moving the wake_up_all() call up near
      the start of the failure code.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      f2791d73
  8. 19 3月, 2012 1 次提交
  9. 17 3月, 2012 3 次提交
    • R
      PM / Domains: Introduce "always on" device flag · 1e78a0c7
      Rafael J. Wysocki 提交于
      The TMU device on the Mackerel board belongs to the A4R power domain
      and loses power when the domain is turned off.  Unfortunately, the
      TMU driver is not prepared to cope with such situations and crashes
      the system when that happens.  To work around this problem introduce
      a new helper function, pm_genpd_dev_always_on(), allowing a device
      driver to mark its device as "always on" in case it belongs to a PM
      domain, which will make the generic PM domains core code avoid
      powering off the domain containing the device, both at run time and
      during system suspend.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Tested-by: NSimon Horman <horms@verge.net.au>
      Acked-by: NPaul Mundt <lethal@linux-sh.org>
      Cc: stable@vger.kernel.org
      1e78a0c7
    • R
      PM / Domains: Fix hibernation restore of devices, v2 · 65533bbf
      Rafael J. Wysocki 提交于
      During resume from hibernation pm_genpd_restore_noirq() should only
      power off domains whose suspend_power_off flags are set once and
      not every time it is called for a device in the given domain.
      Moreover, it shouldn't decrement genpd->suspended_count, because
      that field is not touched during device freezing and therefore it is
      always equal to 0 when pm_genpd_restore_noirq() runs for the first
      device in the given domain.
      
      This means pm_genpd_restore_noirq() may use genpd->suspended_count
      to determine whether or not it it has been called for the domain in
      question already in this cycle (it only needs to increment that
      field every time it runs for this purpose) and whether or not it
      should check if the domain needs to be powered off.  For that to
      work, though, pm_genpd_prepare() has to clear genpd->suspended_count
      when it runs for the first device in the given domain (in which case
      that flag need not be cleared during domain initialization).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: stable@vger.kernel.org
      65533bbf
    • R
      PM / Domains: Fix handling of wakeup devices during system resume · cc85b207
      Rafael J. Wysocki 提交于
      During system suspend pm_genpd_suspend_noirq() checks if the given
      device is in a wakeup path (i.e. it appears to be needed for one or
      more wakeup devices to work or is a wakeup device itself) and if it
      needs to be "active" for wakeup to work.  If that is the case, the
      function returns 0 without incrementing the device domain's counter
      of suspended devices and without executing genpd_stop_dev() for the
      device.  In consequence, the device is not stopped (e.g. its clock
      isn't disabled) and power is always supplied to its domain in the
      resulting system sleep state.
      
      However, pm_genpd_resume_noirq() doesn't repeat that check and it
      runs genpd_start_dev() and decrements the domain's counter of
      suspended devices even for the wakeup device that weren't stopped by
      pm_genpd_suspend_noirq().  As a result, the start callback may be run
      unnecessarily for them and their domains' counters of suspended
      devices may become negative.  Both outcomes aren't desirable, so fix
      pm_genpd_resume_noirq() to look for wakeup devices that might not be
      stopped by during system suspend.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Tested-by: NSimon Horman <horms@verge.net.au>
      Cc: stable@vger.kernel.org
      cc85b207
  10. 14 3月, 2012 1 次提交
    • R
      PM / QoS: Make it possible to expose PM QoS latency constraints · 85dc0b8a
      Rafael J. Wysocki 提交于
      A runtime suspend of a device (e.g. an MMC controller) belonging to
      a power domain or, in a more complicated scenario, a runtime suspend
      of another device in the same power domain, may cause power to be
      removed from the entire domain.  In that case, the amount of time
      necessary to runtime-resume the given device (e.g. the MMC
      controller) is often substantially greater than the time needed to
      run its driver's runtime resume callback.  That may hurt performance
      in some situations, because user data may need to wait for the
      device to become operational, so we should make it possible to
      prevent that from happening.
      
      For this reason, introduce a new sysfs attribute for devices,
      power/pm_qos_resume_latency_us, allowing user space to specify the
      upper bound of the time necessary to bring the (runtime-suspended)
      device up after the resume of it has been requested.  However, make
      that attribute appear only for the devices whose drivers declare
      support for it by calling the (new) dev_pm_qos_expose_latency_limit()
      helper function with the appropriate initial value of the attribute.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: NKevin Hilman <khilman@ti.com>
      Reviewed-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      Acked-by: NLinus Walleij <linus.walleij@linaro.org>
      85dc0b8a
  11. 12 3月, 2012 1 次提交
    • P
      device.h: cleanup users outside of linux/include (C files) · 51990e82
      Paul Gortmaker 提交于
      For files that are actively using linux/device.h, make sure
      that they call it out.  This will allow us to clean up some
      of the implicit uses of linux/device.h within include/*
      without introducing build regressions.
      
      Yes, this was created by "cheating" -- i.e. the headers were
      cleaned up, and then the fallout was found and fixed, and then
      the two commits were reordered.  This ensures we don't introduce
      build regressions into the git history.
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      51990e82
  12. 05 3月, 2012 4 次提交
    • R
      PM / Sleep: Add more wakeup source initialization routines · 8671bbc1
      Rafael J. Wysocki 提交于
      The existing wakeup source initialization routines are not
      particularly useful for wakeup sources that aren't created by
      wakeup_source_create(), because their users have to open code
      filling the objects with zeros and setting their names.  For this
      reason, introduce routines that can be used for initializing, for
      example, static wakeup source objects.
      Requested-by: NArve Hjønnevåg <arve@android.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      8671bbc1
    • R
      PM / Sleep: Make __pm_stay_awake() delete wakeup source timers · 4782e165
      Rafael J. Wysocki 提交于
      If __pm_stay_awake() is called after __pm_wakeup_event() for the same
      wakep source object before its timer expires, it won't cancel the
      timer, so the wakeup source will be deactivated from the timer
      function as scheduled by __pm_wakeup_event().  In that case
      __pm_stay_awake() doesn't have any effect beyond incrementing
      the wakeup source's event_count field, although it should cancel
      the timer and make the wakeup source stay active until __pm_relax()
      is called for it.
      
      To fix this problem make __pm_stay_awake() delete the wakeup source's
      timer and ensure that it won't be deactivated from the timer funtion
      afterwards by clearing its timer_expires field.
      Reported-by: NArve Hjønnevåg <arve@android.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      4782e165
    • R
      PM / Sleep: Fix race conditions related to wakeup source timer function · da863cdd
      Rafael J. Wysocki 提交于
      If __pm_wakeup_event() has been used (with a nonzero timeout) to
      report a wakeup event and then __pm_relax() immediately followed by
      __pm_stay_awake() is called or __pm_wakeup_event() is called once
      again for the same wakeup source object before its timer expires, the
      timer function pm_wakeup_timer_fn() may still be run as a result of
      the previous __pm_wakeup_event() call.  In either of those cases it
      may mistakenly deactivate the wakeup source that has just been
      activated.
      
      To prevent that from happening, make wakeup_source_deactivate()
      clear the wakeup source's timer_expires field and make
      pm_wakeup_timer_fn() check if timer_expires is different from zero
      and if it's not in future before calling wakeup_source_deactivate()
      (if timer_expires is 0, it means that the timer has just been
      deleted and if timer_expires is in future, it means that the timer
      has just been rescheduled to a different time).
      Reported-by: NArve Hjønnevåg <arve@android.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      da863cdd
    • R
      PM / Sleep: Fix possible infinite loop during wakeup source destruction · d94aff87
      Rafael J. Wysocki 提交于
      If wakeup_source_destroy() is called for an active wakeup source that
      is never deactivated, it will spin forever.  To prevent that from
      happening, make wakeup_source_destroy() call __pm_relax() for the
      wakeup source object it is about to free instead of waiting until
      it will be deactivated by someone else.  However, for this to work
      it also needs to make sure that the timer function will not be
      executed after the final __pm_relax(), so make it run
      del_timer_sync() on the wakeup source's timer beforehand.
      
      Additionally, update the kerneldoc comment to document the
      requirement that __pm_stay_awake() and __pm_wakeup_event() must not
      be run in parallel with wakeup_source_destroy().
      Reported-by: NArve Hjønnevåg <arve@android.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      d94aff87
  13. 13 2月, 2012 1 次提交
  14. 30 1月, 2012 3 次提交
    • R
      PM / Domains: Run late/early device suspend callbacks at the right time · 0496c8ae
      Rafael J. Wysocki 提交于
      After the introduction of the late/early phases of device
      suspend/resume during system-wide power transitions it is possible
      to make the generic PM domains code execute its default late/early
      device suspend/resume callbacks during those phases instead of the
      corresponding _noirq phases.  The _noirq device suspend/resume
      phases were only used for executing those callbacks, because this
      was the only way it could be done, but now we can do better.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0496c8ae
    • R
      PM / Sleep: Introduce generic callbacks for new device PM phases · e470d066
      Rafael J. Wysocki 提交于
      Introduce generic subsystem callbacks for the new phases of device
      suspend/resume during system power transitions: "late suspend",
      "early resume", "late freeze", "early thaw", "late poweroff",
      "early restore".
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      e470d066
    • R
      PM / Sleep: Introduce "late suspend" and "early resume" of devices · cf579dfb
      Rafael J. Wysocki 提交于
      The current device suspend/resume phases during system-wide power
      transitions appear to be insufficient for some platforms that want
      to use the same callback routines for saving device states and
      related operations during runtime suspend/resume as well as during
      system suspend/resume.  In principle, they could point their
      .suspend_noirq() and .resume_noirq() to the same callback routines
      as their .runtime_suspend() and .runtime_resume(), respectively,
      but at least some of them require device interrupts to be enabled
      while the code in those routines is running.
      
      It also makes sense to have device suspend-resume callbacks that will
      be executed with runtime PM disabled and with device interrupts
      enabled in case someone needs to run some special code in that
      context during system-wide power transitions.
      
      Apart from this, .suspend_noirq() and .resume_noirq() were introduced
      as a workaround for drivers using shared interrupts and failing to
      prevent their interrupt handlers from accessing suspended hardware.
      It appears to be better not to use them for other porposes, or we may
      have to deal with some serious confusion (which seems to be happening
      already).
      
      For the above reasons, introduce new device suspend/resume phases,
      "late suspend" and "early resume" (and analogously for hibernation)
      whose callback will be executed with runtime PM disabled and with
      device interrupts enabled and whose callback pointers generally may
      point to runtime suspend/resume routines.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      Reviewed-by: NKevin Hilman <khilman@ti.com>
      cf579dfb
  15. 27 1月, 2012 1 次提交
    • T
      PM / Domains: Add OF support · c8aa130b
      Thomas Abraham 提交于
      A device node pointer is added to generic pm domain structure to associate
      the domain with a node in the device tree. The platform code parses the
      device tree to find available nodes representing the generic power domain,
      instantiates the available domains and initializes them by calling
      pm_genpd_init().
      
      Nodes representing the devices include a phandle of the power domain to
      which it belongs. As these devices get instantiated, the driver code
      checkes for availability of a power domain phandle, converts the phandle
      to a device node and uses the new pm_genpd_of_add_device() api to
      associate the device with a power domain.
      
      pm_genpd_of_add_device() runs through its list of registered power domains
      and matches the OF node of the domain with the one specified as the
      parameter. If a match is found, the device is associated with the matched
      domain.
      
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Grant Likely <grant.likely@secretlab.ca>
      Signed-off-by: NThomas Abraham <thomas.abraham@linaro.org>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NKukjin Kim <kgene.kim@samsung.com>
      c8aa130b
  16. 14 1月, 2012 2 次提交
  17. 26 12月, 2011 1 次提交
    • R
      PM / QoS: Introduce dev_pm_qos_add_ancestor_request() · 40a5f8be
      Rafael J. Wysocki 提交于
      Some devices, like the I2C controller on SH7372, are not
      necessary for providing power to their children or forwarding
      wakeup signals (and generally interrupts) from them.  They are
      only needed by their children when there's some data to transfer,
      so they may be suspended for the majority of time and resumed
      on demand, when the children have data to send or receive.  For this
      purpose, however, their power.ignore_children flags have to be set,
      or the PM core wouldn't allow them to be suspended while their
      children were active.
      
      Unfortunately, in some situations it may take too much time to
      resume such devices so that they can assist their children in
      transferring data.  For example, if such a device belongs to a PM
      domain which goes to the "power off" state when that device is
      suspended, it may take too much time to restore power to the
      domain in response to the request from one of the device's
      children.  In that case, if the parent's resume time is critical,
      the domain should stay in the "power on" state, although it still may
      be desirable to power manage the parent itself (e.g. by manipulating
      its clock).
      
      In general, device PM QoS may be used to address this problem.
      Namely, if the device's children added PM QoS latency constraints
      for it, they would be able to prevent it from being put into an
      overly deep low-power state.  However, in some cases the devices
      needing to be serviced are not the immediate children of a
      "children-ignoring" device, but its grandchildren or even less
      direct descendants.  In those cases, the entity wanting to add a
      PM QoS request for a given device's ancestor that ignores its
      children will have to find it in the first place, so introduce a new
      helper function that may be used to achieve that.  This function,
      dev_pm_qos_add_ancestor_request(), will search for the first
      ancestor of the given device whose power.ignore_children flag is
      set and will add a device PM QoS latency request for that ancestor
      on behalf of the caller.  The request added this way may be removed
      with the help of dev_pm_qos_remove_request() in the future, like
      any other device PM QoS latency request.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      40a5f8be
  18. 22 12月, 2011 2 次提交
    • R
      PM: Drop generic_subsys_pm_ops · 90363ddf
      Rafael J. Wysocki 提交于
      Since the PM core is now going to execute driver callbacks directly
      if the corresponding subsystem callbacks are not present,
      forward-only subsystem callbacks (i.e. such that only execute the
      corresponding driver callbacks) are not necessary any more.  Thus
      it is possible to remove generic_subsys_pm_ops, because the only
      callback in there that is not forward-only, .runtime_idle, is not
      really used by the only user of generic_subsys_pm_ops, which is
      vio_bus_type.
      
      However, the generic callback routines themselves cannot be removed
      from generic_ops.c, because they are used individually by a number
      of subsystems.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      90363ddf
    • R
      PM: Run the driver callback directly if the subsystem one is not there · 35cd133c
      Rafael J. Wysocki 提交于
      Make the PM core execute driver PM callbacks directly if the
      corresponding subsystem callbacks are not present.
      
      There are three reasons for doing that.  First, it reflects the
      behavior of drivers/base/dd.c:really_probe() that runs the driver's
      .probe() callback directly if the bus type's one is not defined, so
      this change will remove one arbitrary difference between the PM core
      and the remaining parts of the driver core.  Second, it will allow
      some subsystems, whose PM callbacks don't do anything except for
      executing driver callbacks, to be simplified quite a bit by removing
      those "forward-only" callbacks.  Finally, it will allow us to remove
      one level of indirection in the system suspend and resume code paths
      where it is not necessary, which is going to lead to less debug noise
      with initcall_debug passed in the kernel command line (messages won't
      be printed for driverless devices whose subsystems don't provide
      PM callbacks among other things).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      35cd133c