1. 11 8月, 2017 1 次提交
  2. 08 8月, 2017 1 次提交
    • R
      PM / wakeup: Set power.can_wakeup if wakeup_sysfs_add() fails · 820b9b0c
      Rafael J. Wysocki 提交于
      Currently, an error from wakeup_sysfs_add() in
      device_set_wakeup_capable() causes the device's power.can_wakeup
      flag to remain unset even though the device technically is capable
      of signaling wakeup.
      
      If wakeup_sysfs_add() fails user space may not be able to enable
      the device to wake up the system from sleep states, but at least
      for some devices that does not matter.
      
      For this reason, set or clear power.can_wakeup upfront and if
      wakeup_sysfs_add() returns an error, print a message to the log.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      820b9b0c
  3. 27 6月, 2017 1 次提交
  4. 15 6月, 2017 1 次提交
    • R
      ACPI / PM: Ignore spurious SCI wakeups from suspend-to-idle · 33e4f80e
      Rafael J. Wysocki 提交于
      The ACPI SCI (System Control Interrupt) is set up as a wakeup IRQ
      during suspend-to-idle transitions and, consequently, any events
      signaled through it wake up the system from that state.  However,
      on some systems some of the events signaled via the ACPI SCI while
      suspended to idle should not cause the system to wake up.  In fact,
      quite often they should just be discarded.
      
      Arguably, systems should not resume entirely on such events, but in
      order to decide which events really should cause the system to resume
      and which are spurious, it is necessary to resume up to the point
      when ACPI SCIs are actually handled and processed, which is after
      executing dpm_resume_noirq() in the system resume path.
      
      For this reasons, add a loop around freeze_enter() in which the
      platforms can process events signaled via multiplexed IRQ lines
      like the ACPI SCI and add suspend-to-idle hooks that can be
      used for this purpose to struct platform_freeze_ops.
      
      In the ACPI case, the ->wake hook is used for checking if the SCI
      has triggered while suspended and deferring the interrupt-induced
      system wakeup until the events signaled through it are actually
      processed sufficiently to decide whether or not the system should
      resume.  In turn, the ->sync hook allows all of the relevant event
      queues to be flushed so as to prevent events from being missed due
      to race conditions.
      
      In addition to that, some ACPI code processing wakeup events needs
      to be modified to use the "hard" version of wakeup triggers, so that
      it will cause a system resume to happen on device-induced wakeup
      events even if the "soft" mechanism to prevent the system from
      suspending is not enabled.  However, to preserve the existing
      behavior with respect to suspend-to-RAM, this only is done in
      the suspend-to-idle case and only if an SCI has occurred while
      suspended.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      33e4f80e
  5. 07 6月, 2017 1 次提交
  6. 14 5月, 2017 1 次提交
    • R
      PM / wakeup: Fix up wakeup_source_report_event() · 60d4553b
      Rafael J. Wysocki 提交于
      Commit 8a537ece (PM / wakeup: Integrate mechanism to abort
      transitions in progress) modified wakeup_source_report_event()
      and wakeup_source_activate() to make it possible to call
      pm_system_wakeup() from the latter if so indicated by the
      caller of the former (via a new function argument added by that
      commit), but it overlooked the fact that in some situations
      wakeup_source_report_event() is called to signal a "hard" event
      (ie. such that should abort a system suspend in progress) after
      pm_stay_awake() has been called for the same wakeup source object,
      in which case the pm_system_wakeup() will not trigger.
      
      To work around this issue, modify wakeup_source_activate() and
      wakeup_source_report_event() again so that pm_system_wakeup() is
      called by the latter directly (if its last argument is true), in
      which case the additional argument does not need to be passed
      to wakeup_source_activate() any more, so drop it from there.
      
      Fixes: 8a537ece (PM / wakeup: Integrate mechanism to abort transitions in progress)
      Reported-by: NDavid E. Box <david.e.box@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      60d4553b
  7. 06 5月, 2017 2 次提交
    • R
      ACPI / sleep: Ignore spurious SCI wakeups from suspend-to-idle · eed4d47e
      Rafael J. Wysocki 提交于
      The ACPI SCI (System Control Interrupt) is set up as a wakeup IRQ
      during suspend-to-idle transitions and, consequently, any events
      signaled through it wake up the system from that state.  However,
      on some systems some of the events signaled via the ACPI SCI while
      suspended to idle should not cause the system to wake up.  In fact,
      quite often they should just be discarded.
      
      Arguably, systems should not resume entirely on such events, but in
      order to decide which events really should cause the system to resume
      and which are spurious, it is necessary to resume up to the point
      when ACPI SCIs are actually handled and processed, which is after
      executing dpm_resume_noirq() in the system resume path.
      
      For this reasons, add a loop around freeze_enter() in which the
      platforms can process events signaled via multiplexed IRQ lines
      like the ACPI SCI and add suspend-to-idle hooks that can be
      used for this purpose to struct platform_freeze_ops.
      
      In the ACPI case, the ->wake hook is used for checking if the SCI
      has triggered while suspended and deferring the interrupt-induced
      system wakeup until the events signaled through it are actually
      processed sufficiently to decide whether or not the system should
      resume.  In turn, the ->sync hook allows all of the relevant event
      queues to be flushed so as to prevent events from being missed due
      to race conditions.
      
      In addition to that, some ACPI code processing wakeup events needs
      to be modified to use the "hard" version of wakeup triggers, so that
      it will cause a system resume to happen on device-induced wakeup
      events even if the "soft" mechanism to prevent the system from
      suspending is not enabled (that also helps to catch device-induced
      wakeup events occurring during suspend transitions in progress).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      eed4d47e
    • R
      PM / wakeup: Integrate mechanism to abort transitions in progress · 8a537ece
      Rafael J. Wysocki 提交于
      The system wakeup framework is not very consistent with respect to
      the way it handles suspend-to-idle and generally wakeup events
      occurring during transitions to system low-power states.
      
      First off, system transitions in progress are aborted by the event
      reporting helpers like pm_wakeup_event() only if the wakeup_count
      sysfs attribute is in use (as documented), but there are cases in
      which system-wide transitions should be aborted even if that is
      not the case.  For example, a wakeup signal from a designated
      wakeup device during system-wide PM transition, it should cause
      the transition to be aborted right away.
      
      Moreover, there is a freeze_wake() call in wakeup_source_activate(),
      but that really is only effective after suspend_freeze_state has
      been set to FREEZE_STATE_ENTER by freeze_enter().  However, it
      is very unlikely that wakeup_source_activate() will ever be called
      at that time, as it could only be triggered by a IRQF_NO_SUSPEND
      interrupt handler, so wakeups from suspend-to-idle don't really
      occur in wakeup_source_activate().
      
      At the same time there is a way to abort a system suspend in
      progress (or wake up the system from suspend-to-idle), which is by
      calling pm_system_wakeup(), but in turn that doesn't cause any
      wakeup source objects to be activated, so it will not be covered
      by wakeup source statistics and will not prevent the system from
      suspending again immediately (in case autosleep is used, for
      example).  Consequently, if anyone wants to abort system transitions
      in progress and allow the wakeup_count mechanism to work, they need
      to use both pm_system_wakeup() and pm_wakeup_event(), say, at the
      same time which is awkward.
      
      For the above reasons, make it possible to trigger
      pm_system_wakeup() from within wakeup_source_activate() and
      provide a new pm_wakeup_hard_event() helper to do so within the
      wakeup framework.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8a537ece
  8. 02 3月, 2017 1 次提交
  9. 26 12月, 2016 2 次提交
    • T
      ktime: Cleanup ktime_set() usage · 8b0e1953
      Thomas Gleixner 提交于
      ktime_set(S,N) was required for the timespec storage type and is still
      useful for situations where a Seconds and Nanoseconds part of a time value
      needs to be converted. For anything where the Seconds argument is 0, this
      is pointless and can be replaced with a simple assignment.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      8b0e1953
    • T
      ktime: Get rid of the union · 2456e855
      Thomas Gleixner 提交于
      ktime is a union because the initial implementation stored the time in
      scalar nanoseconds on 64 bit machine and in a endianess optimized timespec
      variant for 32bit machines. The Y2038 cleanup removed the timespec variant
      and switched everything to scalar nanoseconds. The union remained, but
      become completely pointless.
      
      Get rid of the union and just keep ktime_t as simple typedef of type s64.
      
      The conversion was done with coccinelle and some manual mopping up.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      2456e855
  10. 08 12月, 2016 1 次提交
  11. 29 7月, 2016 1 次提交
  12. 08 4月, 2016 1 次提交
  13. 25 9月, 2015 1 次提交
  14. 16 9月, 2015 1 次提交
  15. 07 7月, 2015 1 次提交
  16. 20 5月, 2015 1 次提交
    • T
      PM / Wakeirq: Add automated device wake IRQ handling · 4990d4fe
      Tony Lindgren 提交于
      Turns out we can automate the handling for the device_may_wakeup()
      quite a bit by using the kernel wakeup source list as suggested
      by Rafael J. Wysocki <rjw@rjwysocki.net>.
      
      And as some hardware has separate dedicated wake-up interrupt
      in addition to the IO interrupt, we can automate the handling by
      adding a generic threaded interrupt handler that just calls the
      device PM runtime to wake up the device.
      
      This allows dropping code from device drivers as we currently
      are doing it in multiple ways, and often wrong.
      
      For most drivers, we should be able to drop the following
      boilerplate code from runtime_suspend and runtime_resume
      functions:
      
      	...
      	device_init_wakeup(dev, true);
      	...
      	if (device_may_wakeup(dev))
      		enable_irq_wake(irq);
      	...
      	if (device_may_wakeup(dev))
      		disable_irq_wake(irq);
      	...
      	device_init_wakeup(dev, false);
      	...
      
      We can replace it with just the following init and exit
      time code:
      
      	...
      	device_init_wakeup(dev, true);
      	dev_pm_set_wake_irq(dev, irq);
      	...
      	dev_pm_clear_wake_irq(dev);
      	device_init_wakeup(dev, false);
      	...
      
      And for hardware with dedicated wake-up interrupts:
      
      	...
      	device_init_wakeup(dev, true);
      	dev_pm_set_dedicated_wake_irq(dev, irq);
      	...
      	dev_pm_clear_wake_irq(dev);
      	device_init_wakeup(dev, false);
      	...
      Signed-off-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      4990d4fe
  17. 19 5月, 2015 1 次提交
  18. 08 5月, 2015 1 次提交
  19. 16 4月, 2015 1 次提交
  20. 05 3月, 2015 1 次提交
  21. 01 9月, 2014 1 次提交
  22. 30 5月, 2014 1 次提交
  23. 21 6月, 2013 1 次提交
    • J
      PM / Sleep: Print last wakeup source on failed wakeup_count write · bb177fed
      Julius Werner 提交于
      Commit a938da06 introduced a useful little log message to tell
      users/debuggers which wakeup source aborted a suspend.  However,
      this message is only printed if the abort happens during the
      in-kernel suspend path (after writing /sys/power/state).
      
      The full specification of the /sys/power/wakeup_count facility
      allows user-space power managers to double-check if wakeups have
      already happened before it actually tries to suspend (e.g. while it
      was running user-space pre-suspend hooks), by writing the last known
      wakeup_count value to /sys/power/wakeup_count.  This patch changes
      the sysfs handler for that node to also print said log message if
      that write fails, so that we can figure out the offending wakeup
      source for both kinds of suspend aborts.
      Signed-off-by: NJulius Werner <jwerner@chromium.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      bb177fed
  24. 12 6月, 2013 1 次提交
  25. 10 2月, 2013 1 次提交
    • Z
      PM: Introduce suspend state PM_SUSPEND_FREEZE · 7e73c5ae
      Zhang Rui 提交于
      PM_SUSPEND_FREEZE state is a general state that
      does not need any platform specific support, it equals
      frozen processes + suspended devices + idle processors.
      
      Compared with PM_SUSPEND_MEMORY,
      PM_SUSPEND_FREEZE saves less power
      because the system is still in a running state.
      PM_SUSPEND_FREEZE has less resume latency because it does not
      touch BIOS, and the processors are in idle state.
      
      Compared with RTPM/idle,
      PM_SUSPEND_FREEZE saves more power as
      1. the processor has longer sleep time because processes are frozen.
         The deeper c-state the processor supports, more power saving we can get.
      2. PM_SUSPEND_FREEZE uses system suspend code path, thus we can get
         more power saving from the devices that does not have good RTPM support.
      
      This state is useful for
      1) platforms that do not have STR, or have a broken STR.
      2) platforms that have an extremely low power idle state,
         which can be used to replace STR.
      
      The following describes how PM_SUSPEND_FREEZE state works.
      1. echo freeze > /sys/power/state
      2. the processes are frozen.
      3. all the devices are suspended.
      4. all the processors are blocked by a wait queue
      5. all the processors idles and enters (Deep) c-state.
      6. an interrupt fires.
      7. a processor is woken up and handles the irq.
      8. if it is a general event,
         a) the irq handler runs and quites.
         b) goto step 4.
      9. if it is a real wake event, say, power button pressing, keyboard touch, mouse moving,
         a) the irq handler runs and activate the wakeup source
         b) wakeup_source_activate() notifies the wait queue.
         c) system starts resuming from PM_SUSPEND_FREEZE
      10. all the devices are resumed.
      11. all the processes are unfrozen.
      12. system is back to working.
      
      Known Issue:
      The wakeup of this new PM_SUSPEND_FREEZE state may behave differently
      from the previous suspend state.
      Take ACPI platform for example, there are some GPEs that only enabled
      when the system is in sleep state, to wake the system backk from S3/S4.
      But we are not touching these GPEs during transition to PM_SUSPEND_FREEZE.
      This means we may lose some wake event.
      But on the other hand, as we do not disable all the Interrupts during
      PM_SUSPEND_FREEZE, we may get some extra "wakeup" Interrupts, that are
      not available for S3/S4.
      
      The patches has been tested on an old Sony laptop, and here are the results:
      
      Average Power:
      1. RPTM/idle for half an hour:
         14.8W, 12.6W, 14.1W, 12.5W, 14.4W, 13.2W, 12.9W
      2. Freeze for half an hour:
         11W, 10.4W, 9.4W, 11.3W 10.5W
      3. RTPM/idle for three hours:
         11.6W
      4. Freeze for three hours:
         10W
      5. Suspend to Memory:
         0.5~0.9W
      
      Average Resume Latency:
      1. RTPM/idle with a black screen: (From pressing keyboard to screen back)
         Less than 0.2s
      2. Freeze: (From pressing power button to screen back)
         2.50s
      3. Suspend to Memory: (From pressing power button to screen back)
         4.33s
      
      >From the results, we can see that all the platforms should benefit from
      this patch, even if it does not have Low Power S0.
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      7e73c5ae
  26. 07 9月, 2012 1 次提交
  27. 18 8月, 2012 1 次提交
    • 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
  28. 02 5月, 2012 6 次提交
    • 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
  29. 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
  30. 13 2月, 2012 1 次提交