• Lv Zheng's avatar
    ACPICA: Events: Introduce ACPI_GPE_DISPATCH_RAW_HANDLER to fix 2 issues for the current GPE APIs · 0d0988af
    Lv Zheng authored
    ACPICA commit 199cad16530a45aea2bec98e528866e20c5927e1
    
    Since whether the GPE should be disabled/enabled/cleared should only be
    determined by the GPE driver's state machine:
    1. GPE should be disabled if the driver wants to switch to the GPE polling
       mode when a GPE storm condition is indicated and should be enabled if
       the driver wants to switch back to the GPE interrupt mode when all of
       the storm conditions are cleared. The conditions should be protected by
       the driver's specific lock.
    2. GPE should be enabled if the driver has accepted more than one request
       and should be disabled if the driver has completed all of the requests.
       The request count should be protected by the driver's specific lock.
    3. GPE should be cleared either when the driver is about to handle an edge
       triggered GPE or when the driver has completed to handle a level
       triggered GPE. The handling code should be protected by the driver's
       specific lock.
    Thus the GPE enabling/disabling/clearing operations are likely to be
    performed with the driver's specific lock held while we currently cannot do
    this. This is because:
    1. We have the acpi_gbl_gpe_lock held before invoking the GPE driver's
       handler. Driver's specific lock is likely to be held inside of the
       handler, thus we can see some dead lock issues due to the reversed
       locking order or recursive locking. In order to solve such dead lock
       issues, we need to unlock the acpi_gbl_gpe_lock before invoking the
       handler. BZ 1100.
    2. Since GPE disabling/enabling/clearing should be determined by the GPE
       driver's state machine, we shouldn't perform such operations inside of
       ACPICA for a GPE handler to mess up the driver's state machine. BZ 1101.
    
    Originally this patch includes a logic to flush GPE handlers, it is dropped
    due to the following reasons:
    1. This is a different issue;
    2. Linux OSL has fixed this by flushing SCI in acpi_os_wait_events_complete().
    We will pick up this topic when the Linux OSL fix turns out to be not
    sufficient.
    
    Note that currently the internal operations and the acpi_gbl_gpe_lock are
    also used by ACPI_GPE_DISPATCH_METHOD and ACPI_GPE_DISPATCH_NOTIFY. In
    order not to introduce regressions, we add one
    ACPI_GPE_DISPATCH_RAW_HANDLER type to be distiguished from
    ACPI_GPE_DISPATCH_HANDLER. For which the acpi_gbl_gpe_lock is unlocked before
    invoking the GPE handler and the internal enabling/disabling operations are
    bypassed to allow drivers to perform them at a proper position using the
    GPE APIs and ACPI_GPE_DISPATCH_RAW_HANDLER users should invoke acpi_set_gpe()
    instead of acpi_enable_gpe()/acpi_disable_gpe() to bypass the internal GPE
    clearing code in acpi_enable_gpe(). Lv Zheng.
    
    Known issues:
    1. Edge-triggered GPE lost for frequent enablings
       On some buggy silicon platforms, GPE enable line may not be directly
       wired to the GPE trigger line. In that case, when GPE enabling is
       frequently performed for edge-triggered GPEs, GPE status may stay set
       without being triggered.
       This patch may maginify this problem as it allows GPE enabling to be
       parallel performed during the process the GPEs are handled.
       This is an existing issue, because:
       1. For task context:
          Current ACPI_GPE_DISPATCH_METHOD practices have proven that this
          isn't a real issue - we can re-enable edge-triggered GPE in a work
          queue where the GPE status bit might already be set.
       2. For IRQ context:
          This can even happen when the GPE enabling occurs before returning
          from the GPE handler and after unlocking the GPE lock.
       Thus currently no code is included to protect this.
    
    Link: https://github.com/acpica/acpica/commit/199cad16Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
    Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    0d0988af
evgpeinit.c 13.8 KB