1. 22 6月, 2021 1 次提交
  2. 07 6月, 2021 1 次提交
  3. 22 5月, 2021 1 次提交
  4. 24 11月, 2020 5 次提交
  5. 23 11月, 2020 1 次提交
    • S
      ACPI: EC: Eliminate in_interrupt() usage · 2e84ea5a
      Sebastian Andrzej Siewior 提交于
      advance_transaction() is using in_interrupt() to distinguish between
      an invocation from the interrupt handler and an invocation from
      another part of the stack.
      
      This looks misleading because chains like
      
        acpi_update_all_gpes() -> acpi_ev_gpe_detect() ->
        acpi_ev_detect_gpe() -> acpi_ec_gpe_handler()
      
      should probably also behave as if they were called from an interrupt
      handler.
      
      Replace in_interrupt() usage with a function parameter.
      
      Set this parameter to `true' if invoked from an interrupt handler
      (acpi_ec_gpe_handler() and acpi_ec_irq_handler()) and `false'
      otherwise.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      [ rjw: Subject edits ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      2e84ea5a
  6. 06 10月, 2020 2 次提交
  7. 22 6月, 2020 1 次提交
  8. 25 5月, 2020 1 次提交
  9. 18 5月, 2020 1 次提交
    • R
      ACPI: EC: PM: Avoid flushing EC work when EC GPE is inactive · 607b9df6
      Rafael J. Wysocki 提交于
      Flushing the EC work while suspended to idle when the EC GPE status
      is not set causes some EC wakeup events (notably power button and
      lid ones) to be missed after a series of spurious wakeups on the Dell
      XPS13 9360 in my office.
      
      If that happens, the machine cannot be woken up from suspend-to-idle
      by the power button or lid status change and it needs to be woken up
      in some other way (eg. by a key press).
      
      Flushing the EC work only after successful dispatching the EC GPE,
      which means that its status has been set, avoids the issue, so change
      the code in question accordingly.
      
      Fixes: 7b301750 ("ACPI: EC: PM: Avoid premature returns from acpi_s2idle_wake()")
      Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NChris Chiu <chiu@endlessm.com>
      607b9df6
  10. 14 5月, 2020 1 次提交
  11. 11 5月, 2020 1 次提交
  12. 09 5月, 2020 1 次提交
  13. 06 4月, 2020 1 次提交
  14. 25 3月, 2020 1 次提交
  15. 14 3月, 2020 4 次提交
    • R
      ACPI: EC: Eliminate EC_FLAGS_QUERY_HANDSHAKE · b1e14999
      Rafael J. Wysocki 提交于
      The EC_FLAGS_QUERY_HANDSHAKE switch is never set in the current
      code (the only function setting it is defined under #if 0) and
      has no effect whatever, so eliminate it and drop the code
      depending on it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      b1e14999
    • R
      ACPI: EC: Do not clear boot_ec_is_ecdt in acpi_ec_add() · 65a691f5
      Rafael J. Wysocki 提交于
      The reason for clearing boot_ec_is_ecdt in acpi_ec_add() (if a
      PNP0C09 device object matching the ECDT boot EC had been found in
      the namespace) was to cause acpi_ec_ecdt_start() to return early,
      but since the latter does not look at boot_ec_is_ecdt any more,
      acpi_ec_add() need not clear it.
      
      Moreover, doing that may be confusing as it may cause "DSDT" to be
      printed instead of "ECDT" in the EC initialization completion
      message, so stop doing it.
      
      While at it, split the EC initialization completion message into
      two messages, one regarding the boot EC and another one printed
      regardless of whether or not the EC at hand is the boot one.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      65a691f5
    • R
      ACPI: EC: Simplify acpi_ec_ecdt_start() and acpi_ec_init() · 98ada3c5
      Rafael J. Wysocki 提交于
      Notice that the return value of acpi_ec_init() is discarded anyway,
      so it can be void and it doesn't need to check the return values of
      acpi_bus_register_driver() and acpi_ec_ecdt_start() called by it.
      Thus the latter can be void too and it really has nothing to do
      if acpi_ec_add() has already found an EC matching the boot one in the
      namespace.  Also, acpi_ec_ecdt_get_handle() can be folded into it.
      
      Modify the code accordingly and while at it create a propoer kerneldoc
      comment to document acpi_ec_ecdt_start() and move the remark regarding
      ASUS X550ZE along with the related bug URL from acpi_ec_init() into
      that comment.
      
      Additionally, fix up a stale comment in acpi_ec_init().
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      98ada3c5
    • R
      ACPI: EC: Consolidate event handler installation code · 03e9a0e0
      Rafael J. Wysocki 提交于
      Commit 406857f7 ("ACPI: EC: add support for hardware-reduced
      systems") made ec_install_handlers() return an error on failures
      to configure a GPIO IRQ for the EC, but that is inconsistent with
      the handling of the GPE event handler installation failures even
      though it is exactly the same issue and the driver can respond to
      it in the same way in both cases (the EC can be actively polled
      for events through its registers if the event handler installation
      fails).
      
      Moreover, it requires acpi_ec_add() to take that special case into
      account and disagrees with the ec_install_handlers() header comment.
      
      For this reason, rework the event handler installation code in
      ec_install_handlers() to explicitly take deferred probing (that
      may be needed in the GPIO IRQ case) into account and to avoid
      failing the EC initialization in any other case.
      
      Among other things, reduce code duplication between
      install_gpe_event_handler() and install_gpio_irq_event_handler() by
      moving some code from there into ec_install_handlers() itself and
      simplify the error code path in acpi_ec_add().
      
      While at it, turn the ec_install_handlers() header comment into
      a proper kerneldoc one and add some general control flow information
      to it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NJian-Hong Pan <jian-hong@endlessm.com>
      03e9a0e0
  16. 02 3月, 2020 2 次提交
    • R
      ACPI: EC: Use fast path in acpi_ec_add() for DSDT boot EC · 3d9b8dd8
      Rafael J. Wysocki 提交于
      If the boot EC comes from the DSDT, its ACPI handle is equal to the
      handle of a device object with the PNP0C09 device ID.  If that
      device object is passed to acpi_ec_add(), it is not necessary to
      allocate a new EC structure for it and parse it, because that has
      been done already, so change the function to use the fast path in
      that case.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      3d9b8dd8
    • R
      ACPI: EC: Simplify acpi_ec_add() · e3cfabcd
      Rafael J. Wysocki 提交于
      First, notice that if the device ID in acpi_ec_add() is equal to
      ACPI_ECDT_HID, boot_ec_is_ecdt must be set, because this means
      that the device object passed to acpi_ec_add() comes from
      acpi_ec_ecdt_start() which fails if boot_ec_is_ecdt is unset.
      Accordingly, boot_ec_is_ecdt need not be set again in that case,
      so drop that redundant update of it from the code.
      
      Next, ec->handle must be a valid ACPI handle right before
      returning 0 from acpi_ec_add(), because it either is the handle
      of the device object passed to that function, or it is the boot EC
      handle coming from acpi_ec_ecdt_start() which fails if it cannot
      find a valid handle for the boot EC.  Moreover, the object with
      that handle is regarded as a valid representation of the EC in all
      cases, so there is no reason to avoid the _DEP list update walk if
      that handle is the boot EC handle.  Accordingly, drop the dep_update
      local variable from acpi_ec_add() and call acpi_walk_dep_device_list()
      for ec->handle unconditionally before returning 0 from it.
      
      Finally, the ec local variable in acpi_ec_add() need not be
      initialized to NULL and the status local variable declaration
      can be moved to the block in which it is used, so change the code
      in accordance with these observations.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      e3cfabcd
  17. 28 2月, 2020 3 次提交
    • R
      ACPI: EC: Drop AE_NOT_FOUND special case from ec_install_handlers() · 7247f0c2
      Rafael J. Wysocki 提交于
      If the status value returned by acpi_install_address_space_handler()
      in ec_install_handlers() is AE_NOT_FOUND, it is treated in a special
      way, apparently because it might mean a _REG method evaluation
      failure (at least that is the case according to the comment in
      there), but acpi_install_address_space_handler() does not take
      _REG evaluation errors into account at all, so the AE_NOT_FOUND
      special handling is confusing at best.
      
      For this reason, change ec_install_handlers() to stop the EC and
      return -ENODEV on all acpi_install_address_space_handler() errors.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      7247f0c2
    • R
      ACPI: EC: Avoid passing redundant argument to functions · a2b69177
      Rafael J. Wysocki 提交于
      After commit 406857f7 ("ACPI: EC: add support for hardware-reduced
      systems") the handle_events argument passed to ec_install_handlers()
      and acpi_ec_setup() is redundant, because it is always 'false' when
      the device argument passed to them in NULL and it is always 'true'
      otherwise, so the device argument can be tested against NULL instead
      of testing the handle_events one.
      
      Accordingly, modify ec_install_handlers() and acpi_ec_setup() to take
      two arguments and reduce the number of checks in the former.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      a2b69177
    • R
      ACPI: EC: Avoid printing confusing messages in acpi_ec_setup() · c823c17a
      Rafael J. Wysocki 提交于
      It doesn't really make sense to pass ec->handle of the ECDT EC to
      acpi_handle_info(), because it is set to ACPI_ROOT_OBJECT in
      acpi_ec_ecdt_probe(), so rework acpi_ec_setup() to avoid using
      acpi_handle_info() for printing messages.
      
      First, notice that the "Used as first EC" message is not really
      useful, because it is immediately followed by a more meaningful one
      from either acpi_ec_ecdt_probe() or acpi_ec_dsdt_probe() (the latter
      also includes the EC object path), so drop it altogether.
      
      Second, use pr_info() for printing the EC configuration information.
      
      While at it, make the code in question avoid printing invalid GPE or
      IRQ numbers and make it print the GPE/IRQ information only when the
      driver is ready to handle events.
      
      Fixes: 72c77b7e ("ACPI / EC: Cleanup first_ec/boot_ec code")
      Fixes: 406857f7 ("ACPI: EC: add support for hardware-reduced systems")
      Cc: 5.5+ <stable@vger.kernel.org> # 5.5+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      c823c17a
  18. 11 2月, 2020 1 次提交
    • R
      ACPI: EC: Fix flushing of pending work · f0ac20c3
      Rafael J. Wysocki 提交于
      Commit 016b87ca ("ACPI: EC: Rework flushing of pending work")
      introduced a subtle bug into the flushing of pending EC work while
      suspended to idle, which may cause the EC driver to fail to
      re-enable the EC GPE after handling a non-wakeup event (like a
      battery status change event, for example).
      
      The problem is that the work item flushed by flush_scheduled_work()
      in __acpi_ec_flush_work() may disable the EC GPE and schedule another
      work item expected to re-enable it, but that new work item is not
      flushed, so __acpi_ec_flush_work() returns with the EC GPE disabled
      and the CPU running it goes into an idle state subsequently.  If all
      of the other CPUs are in idle states at that point, the EC GPE won't
      be re-enabled until at least one CPU is woken up by another interrupt
      source, so system wakeup events that would normally come from the EC
      then don't work.
      
      This is reproducible on a Dell XPS13 9360 in my office which
      sometimes stops reacting to power button and lid events (triggered
      by the EC on that machine) after switching from AC power to battery
      power or vice versa while suspended to idle (each of those switches
      causes the EC GPE to trigger for several times in a row, but they
      are not system wakeup events).
      
      To avoid this problem, it is necessary to drain the workqueue
      entirely in __acpi_ec_flush_work(), but that cannot be done with
      respect to system_wq, because work items may be added to it from
      other places while __acpi_ec_flush_work() is running.  For this
      reason, make the EC driver use a dedicated workqueue for EC events
      processing (let that workqueue be ordered so that EC events are
      processed sequentially) and use drain_workqueue() on it in
      __acpi_ec_flush_work().
      
      Fixes: 016b87ca ("ACPI: EC: Rework flushing of pending work")
      Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f0ac20c3
  19. 27 12月, 2019 1 次提交
  20. 02 12月, 2019 1 次提交
    • R
      ACPI: EC: Rework flushing of pending work · 016b87ca
      Rafael J. Wysocki 提交于
      There is a race condition in the ACPI EC driver, between
      __acpi_ec_flush_event() and acpi_ec_event_handler(), that may
      cause systems to stay in suspended-to-idle forever after a wakeup
      event coming from the EC.
      
      Namely, acpi_s2idle_wake() calls acpi_ec_flush_work() to wait until
      the delayed work resulting from the handling of the EC GPE in
      acpi_ec_dispatch_gpe() is processed, and that function invokes
      __acpi_ec_flush_event() which uses wait_event() to wait for
      ec->nr_pending_queries to become zero on ec->wait, and that wait
      queue may be woken up too early.
      
      Suppose that acpi_ec_dispatch_gpe() has caused acpi_ec_gpe_handler()
      to run, so advance_transaction() has been called and it has invoked
      acpi_ec_submit_query() to queue up an event work item, so
      ec->nr_pending_queries has been incremented (under ec->lock).  The
      work function of that work item, acpi_ec_event_handler() runs later
      and calls acpi_ec_query() to process the event.  That function calls
      acpi_ec_transaction() which invokes acpi_ec_transaction_unlocked()
      and the latter wakes up ec->wait under ec->lock, but it drops that
      lock before returning.
      
      When acpi_ec_query() returns, acpi_ec_event_handler() acquires
      ec->lock and decrements ec->nr_pending_queries, but at that point
      __acpi_ec_flush_event() (woken up previously) may already have
      acquired ec->lock, checked the value of ec->nr_pending_queries (and
      it would not have been zero then) and decided to go back to sleep.
      Next, if ec->nr_pending_queries is equal to zero now, the loop
      in acpi_ec_event_handler() terminates, ec->lock is released and
      acpi_ec_check_event() is called, but it does nothing unless
      ec_event_clearing is equal to ACPI_EC_EVT_TIMING_EVENT (which is
      not the case by default).  In the end, if no more event work items
      have been queued up while executing acpi_ec_transaction_unlocked(),
      there is nothing to wake up __acpi_ec_flush_event() again and it
      sleeps forever, so the suspend-to-idle loop cannot make progress and
      the system is permanently suspended.
      
      To avoid this issue, notice that it actually is not necessary to
      wait for ec->nr_pending_queries to become zero in every case in
      which __acpi_ec_flush_event() is used.
      
      First, during platform-based system suspend (not suspend-to-idle),
      __acpi_ec_flush_event() is called by acpi_ec_disable_event() after
      clearing the EC_FLAGS_QUERY_ENABLED flag, which prevents
      acpi_ec_submit_query() from submitting any new event work items,
      so calling flush_scheduled_work() and flushing ec_query_wq
      subsequently (in order to wait until all of the queries in that
      queue have been processed) would be sufficient to flush all of
      the pending EC work in that case.
      
      Second, the purpose of the flushing of pending EC work while
      suspended-to-idle described above really is to wait until the
      first event work item coming from acpi_ec_dispatch_gpe() is
      complete, because it should produce system wakeup events if
      that is a valid EC-based system wakeup, so calling
      flush_scheduled_work() followed by flushing ec_query_wq is also
      sufficient for that purpose.
      
      Rework the code to follow the above observations.
      
      Fixes: 56b99184 ("PM: sleep: Simplify suspend-to-idle control flow")
      Reported-by: NKenneth R. Crudup <kenny@panix.com>
      Tested-by: NKenneth R. Crudup <kenny@panix.com>
      Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      016b87ca
  21. 28 10月, 2019 2 次提交
  22. 22 8月, 2019 1 次提交
  23. 08 8月, 2019 4 次提交
  24. 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
  25. 23 7月, 2019 1 次提交
    • 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