1. 08 8月, 2019 4 次提交
  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 6 次提交
    • 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
    • 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
    • R
      PM: sleep: Fix possible overflow in pm_system_cancel_wakeup() · 2933954b
      Rafael J. Wysocki 提交于
      It is not actually guaranteed that pm_abort_suspend will be
      nonzero when pm_system_cancel_wakeup() is called which may lead to
      subtle issues, so make it use atomic_dec_if_positive() instead of
      atomic_dec() for the safety sake.
      
      Fixes: 33e4f80e ("ACPI / PM: Ignore spurious SCI wakeups from suspend-to-idle")
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      2933954b
    • R
      ACPI: EC: Return bool from acpi_ec_dispatch_gpe() · 9089f16e
      Rafael J. Wysocki 提交于
      On some systems, if suspend-to-idle is used, the EC may signal system
      wakeup events (power button events, for example) as well as events
      that should not cause the system to resume and acpi_ec_dispatch_gpe()
      needs to be called to determine whether or not the system should
      resume then.  In particular, if acpi_ec_dispatch_gpe() doesn't detect
      any EC events at all, the system should remain suspended, so it is
      useful to know when that is the case.
      
      For this reason, make acpi_ec_dispatch_gpe() return a bool value
      indicating whether or not any EC events have been detected by it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      9089f16e
    • R
      ACPICA: Return u32 from acpi_dispatch_gpe() · 6921de89
      Rafael J. Wysocki 提交于
      In some cases it is useful to know whether or not the
      acpi_ev_detect_gpe() called by acpi_dispatch_gpe() has found
      the GPE to be active, so return the return value of it (whose
      data type is u32) from latter.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      6921de89
  4. 22 7月, 2019 1 次提交
    • Q
      iommu/amd: fix a crash in iova_magazine_free_pfns · 8cf66504
      Qian Cai 提交于
      The commit b3aa14f0 ("iommu: remove the mapping_error dma_map_ops
      method") incorrectly changed the checking from dma_ops_alloc_iova() in
      map_sg() causes a crash under memory pressure as dma_ops_alloc_iova()
      never return DMA_MAPPING_ERROR on failure but 0, so the error handling
      is all wrong.
      
         kernel BUG at drivers/iommu/iova.c:801!
          Workqueue: kblockd blk_mq_run_work_fn
          RIP: 0010:iova_magazine_free_pfns+0x7d/0xc0
          Call Trace:
           free_cpu_cached_iovas+0xbd/0x150
           alloc_iova_fast+0x8c/0xba
           dma_ops_alloc_iova.isra.6+0x65/0xa0
           map_sg+0x8c/0x2a0
           scsi_dma_map+0xc6/0x160
           pqi_aio_submit_io+0x1f6/0x440 [smartpqi]
           pqi_scsi_queue_command+0x90c/0xdd0 [smartpqi]
           scsi_queue_rq+0x79c/0x1200
           blk_mq_dispatch_rq_list+0x4dc/0xb70
           blk_mq_sched_dispatch_requests+0x249/0x310
           __blk_mq_run_hw_queue+0x128/0x200
           blk_mq_run_work_fn+0x27/0x30
           process_one_work+0x522/0xa10
           worker_thread+0x63/0x5b0
           kthread+0x1d2/0x1f0
           ret_from_fork+0x22/0x40
      
      Fixes: b3aa14f0 ("iommu: remove the mapping_error dma_map_ops method")
      Signed-off-by: NQian Cai <cai@lca.pw>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8cf66504
  5. 19 7月, 2019 28 次提交