1. 13 Nov, 2017 9 commits
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-core' · 1efef682
      Rafael J. Wysocki authored
      * pm-core:
        ACPI / PM: Take SMART_SUSPEND driver flag into account
        PCI / PM: Take SMART_SUSPEND driver flag into account
        PCI / PM: Drop unnecessary invocations of pcibios_pm_ops callbacks
        PM / core: Add SMART_SUSPEND driver flag
        PCI / PM: Use the NEVER_SKIP driver flag
        PM / core: Add NEVER_SKIP and SMART_PREPARE driver flags
        PM / core: Convert timers to use timer_setup()
        PM / core: Fix kerneldoc comments of four functions
        PM / core: Drop legacy class suspend/resume operations
      1efef682
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-sleep' · 05d658b5
      Rafael J. Wysocki authored
      * pm-sleep:
        freezer: Fix typo in freezable_schedule_timeout() comment
        PM / s2idle: Clear the events_check_enabled flag
        PM / sleep: Remove pm_complete_with_resume_check()
        PM: ARM: locomo: Drop suspend and resume bus type callbacks
        PM: Use a more common logging style
        PM: Document rules on using pm_runtime_resume() in system suspend callbacks
      05d658b5
    • Rafael J. Wysocki's avatar
      Merge branch 'acpi-pm' · 794c3355
      Rafael J. Wysocki authored
      * acpi-pm:
        ACPI / PM: Fix acpi_pm_notifier_lock vs flush_workqueue() deadlock
        ACPI / LPSS: Consolidate runtime PM and system sleep handling
        ACPI / PM: Combine device suspend routines
        ACPI / LPIT: Add Low Power Idle Table (LPIT) support
        ACPI / PM: Split code validating need for runtime resume in ->prepare()
        ACPI / PM: Restore acpi_subsys_complete()
        ACPI / PM: Combine two identical device resume routines
        ACPI / PM: Remove stale function header
      794c3355
    • Rafael J. Wysocki's avatar
      Merge branches 'pm-cpufreq-sched' and 'pm-opp' · 28da4395
      Rafael J. Wysocki authored
      * pm-cpufreq-sched:
        cpufreq: schedutil: Reset cached_raw_freq when not in sync with next_freq
      
      * pm-opp:
        PM / OPP: Add dev_pm_opp_{un}register_get_pstate_helper()
        PM / OPP: Support updating performance state of device's power domain
        PM / OPP: add missing of_node_put() for of_get_cpu_node()
        PM / OPP: Rename dev_pm_opp_register_put_opp_helper()
        PM / OPP: Add missing of_node_put(np)
        PM / OPP: Move error message to debug level
        PM / OPP: Use snprintf() to avoid kasprintf() and kfree()
        PM / OPP: Move the OPP directory out of power/
      28da4395
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-cpufreq' · 60af981c
      Rafael J. Wysocki authored
      * pm-cpufreq: (22 commits)
        cpufreq: stats: Handle the case when trans_table goes beyond PAGE_SIZE
        cpufreq: arm_big_little: make cpufreq_arm_bL_ops structures const
        cpufreq: arm_big_little: make function arguments and structure pointer const
        cpufreq: pxa: convert to clock API
        cpufreq: speedstep-lib: mark expected switch fall-through
        cpufreq: ti-cpufreq: add missing of_node_put()
        cpufreq: dt: Remove support for Exynos4212 SoCs
        cpufreq: imx6q: Move speed grading check to cpufreq driver
        cpufreq: ti-cpufreq: kfree opp_data when failure
        cpufreq: SPEAr: pr_err() strings should end with newlines
        cpufreq: powernow-k8: pr_err() strings should end with newlines
        cpufreq: dt-platdev: drop socionext,uniphier-ld6b from whitelist
        arm64: wire cpu-invariant accounting support up to the task scheduler
        arm64: wire frequency-invariant accounting support up to the task scheduler
        arm: wire cpu-invariant accounting support up to the task scheduler
        arm: wire frequency-invariant accounting support up to the task scheduler
        drivers base/arch_topology: allow inlining cpu-invariant accounting support
        drivers base/arch_topology: provide frequency-invariant accounting support
        cpufreq: dt: invoke frequency-invariance setter function
        cpufreq: arm_big_little: invoke frequency-invariance setter function
        ...
      60af981c
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-cpuidle' · 622ade3a
      Rafael J. Wysocki authored
      * pm-cpuidle:
        intel_idle: Graceful probe failure when MWAIT is disabled
        cpuidle: Avoid assignment in if () argument
        cpuidle: Clean up cpuidle_enable_device() error handling a bit
        cpuidle: ladder: Add per CPU PM QoS resume latency support
        ARM: cpuidle: Refactor rollback operations if init fails
        ARM: cpuidle: Correct driver unregistration if init fails
        intel_idle: replace conditionals with static_cpu_has(X86_FEATURE_ARAT)
        cpuidle: fix broadcast control when broadcast can not be entered
      
       Conflicts:
      	drivers/idle/intel_idle.c
      622ade3a
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-qos' · 4762573b
      Rafael J. Wysocki authored
      * pm-qos:
        PM / QoS: Fix device resume latency framework
        PM / QoS: Drop PM_QOS_FLAG_REMOTE_WAKEUP
      4762573b
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-domains' · 29aaf908
      Rafael J. Wysocki authored
      * pm-domains:
        PM / Domains: Fix genpd to deal with drivers returning 1 from ->prepare()
        PM / domains: Rework governor code to be more consistent
        PM / Domains: Remove gpd_dev_ops.active_wakeup() callback
        soc: rockchip: power-domain: Use GENPD_FLAG_ACTIVE_WAKEUP
        soc: mediatek: Use GENPD_FLAG_ACTIVE_WAKEUP
        ARM: shmobile: pm-rmobile: Use GENPD_FLAG_ACTIVE_WAKEUP
        PM / Domains: Allow genpd users to specify default active wakeup behavior
        PM / Domains: Add support to select performance-state of domains
        PM / Domains: Rename genpd internals from pm_genpd_* to genpd_*
      29aaf908
    • Rafael J. Wysocki's avatar
      Merge branches 'pm-pci', 'pm-avs' and 'pm-docs' · 040e8a4a
      Rafael J. Wysocki authored
      * pm-pci:
        PCI / PM: Add dev_dbg() to print device suspend power states
        PCI / PM: Do not resume any devices in pci_pm_prepare()
      
      * pm-avs:
        PM / AVS: Use %pS printk format for direct addresses
      
      * pm-docs:
        PM: docs: Fix formatting typo in devices.rst
      040e8a4a
  2. 09 Nov, 2017 1 commit
  3. 08 Nov, 2017 21 commits
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-cpufreq-sched' · e029b9bf
      Rafael J. Wysocki authored
      * pm-cpufreq-sched:
        cpufreq: schedutil: Examine the correct CPU when we update util
      e029b9bf
    • Viresh Kumar's avatar
      cpufreq: schedutil: Reset cached_raw_freq when not in sync with next_freq · 07458f6a
      Viresh Kumar authored
      'cached_raw_freq' is used to get the next frequency quickly but should
      always be in sync with sg_policy->next_freq. There is a case where it is
      not and in such cases it should be reset to avoid switching to incorrect
      frequencies.
      
      Consider this case for example:
      
       - policy->cur is 1.2 GHz (Max)
       - New request comes for 780 MHz and we store that in cached_raw_freq.
       - Based on 780 MHz, we calculate the effective frequency as 800 MHz.
       - We then see the CPU wasn't idle recently and choose to keep the next
         freq as 1.2 GHz.
       - Now we have cached_raw_freq is 780 MHz and sg_policy->next_freq is
         1.2 GHz.
       - Now if the utilization doesn't change in then next request, then the
         next target frequency will still be 780 MHz and it will match with
         cached_raw_freq. But we will choose 1.2 GHz instead of 800 MHz here.
      
      Fixes: b7eaf1aa (cpufreq: schedutil: Avoid reducing frequency of busy CPUs prematurely)
      Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Cc: 4.12+ <stable@vger.kernel.org> # 4.12+
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      07458f6a
    • Himanshu Jha's avatar
    • Rajat Jain's avatar
      PM / s2idle: Clear the events_check_enabled flag · 95b982b4
      Rajat Jain authored
      Problem: This flag does not get cleared currently in the suspend or
      resume path in the following cases:
      
       * In case some driver's suspend routine returns an error.
       * Successful s2idle case
       * etc?
      
      Why is this a problem: What happens is that the next suspend attempt
      could fail even though the user did not enable the flag by writing to
      /sys/power/wakeup_count. This is 1 use case how the issue can be seen
      (but similar use case with driver suspend failure can be thought of):
      
       1. Read /sys/power/wakeup_count
       2. echo count > /sys/power/wakeup_count
       3. echo freeze > /sys/power/wakeup_count
       4. Let the system suspend, and wakeup the system using some wake source
          that calls pm_wakeup_event() e.g. power button or something.
       5. Note that the combined wakeup count would be incremented due
          to the pm_wakeup_event() in the resume path.
       6. After resuming the events_check_enabled flag is still set.
      
      At this point if the user attempts to freeze again (without writing to
      /sys/power/wakeup_count), the suspend would fail even though there has
      been no wake event since the past resume.
      
      Address that by clearing the flag just before a resume is completed,
      so that it is always cleared for the corner cases mentioned above.
      Signed-off-by: default avatarRajat Jain <rajatja@google.com>
      Acked-by: default avatarPavel Machek <pavel@ucw.cz>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      95b982b4
    • Gautham R. Shenoy's avatar
      cpufreq: stats: Handle the case when trans_table goes beyond PAGE_SIZE · f7bc9b20
      Gautham R. Shenoy authored
      On platforms with large number of Pstates, the transition table, which
      is a NxN matrix, can overflow beyond the PAGE_SIZE boundary.
      
      This can be seen on POWER9 which has 100+ Pstates.
      
      As a result, each time the trans_table is read for any of the CPUs, we
      will get the following error.
      
      ---------------------------------------------------
      fill_read_buffer: show+0x0/0xa0 returned bad count
      ---------------------------------------------------
      
      This patch ensures that in case of an overflow, we print a warning
      once in the dmesg and return FILE TOO LARGE error for this and all
      subsequent accesses of trans_table.
      Signed-off-by: default avatarGautham R. Shenoy <ego@linux.vnet.ibm.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f7bc9b20
    • Bhumika Goyal's avatar
      cpufreq: arm_big_little: make cpufreq_arm_bL_ops structures const · 0011c6da
      Bhumika Goyal authored
      Make these const as they are only getting passed to the functions
      bL_cpufreq_{register/unregister} having the arguments as const.
      Signed-off-by: default avatarBhumika Goyal <bhumirks@gmail.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0011c6da
    • Bhumika Goyal's avatar
      cpufreq: arm_big_little: make function arguments and structure pointer const · cd6ce860
      Bhumika Goyal authored
      Make the arguments of functions bL_cpufreq_{register/unregister} as
      const as the ops pointer does not modify the fields of the
      cpufreq_arm_bL_ops structure it points to. The pointer arm_bL_ops is
      also getting initialized with ops but the pointer does not modify the
      fields. So, make the function argument and the structure pointer const.
      Add const to function prototypes too.
      Signed-off-by: default avatarBhumika Goyal <bhumirks@gmail.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      cd6ce860
    • Gaurav Jindal's avatar
      cpuidle: Avoid assignment in if () argument · 3fc74bd8
      Gaurav Jindal authored
      Clean up cpuidle_enable_device() to avoid doing an assignment
      in an expression evaluated as an argument of if (), which also
      makes the code in question more readable.
      Signed-off-by: default avatarGaurav Jindal <gauravjindal1104@gmail.com>
      [ rjw: Subject & changelog ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      3fc74bd8
    • Gaurav Jindal's avatar
      cpuidle: Clean up cpuidle_enable_device() error handling a bit · e7b06a09
      Gaurav Jindal authored
      Do not fetch per CPU drv if cpuidle_curr_governor is NULL
      to avoid useless per CPU processing.
      Signed-off-by: default avatarGaurav Jindal <gauravjindal1104@gmail.com>
      [ rjw: Subject & changelog ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      e7b06a09
    • Ville Syrjälä's avatar
      ACPI / PM: Fix acpi_pm_notifier_lock vs flush_workqueue() deadlock · ff165679
      Ville Syrjälä authored
      acpi_remove_pm_notifier() ends up calling flush_workqueue() while
      holding acpi_pm_notifier_lock, and that same lock is taken by
      by the work via acpi_pm_notify_handler(). This can deadlock.
      
      To fix the problem let's split the single lock into two: one to
      protect the dev->wakeup between the work vs. add/remove, and
      another one to handle notifier installation vs. removal.
      
      After commit a1d14934 "workqueue/lockdep: 'Fix' flush_work()
      annotation" I was able to kill the machine (Intel Braswell)
      very easily with 'powertop --auto-tune', runtime suspending i915,
      and trying to wake it up via the USB keyboard. The cases when
      it didn't die are presumably explained by lockdep getting disabled
      by something else (cpu hotplug locking issues usually).
      
      Fortunately I still got a lockdep report over netconsole
      (trickling in very slowly), even though the machine was
      otherwise practically dead:
      
      [  112.179806] ======================================================
      [  114.670858] WARNING: possible circular locking dependency detected
      [  117.155663] 4.13.0-rc6-bsw-bisect-00169-ga1d14934 #119 Not tainted
      [  119.658101] ------------------------------------------------------
      [  121.310242] xhci_hcd 0000:00:14.0: xHCI host not responding to stop endpoint command.
      [  121.313294] xhci_hcd 0000:00:14.0: xHCI host controller not responding, assume dead
      [  121.313346] xhci_hcd 0000:00:14.0: HC died; cleaning up
      [  121.313485] usb 1-6: USB disconnect, device number 3
      [  121.313501] usb 1-6.2: USB disconnect, device number 4
      [  134.747383] kworker/0:2/47 is trying to acquire lock:
      [  137.220790]  (acpi_pm_notifier_lock){+.+.}, at: [<ffffffff813cafdf>] acpi_pm_notify_handler+0x2f/0x80
      [  139.721524]
      [  139.721524] but task is already holding lock:
      [  144.672922]  ((&dpc->work)){+.+.}, at: [<ffffffff8109ce90>] process_one_work+0x160/0x720
      [  147.184450]
      [  147.184450] which lock already depends on the new lock.
      [  147.184450]
      [  154.604711]
      [  154.604711] the existing dependency chain (in reverse order) is:
      [  159.447888]
      [  159.447888] -> #2 ((&dpc->work)){+.+.}:
      [  164.183486]        __lock_acquire+0x1255/0x13f0
      [  166.504313]        lock_acquire+0xb5/0x210
      [  168.778973]        process_one_work+0x1b9/0x720
      [  171.030316]        worker_thread+0x4c/0x440
      [  173.257184]        kthread+0x154/0x190
      [  175.456143]        ret_from_fork+0x27/0x40
      [  177.624348]
      [  177.624348] -> #1 ("kacpi_notify"){+.+.}:
      [  181.850351]        __lock_acquire+0x1255/0x13f0
      [  183.941695]        lock_acquire+0xb5/0x210
      [  186.046115]        flush_workqueue+0xdd/0x510
      [  190.408153]        acpi_os_wait_events_complete+0x31/0x40
      [  192.625303]        acpi_remove_notify_handler+0x133/0x188
      [  194.820829]        acpi_remove_pm_notifier+0x56/0x90
      [  196.989068]        acpi_dev_pm_detach+0x5f/0xa0
      [  199.145866]        dev_pm_domain_detach+0x27/0x30
      [  201.285614]        i2c_device_probe+0x100/0x210
      [  203.411118]        driver_probe_device+0x23e/0x310
      [  205.522425]        __driver_attach+0xa3/0xb0
      [  207.634268]        bus_for_each_dev+0x69/0xa0
      [  209.714797]        driver_attach+0x1e/0x20
      [  211.778258]        bus_add_driver+0x1bc/0x230
      [  213.837162]        driver_register+0x60/0xe0
      [  215.868162]        i2c_register_driver+0x42/0x70
      [  217.869551]        0xffffffffa0172017
      [  219.863009]        do_one_initcall+0x45/0x170
      [  221.843863]        do_init_module+0x5f/0x204
      [  223.817915]        load_module+0x225b/0x29b0
      [  225.757234]        SyS_finit_module+0xc6/0xd0
      [  227.661851]        do_syscall_64+0x5c/0x120
      [  229.536819]        return_from_SYSCALL_64+0x0/0x7a
      [  231.392444]
      [  231.392444] -> #0 (acpi_pm_notifier_lock){+.+.}:
      [  235.124914]        check_prev_add+0x44e/0x8a0
      [  237.024795]        __lock_acquire+0x1255/0x13f0
      [  238.937351]        lock_acquire+0xb5/0x210
      [  240.840799]        __mutex_lock+0x75/0x940
      [  242.709517]        mutex_lock_nested+0x1c/0x20
      [  244.551478]        acpi_pm_notify_handler+0x2f/0x80
      [  246.382052]        acpi_ev_notify_dispatch+0x44/0x5c
      [  248.194412]        acpi_os_execute_deferred+0x14/0x30
      [  250.003925]        process_one_work+0x1ec/0x720
      [  251.803191]        worker_thread+0x4c/0x440
      [  253.605307]        kthread+0x154/0x190
      [  255.387498]        ret_from_fork+0x27/0x40
      [  257.153175]
      [  257.153175] other info that might help us debug this:
      [  257.153175]
      [  262.324392] Chain exists of:
      [  262.324392]   acpi_pm_notifier_lock --> "kacpi_notify" --> (&dpc->work)
      [  262.324392]
      [  267.391997]  Possible unsafe locking scenario:
      [  267.391997]
      [  270.758262]        CPU0                    CPU1
      [  272.431713]        ----                    ----
      [  274.060756]   lock((&dpc->work));
      [  275.646532]                                lock("kacpi_notify");
      [  277.260772]                                lock((&dpc->work));
      [  278.839146]   lock(acpi_pm_notifier_lock);
      [  280.391902]
      [  280.391902]  *** DEADLOCK ***
      [  280.391902]
      [  284.986385] 2 locks held by kworker/0:2/47:
      [  286.524895]  #0:  ("kacpi_notify"){+.+.}, at: [<ffffffff8109ce90>] process_one_work+0x160/0x720
      [  288.112927]  #1:  ((&dpc->work)){+.+.}, at: [<ffffffff8109ce90>] process_one_work+0x160/0x720
      [  289.727725]
      
      Fixes: c072530f (ACPI / PM: Revork the handling of ACPI device wakeup notifications)
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Cc: 3.17+ <stable@vger.kernel.org> # 3.17+
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ff165679
    • Ulf Hansson's avatar
      PM / Domains: Fix genpd to deal with drivers returning 1 from ->prepare() · 5241ab40
      Ulf Hansson authored
      During system-wide PM, genpd relies on its PM callbacks to be invoked for
      all its attached devices, as to deal with powering off/on the PM domain. In
      other words, genpd is not compatible with the direct_complete path, if
      executed by the PM core for any of its attached devices.
      
      However, when genpd's ->prepare() callback invokes pm_generic_prepare(), it
      does not take into account that it may return 1. Instead it treats that as
      an error internally and expects the PM core to abort the prepare phase and
      roll back. This leads to genpd not properly powering on/off the PM domain,
      because its internal counters gets wrongly balanced.
      
      To fix the behaviour, allow drivers to return 1 from their ->prepare()
      callbacks, but let's return 0 from genpd's ->prepare() callback in such
      case, as that prevents the PM core from running the direct_complete path
      for the device.
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5241ab40
    • Ramesh Thomas's avatar
      cpuidle: ladder: Add per CPU PM QoS resume latency support · c523c68d
      Ramesh Thomas authored
      Individual CPUs may have special requirements to not enter
      deep idle states. For example, a CPU running real time
      applications would not want to enter deep idle states to
      avoid latency impacts. At the same time other CPUs that
      do not have such a requirement could allow deep idle
      states to save power.
      
      This was already implemented in the menu governor.
      Implementing similar changes in the ladder governor which
      gets selected when CONFIG_NO_HZ and CONFIG_NO_HZ_IDLE are not
      set. Refer following commits for the menu governor changes.
      Signed-off-by: default avatarRamesh Thomas <ramesh.thomas@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      c523c68d
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-qos' into pm-cpuidle · 4e37fd4d
      Rafael J. Wysocki authored
      4e37fd4d
    • Rafael J. Wysocki's avatar
      PM / QoS: Fix device resume latency framework · 0759e80b
      Rafael J. Wysocki authored
      The special value of 0 for device resume latency PM QoS means
      "no restriction", but there are two problems with that.
      
      First, device resume latency PM QoS requests with 0 as the
      value are always put in front of requests with positive
      values in the priority lists used internally by the PM QoS
      framework, causing 0 to be chosen as an effective constraint
      value.  However, that 0 is then interpreted as "no restriction"
      effectively overriding the other requests with specific
      restrictions which is incorrect.
      
      Second, the users of device resume latency PM QoS have no
      way to specify that *any* resume latency at all should be
      avoided, which is an artificial limitation in general.
      
      To address these issues, modify device resume latency PM QoS to
      use S32_MAX as the "no constraint" value and 0 as the "no
      latency at all" one and rework its users (the cpuidle menu
      governor, the genpd QoS governor and the runtime PM framework)
      to follow these changes.
      
      Also add a special "n/a" value to the corresponding user space I/F
      to allow user space to indicate that it cannot accept any resume
      latencies at all for the given device.
      
      Fixes: 85dc0b8a (PM / QoS: Make it possible to expose PM QoS latency constraints)
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=197323Reported-by: default avatarReinette Chatre <reinette.chatre@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: default avatarReinette Chatre <reinette.chatre@intel.com>
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: default avatarTero Kristo <t-kristo@ti.com>
      Reviewed-by: default avatarRamesh Thomas <ramesh.thomas@intel.com>
      0759e80b
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-domains' into pm-qos · 31f18230
      Rafael J. Wysocki authored
      31f18230
    • Rafael J. Wysocki's avatar
      PM / domains: Rework governor code to be more consistent · 704d2ce6
      Rafael J. Wysocki authored
      The genpd governor currently uses negative PM QoS values to indicate
      the "no suspend" condition and 0 as "no restriction", but it doesn't
      use them consistently.  Moreover, it tries to refresh QoS values for
      already suspended devices in a quite questionable way.
      
      For the above reasons, rework it to be a bit more consistent.
      
      First off, note that dev_pm_qos_read_value() in
      dev_update_qos_constraint() and __default_power_down_ok() is
      evaluated for devices in suspend.  Moreover, that only happens if the
      effective_constraint_ns value for them is negative (meaning "no
      suspend").  It is not evaluated in any other cases, so effectively
      the QoS values are only updated for devices in suspend that should
      not have been suspended in the first place.  In all of the other
      cases, the QoS values taken into account are the effective ones from
      the time before the device has been suspended, so generally devices
      need to be resumed and suspended again for new QoS values to take
      effect anyway.  Thus evaluating dev_update_qos_constraint() in
      those two places doesn't make sense at all, so drop it.
      
      Second, initialize effective_constraint_ns to 0 ("no constraint")
      rather than to (-1) ("no suspend"), which makes more sense in
      general and in case effective_constraint_ns is never updated
      (the device is in suspend all the time or it is never suspended)
      it doesn't affect the device's parent and so on.
      
      Finally, rework default_suspend_ok() to explicitly handle the
      "no restriction" and "no suspend" special cases.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: default avatarTero Kristo <t-kristo@ti.com>
      Reviewed-by: default avatarRamesh Thomas <ramesh.thomas@intel.com>
      704d2ce6
    • Geert Uytterhoeven's avatar
      PM / Domains: Remove gpd_dev_ops.active_wakeup() callback · d0af45f1
      Geert Uytterhoeven authored
      There are no more users left of the gpd_dev_ops.active_wakeup()
      callback.  All have been converted to GENPD_FLAG_ACTIVE_WAKEUP.
      Hence remove the callback.
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      d0af45f1
    • Geert Uytterhoeven's avatar
      soc: rockchip: power-domain: Use GENPD_FLAG_ACTIVE_WAKEUP · 89c7aea9
      Geert Uytterhoeven authored
      Set the newly introduced GENPD_FLAG_ACTIVE_WAKEUP, which allows to
      remove the driver's own flag-based callback.
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      89c7aea9
    • Geert Uytterhoeven's avatar
      soc: mediatek: Use GENPD_FLAG_ACTIVE_WAKEUP · 7534d181
      Geert Uytterhoeven authored
      Set the newly introduced GENPD_FLAG_ACTIVE_WAKEUP, which allows to
      remove the driver's own flag-based callback.
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      7534d181
    • Geert Uytterhoeven's avatar
      ARM: shmobile: pm-rmobile: Use GENPD_FLAG_ACTIVE_WAKEUP · eb0ddf9d
      Geert Uytterhoeven authored
      Set the newly introduced GENPD_FLAG_ACTIVE_WAKEUP, which allows to
      remove the driver's own "always true" callback.
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: default avatarSimon Horman <horms+renesas@verge.net.au>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      eb0ddf9d
    • Geert Uytterhoeven's avatar
      PM / Domains: Allow genpd users to specify default active wakeup behavior · 95a20ef6
      Geert Uytterhoeven authored
      It is quite common for PM Domains to require slave devices to be kept
      active during system suspend if they are to be used as wakeup sources.
      To enable this, currently each PM Domain or driver has to provide its
      own gpd_dev_ops.active_wakeup() callback.
      
      Introduce a new flag GENPD_FLAG_ACTIVE_WAKEUP to consolidate this.
      If specified, all slave devices configured as wakeup sources will be
      kept active during system suspend.
      
      PM Domains that need more fine-grained controls, based on the slave
      device, can still provide their own callbacks, as before.
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      95a20ef6
  4. 06 Nov, 2017 8 commits
    • Rafael J. Wysocki's avatar
      ACPI / PM: Blacklist Low Power S0 Idle _DSM for Dell XPS13 9360 · 71630b7a
      Rafael J. Wysocki authored
      At least one Dell XPS13 9360 is reported to have serious issues with
      the Low Power S0 Idle _DSM interface and since this machine model
      generally can do ACPI S3 just fine, add a blacklist entry to disable
      that interface for Dell XPS13 9360.
      
      Fixes: 8110dd28 (ACPI / sleep: EC-based wakeup from suspend-to-idle on recent systems)
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=196907Reported-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Tested-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: 4.13+ <stable@vger.kernel.org> # 4.13+
      71630b7a
    • Rafael J. Wysocki's avatar
      ACPI / PM: Take SMART_SUSPEND driver flag into account · 05087360
      Rafael J. Wysocki authored
      Make the ACPI PM domain take DPM_FLAG_SMART_SUSPEND into account in
      its system suspend callbacks.
      
      [Note that the pm_runtime_suspended() check in acpi_dev_needs_resume()
      is an optimization, because if is not passed, all of the subsequent
      checks may be skipped and some of them are much more overhead in
      general.]
      
      Also use the observation that if the device is in runtime suspend
      at the beginning of the "late" phase of a system-wide suspend-like
      transition, its state cannot change going forward (runtime PM is
      disabled for it at that time) until the transition is over and the
      subsequent system-wide PM callbacks should be skipped for it (as
      they generally assume the device to not be suspended), so add
      checks for that in acpi_subsys_suspend_late/noirq() and
      acpi_subsys_freeze_late/noirq().
      
      Moreover, if acpi_subsys_resume_noirq() is called during the
      subsequent system-wide resume transition and if the device was left
      in runtime suspend previously, its runtime PM status needs to be
      changed to "active" as it is going to be put into the full-power
      state going forward, so add a check for that too in there.
      
      In turn, if acpi_subsys_thaw_noirq() runs after the device has been
      left in runtime suspend, the subsequent "thaw" callbacks need
      to be skipped for it (as they may not work correctly with a
      suspended device), so set the power.direct_complete flag for the
      device then to make the PM core skip those callbacks.
      
      On top of the above, make the analogous changes in the acpi_lpss
      driver that uses the ACPI PM domain callbacks.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05087360
    • Rafael J. Wysocki's avatar
      PCI / PM: Take SMART_SUSPEND driver flag into account · c4b65157
      Rafael J. Wysocki authored
      Make the PCI bus type take DPM_FLAG_SMART_SUSPEND into account in its
      system-wide PM callbacks and make sure that all code that should not
      run in parallel with pci_pm_runtime_resume() is executed in the "late"
      phases of system suspend, freeze and poweroff transitions.
      
      [Note that the pm_runtime_suspended() check in pci_dev_keep_suspended()
      is an optimization, because if is not passed, all of the subsequent
      checks may be skipped and some of them are much more overhead in
      general.]
      
      Also use the observation that if the device is in runtime suspend
      at the beginning of the "late" phase of a system-wide suspend-like
      transition, its state cannot change going forward (runtime PM is
      disabled for it at that time) until the transition is over and the
      subsequent system-wide PM callbacks should be skipped for it (as
      they generally assume the device to not be suspended), so add checks
      for that in pci_pm_suspend_late/noirq(), pci_pm_freeze_late/noirq()
      and pci_pm_poweroff_late/noirq().
      
      Moreover, if pci_pm_resume_noirq() or pci_pm_restore_noirq() is
      called during the subsequent system-wide resume transition and if
      the device was left in runtime suspend previously, its runtime PM
      status needs to be changed to "active" as it is going to be put
      into the full-power state, so add checks for that too to these
      functions.
      
      In turn, if pci_pm_thaw_noirq() runs after the device has been
      left in runtime suspend, the subsequent "thaw" callbacks need
      to be skipped for it (as they may not work correctly with a
      suspended device), so set the power.direct_complete flag for the
      device then to make the PM core skip those callbacks.
      
      In addition to the above add a core helper for checking if
      DPM_FLAG_SMART_SUSPEND is set and the device runtime PM status is
      "suspended" at the same time, which is done quite often in the new
      code (and will be done elsewhere going forward too).
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      c4b65157
    • Rafael J. Wysocki's avatar
      PCI / PM: Drop unnecessary invocations of pcibios_pm_ops callbacks · 302666d8
      Rafael J. Wysocki authored
      The only user of non-empty pcibios_pm_ops is s390 and it only uses
      "noirq" callbacks, so drop the invocations of the other pcibios_pm_ops
      callbacks from the PCI PM code.
      
      That will allow subsequent changes to be somewhat simpler.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      302666d8
    • Rafael J. Wysocki's avatar
      PM / core: Add SMART_SUSPEND driver flag · 0eab11c9
      Rafael J. Wysocki authored
      Define and document a SMART_SUSPEND flag to instruct bus types and PM
      domains that the system suspend callbacks provided by the driver can
      cope with runtime-suspended devices, so from the driver's perspective
      it should be safe to leave devices in runtime suspend during system
      suspend.
      
      Setting that flag may also cause middle-layer code (bus types,
      PM domains etc.) to skip invocations of the ->suspend_late and
      ->suspend_noirq callbacks provided by the driver if the device
      is in runtime suspend at the beginning of the "late" phase of
      the system-wide suspend transition, in which case the driver's
      system-wide resume callbacks may be invoked back-to-back with
      its ->runtime_suspend callback, so the driver has to be able to
      cope with that too.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      0eab11c9
    • Rafael J. Wysocki's avatar
      PCI / PM: Use the NEVER_SKIP driver flag · c2eac4d3
      Rafael J. Wysocki authored
      Replace the PCI-specific flag PCI_DEV_FLAGS_NEEDS_RESUME with the
      PM core's DPM_FLAG_NEVER_SKIP one everywhere and drop it.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      c2eac4d3
    • Rafael J. Wysocki's avatar
      PM / core: Add NEVER_SKIP and SMART_PREPARE driver flags · 08810a41
      Rafael J. Wysocki authored
      The motivation for this change is to provide a way to work around
      a problem with the direct-complete mechanism used for avoiding
      system suspend/resume handling for devices in runtime suspend.
      
      The problem is that some middle layer code (the PCI bus type and
      the ACPI PM domain in particular) returns positive values from its
      system suspend ->prepare callbacks regardless of whether the driver's
      ->prepare returns a positive value or 0, which effectively prevents
      drivers from being able to control the direct-complete feature.
      Some drivers need that control, however, and the PCI bus type has
      grown its own flag to deal with this issue, but since it is not
      limited to PCI, it is better to address it by adding driver flags at
      the core level.
      
      To that end, add a driver_flags field to struct dev_pm_info for flags
      that can be set by device drivers at the probe time to inform the PM
      core and/or bus types, PM domains and so on on the capabilities and/or
      preferences of device drivers.  Also add two static inline helpers
      for setting that field and testing it against a given set of flags
      and make the driver core clear it automatically on driver remove
      and probe failures.
      
      Define and document two PM driver flags related to the direct-
      complete feature: NEVER_SKIP and SMART_PREPARE that can be used,
      respectively, to indicate to the PM core that the direct-complete
      mechanism should never be used for the device and to inform the
      middle layer code (bus types, PM domains etc) that it can only
      request the PM core to use the direct-complete mechanism for
      the device (by returning a positive value from its ->prepare
      callback) if it also has been requested by the driver.
      
      While at it, make the core check pm_runtime_suspended() when
      setting power.direct_complete so that it doesn't need to be
      checked by ->prepare callbacks.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      08810a41
    • Rafael J. Wysocki's avatar
      Merge branch 'acpi-pm' into pm-core · 69a10ca7
      Rafael J. Wysocki authored
      69a10ca7
  5. 05 Nov, 2017 1 commit