WSL2-Linux-Kernel/drivers/base/power
Jiada Wang 2071ac985d PM / Domains: Avoid a potential deadlock
Lockdep warns that prepare_lock and genpd->mlock can cause a deadlock
the deadlock scenario is like following:
First thread is probing cs2000
cs2000_probe()
  clk_register()
    __clk_core_init()
      clk_prepare_lock()                            ----> acquires prepare_lock
        cs2000_recalc_rate()
          i2c_smbus_read_byte_data()
            rcar_i2c_master_xfer()
              dma_request_chan()
                rcar_dmac_of_xlate()
                  rcar_dmac_alloc_chan_resources()
                    pm_runtime_get_sync()
                      __pm_runtime_resume()
                        rpm_resume()
                          rpm_callback()
                            genpd_runtime_resume()   ----> acquires genpd->mlock

Second thread is attaching any device to the same PM domain
genpd_add_device()
  genpd_lock()                                       ----> acquires genpd->mlock
    cpg_mssr_attach_dev()
      of_clk_get_from_provider()
        __of_clk_get_from_provider()
          __clk_create_clk()
            clk_prepare_lock()                       ----> acquires prepare_lock

Since currently no PM provider access genpd's critical section
in .attach_dev, and .detach_dev callbacks, so there is no need to protect
these two callbacks with genpd->mlock.
This patch avoids a potential deadlock by moving out .attach_dev and .detach_dev
from genpd->mlock, so that genpd->mlock won't be held when prepare_lock is acquired
in .attach_dev and .detach_dev

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-03-19 22:58:04 +01:00
..
Makefile Merge branches 'pm-cpufreq-sched' and 'pm-opp' 2017-11-13 01:40:52 +01:00
clock_ops.c PM: clock_ops: fix missing clk_prepare() return value check 2019-01-18 11:47:07 +01:00
common.c PM / Domains: Mark "name" const in dev_pm_domain_attach_by_name() 2019-02-15 11:36:38 +01:00
domain.c PM / Domains: Avoid a potential deadlock 2019-03-19 22:58:04 +01:00
domain_governor.c PM / domains: Remove one unnecessary blank line 2019-03-11 11:26:45 +01:00
generic_ops.c PM / sleep: Remove pm_complete_with_resume_check() 2017-10-11 15:40:29 +02:00
main.c Additional power management updates for 5.1-rc1 2019-03-14 10:30:06 -07:00
power.h PM-runtime: Consolidate code to get active/suspended time 2019-03-07 11:23:17 +01:00
qos.c PM / QoS: Fix typo in file description 2019-03-11 10:35:53 +01:00
runtime.c Additional power management updates for 5.1-rc1 2019-03-14 10:30:06 -07:00
sysfs.c PM-runtime: Call pm_runtime_active|suspended_time() from sysfs 2019-03-07 11:23:17 +01:00
trace.c PM: Add and use pr_fmt() 2019-03-07 11:02:02 +01:00
wakeirq.c PM / wakeirq: Add wakeup name to dedicated wake irqs 2018-02-26 23:23:37 +01:00
wakeup.c Merge branches 'pm-core', 'pm-sleep' and 'pm-qos' 2019-03-14 10:51:38 +01:00