1. 11 3月, 2022 1 次提交
    • D
      PM: core: keep irq flags in device_pm_check_callbacks() · 524bb1da
      Dmitry Baryshkov 提交于
      The function device_pm_check_callbacks() can be called under the spin
      lock (in the reported case it happens from genpd_add_device() ->
      dev_pm_domain_set(), when the genpd uses spinlocks rather than mutexes.
      
      However this function uncoditionally uses spin_lock_irq() /
      spin_unlock_irq(), thus not preserving the CPU flags. Use the
      irqsave/irqrestore instead.
      
      The backtrace for the reference:
      [    2.752010] ------------[ cut here ]------------
      [    2.756769] raw_local_irq_restore() called with IRQs enabled
      [    2.762596] WARNING: CPU: 4 PID: 1 at kernel/locking/irqflag-debug.c:10 warn_bogus_irq_restore+0x34/0x50
      [    2.772338] Modules linked in:
      [    2.775487] CPU: 4 PID: 1 Comm: swapper/0 Tainted: G S                5.17.0-rc6-00384-ge330d0d82eff-dirty #684
      [    2.781384] Freeing initrd memory: 46024K
      [    2.785839] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [    2.785841] pc : warn_bogus_irq_restore+0x34/0x50
      [    2.785844] lr : warn_bogus_irq_restore+0x34/0x50
      [    2.785846] sp : ffff80000805b7d0
      [    2.785847] x29: ffff80000805b7d0 x28: 0000000000000000 x27: 0000000000000002
      [    2.785850] x26: ffffd40e80930b18 x25: ffff7ee2329192b8 x24: ffff7edfc9f60800
      [    2.785853] x23: ffffd40e80930b18 x22: ffffd40e80930d30 x21: ffff7edfc0dffa00
      [    2.785856] x20: ffff7edfc09e3768 x19: 0000000000000000 x18: ffffffffffffffff
      [    2.845775] x17: 6572206f74206465 x16: 6c696166203a3030 x15: ffff80008805b4f7
      [    2.853108] x14: 0000000000000000 x13: ffffd40e809550b0 x12: 00000000000003d8
      [    2.860441] x11: 0000000000000148 x10: ffffd40e809550b0 x9 : ffffd40e809550b0
      [    2.867774] x8 : 00000000ffffefff x7 : ffffd40e809ad0b0 x6 : ffffd40e809ad0b0
      [    2.875107] x5 : 000000000000bff4 x4 : 0000000000000000 x3 : 0000000000000000
      [    2.882440] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff7edfc03a8000
      [    2.889774] Call trace:
      [    2.892290]  warn_bogus_irq_restore+0x34/0x50
      [    2.896770]  _raw_spin_unlock_irqrestore+0x94/0xa0
      [    2.901690]  genpd_unlock_spin+0x20/0x30
      [    2.905724]  genpd_add_device+0x100/0x2d0
      [    2.909850]  __genpd_dev_pm_attach+0xa8/0x23c
      [    2.914329]  genpd_dev_pm_attach_by_id+0xc4/0x190
      [    2.919167]  genpd_dev_pm_attach_by_name+0x3c/0xd0
      [    2.924086]  dev_pm_domain_attach_by_name+0x24/0x30
      [    2.929102]  psci_dt_attach_cpu+0x24/0x90
      [    2.933230]  psci_cpuidle_probe+0x2d4/0x46c
      [    2.937534]  platform_probe+0x68/0xe0
      [    2.941304]  really_probe.part.0+0x9c/0x2fc
      [    2.945605]  __driver_probe_device+0x98/0x144
      [    2.950085]  driver_probe_device+0x44/0x15c
      [    2.954385]  __device_attach_driver+0xb8/0x120
      [    2.958950]  bus_for_each_drv+0x78/0xd0
      [    2.962896]  __device_attach+0xd8/0x180
      [    2.966843]  device_initial_probe+0x14/0x20
      [    2.971144]  bus_probe_device+0x9c/0xa4
      [    2.975092]  device_add+0x380/0x88c
      [    2.978679]  platform_device_add+0x114/0x234
      [    2.983067]  platform_device_register_full+0x100/0x190
      [    2.988344]  psci_idle_init+0x6c/0xb0
      [    2.992113]  do_one_initcall+0x74/0x3a0
      [    2.996060]  kernel_init_freeable+0x2fc/0x384
      [    3.000543]  kernel_init+0x28/0x130
      [    3.004132]  ret_from_fork+0x10/0x20
      [    3.007817] irq event stamp: 319826
      [    3.011404] hardirqs last  enabled at (319825): [<ffffd40e7eda0268>] __up_console_sem+0x78/0x84
      [    3.020332] hardirqs last disabled at (319826): [<ffffd40e7fd6d9d8>] el1_dbg+0x24/0x8c
      [    3.028458] softirqs last  enabled at (318312): [<ffffd40e7ec90410>] _stext+0x410/0x588
      [    3.036678] softirqs last disabled at (318299): [<ffffd40e7ed1bf68>] __irq_exit_rcu+0x158/0x174
      [    3.045607] ---[ end trace 0000000000000000 ]---
      Signed-off-by: NDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      524bb1da
  2. 18 12月, 2021 1 次提交
  3. 05 11月, 2021 2 次提交
    • R
      PM: sleep: Avoid calling put_device() under dpm_list_mtx · 2aa36604
      Rafael J. Wysocki 提交于
      It is generally unsafe to call put_device() with dpm_list_mtx held,
      because the given device's release routine may carry out an action
      depending on that lock which then may deadlock, so modify the
      system-wide suspend and resume of devices to always drop dpm_list_mtx
      before calling put_device() (and adjust white space somewhat while
      at it).
      
      For instance, this prevents the following splat from showing up in
      the kernel log after a system resume in certain configurations:
      
      [ 3290.969514] ======================================================
      [ 3290.969517] WARNING: possible circular locking dependency detected
      [ 3290.969519] 5.15.0+ #2420 Tainted: G S
      [ 3290.969523] ------------------------------------------------------
      [ 3290.969525] systemd-sleep/4553 is trying to acquire lock:
      [ 3290.969529] ffff888117ab1138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: flush_workqueue+0x87/0x4a0
      [ 3290.969554]
                     but task is already holding lock:
      [ 3290.969556] ffffffff8280fca8 (dpm_list_mtx){+.+.}-{3:3}, at: dpm_resume+0x12e/0x3e0
      [ 3290.969571]
                     which lock already depends on the new lock.
      
      [ 3290.969573]
                     the existing dependency chain (in reverse order) is:
      [ 3290.969575]
                     -> #3 (dpm_list_mtx){+.+.}-{3:3}:
      [ 3290.969583]        __mutex_lock+0x9d/0xa30
      [ 3290.969591]        device_pm_add+0x2e/0xe0
      [ 3290.969597]        device_add+0x4d5/0x8f0
      [ 3290.969605]        hci_conn_add_sysfs+0x43/0xb0 [bluetooth]
      [ 3290.969689]        hci_conn_complete_evt.isra.71+0x124/0x750 [bluetooth]
      [ 3290.969747]        hci_event_packet+0xd6c/0x28a0 [bluetooth]
      [ 3290.969798]        hci_rx_work+0x213/0x640 [bluetooth]
      [ 3290.969842]        process_one_work+0x2aa/0x650
      [ 3290.969851]        worker_thread+0x39/0x400
      [ 3290.969859]        kthread+0x142/0x170
      [ 3290.969865]        ret_from_fork+0x22/0x30
      [ 3290.969872]
                     -> #2 (&hdev->lock){+.+.}-{3:3}:
      [ 3290.969881]        __mutex_lock+0x9d/0xa30
      [ 3290.969887]        hci_event_packet+0xba/0x28a0 [bluetooth]
      [ 3290.969935]        hci_rx_work+0x213/0x640 [bluetooth]
      [ 3290.969978]        process_one_work+0x2aa/0x650
      [ 3290.969985]        worker_thread+0x39/0x400
      [ 3290.969993]        kthread+0x142/0x170
      [ 3290.969999]        ret_from_fork+0x22/0x30
      [ 3290.970004]
                     -> #1 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0}:
      [ 3290.970013]        process_one_work+0x27d/0x650
      [ 3290.970020]        worker_thread+0x39/0x400
      [ 3290.970028]        kthread+0x142/0x170
      [ 3290.970033]        ret_from_fork+0x22/0x30
      [ 3290.970038]
                     -> #0 ((wq_completion)hci0#2){+.+.}-{0:0}:
      [ 3290.970047]        __lock_acquire+0x15cb/0x1b50
      [ 3290.970054]        lock_acquire+0x26c/0x300
      [ 3290.970059]        flush_workqueue+0xae/0x4a0
      [ 3290.970066]        drain_workqueue+0xa1/0x130
      [ 3290.970073]        destroy_workqueue+0x34/0x1f0
      [ 3290.970081]        hci_release_dev+0x49/0x180 [bluetooth]
      [ 3290.970130]        bt_host_release+0x1d/0x30 [bluetooth]
      [ 3290.970195]        device_release+0x33/0x90
      [ 3290.970201]        kobject_release+0x63/0x160
      [ 3290.970211]        dpm_resume+0x164/0x3e0
      [ 3290.970215]        dpm_resume_end+0xd/0x20
      [ 3290.970220]        suspend_devices_and_enter+0x1a4/0xba0
      [ 3290.970229]        pm_suspend+0x26b/0x310
      [ 3290.970236]        state_store+0x42/0x90
      [ 3290.970243]        kernfs_fop_write_iter+0x135/0x1b0
      [ 3290.970251]        new_sync_write+0x125/0x1c0
      [ 3290.970257]        vfs_write+0x360/0x3c0
      [ 3290.970263]        ksys_write+0xa7/0xe0
      [ 3290.970269]        do_syscall_64+0x3a/0x80
      [ 3290.970276]        entry_SYSCALL_64_after_hwframe+0x44/0xae
      [ 3290.970284]
                     other info that might help us debug this:
      
      [ 3290.970285] Chain exists of:
                       (wq_completion)hci0#2 --> &hdev->lock --> dpm_list_mtx
      
      [ 3290.970297]  Possible unsafe locking scenario:
      
      [ 3290.970299]        CPU0                    CPU1
      [ 3290.970300]        ----                    ----
      [ 3290.970302]   lock(dpm_list_mtx);
      [ 3290.970306]                                lock(&hdev->lock);
      [ 3290.970310]                                lock(dpm_list_mtx);
      [ 3290.970314]   lock((wq_completion)hci0#2);
      [ 3290.970319]
                      *** DEADLOCK ***
      
      [ 3290.970321] 7 locks held by systemd-sleep/4553:
      [ 3290.970325]  #0: ffff888103bcd448 (sb_writers#4){.+.+}-{0:0}, at: ksys_write+0xa7/0xe0
      [ 3290.970341]  #1: ffff888115a14488 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x103/0x1b0
      [ 3290.970355]  #2: ffff888100f719e0 (kn->active#233){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x10c/0x1b0
      [ 3290.970369]  #3: ffffffff82661048 (autosleep_lock){+.+.}-{3:3}, at: state_store+0x12/0x90
      [ 3290.970384]  #4: ffffffff82658ac8 (system_transition_mutex){+.+.}-{3:3}, at: pm_suspend+0x9f/0x310
      [ 3290.970399]  #5: ffffffff827f2a48 (acpi_scan_lock){+.+.}-{3:3}, at: acpi_suspend_begin+0x4c/0x80
      [ 3290.970416]  #6: ffffffff8280fca8 (dpm_list_mtx){+.+.}-{3:3}, at: dpm_resume+0x12e/0x3e0
      [ 3290.970428]
                     stack backtrace:
      [ 3290.970431] CPU: 3 PID: 4553 Comm: systemd-sleep Tainted: G S                5.15.0+ #2420
      [ 3290.970438] Hardware name: Dell Inc. XPS 13 9380/0RYJWW, BIOS 1.5.0 06/03/2019
      [ 3290.970441] Call Trace:
      [ 3290.970446]  dump_stack_lvl+0x44/0x57
      [ 3290.970454]  check_noncircular+0x105/0x120
      [ 3290.970468]  ? __lock_acquire+0x15cb/0x1b50
      [ 3290.970474]  __lock_acquire+0x15cb/0x1b50
      [ 3290.970487]  lock_acquire+0x26c/0x300
      [ 3290.970493]  ? flush_workqueue+0x87/0x4a0
      [ 3290.970503]  ? __raw_spin_lock_init+0x3b/0x60
      [ 3290.970510]  ? lockdep_init_map_type+0x58/0x240
      [ 3290.970519]  flush_workqueue+0xae/0x4a0
      [ 3290.970526]  ? flush_workqueue+0x87/0x4a0
      [ 3290.970544]  ? drain_workqueue+0xa1/0x130
      [ 3290.970552]  drain_workqueue+0xa1/0x130
      [ 3290.970561]  destroy_workqueue+0x34/0x1f0
      [ 3290.970572]  hci_release_dev+0x49/0x180 [bluetooth]
      [ 3290.970624]  bt_host_release+0x1d/0x30 [bluetooth]
      [ 3290.970687]  device_release+0x33/0x90
      [ 3290.970695]  kobject_release+0x63/0x160
      [ 3290.970705]  dpm_resume+0x164/0x3e0
      [ 3290.970710]  ? dpm_resume_early+0x251/0x3b0
      [ 3290.970718]  dpm_resume_end+0xd/0x20
      [ 3290.970723]  suspend_devices_and_enter+0x1a4/0xba0
      [ 3290.970737]  pm_suspend+0x26b/0x310
      [ 3290.970746]  state_store+0x42/0x90
      [ 3290.970755]  kernfs_fop_write_iter+0x135/0x1b0
      [ 3290.970764]  new_sync_write+0x125/0x1c0
      [ 3290.970777]  vfs_write+0x360/0x3c0
      [ 3290.970785]  ksys_write+0xa7/0xe0
      [ 3290.970794]  do_syscall_64+0x3a/0x80
      [ 3290.970803]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [ 3290.970811] RIP: 0033:0x7f41b1328164
      [ 3290.970819] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 80 00 00 00 00 8b 05 4a d2 2c 00 48 63 ff 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 f3 c3 66 90 55 53 48 89 d5 48 89 f3 48 83
      [ 3290.970824] RSP: 002b:00007ffe6ae21b28 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
      [ 3290.970831] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f41b1328164
      [ 3290.970836] RDX: 0000000000000004 RSI: 000055965e651070 RDI: 0000000000000004
      [ 3290.970839] RBP: 000055965e651070 R08: 000055965e64f390 R09: 00007f41b1e3d1c0
      [ 3290.970843] R10: 000000000000000a R11: 0000000000000246 R12: 0000000000000004
      [ 3290.970846] R13: 0000000000000001 R14: 000055965e64f2b0 R15: 0000000000000004
      
      Cc: All applicable <stable@vger.kernel.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      2aa36604
    • U
      PM: sleep: Fix runtime PM based cpuidle support · a2bd7be1
      Ulf Hansson 提交于
      In the cpuidle-psci case, runtime PM in combination with the generic PM
      domain (genpd), may be used when entering/exiting a shared idlestate. More
      precisely, genpd relies on runtime PM to be enabled for the attached device
      (in this case it belongs to a CPU), to properly manage the reference
      counting of its PM domain.
      
      This works fine most of the time, but during system suspend in
      dpm_suspend_late(), the PM core disables runtime PM for all devices. Beyond
      this point, calls to pm_runtime_get_sync() to runtime resume a device may
      fail and therefore it could also mess up the reference counting in genpd.
      
      To fix this problem, let's call wake_up_all_idle_cpus() in
      dpm_suspend_late(), prior to disabling runtime PM. In this way a device
      that belongs to a CPU, becomes runtime resumed through cpuidle-psci and
      stays like that, because the runtime PM usage count has been bumped in
      device_prepare().
      Diagnosed-by: NMaulik Shah <mkshah@codeaurora.org>
      Suggested-by: NRafael J. Wysocki <rafael@kernel.org>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      a2bd7be1
  4. 26 10月, 2021 2 次提交
  5. 23 10月, 2021 1 次提交
  6. 08 9月, 2021 1 次提交
    • P
      PM: sleep: core: Avoid setting power.must_resume to false · 4a9344cd
      Prasad Sodagudi 提交于
      There are variables(power.may_skip_resume and dev->power.must_resume)
      and DPM_FLAG_MAY_SKIP_RESUME flags to control the resume of devices after
      a system wide suspend transition.
      
      Setting the DPM_FLAG_MAY_SKIP_RESUME flag means that the driver allows
      its "noirq" and "early" resume callbacks to be skipped if the device
      can be left in suspend after a system-wide transition into the working
      state. PM core determines that the driver's "noirq" and "early" resume
      callbacks should be skipped or not with dev_pm_skip_resume() function by
      checking power.may_skip_resume variable.
      
      power.must_resume variable is getting set to false in __device_suspend()
      function without checking device's DPM_FLAG_MAY_SKIP_RESUME settings.
      In problematic scenario, where all the devices in the suspend_late
      stage are successful and some device can fail to suspend in
      suspend_noirq phase. So some devices successfully suspended in suspend_late
      stage are not getting chance to execute __device_suspend_noirq()
      to set dev->power.must_resume variable to true and not getting
      resumed in early_resume phase.
      
      Add a check for device's DPM_FLAG_MAY_SKIP_RESUME flag before
      setting power.must_resume variable in __device_suspend function.
      
      Fixes: 6e176bf8 ("PM: sleep: core: Do not skip callbacks in the resume phase")
      Signed-off-by: NPrasad Sodagudi <psodagud@codeaurora.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      4a9344cd
  7. 02 7月, 2021 1 次提交
  8. 28 1月, 2021 1 次提交
  9. 24 11月, 2020 1 次提交
  10. 11 11月, 2020 1 次提交
    • C
      PM: sleep: Print driver flags for all devices during suspend/resume · f39ee99f
      Chen Yu 提交于
      Currently there are 4 driver flags to control system suspend/resume
      behavior: DPM_FLAG_NO_DIRECT_COMPLETE, DPM_FLAG_SMART_PREPARE,
      DPM_FLAG_SMART_SUSPEND and DPM_FLAG_MAY_SKIP_RESUME.
      
      Print these flags during suspend/resume so as to get a brief
      understanding of the expected behavior of each device, and to
      facilitate suspend/resume debugging/tuning.
      
      To enable this tracing:
      echo 'file drivers/base/power/main.c +p' >
      /sys/kernel/debug/dynamic_debug/control
      Signed-off-by: NChen Yu <yu.c.chen@intel.com>
      [ rjw: Subject and changelog edits ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f39ee99f
  11. 23 10月, 2020 1 次提交
  12. 25 8月, 2020 1 次提交
    • R
      PM: sleep: core: Fix the handling of pending runtime resume requests · e3eb6e8f
      Rafael J. Wysocki 提交于
      It has been reported that system-wide suspend may be aborted in the
      absence of any wakeup events due to unforseen interactions of it with
      the runtume PM framework.
      
      One failing scenario is when there are multiple devices sharing an
      ACPI power resource and runtime-resume needs to be carried out for
      one of them during system-wide suspend (for example, because it needs
      to be reconfigured before the whole system goes to sleep).  In that
      case, the runtime-resume of that device involves turning the ACPI
      power resource "on" which in turn causes runtime-resume requests
      to be queued up for all of the other devices sharing it.  Those
      requests go to the runtime PM workqueue which is frozen during
      system-wide suspend, so they are not actually taken care of until
      the resume of the whole system, but the pm_runtime_barrier()
      call in __device_suspend() sees them and triggers system wakeup
      events for them which then cause the system-wide suspend to be
      aborted if wakeup source objects are in active use.
      
      Of course, the logic that leads to triggering those wakeup events is
      questionable in the first place, because clearly there are cases in
      which a pending runtime resume request for a device is not connected
      to any real wakeup events in any way (like the one above).  Moreover,
      it is racy, because the device may be resuming already by the time
      the pm_runtime_barrier() runs and so if the driver doesn't take care
      of signaling the wakeup event as appropriate, it will be lost.
      However, if the driver does take care of that, the extra
      pm_wakeup_event() call in the core is redundant.
      
      Accordingly, drop the conditional pm_wakeup_event() call fron
      __device_suspend() and make the latter call pm_runtime_barrier()
      alone.  Also modify the comment next to that call to reflect the new
      code and extend it to mention the need to avoid unwanted interactions
      between runtime PM and system-wide device suspend callbacks.
      
      Fixes: 1e2ef05b ("PM: Limit race conditions between runtime PM and system sleep (v2)")
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NUtkarsh H Patel <utkarsh.h.patel@intel.com>
      Tested-by: NUtkarsh H Patel <utkarsh.h.patel@intel.com>
      Tested-by: NPengfei Xu <pengfei.xu@intel.com>
      Cc: All applicable <stable@vger.kernel.org>
      e3eb6e8f
  13. 10 6月, 2020 2 次提交
  14. 25 4月, 2020 6 次提交
  15. 22 4月, 2020 1 次提交
  16. 20 4月, 2020 2 次提交
    • R
      PM: sleep: core: Fold functions into their callers · 30205377
      Rafael J. Wysocki 提交于
      Fold four functions in the PM core that each have only one caller
      now into their callers.
      
      No intentional functional impact.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      30205377
    • R
      PM: sleep: core: Simplify the SMART_SUSPEND flag handling · 107d47b2
      Rafael J. Wysocki 提交于
      The code to handle the SMART_SUSPEND driver PM flag is hard to follow
      and somewhat inconsistent with respect to devices without middle-layer
      (subsystem) callbacks.
      
      Namely, for those devices the core takes the role of a middle layer
      in providing the expected ordering of execution of callbacks (under
      the assumption that the drivers setting SMART_SUSPEND can reuse their
      PM-runtime callbacks directly for system-wide suspend).  To that end,
      it prevents driver ->suspend_late and ->suspend_noirq callbacks from
      being executed for devices that are still runtime-suspended in
      __device_suspend_late(), because running the same callback funtion
      that was previously run by PM-runtime for them may be invalid.
      
      However, it does that only for devices without any middle-layer
      callbacks for the late/noirq/early suspend/resume phases even
      though it would be simpler and more consistent to skip the
      driver-lavel callbacks for all devices with SMART_SUSPEND set
      that are runtime-suspended in __device_suspend_late().
      
      Simplify the code in accordance with the above observation.
      Suggested-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      107d47b2
  17. 01 4月, 2020 1 次提交
  18. 04 3月, 2020 1 次提交
    • M
      PM: sleep: core: Use built-in RCU list checking · 42beb82e
      Madhuparna Bhowmik 提交于
      This patch passes the cond argument to list_for_each_entry_rcu()
      to fix the following false-positive lockdep warnings:
      (with CONFIG_PROVE_RCU_LIST = y)
      
      [  330.302784] =============================
      [  330.302789] WARNING: suspicious RCU usage
      [  330.302796] 5.6.0-rc1+ #5 Not tainted
      [  330.302801] -----------------------------
      [  330.302808] drivers/base/power/main.c:326 RCU-list traversed in non-reader section!!
      
      [  330.303303] =============================
      [  330.303307] WARNING: suspicious RCU usage
      [  330.303311] 5.6.0-rc1+ #5 Not tainted
      [  330.303315] -----------------------------
      [  330.303319] drivers/base/power/main.c:1698 RCU-list traversed in non-reader section!!
      
      [  331.934969] =============================
      [  331.934971] WARNING: suspicious RCU usage
      [  331.934973] 5.6.0-rc1+ #5 Not tainted
      [  331.934975] -----------------------------
      [  331.934977] drivers/base/power/main.c:1238 RCU-list traversed in non-reader section!!
      
      [  332.467772] WARNING: suspicious RCU usage
      [  332.467775] 5.6.0-rc1+ #5 Not tainted
      [  332.467775] -----------------------------
      [  332.467778] drivers/base/power/main.c:269 RCU-list traversed in non-reader section!!
      Signed-off-by: NMadhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      42beb82e
  19. 24 1月, 2020 1 次提交
    • R
      PM: core: Fix handling of devices deleted during system-wide resume · 0552e05f
      Rafael J. Wysocki 提交于
      If a device is deleted by one of its system-wide resume callbacks
      (for example, because it does not appear to be present or accessible
      any more) along with its children, the resume of the children may
      continue leading to use-after-free errors and other issues
      (potentially).
      
      Namely, if the device's children are resumed asynchronously, their
      resume may have been scheduled already before the device's callback
      runs and so the device may be deleted while dpm_wait_for_superior()
      is being executed for them.  The memory taken up by the parent device
      object may be freed then while dpm_wait() is waiting for the parent's
      resume callback to complete, which leads to a use-after-free.
      Moreover, the resume of the children is really not expected to
      continue after they have been unregistered, so it must be terminated
      right away in that case.
      
      To address this problem, modify dpm_wait_for_superior() to check
      if the target device is still there in the system-wide PM list of
      devices and if so, to increment its parent's reference counter, both
      under dpm_list_mtx which prevents device_del() running for the child
      from dropping the parent's reference counter prematurely.
      
      If the device is not present in the system-wide PM list of devices
      any more, the resume of it cannot continue, so check that again after
      dpm_wait() returns, which means that the parent's callback has been
      completed, and pass the result of that check to the caller of
      dpm_wait_for_superior() to allow it to abort the device's resume
      if it is not there any more.
      
      Link: https://lore.kernel.org/linux-pm/1579568452-27253-1-git-send-email-chanho.min@lge.comReported-by: NChanho Min <chanho.min@lge.com>
      Cc: All applicable <stable@vger.kernel.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0552e05f
  20. 23 7月, 2019 2 次提交
    • R
      PM: sleep: Drop dpm_noirq_begin() and dpm_noirq_end() · b605c44c
      Rafael J. Wysocki 提交于
      Note that after previous changes dpm_noirq_begin() and
      dpm_noirq_end() each have only one caller, so move the code from
      them to their respective callers and drop them.
      
      Also note that dpm_noirq_resume_devices() and
      dpm_noirq_suspend_devices() need not be exported any more, so make
      them both static.
      
      This change is not expected to alter functionality.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      b605c44c
    • R
      PM: sleep: Simplify suspend-to-idle control flow · 56b99184
      Rafael J. Wysocki 提交于
      After commit 33e4f80e ("ACPI / PM: Ignore spurious SCI wakeups
      from suspend-to-idle") the "noirq" phases of device suspend and
      resume may run for multiple times during suspend-to-idle, if there
      are spurious system wakeup events while suspended.  However, this
      is complicated and fragile and actually unnecessary.
      
      The main reason for doing this is that on some systems the EC may
      signal system wakeup events (power button events, for example) as
      well as events that should not cause the system to resume (spurious
      system wakeup events).  Thus, in order to determine whether or not
      a given event signaled by the EC while suspended is a proper system
      wakeup one, the EC GPE needs to be dispatched and to start with that
      was achieved by allowing the ACPI SCI action handler to run, which
      was only possible after calling resume_device_irqs().
      
      However, dispatching the EC GPE this way turned out to take too much
      time in some cases and some EC events might be missed due to that, so
      commit 68e22011 ("ACPI: EC: Dispatch the EC GPE directly on
      s2idle wake") started to dispatch the EC GPE right after a wakeup
      event has been detected, so in fact the full ACPI SCI action handler
      doesn't need to run any more to deal with the wakeups coming from the
      EC.
      
      Use this observation to simplify the suspend-to-idle control flow
      so that the "noirq" phases of device suspend and resume are each
      run only once in every suspend-to-idle cycle, which is reported to
      significantly reduce power drawn by some systems when suspended to
      idle (by allowing them to reach a deep platform-wide low-power state
      through the suspend-to-idle flow).  [What appears to happen is that
      the "noirq" resume of devices after a spurious EC wakeup brings some
      devices into a state in which they prevent the platform from reaching
      the deep low-power state going forward, even after a subsequent
      "noirq" suspend phase, and on some systems the EC triggers such
      wakeups already when the "noirq" suspend of devices is running for
      the first time in the given suspend/resume cycle, so the platform
      cannot reach the deep low-power state at all.]
      
      First, make acpi_s2idle_wake() use the acpi_ec_dispatch_gpe() return
      value to determine whether or not the wakeup may have been triggered
      by the EC (in which case the system wakeup is canceled and ACPI
      events are processed in order to determine whether or not the event
      is a proper system wakeup one) and use rearm_wake_irq() (introduced
      by a previous change) in it to rearm the ACPI SCI for system wakeup
      detection in case the system will remain suspended.
      
      Second, drop acpi_s2idle_sync(), which is not needed any more, and
      the corresponding global platform suspend-to-idle callback.
      
      Next, drop the pm_wakeup_pending() check (which is an optimization
      only) from __device_suspend_noirq() to prevent it from returning
      errors on system wakeups occurring before the "noirq" phase of
      device suspend is complete (as in the case of suspend-to-idle it is
      not known whether or not these wakeups are suprious at that point),
      in order to avoid having to carry out a "noirq" resume of devices
      on a spurious system wakeup.
      
      Finally, change the code flow in s2idle_loop() to (1) run the
      "noirq" suspend of devices once before starting the loop, (2) check
      for spurious EC wakeups (via the platform ->wake callback) for the
      first time before calling s2idle_enter(), and (3) run the "noirq"
      resume of devices once after leaving the loop.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      56b99184
  21. 04 7月, 2019 1 次提交
  22. 14 6月, 2019 1 次提交
  23. 12 4月, 2019 1 次提交
    • U
      PM / core: Propagate dev->power.wakeup_path when no callbacks · dc351d4c
      Ulf Hansson 提交于
      The dev->power.direct_complete flag may become set in device_prepare() in
      case the device don't have any PM callbacks (dev->power.no_pm_callbacks is
      set). This leads to a broken behaviour, when there is child having wakeup
      enabled and relies on its parent to be used in the wakeup path.
      
      More precisely, when the direct complete path becomes selected for the
      child in __device_suspend(), the propagation of the dev->power.wakeup_path
      becomes skipped as well.
      
      Let's address this problem, by checking if the device is a part the wakeup
      path or has wakeup enabled, then prevent the direct complete path from
      being used.
      Reported-by: NLoic Pallardy <loic.pallardy@st.com>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      [ rjw: Comment cleanup ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      dc351d4c
  24. 10 4月, 2019 1 次提交
    • Y
      PM / core: Introduce dpm_async_fn() helper · f2a424f6
      Yangtao Li 提交于
      When we want to execute device pm functions asynchronously, we'll
      do the following for the device:
      
        1) reinit_completion(&dev->power.completion);
        2) Check if the device enables asynchronous suspend.
        3) If necessary, execute the corresponding function asynchronously.
      
      There are a lot of such repeated operations here, in fact we can avoid
      this. So introduce dpm_async_fn() to have better code readability and
      reuse.
      
      And use this function to do some cleanup.
      Signed-off-by: NYangtao Li <tiny.windzz@gmail.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f2a424f6
  25. 09 4月, 2019 3 次提交
  26. 05 4月, 2019 1 次提交
  27. 07 3月, 2019 1 次提交
  28. 19 2月, 2019 1 次提交
    • S
      PM / core: Add support to skip power management in device/driver model · 85945c28
      Sudeep Holla 提交于
      All device objects in the driver model contain fields that control the
      handling of various power management activities. However, it's not
      always useful. There are few instances where pseudo devices are added
      to the model just to take advantage of many other features like
      kobjects, udev events, and so on. One such example is cpu devices and
      their caches.
      
      The sysfs for the cpu caches are managed by adding devices with cpu
      as the parent in cpu_device_create() when secondary cpu is brought
      online. Generally when the secondary CPUs are hotplugged back in as part
      of resume from suspend-to-ram, we call cpu_device_create() from the cpu
      hotplug state machine while the cpu device associated with that CPU is
      not yet ready to be resumed as the device_resume() call happens bit
      later. It's not really needed to set the flag is_prepared for cpu
      devices as they are mostly pseudo device and hotplug framework deals
      with state machine and not managed through the cpu device.
      
      This often results in annoying warning when resuming:
      Enabling non-boot CPUs ...
      CPU1: Booted secondary processor
       cache: parent cpu1 should not be sleeping
      CPU1 is up
      CPU2: Booted secondary processor
       cache: parent cpu2 should not be sleeping
      CPU2 is up
      .... and so on.
      
      So in order to fix these kind of errors, we could just completely avoid
      doing any power management related initialisations and operations if
      they are not used by these devices.
      
      Add no_pm flags to indicate that the device doesn't require any sort of
      PM activities and all of them can be completely skipped. We can use the
      same flag to also avoid adding not used *power* sysfs entries for these
      devices. For now, lets use this for cpu cache devices.
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NSudeep Holla <sudeep.holla@arm.com>
      Tested-by: NEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      85945c28