1. 08 8月, 2019 3 次提交
  2. 30 7月, 2019 1 次提交
    • R
      ACPI: PM: Set up EC GPE for system wakeup from drivers that need it · 10a08fd6
      Rafael J. Wysocki 提交于
      The EC GPE needs to be set up for system wakeup only if there is a
      driver depending on it, either intel-hid or intel-vbtn, bound to a
      button device that is expected to wake up the system from sleep (such
      as the power button on some Dell systems, like the XPS13 9360).  It
      doesn't need to be set up for waking up the system from sleep in any
      other cases and whether or not it is expected to wake up the system
      from sleep doesn't depend on whether or not the LPS0 device is
      present in the ACPI namespace.
      
      For this reason, rearrange the ACPI suspend-to-idle code to make the
      drivers depending on the EC GPE wakeup take care of setting it up and
      decouple that from the LPS0 device handling.
      
      While at it, make intel-hid and intel-vbtn prepare for system wakeup
      only if they are allowed to wake up the system from sleep by user
      space (via sysfs).
      
      [Note that acpi_ec_mark_gpe_for_wake() and acpi_ec_set_gpe_wake_mask()
       are there to prevent the EC GPE from being disabled by the
       acpi_enable_all_wakeup_gpes() call in acpi_s2idle_prepare(), so on
       systems with either intel-hid or intel-vbtn this change doesn't
       affect any interactions with the hardware or platform firmware.]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      10a08fd6
  3. 23 7月, 2019 2 次提交
    • 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
    • R
      ACPI: PM: Set s2idle_wakeup earlier and clear it later · 41275eb5
      Rafael J. Wysocki 提交于
      The role of the s2idle_wakeup variable is to cause
      acpi_pm_wakeup_event() and acpi_pm_notify_handler() to
      increment pm_abort_suspend and trigger a wakeup from
      suspend-to-idle in case the ACPI SCI wakeup was canceled
      by acpi_s2idle_wake().
      
      However, for this purpose it need not be set in acpi_s2idle_wake()
      and cleared in acpi_s2idle_sync(), respectively.  In fact, it
      may be set as early as in acpi_s2idle_prepare() and cleared as
      late as in acpi_s2idle_restore(), so do that to allow subsequent
      changes to be simpler.
      
      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>
      41275eb5
  4. 06 7月, 2019 1 次提交
    • D
      ACPI: PM: Make acpi_sleep_state_supported() non-static · ad5a449b
      Dexuan Cui 提交于
      With some upcoming patches to save/restore the Hyper-V drivers related
      states, a Linux VM running on Hyper-V will be able to hibernate. When
      a Linux VM hibernates, unluckily we must disable the memory hot-add/remove
      and balloon up/down capabilities in the hv_balloon driver
      (drivers/hv/hv_balloon.c), because these can not really work according to
      the design of the related back-end driver on the host.
      
      By default, Hyper-V does not enable the virtual ACPI S4 state for a VM;
      on recent Hyper-V hosts, the administrator is able to enable the virtual
      ACPI S4 state for a VM, so we hope to use the presence of the virtual ACPI
      S4 state as a hint for hv_balloon to disable the aforementioned
      capabilities. In this way, hibernation will work more reliably, from the
      user's perspective.
      
      By marking acpi_sleep_state_supported() non-static, we'll be able to
      implement a hv_is_hibernation_supported() API in the always-built-in
      module arch/x86/hyperv/hv_init.c, and the API will be called by hv_balloon.
      Signed-off-by: NDexuan Cui <decui@microsoft.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ad5a449b
  5. 24 6月, 2019 1 次提交
    • S
      bus_find_device: Unify the match callback with class_find_device · 418e3ea1
      Suzuki K Poulose 提交于
      There is an arbitrary difference between the prototypes of
      bus_find_device() and class_find_device() preventing their callers
      from passing the same pair of data and match() arguments to both of
      them, which is the const qualifier used in the prototype of
      class_find_device().  If that qualifier is also used in the
      bus_find_device() prototype, it will be possible to pass the same
      match() callback function to both bus_find_device() and
      class_find_device(), which will allow some optimizations to be made in
      order to avoid code duplication going forward.  Also with that, constify
      the "data" parameter as it is passed as a const to the match function.
      
      For this reason, change the prototype of bus_find_device() to match
      the prototype of class_find_device() and adjust its callers to use the
      const qualifier in accordance with the new prototype of it.
      
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Andreas Noever <andreas.noever@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Corey Minyard <minyard@acm.org>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: David Kershner <david.kershner@unisys.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: Grygorii Strashko <grygorii.strashko@ti.com>
      Cc: Harald Freudenberger <freude@linux.ibm.com>
      Cc: Hartmut Knaack <knaack.h@gmx.de>
      Cc: Heiko Stuebner <heiko@sntech.de>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Jonathan Cameron <jic23@kernel.org>
      Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michael Jamet <michael.jamet@intel.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
      Cc: Sebastian Ott <sebott@linux.ibm.com>
      Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
      Cc: rafael@kernel.org
      Acked-by: NCorey Minyard <minyard@acm.org>
      Acked-by: NDavid Kershner <david.kershner@unisys.com>
      Acked-by: NMark Brown <broonie@kernel.org>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Acked-by: Wolfram Sang <wsa@the-dreams.de> # for the I2C parts
      Acked-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      418e3ea1
  6. 14 6月, 2019 1 次提交
  7. 05 6月, 2019 1 次提交
  8. 27 5月, 2019 1 次提交
    • R
      ACPI: PM: Call pm_set_suspend_via_firmware() during hibernation · bb186901
      Rafael J. Wysocki 提交于
      On systems with ACPI platform firmware the last stage of hibernation
      is analogous to system suspend to S3 (suspend-to-RAM), so it should
      be handled analogously.  In particular, pm_suspend_via_firmware()
      should return 'true' in that stage to let the callers of it know that
      control will be passed to the platform firmware going forward, so
      pm_set_suspend_via_firmware() needs to be called then in analogy with
      acpi_suspend_begin().
      
      However, the platform hibernation ->begin() callback is invoked
      during the "freeze" transition (before creating a snapshot image of
      system memory) as well as during the "hibernate" transition which is
      the last stage of it and pm_set_suspend_via_firmware() should be
      invoked by that callback in the latter stage only.
      
      In order to implement that redefine the hibernation ->begin()
      callback to take a pm_message_t argument to indicate which stage
      of hibernation is taking place and rework acpi_hibernation_begin()
      and acpi_hibernation_begin_old() to take it into account as needed.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      bb186901
  9. 14 5月, 2019 1 次提交
    • R
      ACPI: PM: Set enable_for_wake for wakeup GPEs during suspend-to-idle · 2f844b61
      Rajat Jain 提交于
      I noticed that recently multiple systems (chromebooks) couldn't wake
      from S0ix using LID or Keyboard after updating to a newer kernel. I
      bisected and it turned up commit f941d3e4 ("ACPI: EC / PM: Disable
      non-wakeup GPEs for suspend-to-idle"). I checked that the issue got
      fixed if that commit was reverted.
      
      I debugged and found that although PNP0C0D:00 (representing the LID)
      is wake capable and should wakeup the system per the code in
      acpi_wakeup_gpe_init() and in drivers/acpi/button.c:
      
      localhost /sys # cat /proc/acpi/wakeup
      Device  S-state   Status   Sysfs node
      LID0      S4    *enabled   platform:PNP0C0D:00
      CREC      S5    *disabled  platform:GOOG0004:00
                      *disabled  platform:cros-ec-dev.1.auto
                      *disabled  platform:cros-ec-accel.0
                      *disabled  platform:cros-ec-accel.1
                      *disabled  platform:cros-ec-gyro.0
                      *disabled  platform:cros-ec-ring.0
                      *disabled  platform:cros-usbpd-charger.2.auto
                      *disabled  platform:cros-usbpd-logger.3.auto
      D015      S3    *enabled   i2c:i2c-ELAN0000:00
      PENH      S3    *enabled   platform:PRP0001:00
      XHCI      S3    *enabled   pci:0000:00:14.0
      GLAN      S4    *disabled
      WIFI      S3    *disabled  pci:0000:00:14.3
      localhost /sys #
      
      On debugging, I found that its corresponding GPE is not being enabled.
      The particular GPE's "gpe_register_info->enable_for_wake" does not
      have any bits set when acpi_enable_all_wakeup_gpes() comes around to
      use it. I looked at code and could not find any other code path that
      should set the bits in "enable_for_wake" bitmask for the wake enabled
      devices for s2idle.  [I do see that it happens for S3 in
      acpi_sleep_prepare()].
      
      Thus I used the same call to enable the GPEs for wake enabled devices,
      and verified that this fixes the regression I was seeing on multiple
      of my devices.
      
      [ rjw: The problem is that commit f941d3e4 ("ACPI: EC / PM:
        Disable non-wakeup GPEs for suspend-to-idle") forgot to add
        the acpi_enable_wakeup_devices() call for s2idle along with
        acpi_enable_all_wakeup_gpes(). ]
      
      Fixes: f941d3e4 ("ACPI: EC / PM: Disable non-wakeup GPEs for suspend-to-idle")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=203579Signed-off-by: NRajat Jain <rajatja@google.com>
      [ rjw: Subject & changelog ]
      Cc: 5.0+ <stable@vger.kernel.org> # 5.0+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      2f844b61
  10. 18 12月, 2018 2 次提交
  11. 11 7月, 2018 1 次提交
    • W
      ACPI / PM: save NVS memory for ASUS 1025C laptop · 231f9415
      Willy Tarreau 提交于
      Every time I tried to upgrade my laptop from 3.10.x to 4.x I faced an
      issue by which the fan would run at full speed upon resume. Bisecting
      it showed me the issue was introduced in 3.17 by commit 821d6f03
      (ACPI / sleep: Do not save NVS for new machines to accelerate S3). This
      code only affects machines built starting as of 2012, but this Asus
      1025C laptop was made in 2012 and apparently needs the NVS data to be
      saved, otherwise the CPU's thermal state is not properly reported on
      resume and the fan runs at full speed upon resume.
      
      Here's a very simple way to check if such a machine is affected :
      
        # cat /sys/class/thermal/thermal_zone0/temp
        55000
      
        ( now suspend, wait one second and resume )
      
        # cat /sys/class/thermal/thermal_zone0/temp
        0
      
        (and after ~15 seconds the fan starts to spin)
      
      Let's apply the same quirk as commit cbc00c13 (ACPI: save NVS memory
      for Lenovo G50-45) and reuse the function it provides. Note that this
      commit was already backported to 4.9.x but not 4.4.x.
      
      Cc: 3.17+ <stable@vger.kernel.org> # 3.17+: requires cbc00c13Signed-off-by: NWilly Tarreau <w@1wt.eu>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      231f9415
  12. 04 7月, 2018 1 次提交
  13. 25 5月, 2018 1 次提交
    • R
      ACPI: EC: Dispatch the EC GPE directly on s2idle wake · 68e22011
      Rafael J. Wysocki 提交于
      On platforms where the Low Power S0 Idle _DSM interface is used,
      on wakeup from suspend-to-idle, when it is known that the ACPI SCI
      has triggered while suspended, dispatch the EC GPE in order to catch
      all EC events that may have triggered the wakeup before carrying out
      the noirq phase of device resume.
      
      That is needed to handle power button wakeup on some platforms where
      the EC goes into a low-power mode during suspend-to-idle and while in
      that mode it will discard events after a timeout.  If that timeout is
      shorter than the time it takes to complete the noirq resume of
      devices, looking for EC events after the latter is too late.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reported-by: NZhang Rui <rui.zhang@intel.com>
      Tested-by: NWendy Wang <wendy.wang@intel.com>
      68e22011
  14. 23 4月, 2018 1 次提交
  15. 31 3月, 2018 1 次提交
    • C
      ACPI / PM: Fix keyboard wakeup from suspend-to-idle on ASUS UX331UA · 6f1d7c45
      Chris Chiu 提交于
      This issue happens on new ASUS laptop UX331UA which has modern
      standby mode (suspend-to-idle). Pressing keys on the PS2 keyboard
      can't wake up the system from suspend-to-idle which is not expected.
      However, pressing power button can wake up without problem.
      
      Per the engineers of ASUS, the keypress event is routed to Embedded
      Controller (EC) in standby mode. EC then signals the SCI event to
      BIOS so BIOS would Notify() power button to wake up the system. It's
      from BIOS perspective. What we observe here is that kernel receives
      the SCI event from SCI interrupt handler which informs that the GPE
      status bit belongs to EC needs to be handled and then queries the EC
      to find out what event is pending. Then execute the following ACPI
      _QDF method which defined in ACPI DSDT for EC to notify power button.
      
       Method (_QDF, 0, NotSerialized)  // _Qxx: EC Query
              {
                  Notify (PWRB, 0x80) // Status Change
              }
      
      With more debug messages added to analyze this problem, we find that
      the keypress does wake up the system from suspend-to-idle but it's back
      to suspend again almost immediately. As we see in the following messages,
      the acpi_button_notify() is invoked but acpi_pm_wakeup_event() can not
      really wake up the system here because acpi_s2idle_wakeup() is false.
      The acpi_s2idle_wakeup() returnd false because the acpi_s2idle_sync() has
      alrealdy exited.
      
      [   52.987048] s2idle_loop going s2idle
      [   59.713392] acpi_s2idle_wake enter
      [   59.713394] acpi_s2idle_wake exit
      [   59.760888] acpi_ev_gpe_detect enter
      [   59.760893] acpi_s2idle_sync enter
      [   59.760893] acpi_ec_query_flushed ec pending queries 0
      [   59.760953] Read registers for GPE 50-57: Status=01, Enable=01, RunEnable=01, WakeEnable=00
      [   59.760955] ACPI: EC: ===== IRQ (1) =====
      [   59.760972] ACPI: EC: EC_SC(R) = 0x28 SCI_EVT=1 BURST=0 CMD=1 IBF=0 OBF=0
      [   59.760979] ACPI: EC: +++++ Polling enabled +++++
      [   59.760979] ACPI: EC: ##### Command(QR_EC) submitted/blocked #####
      [   59.761003] acpi_s2idle_sync exit
      [   59.769587] ACPI: EC: ##### Query(0xdf) started #####
      [   59.769611] ACPI: EC: ##### Query(0xdf) stopped #####
      [   59.774154] acpi_button_notify button type 1
      [   59.813175] s2idle_loop going s2idle
      
      acpi_s2idle_sync() already makes an effort to flush the EC event
      queue, but in this case, the EC event has yet to be generated when
      the call to acpi_ec_flush_work() is made. The event is generated
      shortly after, through the ongoing handling of the SCI interrupt
      which is happening on another CPU, and we must synchronize that
      to make sure that it has run and completed. Adding another call to
      acpi_os_wait_events_complete() solves this issue, since that
      function synchronizes with SCI interrupt completion.
      Signed-off-by: NChris Chiu <chiu@endlessm.com>
      [ rjw: Subject ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6f1d7c45
  16. 19 3月, 2018 1 次提交
    • R
      ACPI / PM: Reduce LPI constraints logging noise · fa54150a
      Rafael J. Wysocki 提交于
      If a device referred to by ACPI LPI constrains (coming from function 1
      of the Low Power S0 Idle _DSM interface) is not power-manageable via
      ACPI (no _PS0 method and no power resources), the code generating
      diagnostic information for the LPI constraints will print a message
      about that to the kernel log on every system suspend-resume cycle
      (possibly for multiple times).
      
      That is not very useful and noisy, so modify that code to disregard
      the LPI list entries corresponding to the devices that are not power-
      manageable after printing that information for them once.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      fa54150a
  17. 23 2月, 2018 1 次提交
  18. 22 2月, 2018 1 次提交
    • R
      ACPI / PM: Do not reconfigure GPEs for suspend-to-idle · 147a7d9d
      Rafael J. Wysocki 提交于
      It is reported that commit 235d81a6 (ACPI / PM: Clean up device
      wakeup enable/disable code) broke wakeup from suspend-to-idle on
      some platforms.  That is due to the acpi_enable_all_wakeup_gpes() in
      acpi_s2idle_prepare() which needs acpi_enable_wakeup_devices() to be
      called before it as the latter sets up the GPE masks used by the
      former and commit 235d81a6 removed acpi_enable_wakeup_devices()
      invocation from the suspend-to-idle path.
      
      However, acpi_enable_wakeup_devices() does more than just setting
      the GPE masks and the remaining part of it is not necessary for
      suspend-to-idle.  Moreover, non-wakeup GPEs are disabled on suspend-
      to-idle entry to avoid spurious wakeups, but that should not be
      strictly necessary any more after commit 33e4f80e (ACPI / PM:
      Ignore spurious SCI wakeups from suspend-to-idle) which prevents
      spurious GPE wakeups from resuming the system.  The only consequence
      of leaving non-wakeup GPEs enabled may be more interrupt-related
      activity while suspended, which is not ideal (more energy is used
      if that happens), but it is not critical too.
      
      For this reason, drop the GPE reconfiguration from the suspend-to-idle
      path entirely.
      
      This change also allows Dells XPS13 9360 blacklisted by commit
      71630b7a (ACPI / PM: Blacklist Low Power S0 Idle _DSM for Dell
      XPS13 9360) to use the power button for waking up from suspend-
      to-idle and it helps at least one other older Dell system (the
      wakeup button GPE on that one is not listed in _PRW for any
      devices, so it is not regarded as a wakeup one and gets disabled
      on suspend-to-idle entry today).
      
      Fixes: 235d81a6 (ACPI / PM: Clean up device wakeup enable/disable code)
      Reported-by: NDu Wenkai <wenkai.du@intel.com>
      Tested-by: NDu Wenkai <wenkai.du@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      147a7d9d
  19. 12 1月, 2018 1 次提交
  20. 27 11月, 2017 1 次提交
    • R
      ACPI / PM: Make it possible to ignore the system sleep blacklist · 57044031
      Rafael J. Wysocki 提交于
      The ACPI code supporting system transitions to sleep states uses
      an internal blacklist to apply special handling to some machines
      reported to behave incorrectly in some ways.
      
      However, some entries of that blacklist cover problematic as well as
      non-problematic systems, so give the users of the latter a chance to
      ignore the blacklist and run their systems in the default way by
      adding acpi_sleep=nobl to the kernel command line.
      
      For example, that allows the users of Dell XPS13 9360 systems not
      affected by the issue that caused the blacklist entry for this
      machine to be added by commit 71630b7a (ACPI / PM: Blacklist Low
      Power S0 Idle _DSM for Dell XPS13 9360) to use suspend-to-idle with
      the Low Power S0 Idle _DSM interface which in principle should be
      more energy-efficient than S3 on them.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      57044031
  21. 07 11月, 2017 1 次提交
  22. 14 9月, 2017 1 次提交
  23. 18 8月, 2017 1 次提交
    • S
      ACPI / PM: Check low power idle constraints for debug only · 726fb6b4
      Srinivas Pandruvada 提交于
      For SoC to achieve its lowest power platform idle state a set of hardware
      preconditions must be met. These preconditions or constraints can be
      obtained by issuing a device specific method (_DSM) with function "1".
      Refer to the document provided in the link below.
      
      Here during initialization (from attach() callback of LPS0 device), invoke
      function 1 to get the device constraints. Each enabled constraint is
      stored in a table.
      
      The devices in this table are used to check whether they were in required
      minimum state, while entering suspend. This check is done from platform
      freeze wake() callback, only when /sys/power/pm_debug_messages attribute
      is non zero.
      
      If any constraint is not met and device is ACPI power managed then it
      prints the device information to kernel logs.
      
      Also if debug is enabled in acpi/sleep.c, the constraint table and state
      of each device on wake is dumped in kernel logs.
      
      Since pm_debug_messages_on setting is used as condition to check
      constraints outside kernel/power/main.c, pm_debug_messages_on is changed
      to a global variable.
      
      Link: http://www.uefi.org/sites/default/files/resources/Intel_ACPI_Low_Power_S0_Idle.pdfSigned-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      726fb6b4
  24. 11 8月, 2017 2 次提交
  25. 05 8月, 2017 1 次提交
    • R
      ACPI / PM: Prefer suspend-to-idle over S3 on some systems · e870c6c8
      Rafael J. Wysocki 提交于
      Modify the ACPI system sleep support setup code to select
      suspend-to-idle as the default system sleep state if
      (1) the ACPI_FADT_LOW_POWER_S0 flag is set in the FADT and
      (2) the Low Power Idle S0 _DSM interface has been discovered and
      (3) the default sleep state was not selected from the kernel command
      line.
      
      The main motivation for this change is that systems where the (1) and
      (2) conditions are met typically ship with OSes that don't exercise
      the S3 path in the platform firmware which remains untested and turns
      out to be non-functional at least in some cases.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NMario Limonciello <mario.limonciello@dell.com>
      e870c6c8
  26. 01 8月, 2017 1 次提交
  27. 20 7月, 2017 1 次提交
    • R
      ACPI / PM / EC: Flush all EC work in acpi_freeze_sync() · 880a6627
      Rafael J. Wysocki 提交于
      Commit eed4d47e (ACPI / sleep: Ignore spurious SCI wakeups from
      suspend-to-idle) introduced acpi_freeze_sync() whose purpose is to
      flush all of the processing of possible wakeup events signaled via
      the ACPI SCI.  However, it doesn't flush the query workqueue used
      by the EC driver, so the events generated by the EC may not be
      processed timely which leads to issues (increased overhead at least,
      lost events possibly).
      
      To fix that introduce acpi_ec_flush_work() that will flush all of
      the outstanding EC work and call it from acpi_freeze_sync().
      
      Fixes: eed4d47e (ACPI / sleep: Ignore spurious SCI wakeups from suspend-to-idle)
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      880a6627
  28. 23 6月, 2017 1 次提交
    • R
      ACPI / sleep: EC-based wakeup from suspend-to-idle on recent systems · 8110dd28
      Rafael J. Wysocki 提交于
      Some recent Dell laptops, including the XPS13 model numbers 9360 and
      9365, cannot be woken up from suspend-to-idle by pressing the power
      button which is unexpected and makes that feature less usable on
      those systems.  Moreover, on the 9365 ACPI S3 (suspend-to-RAM) is
      not expected to be used at all (the OS these systems ship with never
      exercises the ACPI S3 path in the firmware) and suspend-to-idle is
      the only viable system suspend mechanism there.
      
      The reason why the power button wakeup from suspend-to-idle doesn't
      work on those systems is because their power button events are
      signaled by the EC (Embedded Controller), whose GPE (General Purpose
      Event) line is disabled during suspend-to-idle transitions in Linux.
      That is done on purpose, because in general the EC tends to be noisy
      for various reasons (battery and thermal updates and similar, for
      example) and all events signaled by it would kick the CPUs out of
      deep idle states while in suspend-to-idle, which effectively might
      defeat its purpose.
      
      Of course, on the Dell systems in question the EC GPE must be enabled
      during suspend-to-idle transitions for the button press events to
      be signaled while suspended at all, but fortunately there is a way
      out of this puzzle.
      
      First of all, those systems have the ACPI_FADT_LOW_POWER_S0 flag set
      in their ACPI tables, which means that the OS is expected to prefer
      the "low power S0 idle" system state over ACPI S3 on them.  That
      causes the most recent versions of other OSes to simply ignore ACPI
      S3 on those systems, so it is reasonable to expect that it should not
      be necessary to block GPEs during suspend-to-idle on them.
      
      Second, in addition to that, the systems in question provide a special
      firmware interface that can be used to indicate to the platform that
      the OS is transitioning into a system-wide low-power state in which
      certain types of activity are not desirable or that it is leaving
      such a state and that (in principle) should allow the platform to
      adjust its operation mode accordingly.
      
      That interface is a special _DSM object under a System Power
      Management Controller device (PNP0D80).  The expected way to use it
      is to invoke function 0 from it on system initialization, functions
      3 and 5 during suspend transitions and functions 4 and 6 during
      resume transitions (to reverse the actions carried out by the
      former).  In particular, function 5 from the "Low-Power S0" device
      _DSM is expected to cause the platform to put itself into a low-power
      operation mode which should include making the EC less verbose (so to
      speak).  Next, on resume, function 6 switches the platform back to
      the "working-state" operation mode.
      
      In accordance with the above, modify the ACPI suspend-to-idle code
      to look for the "Low-Power S0" _DSM interface on platforms with the
      ACPI_FADT_LOW_POWER_S0 flag set in the ACPI tables.  If it's there,
      use it during suspend-to-idle transitions as prescribed and avoid
      changing the GPE configuration in that case.  [That should reflect
      what the most recent versions of other OSes do.]
      
      Also modify the ACPI EC driver to make it handle events during
      suspend-to-idle in the usual way if the "Low-Power S0" _DSM interface
      is going to be used to make the power button events work while
      suspended on the Dell machines mentioned above
      
      Link: http://www.uefi.org/sites/default/files/resources/Intel_ACPI_Low_Power_S0_Idle.pdfSigned-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8110dd28
  29. 15 6月, 2017 2 次提交
    • R
      ACPI / PM: Ignore spurious SCI wakeups from suspend-to-idle · 33e4f80e
      Rafael J. Wysocki 提交于
      The ACPI SCI (System Control Interrupt) is set up as a wakeup IRQ
      during suspend-to-idle transitions and, consequently, any events
      signaled through it wake up the system from that state.  However,
      on some systems some of the events signaled via the ACPI SCI while
      suspended to idle should not cause the system to wake up.  In fact,
      quite often they should just be discarded.
      
      Arguably, systems should not resume entirely on such events, but in
      order to decide which events really should cause the system to resume
      and which are spurious, it is necessary to resume up to the point
      when ACPI SCIs are actually handled and processed, which is after
      executing dpm_resume_noirq() in the system resume path.
      
      For this reasons, add a loop around freeze_enter() in which the
      platforms can process events signaled via multiplexed IRQ lines
      like the ACPI SCI and add suspend-to-idle hooks that can be
      used for this purpose to struct platform_freeze_ops.
      
      In the ACPI case, the ->wake hook is used for checking if the SCI
      has triggered while suspended and deferring the interrupt-induced
      system wakeup until the events signaled through it are actually
      processed sufficiently to decide whether or not the system should
      resume.  In turn, the ->sync hook allows all of the relevant event
      queues to be flushed so as to prevent events from being missed due
      to race conditions.
      
      In addition to that, some ACPI code processing wakeup events needs
      to be modified to use the "hard" version of wakeup triggers, so that
      it will cause a system resume to happen on device-induced wakeup
      events even if the "soft" mechanism to prevent the system from
      suspending is not enabled.  However, to preserve the existing
      behavior with respect to suspend-to-RAM, this only is done in
      the suspend-to-idle case and only if an SCI has occurred while
      suspended.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      33e4f80e
    • R
      ACPI / PM: Clean up device wakeup enable/disable code · 235d81a6
      Rafael J. Wysocki 提交于
      The wakeup.flags.enabled flag in struct acpi_device is not used
      consistently, as there is no reason why it should only apply
      to the enabling/disabling of the wakeup GPE, so put the invocation
      of acpi_enable_wakeup_device_power() under it too.
      
      Moreover, it is not necessary to call
      acpi_enable_wakeup_devices() and acpi_disable_wakeup_devices() for
      suspend-to-idle, so don't do that.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      235d81a6
  30. 07 6月, 2017 1 次提交
  31. 06 5月, 2017 1 次提交
    • R
      ACPI / sleep: Ignore spurious SCI wakeups from suspend-to-idle · eed4d47e
      Rafael J. Wysocki 提交于
      The ACPI SCI (System Control Interrupt) is set up as a wakeup IRQ
      during suspend-to-idle transitions and, consequently, any events
      signaled through it wake up the system from that state.  However,
      on some systems some of the events signaled via the ACPI SCI while
      suspended to idle should not cause the system to wake up.  In fact,
      quite often they should just be discarded.
      
      Arguably, systems should not resume entirely on such events, but in
      order to decide which events really should cause the system to resume
      and which are spurious, it is necessary to resume up to the point
      when ACPI SCIs are actually handled and processed, which is after
      executing dpm_resume_noirq() in the system resume path.
      
      For this reasons, add a loop around freeze_enter() in which the
      platforms can process events signaled via multiplexed IRQ lines
      like the ACPI SCI and add suspend-to-idle hooks that can be
      used for this purpose to struct platform_freeze_ops.
      
      In the ACPI case, the ->wake hook is used for checking if the SCI
      has triggered while suspended and deferring the interrupt-induced
      system wakeup until the events signaled through it are actually
      processed sufficiently to decide whether or not the system should
      resume.  In turn, the ->sync hook allows all of the relevant event
      queues to be flushed so as to prevent events from being missed due
      to race conditions.
      
      In addition to that, some ACPI code processing wakeup events needs
      to be modified to use the "hard" version of wakeup triggers, so that
      it will cause a system resume to happen on device-induced wakeup
      events even if the "soft" mechanism to prevent the system from
      suspending is not enabled (that also helps to catch device-induced
      wakeup events occurring during suspend transitions in progress).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      eed4d47e
  32. 02 5月, 2017 1 次提交
    • H
      ACPI / power: Delay turning off unused power resources after suspend · 8ece1d83
      Hans de Goede 提交于
      Commit 660b1113 (ACPI / PM: Fix consistency check for power resources
      during resume) introduced a check for ACPI power resources which have
      been turned on by the BIOS during suspend and turns these back off again.
      
      This is causing problems on a Dell Venue Pro 11 7130 (i5-4300Y) it causes
      the following messages to show up in dmesg:
      
      [  131.014605] ACPI: Waking up from system sleep state S3
      [  131.150271] acpi LNXPOWER:07: Turning OFF
      [  131.150323] acpi LNXPOWER:06: Turning OFF
      [  131.150911] acpi LNXPOWER:00: Turning OFF
      [  131.169014] ACPI : EC: interrupt unblocked
      [  131.181811] xhci_hcd 0000:00:14.0: System wakeup disabled by ACPI
      [  133.535728] pci_raw_set_power_state: 76 callbacks suppressed
      [  133.535735] iwlwifi 0000:01:00.0: Refused to change power state,
                     currently in D3
      [  133.597672] PM: noirq resume of devices complete after 2428.891 msecs
      
      Followed by a bunch of iwlwifi errors later on and the pcie device
      dropping from the bus (acpiphp thinks it has been unplugged).
      
      Disabling the turning off of unused power resources fixes this. Instead
      of adding a quirk for this system, this commit fixes this by moving the
      disabling of unused power resources to later in the resume sequence
      when the iwlwifi card has been moved out of D3 so the ref_count for
      its power resource no longer is 0.
      
      This new behavior seems to match the intend of the original commit which
      commit-msg says: "(... which means that no devices are going to need them
      any time soon) and we should turn them off".
      
      This also avoids power resources which we need when bringing devices out
      of D3 from getting bounced off and then back on again.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8ece1d83
  33. 01 2月, 2017 1 次提交
  34. 20 1月, 2017 1 次提交