Linuxize: Add upstream commit ID in the generated patches.

This patch adds support to add ACPICA upstream Commit ID/Author in the
generated linuxized patches. This format follows Linux stable material
format. The modifications include:
1. distiguish COMMITTER, AUTHOR, MAINTAINER:
   1. COMMITTER is automatically extracted using "git config --get";
   2. AUTHOR is automatically extracted using "git log --format=%aN <%aE>";
   3. MAINTAINER is fixed in make-patches.sh, currently it is
      "Bob Moore <robert.moore@intel.com>".
2. add AUTHOR and COMMIT ID information to form the ACPICA release patch
   header.
3. automatically correct "Robert Moore <Robert.Moore@intel.com>" to
   "Bob Moore <bob.moore@intel.com>".
4. automatically remove last empty lines in the patch description.
5. automatically append unique Signed-off-by for AUTHOR, NAINTAINER and
   COMMITTER.
6. automatically add commit URL before SOBs and add "-l" option to be ready
   for changing the host of the repo.
The generated patch format is ACKed by the Linux ACPI maintainer. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Events: Fix an issue that OriginallyEnabled check is not paired.

The OriginallyEnabled check is not paired between AcpiInstallGpeHandler()
and AcpiRemoveGpeHandler(). This patch contains the code that is already in
the Linux upstream. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Events: Fix an issue that GPE APIs cannot be invoked in atomic context.

The GPE APIs should be invoked inside of an IRQ context GPE handler or in
the task context with a driver provided lock held. This driver provided
lock should be safe to be held in the GPE handler by the driver.

While currently we cannot do this, thus we can only use the GPE APIs for
limitted cases.

This patch adds reference counting for ACPI_GPE_HANDLER_INFO. Then the GPE
handler can be safely invoked without holding the GPE lock, thus
facilitates GPE APIs to be invoked in any atomic environment. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Events: Fix an issue that GPE APIs cannot be invoked in deferred handlers.

The AcpiOsWaitEventsComplete() is used for flushing the deferred executed
handlers, invoking it for GPE interrupt handlers doesn't help to protect
GPE handler callback.  On the contrary, it prevents GPE APIs from being
invoked in the deferred notify handlers.

Actually, the GPE interrupt handlers' invocation is protected by the
previous implemented reference counting mechanism.

This patch fixes this GPE APIs invocation issue in a seperate commit other
than the reference counting one, so that if any regressions are reported,
this patch can be temporarily reverted before the regressions are root
caused. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Events: Remove duplicated sanity check in AcpiEvEnableGpe().

This patch deletes a sanity check from AcpiEvEnableGpe().

This kind of check is already done in
AcpiEnableGpe()/AcpiRemoveGpeHandler()/AcpiUpdateAllGpes() before invoking
AcpiEvEnableGpe():
1. AcpiEnableGpe(): same check (skip if DISPATCH_NONE) is now implemented.
2. AcpiRemoveGpeHandler(): a more strict check (skip if !DISPATCH_HANDLER)
                           is implemented.
3. AcpiUpdateAllGpes(): a more strict check (skip if DISPATCH_NONE ||
                        DISPATCH_HANDLER || CAN_WAKE)
4. AcpiSetGpe(): since it is invoked by the OSPM driver where the IRQ
                 handler is known to be available, such check isn't needed.
So we can simply remove this duplicated check from AcpiEvEnableGpe().
Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Events: Add a flag to disable internal auto GPE disabling.

The ACPI specification around the GPE handling is talking about an IRQ
handling code of IRQ polling mode (which is also known as the threaded IRQ
model in Linux) that is suitable for the control method execution. GPE is
disabled in the IRQ context and re-enabled in the IRQ polling context (the
task context of the polling thread) after the interrupt has been correctly
handled.

For IRQ handling code of IRQ interrupt mode (DISPATCH_HANDLER can only be
implemented in this mode), disabling IRQ is useless as further IRQs with
same IRQ no. are ensured to be blocked IRQ for the same CPU. There is no
hardware in the real world can trigger an IRQ on the same CPU to preempt
the handler of the same IRQ. There might be same IRQ handlers triggered on
different CPUs but disabling it in the IRQ handler cannot prevent this from
happening.

And the automatic IRQ disabling is harmful to request based low power IO
drivers where IRQ enabling/disabling is managed by the power references and
the storm conditions.
The IRQ disabling/enabling out of the drivers' control can mess up the IRQ
enabling state where:
1. Enabling IRQ means there is more than 1 requests and no storms;
2. Disabling IRQ means there is no request or there is a storm.

This patch adds a flag to control the ACPICA internal GPE disabling to
facilitate request based low power IO drivers to work in the GPE level.

Since we will have users for the new GPE flag to enable a runtime idle
style GPE driver, this patch also enables AcpiInstallGpeHandler() to
configure NO_AUTO_x flags. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Events: Add a flag to disable internal auto GPE clearing.

The GPE status clearing code should be invoked in the GPE handling code.
There are cases that the GPE is handled in the polling mode and the IRQ
mode handler is a no-op. For which, ACPICA internal clearing should be
bypassed.
Some silicon chips can implement special GPE status as R1C (read once
clear). For those case, the internal auto GPE clearing operations should
also be abandoned.
In AcpiEvEnableGpe(), the clearing code can prevent this API from being
request based IRQ enabling API, so also allows drivers who register GPE
handlers to discard it.

This flag facilitates such driver designs and implementations.

Note that drivers will need to invoke AcpiClearGpe() manually in a proper
position. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Events: Enable APIs to allow interrupt/polling adaptive request based GPE handling model.

For AcpiSetGpe()/AcpiEnableGpe(), our target is to purify them to be APIs
can be used for request based driver handling code, so we need them to be
pure GPE enabling APIs. IRQ enabling/disabling has 2 use cases:
1. Driver may permanently enable/disable IRQs 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. IRQ need
      to be enabled for the first request submission and disabled for the
      last request completion.
   2. When the IRQ is shared between 2+ silicon logics. IRQ need to be
      enabled for either silicon logic's driver and disabled when all of
      the drivers are not started.
   For these cases, AcpiEnableGpe()/AcpiDisableGpe() should be used. When
   the usage count is increased from 0 to 1, the IRQ is enabled and it is
   disabled when the usage count is decrased from 1 to 0.
2. Driver may temporarily disables the IRQ to enter an IRQ polling mode and
   wants to re-enable it later.
   1. Prevent IRQ storming: when a driver cannot fully solve the condition
      that triggered the IRQ in the IRQ context, in order not to trigger
      IRQ storm, driver has to disable IRQ to switch into the polling mode
      and re-enables it in the non-IRQ 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 IRQ handler from returning.
   3. Meet realtime requirement: in order not to block CPU to handle higher
      realtime prioritized IRQs, lower priority IRQs can be handled in the
      polling mode.
   For these cases, AcpiSetGpe() should be used to switch to/from the
   polling mode.

This patch adds unconditional GPE enabling support into AcpiSetGpe() 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
AcpiClearGpe(). 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 AcpiFinishGpe() 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 AcpiSetGpe(ACPI_GPE_ENABLE)
should not be implemented by AcpiHwLowSetGpe(ACPI_GPE_CONDITIONAL_ENABLE).

This patch thus converts AcpiSetGpe(ACPI_GPE_ENABLE) into
AcpiHwLowSetGpe(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 IRQ polling mode. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>