25 Mar, 2020

1 commit

  • The check carried out by acpi_any_gpe_status_set() is not precise enough
    for the suspend-to-idle implementation in Linux and in some cases it is
    necessary make it skip one GPE (specifically, the EC GPE) from the check
    to prevent a race condition leading to a premature system resume from
    occurring.

    For this reason, redefine acpi_any_gpe_status_set() to take the number
    of a GPE to skip as an argument.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=206629
    Tested-by: Ondřej Caletka
    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

12 Feb, 2020

1 commit

  • Introduce a new helper function, acpi_any_gpe_status_set(), for
    checking the status bits of all enabled GPEs in one go.

    It is needed to distinguish spurious SCIs from genuine ones when
    deciding whether or not to wake up the system from suspend-to-idle.

    Cc: 5.4+ # 5.4+
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

13 Jan, 2020

1 commit


23 Jul, 2019

1 commit


19 Jun, 2019

1 commit

  • ACPI GPEs (other than the EC one) can be enabled in two situations.
    First, the GPEs with existing _Lxx and _Exx methods are enabled
    implicitly by ACPICA during system initialization. Second, the
    GPEs without these methods (like GPEs listed by _PRW objects for
    wakeup devices) need to be enabled directly by the code that is
    going to use them (e.g. ACPI power management or device drivers).

    In the former case, if the status of a given GPE is set to start
    with, its handler method (either _Lxx or _Exx) needs to be invoked
    to take care of the events (possibly) signaled before the GPE was
    enabled. In the latter case, however, the first caller of
    acpi_enable_gpe() for a given GPE should not be expected to care
    about any events that might be signaled through it earlier. In
    that case, it is better to clear the status of the GPE before
    enabling it, to prevent stale events from triggering unwanted
    actions (like spurious system resume, for example).

    For this reason, modify acpi_ev_add_gpe_reference() to take an
    additional boolean argument indicating whether or not the GPE
    status needs to be cleared when its reference counter changes from
    zero to one and make acpi_enable_gpe() pass TRUE to it through
    that new argument.

    Fixes: 18996f2db918 ("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume")
    Reported-by: Furquan Shaikh
    Tested-by: Furquan Shaikh
    Tested-by: Mika Westerberg
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

25 Feb, 2019

1 commit


16 Jan, 2019

1 commit


25 May, 2018

1 commit

  • Introduce acpi_dispatch_gpe() as a wrapper around acpi_ev_detect_gpe()
    for checking if the given GPE (as represented by a GPE device handle
    and a GPE number) is currently active and dispatching it (if that's
    the case) outside of interrupt context.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

19 Mar, 2018

2 commits

  • Signed-off-by: Erik Schmauss
    Signed-off-by: Rafael J. Wysocki

    Erik Schmauss
     
  • After being enabled for the first time, the GPEs may have STS bits already
    set. Setting EN bits is not sufficient to trigger the GPEs again, so this
    patch polls GPEs after enabling them for the first time.
    This is a cleaner version on top of the "GPE clear" fix generated according
    to Mika's report and Rafael's original Linux based fix. Based on Linux
    commit originated from Rafael J. Wysocki, fixed by Lv Zheng.

    Signed-off-by: Lv Zheng
    Signed-off-by: Erik Schmauss
    Signed-off-by: Rafael J. Wysocki

    Erik Schmauss
     

06 Feb, 2018

1 commit


18 Aug, 2017

1 commit

  • Runtime GPEs have corresponding _Lxx/_Exx methods and are enabled
    automatically during the initialization of the ACPI subsystem through
    acpi_update_all_gpes() with the assumption that acpi_setup_gpe_for_wake()
    will be called in advance for all of the GPEs pointed to by _PRW
    objects in the namespace that may be affected by acpi_update_all_gpes().
    That is, acpi_ev_initialize_gpe_block() can only be called for a GPE
    block after acpi_setup_gpe_for_wake() has been called for all of the
    _PRW (wakeup) GPEs in it.

    The platform firmware on some systems, however, expects GPEs to be
    enabled before the enumeration of devices which is when
    acpi_setup_gpe_for_wake() is called and that goes against the above
    assumption.

    For this reason, introduce a new flag to be set by
    acpi_ev_initialize_gpe_block() when automatically enabling a GPE
    to indicate to acpi_setup_gpe_for_wake() that it needs to drop the
    reference to the GPE coming from acpi_ev_initialize_gpe_block()
    and modify acpi_setup_gpe_for_wake() accordingly. These changes
    allow acpi_setup_gpe_for_wake() and acpi_ev_initialize_gpe_block()
    to be invoked in any order.

    Signed-off-by: Rafael J. Wysocki
    Tested-by: Mika Westerberg

    Rafael J. Wysocki
     

09 Feb, 2017

1 commit


13 Aug, 2016

1 commit

  • ACPICA commit 23a417ca406a527e7ae1710893e59a8b6db30e14

    There is a facility in Linux, developers can control the enabling/disabling
    of a GPE via /sys/firmware/acpi/interrupts/gpexx. This is mainly for
    debugging purposes.

    But many users expect to use this facility to implement quirks to mask a
    specific GPE when there is a gap in Linux causing this GPE to flood. This
    is not working correctly because currently this facility invokes
    enabling/disabling counting based GPE driver APIs:
    acpi_enable_gpe()/acpi_disable_gpe()
    and the GPE drivers can still affect the count to mess up the GPE
    masking purposes.

    However, most of the IRQ chip designs allow masking/unmasking IRQs via a
    masking bit which is different from the enabled bit to achieve the same
    purpose. But the GPE hardware doesn't contain such a feature, this brings
    the trouble.

    In this patch, we introduce a software mechanism to implement the GPE
    masking feature, and acpi_mask_gpe() are provided to the OSPMs to
    mask/unmask GPEs in the above mentioned situation instead of
    acpi_enable_gpe()/acpi_disable_gpe(). ACPICA BZ 1102. Lv Zheng.

    Link: https://github.com/acpica/acpica/commit/23a417ca
    Link: https://bugs.acpica.org/show_bug.cgi?id=1102
    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

05 May, 2016

1 commit

  • ACPICA commit b2294cae776f5a66a7697414b21949d307e6856f

    This patch removes unwanted spaces for typedef. This solution doesn't cover
    function types.

    Note that the linuxize result of this commit is very giant and should have
    many conflicts against the current Linux upstream. Thus it is required to
    modify the linuxize result of this commit and the commits around it
    manually in order to have them merged to the Linux upstream. Since this is
    very costy, we should do this only once, and if we can't ensure to do this
    only once, we need to revert the Linux code to the wrong indentation result
    before merging the linuxize result of this commit. Lv Zheng.

    Link: https://github.com/acpica/acpica/commit/b2294cae
    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

16 Jan, 2016

1 commit


05 Feb, 2015

5 commits

  • ACPICA commit da9a83e1a845f2d7332bdbc0632466b2595e5424

    For acpi_set_gpe()/acpi_enable_gpe(), our target is to purify them to be APIs
    that can be used for various GPE handling models, so we need them to be
    pure GPE enabling APIs. GPE enabling/disabling has 2 use cases:
    1. Driver may permanently enable/disable GPEs according to the usage
    counts.
    1. When upper layers (the users of the driver) submit requests to the
    driver, it means they care about the underlying hardware. GPE need
    to be enabled for the first request submission and disabled for the
    last request completion.
    2. When the GPE is shared between 2+ silicon logics. GPE need to be
    enabled for either silicon logic's driver and disabled when all of
    the drivers are not started.
    For these cases, acpi_enable_gpe()/acpi_disable_gpe() should be used. When
    the usage count is increased from 0 to 1, the GPE is enabled and it is
    disabled when the usage count is decrased from 1 to 0.
    2. Driver may temporarily disables the GPE to enter an GPE polling mode and
    wants to re-enable it later.
    1. Prevent GPE storming: when a driver cannot fully solve the condition
    that triggered the GPE in the GPE context, in order not to trigger
    GPE storm, driver has to disable GPE to switch into the polling mode
    and re-enables it in the non interrupt context after the storming
    condition is cleared.
    2. Meet throughput requirement: some IO drivers need to poll hardware
    again and again until nothing indicated instead of just handling once
    for one interruption, this need to be done in the polling mode or the
    IO flood may prevent the GPE handler from returning.
    3. Meet realtime requirement: in order not to block CPU to handle higher
    realtime prioritized GPEs, lower priority GPEs can be handled in the
    polling mode.
    For these cases, acpi_set_gpe() should be used to switch to/from the
    polling mode.

    This patch adds unconditional GPE enabling support into acpi_set_gpe() so
    that this API can be used by the drivers to switch back from the GPE
    polling mode unconditionally.

    Originally this function includes GPE clearing logic in it.
    First, the GPE clearing is typically used in the GPE handling code to:
    1. Acknowledge the GPE when we know there is an edge triggered GPE raised
    and is about to handle it, otherwise the unexpected clearing may lead to
    a GPE loss;
    2. Issue actions after we have handled a level triggered GPE, otherwise
    the unexpected clearing may trigger unwanted OSPM actions to the
    hardware (for example, clocking in out-dated write FIFO data).
    Thus the GPE clearing is not suitable to be used in the GPE enabling APIs.
    Second, the combination of acknowledging and enabling may also not be
    expected by the hardware drivers. For GPE clearing, we have a seperate API
    acpi_clear_gpe(). There are cases drivers do want the 2 operations to be
    split. So splitting these 2 operations could facilitates drivers the
    maximum possibilities to achieve success. For a combined one, we already
    have acpi_finish_gpe() ready to be invoked.

    Given the fact that drivers should complete all outstanding requests before
    putting themselves into the sleep states, as this API is executed for
    outstanding requests, it should also have nothing to do with the
    "RUN"/"WAKE" distinguishing. That's why the acpi_set_gpe(ACPI_GPE_ENABLE)
    should not be implemented by acpi_hw_low_set_gpe(ACPI_GPE_CONDITIONAL_ENABLE).

    This patch thus converts acpi_set_gpe(ACPI_GPE_ENABLE) into
    acpi_hw_low_set_gpe(ACPI_GPE_ENABLE) to achieve a seperate GPE enabling API.
    Drivers then are encouraged to use this API when they need to switch
    to/from the GPE polling mode.

    Note that the acpi_set_gpe()/acpi_finish_gpe() should be first introduced to
    Linux using a divergence reduction patch before sending a linuxized version
    of this patch. Lv Zheng.

    Link: https://github.com/acpica/acpica/commit/da9a83e1
    Signed-off-by: Lv Zheng
    Signed-off-by: David E. Box
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • This can help to reduce source code differences between Linux and ACPICA
    upstream. Further driver cleanups also require these APIs to eliminate GPE
    storms.
    1. acpi_set_gpe(): An API that driver should invoke in the case it wants
    to disable/enable IRQ without honoring the reference
    count implemented in the acpi_disable_gpe() and
    acpi_enable_gpe(). Note that this API should only be
    invoked inside a acpi_enable_gpe()/acpi_disable_gpe()
    pair.
    2. acpi_finish_gpe(): Drivers returned ACPI_REENABLE_GPE unset from the
    GPE handler should use this API instead of
    invoking acpi_set_gpe()/acpi_enable_gpe() to
    re-enable the GPE.
    The GPE APIs can be invoked inside of a GPE handler or in the task context
    with a driver provided lock held. This driver provided lock is safe to be
    held in the GPE handler by the driver.

    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • ACPICA commit 8990e73ab2aa15d6a0068b860ab54feff25bee36

    Link: https://github.com/acpica/acpica/commit/8990e73a
    Signed-off-by: David E. Box
    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    David E. Box
     
  • ACPICA commit 7926d5ca9452c87f866938dcea8f12e1efb58f89

    There is an issue in acpi_install_gpe_handler() and acpi_remove_gpe_handler().
    The code to obtain the GPE dispatcher type from the Handler->original_flags
    is wrong:
    if (((Handler->original_flags & ACPI_GPE_DISPATCH_METHOD) ||
    (Handler->original_flags & ACPI_GPE_DISPATCH_NOTIFY)) &&
    ACPI_GPE_DISPATCH_NOTIFY is 0x03 and ACPI_GPE_DISPATCH_METHOD is 0x02, thus
    this statement is TRUE for the following dispatcher types:
    0x01 (ACPI_GPE_DISPATCH_HANDLER): not expected
    0x02 (ACPI_GPE_DISPATCH_METHOD): expected
    0x03 (ACPI_GPE_DISPATCH_NOTIFY): expected

    There is no functional issue due to this because Handler->original_flags is
    only set in acpi_install_gpe_handler(), and an earlier checker has excluded
    the ACPI_GPE_DISPATCH_HANDLER:
    if ((gpe_event_info->Flags & ACPI_GPE_DISPATCH_MASK) ==
    ACPI_GPE_DISPATCH_HANDLER)
    {
    Status = AE_ALREADY_EXISTS;
    goto free_and_exit;
    }
    ...
    Handler->original_flags = (u8) (gpe_event_info->Flags &
    (ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK));

    We need to clean this up before modifying the GPE dispatcher type values.

    In order to prevent such issue from happening in the future, this patch
    introduces ACPI_GPE_DISPATCH_TYPE() macro to be used to obtain the GPE
    dispatcher types. Lv Zheng.

    Link: https://github.com/acpica/acpica/commit/7926d5ca
    Signed-off-by: Lv Zheng
    Signed-off-by: David E. Box
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • This is a back port result of the Linux commit:
    Commit c50f13c672df758b59e026c15b9118f3ed46edc4
    Subject: ACPICA: Save current masks of enabled GPEs after enable register writes

    Besides of the indent divergences, only a missing prototype added due to
    the ACPICA internal coding style.

    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

21 Oct, 2014

2 commits

  • This patch is a partial linuxized result of the following ACPICA commit:
    ACPICA commit: a73b66c6aa1846d055bb6390d9c9b9902f7d804d
    Subject: Add "has handler" flag to event/gpe status interfaces.
    This change adds a new flag, ACPI_EVENT_FLAGS_HAS_HANDLER to the
    acpi_get_event_status and acpi_get_gpe_status external interfaces. It
    is set if the event/gpe currently has a handler associated with it.
    This commit back ports ACPI_EVENT_FLAG_HANDLE from Linux upstream to
    ACPICA, the flag along with its support code currently can only be found
    in the Linux upstream and is used by the ACPI sysfs GPE interfaces and
    the ACPI bus scanning support.

    Link: https://github.com/acpica/acpica/commit/a73b66c6
    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • This patch reduces indent divergences first in order to reduce human
    intervention work for the follow-up linuxized event patches.

    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

01 Oct, 2014

1 commit


24 Jul, 2014

2 commits

  • ACPICA commit c49dbfed2bc069d0038ea7e1294409bfde7c2c8c

    Some potential callers of acpi_setup_gpe_for_wake may know in advance that
    there won't be any notify handlers installed for device wake notifications
    from the given GPE (one example is a button GPE in Linux). For these cases,
    acpi_mark_gpe_for_wake should be used instead of acpi_setup_gpe_for_wake.
    This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
    setup implicit wake notification for it (since there's no handler method).
    Rafael Wysocki.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng

    Rafael J. Wysocki
     
  • ACPICA commit 23b5a8542283af28c3a3a4e3f81096d6e2569faa

    There is no point in enabling a GPE that has no handler or
    GPE method. At worst, it can cause GPE floods.
    Rafael Wysocki.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng

    Rafael J. Wysocki
     

07 May, 2014

1 commit


11 Feb, 2014

2 commits


31 Oct, 2013

2 commits

  • It is reported by kernel build test systems that all ACPICA source
    files in the kernel tree have incorrect label indentation. This
    patch changes default indent option used in the release process to
    fix this bug. Lv Zheng.

    Signed-off-by: Lv Zheng
    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • For Linux, there are no functional changes/binary generation differences
    introduced by this patch.

    This change adds a new macro to all files that contain external ACPICA
    interfaces. It can be detected and used by the host (via the host-specific
    header) for any special processing required for such modules. Lv Zheng.

    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

16 Jun, 2013

1 commit

  • After many years, different formatting for switch() has crept in.
    This change makes every switch block identical. Chao Guan.
    ACPICA bugzilla 997.

    References: https://bugs.acpica.org/show_bug.cgi?id=997
    Signed-off-by: Chao Guan
    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Chao Guan
     

25 Jan, 2013

1 commit


10 Jan, 2013

2 commits

  • This is a cosmetic patch only. Comparison of the resulting binary showed
    only line number differences.

    This patch does not affect the generation of the Linux binary.
    This patch decreases 210 lines of 20121018 divergence.diff.

    The ACPICA source codes uses a totally different indentation style from the
    Linux to be compatible with other users (operating systems or BIOS).

    Indentation differences are critical to the release automation. There are
    two causes related to the "indentation" that are affecting the release
    automation:
    1. The ACPICA -> Linux release process is:
    ACPICA source -- acpisrc - hierarchy - indent ->
    linuxized ACPICA source -- diff ->
    linuxized ACPICA patch (x) -- human intervention ->
    linuxized ACPICA patch (o)
    Where
    'x' means "cannot be directly applied to the Linux"
    'o' means "can be directly applied to the Linux"
    Different "indent" version or "indent" options used in the "indent"
    step will lead to different divergences.
    The version of "indent" used for the current release process is:
    GNU indent 2.2.11
    The options of "indent" used for the current release process is:
    -npro -kr -i8 -ts8 -sob -l80 -ss -ncs
    2. Manual indentation prettifying work in the Linux side will also harm the
    automatically generated linuxized ACPICA patches, making them impossible
    to apply directly.

    This patch fixes source code differences caused by the two causes so that
    the "human intervention" can be reduced in the future.

    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     
  • This is a cosmetic patch only. Comparison of the resulting binary showed
    only line number differences.

    This patch does not affect the generation of the Linux binary.
    This patch decreases 558 lines of 20121018 divergence.diff.

    This patch reduces the source code diff between Linux and ACPICA by
    cleaning the comments that already have been updated in ACPICA.

    There is no extra indentation done in this patch. Even the empty line
    deletions and insertions are also splitted into another cleanup patch so
    that this patch can be easily reviewed, and the binary differences can be
    held to a lowest level.

    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

15 Nov, 2012

2 commits

  • 1) Ensure that all functions that use the various TRACE macros
    also use the appropriate ACPICA return macros.
    2) Ensure that all normal return statements surround the return
    expression (value) with parens.

    Signed-off-by: Bob Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Bob Moore
     
  • New version of "indent" program will generate different outputs that
    will lead to the divergences between the Linux and the ACPICA.
    This patch fixes such divergences caused by the "indent" program.
    The version of the "indent" used for this patch is "GNU indent 2.2.11".

    This patch will not affect the generated vmlinux binary.
    This will decrease 581 lines of 20120913 divergence.diff.

    Signed-off-by: Robert Moore
    Signed-off-by: Lv Zheng
    Signed-off-by: Rafael J. Wysocki

    Lv Zheng
     

21 Sep, 2012

1 commit


17 Jul, 2012

1 commit


14 Jul, 2012

1 commit

  • Adds basic support to allow multiple devices to be implicitly
    notified.

    This change is partially derived from original commit 981858b("ACPI /
    ACPICA: Implicit notify for multiple devices") by Rafael.

    Signed-off-by: Bob Moore
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jung-uk Kim
    Signed-off-by: Lin Ming
    Signed-off-by: Len Brown

    Bob Moore