1. 21 10月, 2016 1 次提交
  2. 16 9月, 2016 1 次提交
    • P
      PM / runtime: Use _rcuidle for runtime suspend tracepoints · 77893577
      Paul E. McKenney 提交于
      Further testing with false negatives suppressed by commit 293e2421
      ("rcu: Remove superfluous versions of rcu_read_lock_sched_held()")
      identified a few more unprotected uses of RCU from the idle loop.
      Because RCU actively ignores idle-loop code (for energy-efficiency
      reasons, among other things), using RCU from the idle loop can result
      in too-short grace periods, in turn resulting in arbitrary misbehavior.
      
      The affected function is rpm_suspend().
      
      The resulting lockdep-RCU splat is as follows:
      
      ------------------------------------------------------------------------
      
      Warning from omap3
      
      ===============================
      [ INFO: suspicious RCU usage. ]
      4.6.0-rc5-next-20160426+ #1112 Not tainted
      -------------------------------
      include/trace/events/rpm.h:63 suspicious rcu_dereference_check() usage!
      
      other info that might help us debug this:
      
      RCU used illegally from idle CPU!
      rcu_scheduler_active = 1, debug_locks = 0
      RCU used illegally from extended quiescent state!
      1 lock held by swapper/0/0:
       #0:  (&(&dev->power.lock)->rlock){-.-...}, at: [<c052ee24>] __pm_runtime_suspend+0x54/0x84
      
      stack backtrace:
      CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.6.0-rc5-next-20160426+ #1112
      Hardware name: Generic OMAP36xx (Flattened Device Tree)
      [<c0110308>] (unwind_backtrace) from [<c010c3a8>] (show_stack+0x10/0x14)
      [<c010c3a8>] (show_stack) from [<c047fec8>] (dump_stack+0xb0/0xe4)
      [<c047fec8>] (dump_stack) from [<c052d7b4>] (rpm_suspend+0x604/0x7e4)
      [<c052d7b4>] (rpm_suspend) from [<c052ee34>] (__pm_runtime_suspend+0x64/0x84)
      [<c052ee34>] (__pm_runtime_suspend) from [<c04bf3bc>] (omap2_gpio_prepare_for_idle+0x5c/0x70)
      [<c04bf3bc>] (omap2_gpio_prepare_for_idle) from [<c01255e8>] (omap_sram_idle+0x140/0x244)
      [<c01255e8>] (omap_sram_idle) from [<c0126b48>] (omap3_enter_idle_bm+0xfc/0x1ec)
      [<c0126b48>] (omap3_enter_idle_bm) from [<c0601db8>] (cpuidle_enter_state+0x80/0x3d4)
      [<c0601db8>] (cpuidle_enter_state) from [<c0183c74>] (cpu_startup_entry+0x198/0x3a0)
      [<c0183c74>] (cpu_startup_entry) from [<c0b00c0c>] (start_kernel+0x354/0x3c8)
      [<c0b00c0c>] (start_kernel) from [<8000807c>] (0x8000807c)
      
      ------------------------------------------------------------------------
      Reported-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Tested-by: NTony Lindgren <tony@atomide.com>
      Tested-by: NGuenter Roeck <linux@roeck-us.net>
      [ rjw: Subject ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      77893577
  3. 31 8月, 2016 2 次提交
    • P
      PM / runtime: Add _rcuidle suffix to allow rpm_idle() use from idle · d7737ce9
      Paul E. McKenney 提交于
      This commit appends a few _rcuidle suffixes to fix the following
      RCU-used-from-idle bug:
      
      > ===============================
      > [ INFO: suspicious RCU usage. ]
      > 4.6.0-rc5-next-20160426+ #1116 Not tainted
      > -------------------------------
      > include/trace/events/rpm.h:95 suspicious rcu_dereference_check() usage!
      >
      > other info that might help us debug this:
      >
      >
      > RCU used illegally from idle CPU!
      > rcu_scheduler_active = 1, debug_locks = 0
      > RCU used illegally from extended quiescent state!
      > 1 lock held by swapper/0/0:
      >  #0:  (&(&dev->power.lock)->rlock){-.-...}, at: [<c052cc2c>] __rpm_callback+0x58/0x60
      >
      > stack backtrace:
      > CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.6.0-rc5-next-20160426+ #1116
      > Hardware name: Generic OMAP36xx (Flattened Device Tree)
      > [<c0110290>] (unwind_backtrace) from [<c010c3a8>] (show_stack+0x10/0x14)
      > [<c010c3a8>] (show_stack) from [<c047fd68>] (dump_stack+0xb0/0xe4)
      > [<c047fd68>] (dump_stack) from [<c052d5d0>] (rpm_suspend+0x580/0x768)
      > [<c052d5d0>] (rpm_suspend) from [<c052ec58>] (__pm_runtime_suspend+0x64/0x84)
      > [<c052ec58>] (__pm_runtime_suspend) from [<c04bf25c>] (omap2_gpio_prepare_for_idle+0x5c/0x70)
      > [<c04bf25c>] (omap2_gpio_prepare_for_idle) from [<c0125568>] (omap_sram_idle+0x140/0x244)
      > [<c0125568>] (omap_sram_idle) from [<c01269dc>] (omap3_enter_idle_bm+0xfc/0x1ec)
      > [<c01269dc>] (omap3_enter_idle_bm) from [<c0601bdc>] (cpuidle_enter_state+0x80/0x3d4)
      > [<c0601bdc>] (cpuidle_enter_state) from [<c0183b08>] (cpu_startup_entry+0x198/0x3a0)
      > [<c0183b08>] (cpu_startup_entry) from [<c0b00c0c>] (start_kernel+0x354/0x3c8)
      > [<c0b00c0c>] (start_kernel) from [<8000807c>] (0x8000807c)
      
      In the immortal words of Steven Rostedt, "*Whack* *Whack* *Whack*!!!"
      Reported-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Tested-by: NTony Lindgren <tony@atomide.com>
      Tested-by: NGuenter Roeck <linux@roeck-us.net>
      WhACKED-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      d7737ce9
    • P
      PM / runtime: Add _rcuidle suffix to allow rpm_resume() to be called from idle · d44c950e
      Paul E. McKenney 提交于
      This commit applies another _rcuidle suffix to fix an RCU use from
      idle.
      
      > ===============================
      > [ INFO: suspicious RCU usage. ]
      > 4.6.0-rc5-next-20160426+ #1122 Not tainted
      > -------------------------------
      > include/trace/events/rpm.h:69 suspicious rcu_dereference_check() usage!
      >
      > other info that might help us debug this:
      >
      >
      > RCU used illegally from idle CPU!
      > rcu_scheduler_active = 1, debug_locks = 0
      > RCU used illegally from extended quiescent state!
      > 1 lock held by swapper/0/0:
      >  #0:  (&(&dev->power.lock)->rlock){-.-...}, at: [<c052e3dc>] __pm_runtime_resume+0x3c/0x64
      >
      > stack backtrace:
      > CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.6.0-rc5-next-20160426+ #1122
      > Hardware name: Generic OMAP36xx (Flattened Device Tree)
      > [<c0110290>] (unwind_backtrace) from [<c010c3a8>] (show_stack+0x10/0x14)
      > [<c010c3a8>] (show_stack) from [<c047fd68>] (dump_stack+0xb0/0xe4)
      > [<c047fd68>] (dump_stack) from [<c052e178>] (rpm_resume+0x5cc/0x7f4)
      > [<c052e178>] (rpm_resume) from [<c052e3ec>] (__pm_runtime_resume+0x4c/0x64)
      > [<c052e3ec>] (__pm_runtime_resume) from [<c04bf2c4>] (omap2_gpio_resume_after_idle+0x54/0x68)
      > [<c04bf2c4>] (omap2_gpio_resume_after_idle) from [<c01269dc>] (omap3_enter_idle_bm+0xfc/0x1ec)
      > [<c01269dc>] (omap3_enter_idle_bm) from [<c060198c>] (cpuidle_enter_state+0x80/0x3d4)
      > [<c060198c>] (cpuidle_enter_state) from [<c0183b08>] (cpu_startup_entry+0x198/0x3a0)
      > [<c0183b08>] (cpu_startup_entry) from [<c0b00c0c>] (start_kernel+0x354/0x3c8)
      > [<c0b00c0c>] (start_kernel) from [<8000807c>] (0x8000807c)
      Reported-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Tested-by: NTony Lindgren <tony@atomide.com>
      Tested-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      d44c950e
  4. 02 7月, 2016 1 次提交
  5. 28 6月, 2016 1 次提交
  6. 16 6月, 2016 1 次提交
  7. 22 4月, 2016 1 次提交
  8. 21 12月, 2015 1 次提交
  9. 30 11月, 2015 1 次提交
    • U
      PM / runtime: Re-init runtime PM states at probe error and driver unbind · 5de85b9d
      Ulf Hansson 提交于
      There are two common expectations among several subsystems/drivers that
      deploys runtime PM support, but which isn't met by the driver core.
      
      Expectation 1)
      At ->probe() the subsystem/driver expects the runtime PM status of the
      device to be RPM_SUSPENDED, which is the initial status being assigned at
      device registration.
      
      This expectation is especially common among some of those subsystems/
      drivers that manages devices with an attached PM domain, as those requires
      the ->runtime_resume() callback at the PM domain level to be invoked
      during ->probe().
      
      Moreover these subsystems/drivers entirely relies on runtime PM resources
      being managed at the PM domain level, thus don't implement their own set
      of runtime PM callbacks.
      
      These are two scenarios that suffers from this unmet expectation.
      
      i) A failed ->probe() sequence requests probe deferral:
      
      ->probe()
        ...
        pm_runtime_enable()
        pm_runtime_get_sync()
        ...
      
      err:
        pm_runtime_put()
        pm_runtime_disable()
        ...
      
      As there are no guarantees that such sequence turns the runtime PM status
      of the device into RPM_SUSPENDED, the re-trying ->probe() may start with
      the status in RPM_ACTIVE.
      
      In such case the runtime PM core won't invoke the ->runtime_resume()
      callback because of a pm_runtime_get_sync(), as it considers the device to
      be already runtime resumed.
      
      ii) A driver re-bind sequence:
      
      At driver unbind, the subsystem/driver's >remove() callback invokes a
      sequence of runtime PM APIs, to undo actions during ->probe() and to put
      the device into low power state.
      
      ->remove()
        ...
        pm_runtime_put()
        pm_runtime_disable()
        ...
      
      Similar as in the failing ->probe() case, this sequence don't guarantee
      the runtime PM status of the device to turn into RPM_SUSPENDED.
      
      Trying to re-bind the driver thus causes the same issue as when re-trying
      ->probe(), in the probe deferral scenario.
      
      Expectation 2)
      Drivers that invokes the pm_runtime_irq_safe() API during ->probe(),
      triggers the runtime PM core to increase the usage count for the device's
      parent and permanently make it runtime resumed.
      
      The usage count is only dropped at device removal, which also allows it to
      be runtime suspended again.
      
      A re-trying ->probe() repeats the call to pm_runtime_irq_safe() and thus
      once more triggers the usage count of the device's parent to be increased.
      
      This leads to not only an imbalance issue of the usage count of the
      device's parent, but also to keep it runtime resumed permanently even if
      ->probe() fails.
      
      To address these issues, let's change the policy of the driver core to
      meet these expectations. More precisely, at ->probe() failures and driver
      unbind, restore the initial states of runtime PM.
      
      Although to still allow subsystem's to control PM for devices that doesn't
      ->probe() successfully, don't restore the initial states unless runtime PM
      is disabled.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NKevin Hilman <khilman@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5de85b9d
  10. 20 5月, 2015 2 次提交
    • 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
    • T
      PM / Runtime: Update last_busy in rpm_resume · 56f487c7
      Tony Lindgren 提交于
      If we don't update last_busy in rpm_resume, devices can go back
      to sleep immediately after resume. This happens at least in
      cases where the device has been powered off and does not have
      any interrupt pending until there's something in the FIFO.
      Signed-off-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      56f487c7
  11. 04 12月, 2014 1 次提交
  12. 06 11月, 2014 1 次提交
  13. 12 3月, 2014 1 次提交
  14. 02 3月, 2014 2 次提交
    • U
      PM: Add pm_runtime_suspend|resume_force functions · 37f20416
      Ulf Hansson 提交于
      This patch provides two new runtime PM helper functions which intend to
      be used from system suspend/resume callbacks, to make sure devices are
      put into low power state during system suspend and brought back to full
      power at system resume.
      
      The prerequisite is to have all levels of a device's runtime PM
      callbacks to be defined through the SET_PM_RUNTIME_PM_OPS macro, which
      means these are available for CONFIG_PM.
      
      By using the new runtime PM helper functions especially the two
      scenarios below will be addressed.
      
      1) The PM core prevents .runtime_suspend callbacks from being invoked
      during system suspend. That means even for a runtime PM centric
      subsystem and driver, the device needs to be put into low power state
      from a system suspend callback. Otherwise it may very well be left in
      full power state (runtime resumed) while the system is suspended. By
      using the new helper functions, we make sure to walk the hierarchy of
      a device's power domain, subsystem and driver.
      
      2) Subsystems and drivers need to cope with all the combinations of
      CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME. The two new helper functions
      smothly addresses this.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      37f20416
    • U
      PM / runtime: Fetch runtime PM callbacks using a macro · 5f59df79
      Ulf Hansson 提交于
      While fetching the proper runtime PM callback, we walk the hierarchy of
      device's power domains, subsystems and drivers.
      
      This is common for rpm_suspend(), rpm_idle() and rpm_resume(). Let's
      clean up the code by using a macro that handles this.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5f59df79
  15. 16 10月, 2013 1 次提交
  16. 04 6月, 2013 1 次提交
  17. 12 4月, 2013 1 次提交
  18. 24 2月, 2013 2 次提交
    • M
      pm / runtime: force memory allocation with no I/O during Runtime PM callbcack · db88175f
      Ming Lei 提交于
      Apply the introduced memalloc_noio_save() and memalloc_noio_restore() to
      force memory allocation with no I/O during runtime_resume/runtime_suspend
      callback on device with the flag of 'memalloc_noio' set.
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: David Decotigny <david.decotigny@google.com>
      Cc: Tom Herbert <therbert@google.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Oliver Neukum <oneukum@suse.de>
      Cc: Jiri Kosina <jiri.kosina@suse.com>
      Cc: Mel Gorman <mel@csn.ul.ie>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      db88175f
    • M
      pm / runtime: introduce pm_runtime_set_memalloc_noio() · e823407f
      Ming Lei 提交于
      Introduce the flag memalloc_noio in 'struct dev_pm_info' to help PM core
      to teach mm not allocating memory with GFP_KERNEL flag for avoiding
      probable deadlock.
      
      As explained in the comment, any GFP_KERNEL allocation inside
      runtime_resume() or runtime_suspend() on any one of device in the path
      from one block or network device to the root device in the device tree
      may cause deadlock, the introduced pm_runtime_set_memalloc_noio() sets
      or clears the flag on device in the path recursively.
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Oliver Neukum <oneukum@suse.de>
      Cc: Jiri Kosina <jiri.kosina@suse.com>
      Cc: Mel Gorman <mel@csn.ul.ie>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
      Cc: Greg KH <greg@kroah.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: David Decotigny <david.decotigny@google.com>
      Cc: Tom Herbert <therbert@google.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e823407f
  19. 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
  20. 04 9月, 2012 2 次提交
    • 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: 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
  21. 18 8月, 2012 3 次提交
    • 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
  22. 02 5月, 2012 1 次提交
  23. 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
  24. 22 12月, 2011 1 次提交
    • 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
  25. 02 12月, 2011 1 次提交
    • R
      PM / Runtime: Use device PM QoS constraints (v2) · 00dc9ad1
      Rafael J. Wysocki 提交于
      Make the runtime PM core use device PM QoS constraints to check if
      it is allowed to suspend a given device, so that an error code is
      returned if the device's own PM QoS constraint is negative or one of
      its children has already been suspended for too long.  If this is
      not the case, the maximum estimated time the device is allowed to be
      suspended, computed as the minimum of the device's PM QoS constraint
      and the PM QoS constraints of its children (reduced by the difference
      between the current time and their suspend times) is stored in a new
      device's PM field power.max_time_suspended_ns that can be used by
      the device's subsystem or PM domain to decide whether or not to put
      the device into lower-power (and presumably higher-latency) states
      later (if the constraint is 0, which means "no constraint", the
      power.max_time_suspended_ns is set to -1).
      
      Additionally, the time of execution of the subsystem-level
      .runtime_suspend() callback for the device is recorded in the new
      power.suspend_time field for later use by the device's subsystem or
      PM domain along with power.max_time_suspended_ns (it also is used
      by the core code when the device's parent is suspended).
      
      Introduce a new helper function,
      pm_runtime_update_max_time_suspended(), allowing subsystems and PM
      domains (or device drivers) to update the power.max_time_suspended_ns
      field, for example after changing the power state of a suspended
      device.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      00dc9ad1
  26. 05 11月, 2011 2 次提交
  27. 01 11月, 2011 1 次提交
  28. 17 10月, 2011 2 次提交
    • M
      PM / Runtime: Handle .runtime_suspend() failure correctly · 857b36c7
      Ming Lei 提交于
      If .runtime_suspend() returns -EAGAIN or -EBUSY, the device should
      still be in ACTIVE state, so it is not necessary to send an idle
      notification to its parent.  If .runtime_suspend() returns other
      fatal failure, it doesn't make sense to send idle notification to
      its parent.
      
      Skip parent idle notification when failure is returned from
      .runtime_suspend() and update comments in rpm_suspend() to reflect
      that change.
      
      [rjw: Modified the subject and changelog slightly.]
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      857b36c7
    • M
      PM / Runtime: Fix kerneldoc comment for rpm_suspend() · 47d8f0ba
      Ming Lei 提交于
      This patch fix kerneldoc comments for rpm_suspend():
      
       - 'Cancel a pending idle notification' should be put before, also
         should be changed to 'Cancel a pending idle notification,
         autosuspend or suspend'.
      
       - idle notification for the device after succeeding suspend has
         been removed, so update the comment accordingly.
      
      [rjw: Modified the subject and changelog slightly.]
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      47d8f0ba
  29. 28 9月, 2011 2 次提交
    • M
      PM / Runtime: Replace dev_dbg() with trace_rpm_*() · c3dc2f14
      Ming Lei 提交于
      This patch replaces dev_dbg with trace_rpm_* inside
      the three important functions:
      
      	rpm_idle
      	rpm_suspend
      	rpm_resume
      
      Trace points have the below advantages compared with dev_dbg:
      
      	- trace points include much runtime information(such as
      	running cpu, current task, ...)
      
      	- most of linux distributions may disable "verbose debug"
      	driver debug compile switch, so it is very difficult to
      	report/debug runtime pm related problems from distribution
      	users without this kind of debug information.
      
      	- for upstream kernel users, enableing the debug switch will
      	produce many useless "rpm_resume" output, and it is very noise.
      
      	- dev_dbg inside rpm_suspend/rpm_resume may have some effects
      	on runtime pm behaviour of console devicer
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      c3dc2f14
    • R
      PM / Runtime: Don't run callbacks under lock for power.irq_safe set · ad3c36a5
      Rafael J. Wysocki 提交于
      The rpm_suspend() and rpm_resume() routines execute subsystem or PM
      domain callbacks under power.lock if power.irq_safe is set for the
      given device.  This is inconsistent with that rpm_idle() does after
      commit 02b26774 (PM / Runtime: Allow _put_sync() from
      interrupts-disabled context) and is problematic for subsystems and PM
      domains wanting to use power.lock for synchronization in their
      runtime PM callbacks.
      
      This change requires the code checking if the device's runtime PM
      status is RPM_SUSPENDING or RPM_RESUMING to be modified too, to take
      the power.irq_safe set case into account (that code wasn't reachable
      before with power.irq_safe set, because it's executed with the
      device's power.lock held).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: NMing Lei <tom.leiming@gmail.com>
      Reviewed-by: NKevin Hilman <khilman@ti.com>
      ad3c36a5
  30. 14 8月, 2011 1 次提交
    • C
      PM / Runtime: Add might_sleep() to runtime PM functions · 311aab73
      Colin Cross 提交于
      Some of the entry points to pm runtime are not safe to
      call in atomic context unless pm_runtime_irq_safe() has
      been called.  Inspecting the code, it is not immediately
      obvious that the functions sleep at all, as they run
      inside a spin_lock_irqsave, but under some conditions
      they can drop the lock and turn on irqs.
      
      If a driver incorrectly calls the pm_runtime apis, it can
      cause sleeping and irq processing when it expects to stay
      in atomic context.
      
      Add might_sleep_if to the majority of the __pm_runtime_* entry points
      to enforce correct usage.
      
      Add pm_runtime_put_sync_autosuspend to the list of
      functions that can be called in atomic context.
      Signed-off-by: NColin Cross <ccross@android.com>
      Reviewed-by: NKevin Hilman <khilman@ti.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      311aab73