History log of /drivers/acpi/ec.c
Revision Date Author Comments
79149001105f18bd2285ada109f9229ea24a7571 29-Oct-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Fix regression due to conflicting firmware behavior between Samsung and Acer.

It is reported that Samsung laptops that need to poll events are broken by
the following commit:
Commit 3afcf2ece453e1a8c2c6de19cdf06da3772a1b08
Subject: ACPI / EC: Add support to disallow QR_EC to be issued when SCI_EVT isn't set

The behaviors of the 2 vendor firmwares are conflict:
1. Acer: OSPM shouldn't issue QR_EC unless SCI_EVT is set, firmware
automatically sets SCI_EVT as long as there is event queued up.
2. Samsung: OSPM should issue QR_EC whatever SCI_EVT is set, firmware
returns 0 when there is no event queued up.

This patch is a quick fix to distinguish the behaviors to make Acer
behavior only effective for Acer EC firmware so that the breakages on
Samsung EC firmware can be avoided.

Fixes: 3afcf2ece453 (ACPI / EC: Add support to disallow QR_EC to be issued ...)
Link: https://bugzilla.kernel.org/show_bug.cgi?id=44161
Reported-and-tested-by: Ortwin Glück <odi@odi.ch>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: 3.17+ <stable@vger.kernel.org> # 3.17+
[ rjw : Subject ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
df9ff91801da603079018f21a9412385b62f0f8e 29-Oct-2014 Lv Zheng <lv.zheng@intel.com> Revert "ACPI / EC: Add support to disallow QR_EC to be issued before completing previous QR_EC"

It is reported that the following commit breaks Samsung hardware:
Commit: 558e4736f2e1b0e6323adf7a5e4df77ed6cfc1a4.
Subject: ACPI / EC: Add support to disallow QR_EC to be issued before
completing previous QR_EC

Which means the Samsung behavior conflicts with the Acer behavior.

1. Samsung may behave like:
[ +event 1 ] SCI_EVT set
[ +event 2 ] SCI_EVT set
write QR_EC
read event
[ -event 1 ] SCI_EVT clear
Without the above commit, Samsung can work:
[ +event 1 ] SCI_EVT set
[ +event 2 ] SCI_EVT set
write QR_EC
CAN prepare next QR_EC as SCI_EVT=1
read event
[ -event 1 ] SCI_EVT clear
write QR_EC
read event
[ -event 2 ] SCI_EVT clear
With the above commit, Samsung cannot work:
[ +event 1 ] SCI_EVT set
[ +event 2 ] SCI_EVT set
write QR_EC
read event
[ -event 1 ] SCI_EVT clear
CANNOT prepare next QR_EC as SCI_EVT=0
2. Acer may behave like:
[ +event 1 ] SCI_EVT set
[ +event 2 ]
write QR_EC
read event
[ -event 1 ] SCI_EVT clear
[ +event 2 ] SCI_EVT set
Without the above commit, Acer cannot work when there is only 1 event:
[ +event 1 ] SCI_EVT set
write QR_EC
can prepared next QR_EC as SCI_EVT=1
read event
[ -event 1 ] SCI_EVT clear
CANNOT write QR_EC as SCI_EVT=0
With the above commit, Acer can work:
[ +event 1 ] SCI_EVT set
[ +event 2 ]
write QR_EC
read event
[ -event 1 ] SCI_EVT set
can prepare next QR_EC because SCI_EVT=0
CAN write QR_EC as SCI_EVT=1

Since Acer can also work with only the following commit applied:
Commit: 3afcf2ece453e1a8c2c6de19cdf06da3772a1b08
Subject: ACPI / EC: Add support to disallow QR_EC to be issued when
SCI_EVT isn't set
commit 558e4736f2e1b0e6323adf7a5e4df77ed6cfc1a4 can be reverted.

Fixes: 558e4736f2e1 (ACPI / EC: Add support to disallow QR_EC to be issued ...)
Link: https://bugzilla.kernel.org/show_bug.cgi?id=44161
Reported-and-tested-by: Ortwin Glück <odi@odi.ch>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: 3.17+ <stable@vger.kernel.org> # 3.17+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7a73e60e398a61612651d503aef9c81260d33918 14-Oct-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Cleanup coding style.

This patch cleans up the following coding style issues that are detected by
scripts/checkpatch.pl:
ERROR: code indent should use tabs where possible
ERROR: "foo * bar" should be "foo *bar"
WARNING: Missing a blank line after declarations
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
WARNING: void function return statements are not generally useful
WARNING: else is not generally useful after a break or return
WARNING: break is not useful after a goto or return
WARNING: braces {} are not necessary for single statement blocks
WARNING: line over 80 characters
WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
No functional changes.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
d3090b6a6cfa6c7a762d6c13340170ca072b2b81 14-Oct-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Refine event/query debugging messages.

This patch refines event/query debugging messages to use a unified format
as commands. Developers can clearly find different processes by checking
different log seperators. No functional changes.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
e34c0e2bb4046d574224de3752642177a45a067a 14-Oct-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Add detailed command/query debugging information.

Developers really don't need to translate EC commands in mind. This patch
adds detailed debugging information for the EC commands.
The address can be found in the follow-up sequential EC_DATA(W) accesses,
thus this patch also removes some of the redundant address information.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
459572a7503bccb5435936488088c8db4f51d3ab 14-Oct-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Enhance the logs to apply to QR_EC transactions.

Currently some logs are applied to new transactions, but QR_EC transactions
are not included. This patch merges the code path to make the logs also
applying to the QR_EC transactions.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
c95f25b03667c50e7184a63bdf4c32dff0de2f6f 14-Oct-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Add CPU ID to debugging messages.

This patch adds CPU ID to the context entries' debugging output. no
functional changes.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
777cb382958851c88763253fe00a26529be4c0e9 29-Aug-2014 Lan Tianyu <tianyu.lan@intel.com> ACPI / EC: Add msi quirk for Clevo W350etq

Clevo W350etq's EC will not produce GPE interrupt some time after
booting. The ACPI notify event won't trigger when the issue takes
place. After debugging, adding msi quirk for the machine can fix
the issue. This patch is to add msi quirk for the machine.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=77431
Reported-and-tested-by: qbanin@gmail.com
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
558e4736f2e1b0e6323adf7a5e4df77ed6cfc1a4 21-Aug-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Add support to disallow QR_EC to be issued before completing previous QR_EC

There is platform refusing to respond QR_EC when SCI_EVT isn't set
which is Acer Aspire V5-573G.

By disallowing QR_EC to be issued before the previous one has been
completed we are able to reduce the possibilities to trigger issues on
such platforms.

Note that this fix can only reduce the occurrence rate of this issue, but
this issue may still occur when such a platform doesn't clear SCI_EVT
before or immediately after completing the previous QR_EC transaction.
This patch cannot fix the CLEAR_ON_RESUME quirk which also relies on
the assumption that the platforms are able to respond even when SCI_EVT
isn't set.

But this patch is still useful as it can help to reduce the number of
scheduled QR_EC work items.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=82611
Reported-and-tested-by: Alexander Mezin <mezin.alexander@gmail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: 3.16+ <stable@vger.kernel.org> # 3.16+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
3afcf2ece453e1a8c2c6de19cdf06da3772a1b08 21-Aug-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Add support to disallow QR_EC to be issued when SCI_EVT isn't set

There is a platform refusing to respond QR_EC when SCI_EVT isn't set
(Acer Aspire V5-573G).

Currently, we rely on the behaviour that the EC firmware can respond
something (for example, 0x00 to indicate "no outstanding events") to
QR_EC even when SCI_EVT is not set, but the reporter has complained
about AC/battery pluging/unpluging and video brightness change delay
on that platform.

This is because the work item that has issued QR_EC has to wait until
timeout in this case, and the _Qxx method evaluation work item queued
after QR_EC one is delayed.

It sounds reasonable to fix this issue by:
1. Implementing SCI_EVT sanity check before issuing QR_EC in the EC
driver's main state machine.
2. Moving QR_EC issuing out of the work queue used by _Qxx evaluation
to a seperate IRQ handling thread.

This patch fixes this issue using solution 1.

By disallowing QR_EC to be issued when SCI_EVT isn't set, we are able to
handle such platform in the EC driver's main state machine. This patch
enhances the state machine in this way to survive with such malfunctioning
EC firmware.

Note that this patch can also fix CLEAR_ON_RESUME quirk which also relies
on the assumption that the platforms are able to respond even when SCI_EVT
isn't set.

Fixes: c0d653412fc8 ACPI / EC: Fix race condition in ec_transaction_completed()
Link: https://bugzilla.kernel.org/show_bug.cgi?id=82611
Reported-and-tested-by: Alexander Mezin <mezin.alexander@gmail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: 3.16+ <stable@vger.kernel.org> # 3.16+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ed4b197ddd4d7aa6623e7777ea326c67c3a6b8ed 03-Jul-2014 Colin Ian King <colin.king@canonical.com> ACPI / EC: Free saved_ec on error exit path

Smatch detected two memory leaks on saved_ec:

drivers/acpi/ec.c:1070 acpi_ec_ecdt_probe() warn: possible
memory leak of 'saved_ec'
drivers/acpi/ec.c:1109 acpi_ec_ecdt_probe() warn: possible
memory leak of 'saved_ec'

Free saved_ec on these two error exit paths to stop the memory
leak. Note that saved_ec maybe null, but kfree on null is allowed.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
dd43de20f540179863d9d7c3188b6a6cfde9a731 15-Jun-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Add detailed fields debugging support of EC_SC(R).

Developers really don't need to translate EC_SC(R) in mind as long as the
field details are decoded in the debugging message.

Tested-by: Gareth Williams <gareth@garethwilliams.me.uk>
Tested-by: Steffen Weber <steffen.weber@gmail.com>
Tested-by: Hans de Goede <jwrdegoede@fedoraproject.org>
Tested-by: Arthur Chen <axchen@nvidia.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4a3f6b5bf3f3293087a5f60ea3328715fe14b6de 15-Jun-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Update revision due to recent changes

The bug fixes and asynchronous improvements have been done to the EC driver
by the previous commits. This patch increases the revision to 2.2 to
indicate the behavior differences between the old and the new drivers. The
copyright/authorship notices are also updated.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
c0d653412fc8450370167a3268b78fc772ff9c87 15-Jun-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Fix race condition in ec_transaction_completed()

There is a race condition in ec_transaction_completed().

When ec_transaction_completed() is called in the GPE handler, it could
return true because of (ec->curr == NULL). Then the wake_up() invocation
could complete the next command unexpectedly since there is no lock between
the 2 invocations. With the previous cleanup, the IBF=0 waiter race need
not be handled any more. It's now safe to return a flag from
advance_condition() to indicate the requirement of wakeup, the flag is
returned from a locked context.

The ec_transaction_completed() is now only invoked by the ec_poll() where
the ec->curr is ensured to be different from NULL.

After cleaning up, the EVT_SCI=1 check should be moved out of the wakeup
condition so that an EVT_SCI raised with (ec->curr == NULL) can trigger a
QR_SC command.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=70891
Link: https://bugzilla.kernel.org/show_bug.cgi?id=63931
Link: https://bugzilla.kernel.org/show_bug.cgi?id=59911
Reported-and-tested-by: Gareth Williams <gareth@garethwilliams.me.uk>
Reported-and-tested-by: Hans de Goede <jwrdegoede@fedoraproject.org>
Reported-by: Barton Xu <tank.xuhan@gmail.com>
Tested-by: Steffen Weber <steffen.weber@gmail.com>
Tested-by: Arthur Chen <axchen@nvidia.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
9b80f0f73ae1583c22325ede341c74195847618c 15-Jun-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Remove duplicated ec_wait_ibf0() waiter

After we've added the first command byte write into advance_transaction(),
the IBF=0 waiter is duplicated with the command completion waiter
implemented in the ec_poll() because:
If IBF=1 blocked the first command byte write invoked in the task
context ec_poll(), it would be kicked off upon IBF=0 interrupt or timed
out and retried again in the task context.

Remove this seperate and duplicate IBF=0 waiter. By doing so we can
reduce the overall number of times to access the EC_SC(R) status
register.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=70891
Link: https://bugzilla.kernel.org/show_bug.cgi?id=63931
Link: https://bugzilla.kernel.org/show_bug.cgi?id=59911
Reported-and-tested-by: Gareth Williams <gareth@garethwilliams.me.uk>
Reported-and-tested-by: Hans de Goede <jwrdegoede@fedoraproject.org>
Reported-by: Barton Xu <tank.xuhan@gmail.com>
Tested-by: Steffen Weber <steffen.weber@gmail.com>
Tested-by: Arthur Chen <axchen@nvidia.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
f92fca0060fc4dc9227342d0072d75df98c1e5a5 15-Jun-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Add asynchronous command byte write support

Move the first command byte write into advance_transaction() so that all
EC register accesses that can affect the command processing state machine
can happen in this asynchronous state machine advancement function.

The advance_transaction() function then can be a complete implementation
of an asyncrhonous transaction for a single command so that:
1. The first command byte can be written in the interrupt context;
2. The command completion waiter can also be used to wait the first command
byte's timeout;
3. In BURST mode, the follow-up command bytes can be written in the
interrupt context directly, so that it doesn't need to return to the
task context. Returning to the task context reduces the throughput of
the BURST mode and in the worst cases where the system workload is very
high, this leads to the hardware driven automatic BURST mode exit.

In order not to increase memory consumption, convert 'done' into 'flags'
to contain multiple indications:
1. ACPI_EC_COMMAND_COMPLETE: converting from original 'done' condition,
indicating the completion of the command transaction.
2. ACPI_EC_COMMAND_POLL: indicating the availability of writing the first
command byte. A new command can utilize this flag to compete for the
right of accessing the underlying hardware. There is a follow-up bug
fix that has utilized this new flag.

The 2 flags are important because it also reflects a key concept of IO
programs' design used in the system softwares. Normally an IO program
running in the kernel should first be implemented in the asynchronous way.
And the 2 flags are the most common way to implement its synchronous
operations on top of the asynchronous operations:
1. POLL: This flag can be used to block until the asynchronous operations
can happen.
2. COMPLETE: This flag can be used to block until the asynchronous
operations have completed.
By constructing code cleanly in this way, many difficult problems can be
solved smoothly.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=70891
Link: https://bugzilla.kernel.org/show_bug.cgi?id=63931
Link: https://bugzilla.kernel.org/show_bug.cgi?id=59911
Reported-and-tested-by: Gareth Williams <gareth@garethwilliams.me.uk>
Reported-and-tested-by: Hans de Goede <jwrdegoede@fedoraproject.org>
Reported-by: Barton Xu <tank.xuhan@gmail.com>
Tested-by: Steffen Weber <steffen.weber@gmail.com>
Tested-by: Arthur Chen <axchen@nvidia.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
66b42b78bc1e816f92b662e8888c89195e4199e1 15-Jun-2014 Lv Zheng <lv.zheng@intel.com> ACPI / EC: Avoid race condition related to advance_transaction()

The advance_transaction() will be invoked from the IRQ context GPE handler
and the task context ec_poll(). The handling of this function is locked so
that the EC state machine are ensured to be advanced sequentially.

But there is a problem. Before invoking advance_transaction(), EC_SC(R) is
read. Then for advance_transaction(), there could be race condition around
the lock from both contexts. The first one reading the register could fail
this race and when it passes the stale register value to the state machine
advancement code, the hardware condition is totally different from when
the register is read. And the hardware accesses determined from the wrong
hardware status can break the EC state machine. And there could be cases
that the functionalities of the platform firmware are seriously affected.
For example:
1. When 2 EC_DATA(W) writes compete the IBF=0, the 2nd EC_DATA(W) write may
be invalid due to IBF=1 after the 1st EC_DATA(W) write. Then the
hardware will either refuse to respond a next EC_SC(W) write of the next
command or discard the current WR_EC command when it receives a EC_SC(W)
write of the next command.
2. When 1 EC_SC(W) write and 1 EC_DATA(W) write compete the IBF=0, the
EC_DATA(W) write may be invalid due to IBF=1 after the EC_SC(W) write.
The next EC_DATA(R) could never be responded by the hardware. This is
the root cause of the reported issue.

Fix this issue by moving the EC_SC(R) access into the lock so that we can
ensure that the state machine is advanced consistently.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=70891
Link: https://bugzilla.kernel.org/show_bug.cgi?id=63931
Link: https://bugzilla.kernel.org/show_bug.cgi?id=59911
Reported-and-tested-by: Gareth Williams <gareth@garethwilliams.me.uk>
Reported-and-tested-by: Hans de Goede <jwrdegoede@fedoraproject.org>
Reported-by: Barton Xu <tank.xuhan@gmail.com>
Tested-by: Steffen Weber <steffen.weber@gmail.com>
Tested-by: Arthur Chen <axchen@nvidia.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
3eba563e280101209bad27d40bfc83ddf1489234 29-Apr-2014 Kieran Clancy <clancy.kieran@gmail.com> ACPI / EC: Process rather than discard events in acpi_ec_clear

Address a regression caused by commit ad332c8a4533:
(ACPI / EC: Clear stale EC events on Samsung systems)

After the earlier patch, there was found to be a race condition on some
earlier Samsung systems (N150/N210/N220). The function acpi_ec_clear was
sometimes discarding a new EC event before its GPE was triggered by the
system. In the case of these systems, this meant that the "lid open"
event was not registered on resume if that was the cause of the wake,
leading to problems when attempting to close the lid to suspend again.

After testing on a number of Samsung systems, both those affected by the
previous EC bug and those affected by the race condition, it seemed that
the best course of action was to process rather than discard the events.
On Samsung systems which accumulate stale EC events, there does not seem
to be any adverse side-effects of running the associated _Q methods.

This patch adds an argument to the static function acpi_ec_sync_query so
that it may be used within the acpi_ec_clear loop in place of
acpi_ec_query_unlocked which was used previously.

With thanks to Stefan Biereigel for reporting the issue, and for all the
people who helped test the new patch on affected systems.

Fixes: ad332c8a4533 (ACPI / EC: Clear stale EC events on Samsung systems)
References: https://lkml.kernel.org/r/532FE3B2.9060808@biereigel-wb.de
References: https://bugzilla.kernel.org/show_bug.cgi?id=44161#c173
Reported-by: Stefan Biereigel <stefan@biereigel.de>
Signed-off-by: Kieran Clancy <clancy.kieran@gmail.com>
Tested-by: Stefan Biereigel <stefan@biereigel.de>
Tested-by: Dennis Jansen <dennis.jansen@web.de>
Tested-by: Nicolas Porcel <nicolasporcel06@gmail.com>
Tested-by: Maurizio D'Addona <mauritiusdadd@gmail.com>
Tested-by: Juan Manuel Cabo <juanmanuel.cabo@gmail.com>
Tested-by: Giannis Koutsou <giannis.koutsou@gmail.com>
Tested-by: Kieran Clancy <clancy.kieran@gmail.com>
Cc: 3.14+ <stable@vger.kernel.org> # 3.14+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ad332c8a45330d170bb38b95209de449b31cd1b4 28-Feb-2014 Kieran Clancy <clancy.kieran@gmail.com> ACPI / EC: Clear stale EC events on Samsung systems

A number of Samsung notebooks (530Uxx/535Uxx/540Uxx/550Pxx/900Xxx/etc)
continue to log events during sleep (lid open/close, AC plug/unplug,
battery level change), which accumulate in the EC until a buffer fills.
After the buffer is full (tests suggest it holds 8 events), GPEs stop
being triggered for new events. This state persists on wake or even on
power cycle, and prevents new events from being registered until the EC
is manually polled.

This is the root cause of a number of bugs, including AC not being
detected properly, lid close not triggering suspend, and low ambient
light not triggering the keyboard backlight. The bug also seemed to be
responsible for performance issues on at least one user's machine.

Juan Manuel Cabo found the cause of bug and the workaround of polling
the EC manually on wake.

The loop which clears the stale events is based on an earlier patch by
Lan Tianyu (see referenced attachment).

This patch:
- Adds a function acpi_ec_clear() which polls the EC for stale _Q
events at most ACPI_EC_CLEAR_MAX (currently 100) times. A warning is
logged if this limit is reached.
- Adds a flag EC_FLAGS_CLEAR_ON_RESUME which is set to 1 if the DMI
system vendor is Samsung. This check could be replaced by several
more specific DMI vendor/product pairs, but it's likely that the bug
affects more Samsung products than just the five series mentioned
above. Further, it should not be harmful to run acpi_ec_clear() on
systems without the bug; it will return immediately after finding no
data waiting.
- Runs acpi_ec_clear() on initialisation (boot), from acpi_ec_add()
- Runs acpi_ec_clear() on wake, from acpi_ec_unblock_transactions()

References: https://bugzilla.kernel.org/show_bug.cgi?id=44161
References: https://bugzilla.kernel.org/show_bug.cgi?id=45461
References: https://bugzilla.kernel.org/show_bug.cgi?id=57271
References: https://bugzilla.kernel.org/attachment.cgi?id=126801
Suggested-by: Juan Manuel Cabo <juanmanuel.cabo@gmail.com>
Signed-off-by: Kieran Clancy <clancy.kieran@gmail.com>
Reviewed-by: Lan Tianyu <tianyu.lan@intel.com>
Reviewed-by: Dennis Jansen <dennis.jansen@web.de>
Tested-by: Kieran Clancy <clancy.kieran@gmail.com>
Tested-by: Juan Manuel Cabo <juanmanuel.cabo@gmail.com>
Tested-by: Dennis Jansen <dennis.jansen@web.de>
Tested-by: Maurizio D'Addona <mauritiusdadd@gmail.com>
Tested-by: San Zamoyski <san@plusnet.pl>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
b8a0b0d199307eca0e99c30a06c9ed85a7f49678 17-Dec-2013 Rashika <rashika.kheria@gmail.com> ACPI / EC: Remove unused functions and add prototype declaration in internal.h

Adds the prototype declarations of functions acpi_ec_add_query_handler()
and acpi_ec_remove_query_handler() in header file internal.h and removes
unused functions ec_burst_enable() and ec_burst_disable() in ec.c.

This eliminates the following warnings in ec.c:
drivers/acpi/ec.c:393:5: warning: no previous prototype for ‘ec_burst_enable’ [-Wmissing-prototypes]
drivers/acpi/ec.c:402:5: warning: no previous prototype for ‘ec_burst_disable’ [-Wmissing-prototypes]
drivers/acpi/ec.c:531:5: warning: no previous prototype for ‘acpi_ec_add_query_handler’ [-Wmissing-prototypes]
drivers/acpi/ec.c:552:6: warning: no previous prototype for ‘acpi_ec_remove_query_handler’ [-Wmissing-prototypes]

Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
42b946bb35ef0057f13887dec5f081df0ba8840a 12-Dec-2013 Lan Tianyu <tianyu.lan@intel.com> ACPI / EC: disable GPE before removing GPE handler

Adjust the order of disabling the EC GPE and removing its handler to
avoid unhandled events.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8b48463f89429af408ff695244dc627e1acff4f7 03-Dec-2013 Lv Zheng <lv.zheng@intel.com> ACPI: Clean up inclusions of ACPI header files

Replace direct inclusions of <acpi/acpi.h>, <acpi/acpi_bus.h> and
<acpi/acpi_drivers.h>, which are incorrect, with <linux/acpi.h>
inclusions and remove some inclusions of those files that aren't
necessary.

First of all, <acpi/acpi.h>, <acpi/acpi_bus.h> and <acpi/acpi_drivers.h>
should not be included directly from any files that are built for
CONFIG_ACPI unset, because that generally leads to build warnings about
undefined symbols in !CONFIG_ACPI builds. For CONFIG_ACPI set,
<linux/acpi.h> includes those files and for CONFIG_ACPI unset it
provides stub ACPI symbols to be used in that case.

Second, there are ordering dependencies between those files that always
have to be met. Namely, it is required that <acpi/acpi_bus.h> be included
prior to <acpi/acpi_drivers.h> so that the acpi_pci_root declarations the
latter depends on are always there. And <acpi/acpi.h> which provides
basic ACPICA type declarations should always be included prior to any other
ACPI headers in CONFIG_ACPI builds. That also is taken care of including
<linux/acpi.h> as appropriate.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> (drivers/pci stuff)
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> (Xen stuff)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
36b15875a7819a2ec4cb5748ff7096ad7bd86cbb 15-Nov-2013 Puneet Kumar <puneetster@chromium.org> ACPI / EC: Ensure lock is acquired before accessing ec struct members

A bug was introduced by commit b76b51ba0cef ('ACPI / EC: Add more debug
info and trivial code cleanup') that erroneously caused the struct member
to be accessed before acquiring the required lock. This change fixes
it by ensuring the lock acquisition is done first.

Found by Aaron Durbin <adurbin@chromium.org>

Fixes: b76b51ba0cef ('ACPI / EC: Add more debug info and trivial code cleanup')
References: http://crbug.com/319019
Signed-off-by: Puneet Kumar <puneetster@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
[olof: Commit message reworded a bit]
Signed-off-by: Olof Johansson <olof@lixom.net>
Cc: 3.8+ <stable@vger.kernel.org> # 3.8+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
16a26e85279fd672050ffc3637038366629e8653 12-Sep-2013 Lan Tianyu <tianyu.lan@intel.com> ACPI / EC: Convert all printk() calls to dynamic debug function

This patch is to convert all printks in the ec driver to pr_debug/info/err
and define pr_fmt macro to replace PREFIX.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
524f42fab787a9510be826ce3d736b56d454ac6d 26-Aug-2013 Lan Tianyu <tianyu.lan@intel.com> ACPI / EC: Add ASUSTEK L4R to quirk list in order to validate ECDT

The ECDT of ASUSTEK L4R doesn't provide correct command and data
I/O ports. The DSDT provides the correct information instead.

For this reason, add this machine to quirk list for ECDT validation
and use the EC information from the DSDT.

[rjw: Changelog]
References: https://bugzilla.kernel.org/show_bug.cgi?id=60765
Reported-and-tested-by: Daniele Esposti <expo@expobrain.net>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Cc: All <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6cef74970186797c45b3add1e73a14aa71d338d1 07-Aug-2013 Sachin Kamat <sachin.kamat@linaro.org> ACPI / EC: Fix incorrect placement of __initdata

__initdata should be placed between the variable name and equal
sign for the variable to be placed in the intended section.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
952c63e9512b63220886105cfc791507046fa39a 28-Jun-2013 Jiang Liu <jiang.liu@huawei.com> ACPI: introduce helper function acpi_has_method()

Introduce helper function acpi_has_method() and use it in a number
of places to simplify code.

[rjw: Changelog]
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
eff9a4b62b14cf0d9913e3caf1f26f8b7a6105c9 05-Jun-2013 Lan Tianyu <tianyu.lan@intel.com> ACPI / EC: Add HP Folio 13 to ec_dmi_table in order to skip DSDT scan

HP Folio 13's BIOS defines CMOS RTC Operation Region and the EC's
_REG method will access that region. To allow the CMOS RTC region
handler to be installed before the EC _REG method is first invoked,
add ec_skip_dsdt_scan() as HP Folio 13's callback to ec_dmi_table.

References: https://bugzilla.kernel.org/show_bug.cgi?id=54621
Reported-and-tested-by: Stefan Nagy <public@stefan-nagy.at>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Cc: 3.9+ <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
28fe5c825f8e15744d04c7c1b8df197950923ecd 06-May-2013 Lan Tianyu <tianyu.lan@intel.com> ACPI / EC: Restart transaction even when the IBF flag set

The EC driver works abnormally with IBF flag always set.
IBF means "The host has written a byte of data to the command
or data port, but the embedded controller has not yet read it".
If IBF is set in the EC status and not cleared, this will cause
all subsequent EC requests to fail with a timeout error.

Change the EC driver so that it doesn't refuse to restart a
transaction if IBF is set in the status. Also increase the
number of transaction restarts to 5, as it turns out that 2
is not sufficient in some cases.

This bug happens on several different machines (Asus V1S,
Dell Latitude E6530, Samsung R719, Acer Aspire 5930G,
Sony Vaio SR19VN and others).

[rjw: Changelog]
References: https://bugzilla.kernel.org/show_bug.cgi?id=14733
References: https://bugzilla.kernel.org/show_bug.cgi?id=15560
References: https://bugzilla.kernel.org/show_bug.cgi?id=15946
References: https://bugzilla.kernel.org/show_bug.cgi?id=42945
References: https://bugzilla.kernel.org/show_bug.cgi?id=48221
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Cc: All <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
51fac8388a0325a43f0ae67453ece2c373e2ec28 24-Jan-2013 Rafael J. Wysocki <rafael.j.wysocki@intel.com> ACPI: Remove useless type argument of driver .remove() operation

The second argument of ACPI driver .remove() operation is only used
by the ACPI processor driver and the value passed to that driver
through it is always available from the given struct acpi_device
object's removal_type field. For this reason, the second ACPI driver
.remove() argument is in fact useless, so drop it.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
a3cd8d2789c2e265e09377f260e7d2ac9cec81bb 23-Oct-2012 Feng Tang <feng.tang@intel.com> ACPI / EC: Don't count a SCI interrupt as a false one

Currently when advance_transaction() is called in EC interrupt handler,
if there is nothing driver can do with the interrupt, it will be taken
as a false one.

But this is not always true, as there may be a SCI EC interrupt fired
during normal read/write operation, which should not be counted as a
false one. This patch fixes the problem.

Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
b76b51ba0cef13980813373a548a12206e3cd3c9 23-Oct-2012 Feng Tang <feng.tang@intel.com> ACPI / EC: Add more debug info and trivial code cleanup

Add more debug info for EC transaction debugging, like the interrupt
status register value, the detail info of a EC transaction.

Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
f351d027eea545a7996af54fce99f5668a67fec5 23-Oct-2012 Feng Tang <feng.tang@intel.com> ACPI / EC: Cleanup the member name for spinlock/mutex in struct

Current member names for mutex/spinlock are a little confusing.

Change the
{
struct mutex lock;
spinlock_t curr_lock;
}
to
{
struct mutex mutex;
spinlock_t lock;
}

So that the code is cleaner and easier to read.

Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
67bfa9b60bd689601554526d144b21d529f78a09 28-Sep-2012 Feng Tang <feng.tang@intel.com> ACPI: EC: Add a quirk for CLEVO M720T/M730T laptop

By enlarging the GPE storm threshold back to 20, that laptop's
EC works fine with interrupt mode instead of polling mode.

https://bugzilla.kernel.org/show_bug.cgi?id=45151

Reported-and-Tested-by: Francesco <trentini@dei.unipd.it>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
cc: stable@vger.kernel.org
a520d52e99b14ba7db135e916348f12f2a6e09be 28-Sep-2012 Feng Tang <feng.tang@intel.com> ACPI: EC: Make the GPE storm threshold a module parameter

The Linux EC driver includes a mechanism to detect GPE storms,
and switch from interrupt-mode to polling mode. However, polling
mode sometimes doesn't work, so the workaround is problematic.
Also, different systems seem to need the threshold for detecting
the GPE storm at different levels.

ACPI_EC_STORM_THRESHOLD was initially 20 when it's created, and
was changed to 8 in 2.6.28 commit 06cf7d3c7 "ACPI: EC: lower interrupt storm
threshold" to fix kernel bug 11892 by forcing the laptop in that bug to
work in polling mode. However in bug 45151, it works fine in interrupt
mode if we lift the threshold back to 20.

This patch makes the threshold a module parameter so that user has a
flexible option to debug/workaround this issue.

The default is unchanged.

This is also a preparation patch to fix specific systems:
https://bugzilla.kernel.org/show_bug.cgi?id=45151

Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
cc: stable@vger.kernel.org
d6795fe32da13bde39ea483e42799a22daa730b5 06-Feb-2012 Andi Kleen <andi@firstfloor.org> ACPI: ec: Do request_region outside WARN()

WARN() is not supposed to have side effects, so move the request_regions
outside.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
3e2abc5a35d25442821e1733687b7abbc83b5072 18-Jan-2012 Seth Forshee <seth.forshee@canonical.com> ACPI: EC: Add ec_get_handle()

toshiba_acpi needs to execute an AML method within the EC namespace
to make hotkeys work on some platforms. Provide an interface to
allow it to easily get a handle to the EC namespace for this purpose.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
08b53f0e6b565fe8dc0b8f929960ed16d76291bd 26-Apr-2011 Zhang Rui <rui.zhang@intel.com> ACPI EC: remove redundant code

ec->handle is set in ec_parse_device(), so don't bother to set it again.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
534bc4e3d27096e2f3fc00c14a20efd597837a4f 26-Apr-2011 Zhang Rui <rui.zhang@intel.com> ACPI EC: enable MSI workaround for Quanta laptops

Enable MSI workaround for Quanta laptops.
https://bugzilla.kernel.org/show_bug.cgi?id=20242

Tested-by: Jan-Matthias Braun <jan_braun@gmx.net>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
af986d101d141f10231ffa7e40ae397dc7356857 24-Apr-2011 Peter Collingbourne <peter@pcc.me.uk> ACPI: EC: add another DMI check for ASUS hardware

Commit 0adf3c746a73684b3f8c2821a584e1db998f61e9 introduced a regression
by making the ECDT validation test for ASUS hardware more restrictive.
The previous test used the dmi_name_in_vendors function which searches
a number of DMI fields, while the new test checked only the BIOS
vendor, which is known to not match on an ASUS F5GL laptop which
requires ECDT validation.

Add a rule to ec_dmi_table based on an alternative DMI pattern for
ASUS hardware as found elsewhere in the kernel.

Signed-off-by: Peter Collingbourne <peter@pcc.me.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
1cb7b1e0de6a1f8f071f4a146e3d10f3a662f707 31-Mar-2011 Thomas Renninger <trenn@suse.de> ACPI EC: remove dead code

static void acpi_ec_gpe_query(void *ec_cxt);
-> The function is right above this declaration -> not needed.

poll_force is also not used, cleaned up in ec.c and its users:
compal-laptop and msi-laptop.

Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
bba63a296ffab20e08d9e8252d2f0d99050ac859 13-Dec-2010 Lin Ming <ming.m.lin@intel.com> ACPICA: Implicit notify support

This feature provides an automatic device notification for wake devices
when a wakeup GPE occurs and there is no corresponding GPE method or
handler. Rather than ignoring such a GPE, an implicit AML Notify
operation is performed on the parent device object.
This feature is not part of the ACPI specification and is provided for
Windows compatibility only.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
8b6cd8ad18def34bfc5045b2a0234329bf94cf78 13-Dec-2010 Lin Ming <ming.m.lin@intel.com> ACPICA: New GPE handler callback definition

The new GPE handler callback has 2 additional parameters, gpe_device and
gpe_number.

typedef
u32 (*acpi_gpe_handler) (acpi_handle gpe_device, u32 gpe_number, void *context);

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
a5dc4f898c2a0f66e2cefada6c687db82ba2fcbc 09-Dec-2010 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Add another dmi match entry for MSI hardware

http://bugzilla.kernel.org/show_bug.cgi?id=15418

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
cc: stable@kernel.org
Signed-off-by: Len Brown <len.brown@intel.com>
7a18e96dcbdec3c96876444ae2c7e36ce458e151 21-Oct-2010 Thomas Renninger <trenn@suse.de> ACPI: Make Embedded Controller command timeout delay configurable

Here and then there show up machines which need higher timeout values.
Finding this on affected machines can be cumbersome, because
ACPI_EC_DELAY is a compile option -> make it configurable via boot param.

This can even be provided writable at runtime via:
/sys/modules/acpi/parameters/ec_delay

Known machines where this helps:
Some HP machines where for whatever reasons specific EC accesses take
very long at resume from S3 (in _WAK function).
The AE_TIME error is passed upwards and the ACPI interpreter will
not execute the rest of the _WAK function which results in not properly
initialized devices/variables with different side-effects.

Afaik, on some MSI machines this helped as well.

If this param is needed there probably are underlying problems like:
- EC firmware bug
- A kernel EC driver bug
- An ACPI interpreter behavior (e.g. timings when specific
EC accesses happen and how) which the EC does not like
- ...
which should get evaluated further, but often are nasty or
impossible to fix from OS side.

Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
de4f10466e9347a2f1bfe39e501539557bed2c4b 29-Jul-2010 Thomas Renninger <trenn@suse.de> acpi ec: Fix possible double io port registration

which will result in a harmless but ugly WARN message on
some machines.

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: mjg59@srcf.ucam.org
CC: platform-driver-x86@vger.kernel.org
CC: linux-acpi@vger.kernel.org
CC: astarikovskiy@suse.de
CC: akpm@linux-foundation.org
Signed-off-by: Matthew Garrett <mjg@redhat.com>
b52e04216fcd86968c01ad0cfdb249375f19134d 16-Jul-2010 Thomas Renninger <trenn@suse.de> ACPI: Register EC io ports in /proc/ioports

Formerly these have been exposed through /proc/..
Better register them where all IO ports should get registered
and scream loud if someone else claims to use them.

EC data and command port typically should show up like this
then:
...
0060-0060 : keyboard
0062-0062 : EC data
0064-0064 : keyboard
0066-0066 : EC command
0070-0071 : rtc0
...

Signed-off-by: Thomas Renninger <trenn@suse.de>

CC: Alexey Starikovskiy <astarikovskiy@suse.de>
CC: Len Brown <lenb@kernel.org>
CC: linux-kernel@vger.kernel.org
CC: linux-acpi@vger.kernel.org
CC: Bjorn Helgaas <bjorn.helgaas@hp.com>
CC: platform-driver-x86@vger.kernel.org
Signed-off-by: Matthew Garrett <mjg@redhat.com>
1195a098168fcacfef1cd80d05358e52fb366bf6 16-Jul-2010 Thomas Renninger <trenn@suse.de> ACPI: Provide /sys/kernel/debug/ec/...

This patch provides the same information through debugfs, which previously was
provided through /proc/acpi/embedded_controller/*/info

This is the gpe the EC is connected to and whether the global lock
gets used.
The io ports used are added to /proc/ioports in another patch.
Beside the fact that /proc/acpi is deprecated for quite some time,
this info is not needed for applications and thus can be moved
to debugfs instead of a public interface like /sys.

Signed-off-by: Thomas Renninger <trenn@suse.de>

CC: Alexey Starikovskiy <astarikovskiy@suse.de>
CC: Len Brown <lenb@kernel.org>
CC: linux-kernel@vger.kernel.org
CC: linux-acpi@vger.kernel.org
CC: Bjorn Helgaas <bjorn.helgaas@hp.com>
CC: platform-driver-x86@vger.kernel.org
Signed-off-by: Matthew Garrett <mjg@redhat.com>
49c6c5ff924cecc0b6260109a510b7ed4c970dc5 16-Jul-2010 Thomas Renninger <trenn@suse.de> ACPI: Remove /proc/acpi/embedded_controller/..

Other patches in this series add the same info to /sys/... and
/proc/ioports.

The info removed should never have been used in an application,
eventually someone read it manually.
/proc/acpi is deprecated for more than a year anyway...

Signed-off-by: Thomas Renninger <trenn@suse.de>

CC: Alexey Starikovskiy <astarikovskiy@suse.de>
CC: Len Brown <lenb@kernel.org>
CC: linux-kernel@vger.kernel.org
CC: linux-acpi@vger.kernel.org
CC: platform-driver-x86@vger.kernel.org
Signed-off-by: Matthew Garrett <mjg@redhat.com>
3784730b02b9f147a55b0e4623fcad671273e6e6 25-Jun-2010 Rafael J. Wysocki <rjw@sisk.pl> ACPI / EC: Do not use acpi_set_gpe

The EC driver is the last user of acpi_set_gpe() and since it is
guaranteed that the EC GPE will not be shared, acpi_disable_gpe()
and acpi_enable_gpe() may be used for disabling the GPE temporarilty
if a GPE storm is detected and re-enabling it during EC transactions.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
b63559f5ce08bc8f94ce144a8d06f7af607ecc53 25-Jun-2010 Rafael J. Wysocki <rjw@sisk.pl> ACPI / EC: Drop suspend and resume routines

The suspend and resume routines provided by the EC driver are not
really necessary, because the handler of the GPE disabled by them
is not going to be executed after suspend_device_irqs() and before
resume_device_irqs() anyway.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
a44061aa8b5d58b2729faca4c155a94a5bea2a09 01-Jul-2010 Rafael J. Wysocki <rjw@sisk.pl> ACPICA: Remove wakeup GPE reference counting which is not used

After the previous patch that introduced acpi_gpe_wakeup() and
modified the ACPI suspend and wakeup code to use it, the third
argument of acpi_{enable|disable}_gpe() and the GPE wakeup
reference counter are not necessary any more. Remove them and
modify all of the users of acpi_{enable|disable}_gpe()
accordingly. Also drop GPE type constants that aren't used
any more.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
fe955682d2153b35dffcf1673dff0491096a3f0a 09-Apr-2010 Rafael J. Wysocki <rjw@sisk.pl> ACPI / EC / PM: Fix names of functions that block/unblock EC transactions

The names of the functions used for blocking/unblocking EC
transactions during suspend/hibernation suggest that the transactions
are suspended and resumed by them, while in fact they are disabled
and enabled. Rename the functions (and the flag used by them) to
better reflect what they really do.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
d5a64513c6a171262082c250592c062e97a2c693 09-Apr-2010 Rafael J. Wysocki <rjw@sisk.pl> ACPI / EC / PM: Fix race between EC transactions and system suspend

There still is a race that may result in suspending the system in
the middle of an EC transaction in progress, which leads to problems
(like the kernel thinking that the ACPI global lock is held during
resume while in fact it's not).

To remove the race condition, modify the ACPI platform suspend and
hibernate callbacks so that EC transactions are blocked right after
executing the _PTS global control method and are allowed to happen
again right after the low-level wakeup.

Introduce acpi_pm_freeze() that will disable GPEs, wait until the
event queues are empty and block EC transactions. Use it wherever
GPEs are disabled in preparation for switching local interrupts off.
Introduce acpi_pm_thaw() that will allow EC transactions to happen
again and enable runtime GPEs. Use it to balance acpi_pm_freeze()
wherever necessary.

In addition to that use acpi_ec_resume_transactions_early() to
unblock EC transactions as early as reasonably possible during
resume. Also unblock EC transactions in acpi_hibernation_finish()
and in the analogous suspend routine to make sure that the EC
transactions are enabled in all error paths.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=14668

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reported-and-tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
d6bd535d88429b4804d6d917ab4f586306f9a855 15-May-2010 Julia Lawall <julia@diku.dk> ACPI: EC: Use kmemdup

Use kmemdup when some other buffer is immediately copied into the
allocated region.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression from,to,size,flag;
statement S;
@@

- to = \(kmalloc\|kzalloc\)(size,flag);
+ to = kmemdup(from,size,flag);
if (to==NULL || ...) S
- memcpy(to, from, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
dadf28a10c3eb29421837a2e413ab869ebd9e168 17-Mar-2010 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Allow multibyte access to EC

http://bugzilla.kernel.org/show_bug.cgi?id=14667

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
f6bb13aa1ea3bb26a4c783822347873f085b9000 04-Mar-2010 Rafael J. Wysocki <rjw@sisk.pl> ACPI / EC / PM: Close race between EC and resume from hibernation

There is a race between resume from hibernation and the EC driver
that may result in restoring the hibernation image in the middle of
an EC transaction in progress, which in turn may lead to
unpredictable behavior of the platform.

To remove that race condition, add a helpers for suspending and
resuming EC transactions in a safe way to be executed by the ACPI
platform hibernate pre-restore and restore cleanup callbacks.

http://bugzilla.kernel.org/show_bug.cgi?id=14668

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reported-and-tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
cbbc0de700e61d0cdc854d435dbc2ef148de0e00 24-Feb-2010 Rafael J. Wysocki <rjw@sisk.pl> ACPI: Use GPE reference counting to support shared GPEs

To fix a bug and address the reviewers' comments regarding the ACPI
GPE refcounting patch, do the following additional changes:

o Remove the second argument of acpi_ev_enable_gpe(),
'write_to_hardware', because it is not necessary any more.

o Add the "bad parameter" test against 'type' in
acpi_enable_gpe() and acpi_disable_gpe().

o Make acpi_enable_gpe() only check 'status' for runtime GPEs if
acpi_ev_enable_gpe() was actually called.

o Make acpi_disable_gpe() return 'status' returned by
acpi_ev_disable_gpe() and fix a bug where ACPI_GPE_TYPE_WAKE
and ACPI_GPE_TYPE_RUNTIME were exchanged by mistake.

o Add comments explaining why acpi_set_gpe() is used by the ACPI EC
driver.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
9630bdd9b15d2f489c646d8bc04b60e53eb5ec78 17-Feb-2010 Rafael J. Wysocki <rjw@sisk.pl> ACPI: Use GPE reference counting to support shared GPEs

ACPI GPEs may map to multiple devices. The current GPE interface
only provides a mechanism for enabling and disabling GPEs, making
it difficult to change the state of GPEs at runtime without extensive
cooperation between devices.

Add an API to allow devices to indicate whether or not they want
their device's GPE to be enabled for both runtime and wakeup events.

Remove the old GPE type handling entirely, which gets rid of various
quirks, like the implicit disabling with GPE type setting. This
requires a small amount of rework in order to ensure that non-wake
GPEs are enabled by default to preserve existing behaviour.

Based on patches from Matthew Garrett <mjg@redhat.com>.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
439913fffd39374c3737186b22d2d56c3a0ae526 28-Jan-2010 Lin Ming <ming.m.lin@intel.com> ACPI: replace acpi_integer by u64

acpi_integer is now obsolete and removed from the ACPICA code base,
replaced by u64.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
54070101f86ca9a6e9ba243c999d144721ec3db7 30-Dec-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Add wait for irq storm

Merge of poll and irq modes accelerated EC transaction, so
that keyboard starts to suffer again. Add msleep(1) into
transaction path for the storm to allow keyboard controller
to do its job.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=14747

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
f5347867c5aea94c625246eaff8f7820b0a4cd8a 30-Dec-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: SBS: Move SBS HC callback to faster Notify queue

SBS transactions should happen in Notify work queue, to not create
a dead lock with GPE execution accessing SBS devices.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
a62e8f1978f49e52f87a711ff6711b323d4b12ff 24-Dec-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Accelerate query execution

Split EC query handling into acknowledge and execution phase.
This allows much smaller pending query lattency and lowers chances
of EC going "wild" and losing events.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=14858

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
55b313f249e11b815fd0be51869f166aaf368f44 22-Dec-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Fix MSI DMI detection

MSI strings should be ORed, not ANDed.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=14446

cc: stable@kernel.org
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
2263576cfc6e8f6ab038126c3254404b9fcb1c33 13-Nov-2009 Lin Ming <ming.m.lin@intel.com> ACPICA: Add post-order callback to acpi_walk_namespace

The existing interface only has a pre-order callback. This change
adds an additional parameter for a post-order callback which will
be more useful for bus scans. ACPICA BZ 779.

Also update the external calls to acpi_walk_namespace.

http://www.acpica.org/bugzilla/show_bug.cgi?id=779

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
478fa03b32f1b3320aebc482b1685272e17a4762 02-Oct-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Don't parse DSDT for EC early init on Compal

Compal DSDT breaks if scanned early, while we need early scan
for almost all ASUS machines. Safest workaround seems to be to
continue do an early scan for all machines, but this Compal model.

http://bugzilla.kernel.org/show_bug.cgi?id=14086

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
0adf3c746a73684b3f8c2821a584e1db998f61e9 02-Oct-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Rewrite DMI checks

Use dmi_check_system() for DMI matching.
Don't use string "Notebook" for matching MSI hardware.

http://bugzilla.kernel.org/show_bug.cgi?id=14081

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
e12ac3d018dd8f20a075f5520209862969146fa6 02-Oct-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Restart command even if no interrupts from EC

EC may forget a command without sending any "reset" interrupt,
thus we need to lessen the requirement for transaction restart.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=14247
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
eb27cae8adaa658a0bf31631baa1ce29d8183759 07-Jul-2009 Len Brown <len.brown@intel.com> ACPI: linux/acpi.h should not include linux/dmi.h

users of acpi.h that need dmi.h should include it directly.

Signed-off-by: Len Brown <len.brown@intel.com>
f25752e67d9d9ee7562ae9944314dd8c057d3fa2 28-Aug-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Drop orphan comment

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
6a63b06f3c494cc87eade97f081300bda60acec7 28-Aug-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: use BURST mode only for MSI notebooks

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
2a84cb9852f52c0cd1c48bca41a8792d44ad06cc 30-Aug-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Merge IRQ and POLL modes

In general, EC transaction should complete in less than 1ms, thus it is possible to merge wait for
1ms in poll mode and 1ms of interrupt transaction timeout.
Still, driver will wait 500ms for EC to complete transaction.

This significantly simplifies driver and makes it immune to problematic EC interrupt
implementations.

It also may lessen kernel start-up time by 500ms.

References: http://bugzilla.kernel.org/show_bug.cgi?id=12949

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
a192a9580bcc41692be1f36b77c3b681827f566a 28-Jul-2009 Len Brown <len.brown@intel.com> ACPI: Move definition of PREFIX from acpi_bus.h to internal..h

Linux/ACPI core files using internal.h all PREFIX "ACPI: ",
however, not all ACPI drivers use/want it -- and they
should not have to #undef PREFIX to define their own.

Add GPL commment to internal.h while we are there.

This does not change any actual console output,
asside from a whitespace fix.

Signed-off-by: Len Brown <len.brown@intel.com>
cf745ec7a1222a661b2c5f0e8c2c4be81300d2a4 22-Jun-2009 Bjorn Helgaas <bjorn.helgaas@hp.com> ACPI: EC: remove .stop() method

This patch folds the .stop() method into .remove().

acpi_ec_stop() is only called via acpi_device_probe() and
acpi_device_remove(), and in both cases it is called immediately before
acpi_ec_remove(), so there's no need to have it be a separate method.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Reviewed-by: Alex Chiang <achiang@hp.com>
CC: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
d02be04707b8ff5375a76c027327e8708877da39 22-Jun-2009 Bjorn Helgaas <bjorn.helgaas@hp.com> ACPI: EC: remove .start() method

This patch folds the .start() method into .add().

acpi_ec_start() is always called immediately after acpi_ec_add(),
so there's no need to have it be a separate method.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Reviewed-by: Alex Chiang <achiang@hp.com>
CC: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
5efc5476184173996dfcce780c2bb5e727df674e 22-Jun-2009 Bjorn Helgaas <bjorn.helgaas@hp.com> ACPI: EC: move acpi_ec_start() after acpi_ec_add()

This patch rearranges ec_install_handlers() and acpi_ec_start() so
acpi_ec_start() ends up just after acpi_ec_add(). A subsequent patch
will merge them.

Code movement only; no functional change.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
CC: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
5aa63f038f042fd1acd6e720a95df72857db0bc7 12-Apr-2009 Almer S. Tigelaar <almer@gnome.org> ACPI: EC: Fix ACPI EC resume non-query interrupt message

When resuming from standby (on a laptop) I see the following message in
my kernel.log:
"ACPI: EC: non-query interrupt received, switching to interrupt mode"
This apparently prevented sony-laptop to properly restore the brightness
level on resume.

The cause: In drivers/acpi/ec.c the acpi_ec_suspend function clears the
GPE mode bit, but this is not restored in acpi_ec_resume (the function
below it). The patch below fixes this by properly restoring the GPE_MODE
bit. Tested and confirmed to work.

Signed-off-by: Almer S. Tigelaar <almer@gnome.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
070d8eb1f6b789206486ea6a4a1bb7745d86d314 12-Jan-2009 Jan Engelhardt <jengelh@medozas.de> ACPI: constify VFTs (1/2)

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Len Brown <len.brown@intel.com>
a5032bfdd9c80e0231a6324661e123818eb46ecd 01-Apr-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Always parse EC device

If ECDT info is not valid, we have last chance to configure
EC driver properly at this point, don't miss it.

http://bugzilla.kernel.org/show_bug.cgi?id=12461

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
34ff4dbccccce54c83b1234d39b7ad9e548a75dd 01-Apr-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Separate delays for MSI hardware

MSI notebooks require very strict delays, while all others
are happy with msleep().

References: http://bugzilla.kernel.org/show_bug.cgi?id=9998

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
a5f820feb54a59fcdaf4a67a6381ea1ddb36cc6e 24-Mar-2009 Bjorn Helgaas <bjorn.helgaas@hp.com> ACPI: call acpi_ec_init() explicitly rather than as initcall

This patch makes acpi_init() call acpi_ec_init() directly.
Previously, both were subsys_initcalls. acpi_ec_init()
must happen after acpi_init(), and it's better to call it
explicitly rather than rely on link ordering.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
CC: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
5423a0cb3f74c16e90683f8ee1cec6c240a9556e 21-Feb-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Add delay for slow MSI controller

http://bugzilla.kernel.org/show_bug.cgi?id=12011

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
4312495f7db63d27ef52ec83dab55f14a8c43827 17-Jan-2009 Tero Roponen <tero.roponen@gmail.com> ACPI: Fix crash on ASUS laptops

This patch fixes the crash I experienced in 2.6.29-rc2.
Tested on ASUS M50vm.

Signed-off-by: Tero Roponen <tero.roponen@gmail.com>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
c6cb0e878446c79f42e7833d7bb69ed6bfbb381f 14-Jan-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Don't trust ECDT tables from ASUS

http://bugzilla.kernel.org/show_bug.cgi?id=9399
http://bugzilla.kernel.org/show_bug.cgi?id=11880

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
235c4a59278eb07e61d909f1f0c233733034a8b3 14-Jan-2009 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Limit workaround for ASUS notebooks even more

References: http://bugzilla.kernel.org/show_bug.cgi?id=11884

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
ea7e96e0f2277107d9ea14c3f16c86ba82b2e560 16-Dec-2008 Lin Ming <ming.m.lin@intel.com> ACPI: remove private acpica headers from driver files

External driver files should not include any private acpica headers.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
0175d562a29ad052c510782c7e76bc63d5155b9b 16-Dec-2008 Lin Ming <ming.m.lin@intel.com> ACPI: ec.c: call acpi_get_name to get node name

acpi_namespace_node is internal struct, it should not be used outside of ACPICA
call acpi_get_name to get node ascii name

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
8a383ef0be01e0e6e84c85f8bf35e4e6fcfb8981 09-Dec-2008 Roel Kluin <roel.kluin@gmail.com> ACPI: ec.c, pci_link.c, video_detec.c: static

Sparse asked whether these could be static.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
3e54048691bce3f323fd5460695273be379803b9 29-Nov-2008 Hannes Eder <hannes@hanneseder.net> ACPI: EC: fix compilation warning

Fix the warning introduced in commit c5279dee26c0e8d7c4200993bfc4b540d2469598,
and give the dummy variable a more verbose name.

drivers/acpi/ec.c: In function 'acpi_ec_ecdt_probe':
drivers/acpi/ec.c:1015: warning: ISO C90 forbids mixed declarations and code

Signed-off-by: Hannes Eder <hannes@hanneseder.net>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
7b4d469228a92a00e412675817cedd60133de38a 12-Nov-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: count interrupts only if called from interrupt handler.

fix 2.6.28 EC interrupt storm regression

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
c5279dee26c0e8d7c4200993bfc4b540d2469598 26-Nov-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Add some basic check for ECDT data

One more ASUS comes with empty ECDT, add a guard for it...

http://bugzilla.kernel.org/show_bug.cgi?id=11880

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
8517934ef6aaa28d6e055b98df65b31cedbd1372 10-Nov-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Don't do transaction from GPE handler in poll mode.

Referencies: http://bugzilla.kernel.org/show_bug.cgi?id=12004

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
06cf7d3c7af902939cd1754abcafb2464060cba8 09-Nov-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: lower interrupt storm treshold

http://bugzilla.kernel.org/show_bug.cgi?id=11892

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
0b7084ac67fb84f0cf2f8bc02d7e0dea8521dd2d 25-Oct-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPICA: Use spinlock for acpi_{en|dis}able_gpe

Disabling gpe might interfere with gpe detection/handling,
thus producing "interrupt not handled" errors.
Ironically, disabling of GPE from interrupt context is already
under spinlock, so only userspace needs to start using it.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
a2f93aeadf97e870ff385030633a73e21146815d 11-Nov-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: restart failed command

Restart current transaction if we recieved unexpected GPEs instead
of needed ones.

http://bugzilla.kernel.org/show_bug.cgi?id=11896

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
dd15f8c42af09031e27da5b4d697ce925511f2e1 08-Nov-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: wait for last write gpe

There is a possibility that EC might break if next command is
issued within 1 us after write or burst-disable command.

Suggestd-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
f8248434e6a11d7cd314281be3b39bbcf82fc243 01-Nov-2008 Alan Jenkins <alan-jenkins@tuffmail.co.uk> ACPI: EC: make kernel messages more useful when GPE storm is detected

Make sure we can tell if the GPE storm workaround gets activated,
and avoid flooding the logs afterwards.

http://bugzilla.kernel.org/show_bug.cgi?id=11841
"plenty of line "ACPI: EC: non-query interrupt received,
switching to interrupt mode" in dmesg"

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
1cfe62c8010ac56e1bd3827e30386a87cc2f3594 27-Oct-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: revert msleep patch

With the better solution for EC interrupt storm issue,
there is no need to use msleep over udelay.

References:
http://bugzilla.kernel.org/show_bug.cgi?id=11810
http://bugzilla.kernel.org/show_bug.cgi?id=10724

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
d21cf3c16b1191f3154a51e0b20c82bf851cc553 03-Nov-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI EC: Fix regression due to use of uninitialized variable

breakage introduced by following patch
commit 27663c5855b10af9ec67bc7dfba001426ba21222
Author: Matthew Wilcox <willy@linux.intel.com>
Date: Fri Oct 10 02:22:59 2008 -0400

acpi_evaluate_integer() does not clear passed variable if
there is an error at evaluation.
So if we ignore error, we must supply initialized variable.

http://bugzilla.kernel.org/show_bug.cgi?id=11917

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
20edd74fcf9ad02c19efba0c13670a7b6b045099 17-Oct-2008 Zhao Yakui <yakui.zhao@intel.com> ACPI: Ignore AE_NOT_FOUND error of EC _REG method and continue to initialize EC

On some broken BIOS the ACPI object in EC _REG method can't be found in
ACPI namespace, which causes that the status code of AE_NOT_FOUND is returned by
the EC _REG object. In such case the EC device can't be initialized correctly,
which causes that battery/AC adapter can't work normally. As the EC address
space handler is not removed and the memory pointed by its input argument is
already free, sometimes the kernel will also be panic when EC internal register
is still accessed. But the windows can work well on such broken BIOS.

Maybe it will be reasonable that OS ignores the AE_NOT_FOUND error
returned by the EC _REG object and continues to initialize EC device
on some broken BIOS.
For example: the ACPI object in EC _REG method can't be found and status error
code is AE_NOT_FOUND.

http://bugzilla.kernel.org/show_bug.cgi?id=8953
http://bugzilla.kernel.org/show_bug.cgi?id=10237

lenb: we may find a more general solution to this in the future.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
c0ff17720ec5f42205b3d2ca03a18da0a8272976 16-Oct-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Check for IBF=0 periodically if not in GPE mode

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
27663c5855b10af9ec67bc7dfba001426ba21222 10-Oct-2008 Matthew Wilcox <willy@linux.intel.com> ACPI: Change acpi_evaluate_integer to support 64-bit on 32-bit kernels

As of version 2.0, ACPI can return 64-bit integers. The current
acpi_evaluate_integer only supports 64-bit integers on 64-bit platforms.
Change the argument to take a pointer to an acpi_integer so we support
64-bit integers on all platforms.

lenb: replaced use of "acpi_integer" with "unsigned long long"
lenb: fixed bug in acpi_thermal_trips_update()

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
db89b4f0dbab837d0f3de2c3e9427a8d5393afa3 22-Sep-2008 Pavel Machek <pavel@suse.cz> ACPI: catch calls of acpi_driver_data on pointer of wrong type

Catch attempts to use of acpi_driver_data on pointers of wrong type.

akpm: rewritten to use proper C typechecking and remove the
"function"-used-as-lvalue thing.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
8463200a00fe2aea938b40173198a0983f2929ef 25-Sep-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Rename some variables

No functional changes.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Acked-by: Rafael J. Wysocki <rjw@suse.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7c6db4e050601f359081fde418ca6dc4fc2d0011 25-Sep-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: do transaction from interrupt context

It is easier and faster to do transaction directly from interrupt context
rather than waking control thread.
Also, cleaner GPE storm avoidance is implemented.
References: http://bugzilla.kernel.org/show_bug.cgi?id=9998
http://bugzilla.kernel.org/show_bug.cgi?id=10724
http://bugzilla.kernel.org/show_bug.cgi?id=10919
http://bugzilla.kernel.org/show_bug.cgi?id=11309
http://bugzilla.kernel.org/show_bug.cgi?id=11549
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Signed-off-by: Len Brown <len.brown@intel.com>
9d699ed92a459cb408e2577e8bbeabc8ec3989e1 11-Aug-2008 Zhao Yakui <yakui.zhao@intel.com> ACPI: Avoid bogus EC timeout when EC is in Polling mode

When EC is in Polling mode, OS will check the EC status continually by using
the following source code:
clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
while (time_before(jiffies, delay)) {
if (acpi_ec_check_status(ec, event))
return 0;
msleep(1);
}
But msleep is realized by the function of schedule_timeout. At the same time
although one process is already waken up by some events, it won't be scheduled
immediately. So maybe there exists the following phenomena:
a. The current jiffies is already after the predefined jiffies.
But before timeout happens, OS has no chance to check the EC
status again.
b. If preemptible schedule is enabled, maybe preempt schedule will happen
before checking loop. When the process is resumed again, maybe
timeout already happens, which means that OS has no chance to check
the EC status.

In such case maybe EC status is already what OS expects when timeout happens.
But OS has no chance to check the EC status and regards it as AE_TIME.

So it will be more appropriate that OS will try to check the EC status again
when timeout happens. If the EC status is what we expect, it won't be regarded
as timeout. Only when the EC status is not what we expect, it will be regarded
as timeout, which means that EC controller can't give a response in time.

http://bugzilla.kernel.org/show_bug.cgi?id=9823
http://bugzilla.kernel.org/show_bug.cgi?id=11141

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
2500822bf4eb0179ef80e5b072c1e0fa83037381 12-Aug-2008 Zhao Yakui <yakui.zhao@intel.com> ACPI : Add the EC dmi table to fix the incorrect ECDT table

On some ASUS laptops the ECDT gives the incorrect command/status & Data I/O
register address.

AK: it seems like the command/data addresses are exchanged.

In such case it will cause that EC device can't be
initialized correctly.
To add the EC dmi table is to fix this issue. If the laptop falls into the
EC dmi table, the EC command/data I/O address will be fixed.

AK: Add comments describing this better

http://bugzilla.kernel.org/show_bug.cgi?id=9399

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
tested-by : Jan Kasprzak <kas@fi.muni.cz>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
1b7fc5aae8867046f8d3d45808309d5b7f2e036a 06-Jun-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Use msleep instead of udelay while waiting for event.

http://bugzilla.kernel.org/show_bug.cgi?id=10724

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
cf7acfab032ff262f42954328cdfd20a5d9aaaac 29-Apr-2008 Denis V. Lunev <den@openvz.org> acpi: use non-racy method for proc entries creation

Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.

Add correct ->owner to proc_fops to fix reading/module unloading race.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
ce52ddf58cbc2c40f5f08d37d2217945e4d5adf3 24-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Don't delete boot EC

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
6d9e11206371be370b153264934378a29b6afe9b 24-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Use default setup handler

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
fa95ba04e6ba11d71e1b87becd054b38faf546c8 21-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Detect irq storm

Problem seems to be that hw fails to clear GPE after we service it and write 1
into corresponding bit. Thus, as soon as we get interrupts enabled again, we
receive a new one. Google gives too many results for "acer interrupt storm" for
this being one-broken-machine case.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9998

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
223883b7aafa02410ed2e571d6032c876d0b23b8 21-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Switch off GPE mode during suspend/resume

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
b77d81b2678950077088956da4638c26853389fc 21-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Replace broken controller workarounds with poll mode.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
dc0e8490fe884a9378b8ee04a5b5f905f06f4633 21-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Improve debug output

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
845625cdcb17119d5f6c5c8dbe586f2f36e8008a 21-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Add poll timer

If we can not use interrupt mode of EC for some reason, start polling
EC for events periodically.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
e6e82a3087e6dad619149246082c910623ea9c36 21-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Restore udelay in poll mode

This fixes keyboard event handling on some systems.

Note that this delay was thought unnecessary, and removed
from linux-2.6.20 with 50c1e1138cb94f6aca0f8555777edbcefe0324e2
'ACPI: ec: Drop udelay() from poll mode. Loop by reading status field instead.'

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
d7a0e1f56472db0825e13f9dd39f0ad79b8c8b3e 19-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> Revert "ACPI: EC: Handle IRQ storm on Acer laptops"

This reverts commit 2c81ce4c9c37b910210f2640c28e98a0c398dc26.

It caused several new troubles (eg suspend slowdown bisected down to
this patch by Pavel Machek), so just revert it for now.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Cc: Pavel Machek <pavel@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2c81ce4c9c37b910210f2640c28e98a0c398dc26 11-Mar-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Handle IRQ storm on Acer laptops

On some Acer systems, the HW fails to clear the GPE source,
causing an interrupt storm.

So in EC interrupt mode, we count how many interrupts we
receive when waiting. If we get more than 5, we give
up on interrupt mode and revert to polling mode.

Also, for polling mode to work on Acers, we need
to insert a delay.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
4af8e10a6c57e7292862bd1703712f0565c7e429 11-Mar-2008 Len Brown <len.brown@intel.com> Revert "ACPI: EC: Use proper handle for boot EC"

This reverts commit 208c70a45624400fafd7511b96bc426bf01f8f5e.

http://bugzilla.kernel.org/show_bug.cgi?id=10100

Signed-off-by: Len Brown <len.brown@intel.com>
208c70a45624400fafd7511b96bc426bf01f8f5e 14-Feb-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Use proper handle for boot EC

Fall back to ACPI_ROOT_HANDLE only in case of error.

ACPI: EC: EC description table is found, configuring boot EC
ACPI Error (evregion-0316): No handler for Region [ECOR] (ffff81007a651620) [EmbeddedControl] [20070126]
ACPI Error (exfldio-0289): Region EmbeddedControl(3) has no handler [20070126]

http://bugzilla.kernel.org/show_bug.cgi?id=9916

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
d772b3b323a15588a757f5af28e51a57d0d2f622 24-Jan-2008 Márton Németh <nm127@freemail.hu> ACPI: EC: "DEBUG" needs to be defined earlier

The "DEBUG" symbol needs to be defined before #including <linux/kernel.h> to
get the pr_debug() working.

Signed-off-by: Márton Németh <nm127@freemail.hu>
Signed-off-by: Len Brown <len.brown@intel.com>
86dae0154a49b67c908faffeb33ba37eddceba74 24-Jan-2008 Márton Németh <nm127@freemail.hu> ACPI: EC: add leading zeros to debug messages

Add leading zeros to pr_debug() calls. For example if x=0x0a, the format
"0x%2x" will result the string "0x a", the format "0x%2.2x" will result "0x0a".

Signed-off-by: Márton Németh <nm127@freemail.hu>
Signed-off-by: Len Brown <len.brown@intel.com>
03d1d99c55649ca641b86d2e3489b167ede1671a 24-Jan-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: fix dmesg spam regression

Return OBF_1 optimization workaround

http://bugzilla.kernel.org/show_bug.cgi?id=8459

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
b3b233c7d948a5f55185fb5a1b248157b948a1e5 11-Jan-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Some hardware requires burst mode to operate properly

Burst mode temporary (50 ms) locks EC to do only transactions with
driver, without it some hardware returns abstract garbage.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9341

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
3e71a87d03055de0b8c8e42aba758ee6494af083 11-Jan-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Do the byte access with a fast path

Specification allows only byte access for EC region, so
make it separate from bug-compatible multi-byte access.
Also do not allow return of garbage in supplied *value.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9341

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
c04209a7948b95e8c52084e8595e74e9428653d3 01-Jan-2008 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Enable boot EC before bus_scan

Some _STA methods called during bus_scan() might require EC region handler,
which might be enabled later in the scan.
Enable it explicitly before scan to avoid errors.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9627

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
e790cc8bbb990df900eabdda18a5a480d22a60c8 21-Nov-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Workaround for optimized controllers (version 3)

Some controllers fail to send confirmation GPE after address or data write.
Detect this and don't expect such confirmation in future.
This is a generalization of previous workaround
(66c5f4e7367b0085652931b2f3366de29e7ff5ec), which did only read address.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9327

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Romano Giannetti <romano.giannetti@gmail.com>
Tested-by: Mats Johannesson
Signed-off-by: Len Brown <len.brown@intel.com>
3ebe08a749a0971a5407818169dc16212ef562f9 21-Nov-2007 Márton Németh <nm127@freemail.hu> ACPI: EC: use printk_ratelimit(), add some DEBUG mode messages

Sometimes it is usefull to see raw protocol dump.
Uncomment '#define DEBUG' at the beginning of file to make EC
really verbose.

Signed-off-by: Márton Németh <nm127@freemail.hu>
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
0af2f653c504d302d83d3a648c0408882ff62d4c 21-Nov-2007 Len Brown <len.brown@intel.com> Revert "ACPI: EC: Workaround for optimized controllers"

This reverts commit f2d68935ba08cf80f151bbdb5628381184e4a498.
4fdb2a05ef5703553fdd28f1b96ebdd79f173657 20-Nov-2007 Joe Perches <joe@perches.com> ACPI: Add missing spaces to printk format

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Len Brown <len.brown@intel.com>
5870a8cd23181703cc76f88f630372f8602c7648 15-Nov-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Don't init EC early if it has no _INI

Option to init EC early inserted to handle #8598 ASUS problem,
introduced several others.

EC driver in this particular case has fake _INI method, not present on
other machines, which don't need or break from this workaround, so lets use
its presence as a flag for early init.

http://bugzilla.kernel.org/show_bug.cgi?id=9262
http://bugzilla.kernel.org/show_bug.cgi?id=8598
https://bugzilla.novell.com/show_bug.cgi?id=334806

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
f2d68935ba08cf80f151bbdb5628381184e4a498 18-Nov-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Workaround for optimized controllers

Some controllers fail to send confirmation GPE after address write.
Detect this and don't expect such confirmation in future.
This is a generalization of previous workaround
(66c5f4e7367b0085652931b2f3366de29e7ff5ec), which did only read address.

http://bugzilla.kernel.org/show_bug.cgi?id=9327

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Romano Giannetti <romano.giannetti@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
1544fdbc857cbe8afca16a521d3254346befeb06 24-Oct-2007 Adrian Bunk <bunk@kernel.org> ACPI: EC: fix use-after-free

This patch fixes a use-after-free introduced by
commit 30c08574da0ead1a47797ce028218ce5b2de61c7
(ACPI: EC: Add new query handler to list head)

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
95b937e3f52a7f5546c4bffe29886fe400bad1d1 22-Oct-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Output changes to operational mode

Insert printk() for every change in operational mode.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
66c5f4e7367b0085652931b2f3366de29e7ff5ec 22-Oct-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Add workaround for "optimized" controllers

Some controllers do not send interrupts for OBF=1 event, but send
them for IBF=0. Add workaround for them.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=8459

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
1c55053c21706ccf1fdb26b4bb6d05c4a2782ffe 22-Oct-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Don't re-enable GPE for each transaction.

With the auto selection of operation mode, absence of GPEs does not
really degrade performance, so let PM code to handle
enabling/disabling GPEs.
This is a revert of 5d57a6a55ec0bdcb952dbcd3f8ffcde8a3ee9413,
which was meant to be temporary.

Reference: http://bugzilla.kernel.org/show_bug.cgi?id=7977

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
7843932ac42899b936085beaea8620d4489b8b3f 22-Oct-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: auto select interrupt mode

Start in POLL mode, and if we receive confirmation GPE,
switch to INT mode.
If confirmations are not sent, switch back to POLL.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
0c5d31f48e54b2e56e9cef8d49ffedaef1e0ea52 22-Oct-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Don't expect interrupt after last read

There is no interrupt after last read according to spec, so
don't set bit that we are expecting one.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
080e412cc0bdb9ef8e7a983d5e008537e1c4d36c 22-Oct-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Replace atomic variables with bits

Number of flags is about to be increased, so it is better to
put them all into bits.
No functional changes.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
30c08574da0ead1a47797ce028218ce5b2de61c7 26-Sep-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Add new query handler to list head.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
4c611060660f0de3e9b8f02df207312bc6f5c331 06-Sep-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Drop ECDT-based boot_ec as soon as we find DSDT-based one.

ASUS notebooks have numerous problems with EC initialization
This patch tries to work around three known issues reported
in bugzilla 8598, 8709 and 8909/8919.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
2d8348b429b4ae5cc47449c787881221fe43af4b 31-Aug-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Check if boot_ec was really found in DSDT

acpi_get_devices() returns success if it did not find any device.
We have to check for this case.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Daniel Ritz <daniel.ritz-ml@swissonline.ch>
Tested-by: Luca <kronos.it@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
f9319f903f898dd4b15dbc386499725ce6c59776 24-Aug-2007 Alexey Starikovskiy <astarikovskiy@novell.com> ACPI: EC: revert fix for bugzilla 8709

This is a manual revert of 7c010de7506954e973abfab5c5999c5a97f7a73e,
a fix that broke another ASUS in 8909 and 8919.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
c019b1933015ee31366eeaa085bad3ee9516991c 14-Aug-2007 Alexey Starikovskiy <astarikivskiy@suse.de> ACPI: EC: Fix "no battery" regression

Restore deleted call to register query methods.

http://bugzilla.kernel.org/show_bug.cgi?id=8886

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
199e9e7d1106686a85ee9fdf6a824051aa82682e 10-Aug-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI EC: remove potential deadlock from EC

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
0a5245099819b0ae0a8e985f54909ba8414faba5 25-Jul-2007 Meelis Roos <mroos@linux.ee> ACPI: EC: fix run-together printk lines

Signed-off-by: Meelis Roos <mroos@linux.ee>
Signed-off-by: Len Brown <len.brown@intel.com>
07ddf768d860bee7bd6581b7af3ce1009dbd05d0 29-Jul-2007 Adrian Bunk <bunk@stusta.de> ACPI: EC: acpi_ec_remove(): fix use-after-free

This patch fixes an obvious use-after-free introduced by
commit 837012ede14a8fc088be3682c964da7fc6af026b.

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
7c010de7506954e973abfab5c5999c5a97f7a73e 03-Aug-2007 Alexey Starikovskiy <astarikivskiy@suse.de> ACPI: EC: Switch from boot_ec as soon as we find its desc in DSDT.

Some ASUS laptops fail to use boot time EC
and need to eventually switch to one described in DSDT.

http://bugzilla.kernel.org/show_bug.cgi?id=8709

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
52fe4bdf40bc07498c5f7935551774e8f8458190 03-Aug-2007 Len Brown <len.brown@intel.com> ACPI: EC: fix build warning

drivers/acpi/ec.c:657: warning: ‘acpi_ec_register_query_methods’ defined but not used

Signed-off-by: Len Brown <len.brown@intel.com>
cd8c93a4e04dce8f00d1ef3a476aac8bd65ae40b 03-Aug-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: If ECDT is not found, look up EC in DSDT.

Some ASUS laptops access EC space from device _INI methods, but do not
provide ECDT for early EC setup. In order to make them function properly,
there is a need to find EC is DSDT before any _INI is called.

Similar functionality was turned on by acpi_fake_ecdt=1 command line
before. Now it is on all the time.

http://bugzilla.kernel.org/show_bug.cgi?id=8598

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
f1cd1fe61b96e4312312d42c0a9784dfab12e007 03-Aug-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI: EC: Remove noisy debug printk fron EC driver.

ACPI: EC: Handler for query 0x57 is not found!

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
1ba90e3a87c46500623afdc3898573e4a5ebb21b 23-Jul-2007 Thomas Renninger <trenn@suse.de> ACPI: autoload modules - Create __mod_acpi_device_table symbol for all ACPI drivers

modpost is going to use these to create e.g. acpi:ACPI0001
in modules.alias.

Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
837012ede14a8fc088be3682c964da7fc6af026b 29-May-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI EC: Add support for non-AML EC query handlers

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
4350933a7447591041b51157a6b307be1816415f 29-May-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI EC: drop usage of ACPI_DEBUG_PRINT as too heavy weight

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
5b7734b440d29dab583a6c3f0ee49ff20f323332 29-May-2007 Alexey Starikovskiy <astarikovskiy@suse.de> ACPI EC: Re-factor EC space handler to avoid using label/goto for cycle.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
00eb43a1897a8845d0edb198cec69ac5f1f299dd 04-May-2007 Lennart Poettering <mzxreary@0pointer.de> acpi,msi-laptop: Fall back to EC polling mode for MSI laptop specific EC commands

The ACPI EC that is used in MSI laptops knows some non-standard
commands for changing the screen brighntess and a few other things,
which are used by the msi-laptop.c driver. Unfortunately for these
commands no GPE events for IBF and OBF are triggered. Since nowadays
the EC code uses the ec_intr=1 mode by default, this causes these
operations to timeout, although they don't fail. In result, all
operations that you can do with the msi-laptop.c driver take more or
less 1s to complete, which is awfully slow.

In one of the more recent kernels (2.6.20?) the EC subsystem has been
revamped. With that change the EC timeout has been increased. before
that increase the MSI EC accesses were slow -- but not *that* slow,
hence I took notice of this limitation of the MSI EC hardware only very
recently.

The standard EC operations on the MSI EC as defined in the ACPI spec
support GPE events properly.

The following patch adds a new argument "force_poll" to the
ec_transaction() function (and friends). If set to 1, the function
will poll for IBF/OBF even if ec_intr=1 is enabled. If set to 0 the
current behaviour is used. The msi-laptop driver is modified to make
use of this new flag, so that OBF/IBF is polled for the special MSI EC
transactions -- but only for them.

Signed-off-by: Lennart Poettering <mzxreary@0pointer.de>
Acked-by: Alexey Starikovskiy <aystarik@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
9fd9f8e8bdcfc9aa309dae5bccc55d02804337d0 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: Block queries until EC is fully initialized

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
01f2246269639f6aa93086719a8dbec26cb68e98 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: Cleanup of EC initialization

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
d033879c9838b960014e861d0eb3bdf11d3b9d9d 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: first_ec is better to be acpi_ec than acpi_device.

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
d66d969df88c742494736ed06eeaf3229d3a7259 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: Rename ec_ecdt to more informative boot_ec

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
c0900c3512dc8fd0b37f8fbcebc7853ed9efff10 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: Clean ECDT and namespace parsing.

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
e8284321048aac7be307b3ec5e0631f5c514935a 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: Put install handlers into separate function.

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
3d02b90be2c7bc7ffbc5e502a135c13838d23ef4 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: Remove casts to/from void* from ec.c

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
c45aac43fec2d6ca8d0be8408f94e8176c8110ef 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: enable burst functionality in EC.

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
33c7a0738c5f753a7d94fd3b2ec7d84e79a141a8 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: "Fake ECDT" workaround is not needed any longer.

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
a5f8dee2d367e69fd57f5ea107072bb72eb15327 07-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: EC: Don't use Global Lock if not asked to do so

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
9e197219605513c14d3eae41039ecf1b82d1920d 08-Mar-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: fix race in status register access

Delay the read of the EC status register until
after the event that caused it occurs -- otherwise
it is possible to read and act on stale status that was
associated with the previous event.

Do this with a perpetually incrementing "event_count" to detect
when a new event occurs and it is safe to read status.

There is no workaround for polling mode -- it is inherently
exposed to reading and acting on stale status, since it
doesn't have an interrupt to tell it the event completed.

http://bugzilla.kernel.org/show_bug.cgi?id=8110

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
c24e912b61b1ab2301c59777134194066b06465c 15-Feb-2007 Alexey Starikovskiy <alexey.y.starikovskiy@linux.intel.com> ACPI: ec: add unlock in error path

Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7cda93e008e1a477970adbf82dba81a5d4f0ae40 13-Feb-2007 Len Brown <len.brown@intel.com> ACPI: delete extra #defines in /drivers/acpi/ drivers

Cosmetic only.

Except in a single case, #define ACPI_*_DRIVER_NAME
were invoked 0 or 1 times.

Signed-off-by: Len Brown <len.brown@intel.com>
c2b6705b75d9c7aff98a4602a32230639e10891c 13-Feb-2007 Len Brown <len.brown@intel.com> ACPI: fix acpi_driver.name usage

It was erroneously used as a description rather than a name.

ie. turn this:

lenb@se7525gp2:/sys> ls bus/acpi/drivers
ACPI AC Adapter Driver ACPI Embedded Controller Driver ACPI Power Resource Driver
ACPI Battery Driver ACPI Fan Driver ACPI Processor Driver
ACPI Button Driver ACPI PCI Interrupt Link Driver ACPI Thermal Zone Driver
ACPI container driver ACPI PCI Root Bridge Driver hpet

into this:

lenb@se7525gp2:~> ls /sys/bus/acpi/drivers
ac battery button container ec fan hpet pci_link pci_root power processor thermal

Signed-off-by: Len Brown <len.brown@intel.com>
f52fd66d2ea794010c2d7536cf8e6abed0ac4947 13-Feb-2007 Len Brown <len.brown@intel.com> ACPI: clean up ACPI_MODULE_NAME() use

cosmetic only

Make "module name" actually match the file name.
Invoke with ';' as leaving it off confuses Lindent and gcc doesn't care.
Fix indentation where Lindent did get confused.

Signed-off-by: Len Brown <len.brown@intel.com>
15a58ed12142939d51076380e6e58af477ad96ec 02-Feb-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPICA: Remove duplicate table definitions (non-conflicting), cont

Signed-off-by: Len Brown <len.brown@intel.com>
ad363f80c386bc4701b1bc2cdf08ca9b96a9337b 02-Feb-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPICA: Remove duplicate table definitions.

Signed-off-by: Len Brown <len.brown@intel.com>
ad71860a17ba33eb0e673e9e2cf5ba0d8e3e3fdd 02-Feb-2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPICA: minimal patch to integrate new tables into Linux

Signed-off-by: Len Brown <len.brown@intel.com>
723fe2ca82d1ffc80c9d53035babf011f84c65d4 06-Jan-2007 Len Brown <len.brown@intel.com> ACPI: ec: enable printk on cmdline use

if somebody uses "ec_intr=", lets be sure to
capture that in the dmesg even in the non-debug case.

Signed-off-by: Len Brown <len.brown@intel.com>
c6e19194b6e1a565f8fe18d56d509e9892c32ee1 24-Dec-2006 Guillaume Chazarain <guichaz@yahoo.fr> ACPI: EC: move verbose printk to debug build only

The recent EC cleanup left a printk enabled on handler evaluation
resulting in a bunch of messages on normal operation, like so:

ACPI: EC: evaluating _Q60

Signed-off-by: Len Brown <len.brown@intel.com>
36bcbec7ce21e2e8b3143b11a05747330abeca70 19-Dec-2006 Burman Yan <yan_952@hotmail.com> ACPI: replace kmalloc+memset with kzalloc

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Len Brown <len.brown@intel.com>
a854e08a5a4f57d54991b3a40a80823dd548339d 19-Dec-2006 Adrian Bunk <bunk@stusta.de> ACPI: make drivers/acpi/ec.c:ec_ecdt static

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Len Brown <len.brown@intel.com>
6ccedb10e39c34a4cb68f6c8dae67ecdd3e0b138 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Lindent once again

Signed-off-by: Len Brown <len.brown@intel.com>
3261ff4db3a33ac7e1b9ed98e905663845cadbc6 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Change #define to enums there possible.

Signed-off-by: Len Brown <len.brown@intel.com>
78d0af3392cba6dfdd1dc1eab5a86ba8e4af8fff 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Style changes.

Signed-off-by: Len Brown <len.brown@intel.com>
523953b41e52952347d7d50dcc4bfc27bc001dc8 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Acquire Global Lock under EC mutex.

Signed-off-by: Len Brown <len.brown@intel.com>
50c1e1138cb94f6aca0f8555777edbcefe0324e2 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Drop udelay() from poll mode. Loop by reading status field instead.

Signed-off-by: Len Brown <len.brown@intel.com>
a86e277259b08be0f00cfcb182922da3ffc50f04 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Rename gpe_bit to gpe

Signed-off-by: Len Brown <len.brown@intel.com>
c787a8551e7fee85366962881e7a4f2fda656dfc 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Change semaphore to mutex.

Signed-off-by: Len Brown <len.brown@intel.com>
5d0c288b7362ad7ee235b59352ac2a89480e4757 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Query only single query at a time.

Signed-off-by: Len Brown <len.brown@intel.com>
e41334c0a6ef71458f255db25f011d15099e7cca 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Remove calls to clear_gpe() and enable_gpe(), as these are handled at

dispatch_gpe() level.

Signed-off-by: Len Brown <len.brown@intel.com>
af3fd1404fd4f0f58ebbb52b22be4f1ca0794cda 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Remove expect_event and all races around it.

Signed-off-by: Len Brown <len.brown@intel.com>
bec5a1e0604d1b829b87b4b7e85f71ccc43dda50 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Read status register from check_status() function

Signed-off-by: Len Brown <len.brown@intel.com>
5c4064124a5720a2576eb4bd5b7200d70052e9b5 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Increase timeout from 50 to 500 ms to handle old slow machines.

http://bugzilla.kernel.org/show_bug.cgi?id=7466

Signed-off-by: Len Brown <len.brown@intel.com>
5d57a6a55ec0bdcb952dbcd3f8ffcde8a3ee9413 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Enable EC GPE at beginning of transaction

Temporary measure until resume sequence is right.

Signed-off-by: Len Brown <len.brown@intel.com>
d91df1aaa9e4c06f8ea10d4935888c4f1976ef56 07-Dec-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: ec: Allow for write semantics in any command.

Check for transaction attributes, not command index to decide on event to
expect.

Signed-off-by: Len Brown <len.brown@intel.com>
616362de2fe224512fe105aec08f19f5470afb01 27-Oct-2006 Randy Dunlap <randy.dunlap@oracle.com> ACPI: make ec_transaction not extern

Fix sparse warning:
drivers/acpi/ec.c:372:12: warning: function 'ec_transaction' with external linkage has definition

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Len Brown <len.brown@intel.com>
50dd096973f1d95aa03c6a6d9e148d706b62b68e 01-Oct-2006 Jan Engelhardt <jengelh@linux01.gwdg.de> ACPI: Remove unnecessary from/to-void* and to-void casts in drivers/acpi

Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
Signed-off-by: Len Brown <len.brown@intel.com>
ab9e43c640b2b7d6e296fc39dd8cbcb96f9ae393 04-Oct-2006 Lennart Poettering <mzxreary@0pointer.de> ACPI: EC: export ec_transaction() for msi-laptop driver

Signed-off-by: Lennart Poettering <mzxreary@0pointer.de>
Signed-off-by: Len Brown <len.brown@intel.com>
6ffb221a82de962f31034b45d945e203a0f0500f 26-Sep-2006 Denis M. Sadykov <denis.m.sadykov@intel.com> ACPI: EC: Simplify acpi_hw_low_level*() with inb()/outb().

Simplify acpi_hw_low_level_xxx() functions to inb() and outb().

Signed-off-by: Alexey Y. Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
8e0341ba791cc72c643340b0d8119141ae5a80c5 26-Sep-2006 Denis M. Sadykov <denis.m.sadykov@intel.com> ACPI: EC: Unify poll and interrupt gpe handlers

Signed-off-by: Alexey Y. Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
3576cf619b73d850f5b21375609645f221e6270f 26-Sep-2006 Denis M. Sadykov <denis.m.sadykov@intel.com> ACPI: EC: Unify poll and interrupt mode transaction functions

Signed-off-by: Alexey Y. Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
703959d47e887a29dc58123c05aa0ffcbbfa131d 26-Sep-2006 Denis M. Sadykov <denis.m.sadykov@intel.com> ACPI: EC: Remove unused variables and duplicated code

Signed-off-by: Alexey Y. Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7c6db5e51227761f42c6ac8260753f5c24dc1dde 26-Sep-2006 Denis M. Sadykov <denis.m.sadykov@intel.com> ACPI: EC: Remove unnecessary delay added by previous transation patch.

Remove unnecessary delay (50 ms) while reading data from EC in interrupt mode.

Signed-off-by: Alexey Y. Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
d7a76e4cb3b4469b1eccb6204c053e3ebcd4c196 05-Sep-2006 Lennart Poettering <mzxreary@0pointer.de> ACPI: consolidate functions in acpi ec driver

Unify the following functions:

acpi_ec_poll_read()
acpi_ec_poll_write()
acpi_ec_poll_query()
acpi_ec_intr_read()
acpi_ec_intr_write()
acpi_ec_intr_query()

into:

acpi_ec_poll_transaction()
acpi_ec_intr_transaction()

These new functions take as arguments an ACPI EC command, a few bytes
to write to the EC data register and a buffer for a few bytes to read
from the EC data register. The old _read(), _write(), _query() are
just special cases of these functions.

Then unified the code in acpi_ec_poll_transaction() and
acpi_ec_intr_transaction() a little more. Both functions are now just
wrappers around the new acpi_ec_transaction_unlocked() function. The
latter contains the EC access logic, the two original
function now just do their special way of locking and call the the
new function for the actual work.

This saves a lot of very similar code. The primary reason for doing
this, however, is that my driver for MSI 270 laptops needs to issue
some non-standard EC commands in a safe way. Due to this I added a new
exported function similar to ec_write()/ec_write() which is called
ec_transaction() and is essentially just a wrapper around
acpi_ec_{poll,intr}_transaction().

Signed-off-by: Lennart Poettering <mzxreary@0pointer.de>
Acked-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Len Brown <len.brown@intel.com>
d75080328affb4b268da430b7074cc8139cc662a 04-Jul-2006 Arjan van de Ven <arjan@infradead.org> ACPI: add 'const' to several ACPI file_operations

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
49fee981fa98f3c0a21f3d6c8193eddcc15e84e9 20-Jun-2006 Vladimir Lebedev <vladimir.p.lebedev@intel.com> ACPI: fix battery on HP NX6125

EC problem was cause of both battery and AC issues.
http://bugzilla.kernel.org/show_bug.cgi?id=6455

Signed-off-by: Len Brown <len.brown@intel.com>
d550d98d3317378d93a4869db204725d270ec812 27-Jun-2006 Patrick Mochel <mochel@linux.intel.com> ACPI: delete tracing macros from drivers/acpi/*.c

Signed-off-by: Len Brown <len.brown@intel.com>
6468463abd7051fcc29f3ee7c931f9bbbb26f5a4 27-Jun-2006 Len Brown <len.brown@intel.com> ACPI: un-export ACPI_ERROR() -- use printk(KERN_ERR...)

Signed-off-by: Len Brown <len.brown@intel.com>
a6fc67202e0224e6c9d1d285cc0b444bce887ed5 27-Jun-2006 Thomas Renninger <trenn@suse.de> ACPI: Enable ACPI error messages w/o CONFIG_ACPI_DEBUG

Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
b8d35192c55fb055792ff0641408eaaec7c88988 05-May-2006 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> ACPI: execute Notify() handlers on new thread

http://bugzilla.kernel.org/show_bug.cgi?id=5534

Thanks to Peter Wainwright for isolating the issue.
Thanks to Andi Kleen and Bob Moore for feedback.
Thanks to Richard Mace and others for testing.
Updates by Konstantin Karasyov.

Signed-off-by: Konstantin Karasyov <konstantin.a.karasyov@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
f9a6ee1afb84fd767508428ec5d1df4fb60a03ad 20-Dec-2005 Rich Townsend <rhdt@bartol.udel.edu> ACPI: replace spin_lock_irq with mutex for ec poll mode

http://bugzilla.kernel.org/show_bug.cgi?id=5764

Signed-off-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
ff2fc3e9e3edb918b6c6b288485c6cb267bc865e 29-Mar-2006 Jiri Slaby <jirislaby@gmail.com> ACPI: EC acpi-ecdt-uid-hack

On some boxes ecdt uid may be equal to 0, so do not test for uids equality,
so that fake handler will be unconditionally removed to allow loading the
real one.

See http://bugzilla.kernel.org/show_bug.cgi?id=6111

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Luming Yu <luming.yu@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Len Brown <len.brown@intel.com>
9b41046cd0ee0a57f849d6e1363f7933e363cca9 31-Mar-2006 OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> [PATCH] Don't pass boot parameters to argv_init[]

The boot cmdline is parsed in parse_early_param() and
parse_args(,unknown_bootoption).

And __setup() is used in obsolete_checksetup().

start_kernel()
-> parse_args()
-> unknown_bootoption()
-> obsolete_checksetup()

If __setup()'s callback (->setup_func()) returns 1 in
obsolete_checksetup(), obsolete_checksetup() thinks a parameter was
handled.

If ->setup_func() returns 0, obsolete_checksetup() tries other
->setup_func(). If all ->setup_func() that matched a parameter returns 0,
a parameter is seted to argv_init[].

Then, when runing /sbin/init or init=app, argv_init[] is passed to the app.
If the app doesn't ignore those arguments, it will warning and exit.

This patch fixes a wrong usage of it, however fixes obvious one only.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
858119e159384308a5dde67776691a2ebf70df0f 14-Jan-2006 Arjan van de Ven <arjan@infradead.org> [PATCH] Unlinline a bunch of other functions

Remove the "inline" keyword from a bunch of big functions in the kernel with
the goal of shrinking it by 30kb to 40kb

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
50eca3eb89d73d9f0aa070b126c7ee6a616016ab 01-Oct-2005 Bob Moore <robert.moore@intel.com> [ACPI] ACPICA 20050930

Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)

All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".

The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)

Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.

acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
1e8df53c925024548cca4374f03bed1a7e2b0c45 05-Dec-2005 Len Brown <len.brown@intel.com> [ACPI] Embedded Controller (EC) driver printk syntax update

no functional changes

Signed-off-by: Len Brown <len.brown@intel.com>
53f11d4ff8797bcceaf014e62bd39f16ce84baec 05-Dec-2005 Len Brown <len.brown@intel.com> [ACPI] Enable Embedded Controller (EC) interrupt mode by default

"ec_intr=0" reverts to polling
"ec_burst=" no longer exists.

Signed-off-by: Len Brown <len.brown@intel.com>
Acked-by: Luming Yu <luming.yu@intel.com>
02b28a33aae93a3b53068e0858d62f8bcaef60a3 05-Dec-2005 Len Brown <len.brown@intel.com> [ACPI] Embedded Controller (EC) driver syntax update

"intr" largely replaces "burst" for syntax to follow semantics
"poll" largely replaces "polling" for economy of expression
append "interrupt mode" or "polling mode" to dmesg line

no functional changes

Signed-off-by: Len Brown <len.brown@intel.com>
06a2a3855e20ed3df380d69b37130ba86bec8001 27-Sep-2005 Luming Yu <luming.yu@intel.com> [ACPI] Disable EC burst mode w/o disabling EC interrupts

Need to de-couple the concept of polling/interrupts
vs burst/non-burst.

http://bugzilla.kernel.org/show_bug.cgi?id=4980

Signed-off-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
eca008c8134df15262a0362623edb59902628c95 22-Sep-2005 Len Brown <len.brown@intel.com> [ACPI] handle ACPICA 20050916's acpi_resource.type rename

Signed-off-by: Len Brown <len.brown@intel.com>
50526df605e7c3e22168664acf726269eae10171 11-Aug-2005 Len Brown <len.brown@intel.com> [ACPI] Lindent drivers/acpi/ec.c

necessary for clean merge from acpi-2.6.12 to-akpm

Signed-off-by: Len Brown <len.brown@intel.com>
716e084edb0230910b174000dc3490f9e91652e3 10-Aug-2005 Luming Yu <luming.yu@intel.com> [ACPI] Fix "ec_burst=1" mode latency issue

http://bugzilla.kernel.org/show_bug.cgi?id=3851

Signed-off-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
4be44fcd3bf648b782f4460fd06dfae6c42ded4b 05-Aug-2005 Len Brown <len.brown@intel.com> [ACPI] Lindent all ACPI files

Signed-off-by: Len Brown <len.brown@intel.com>
7b15f5e7bb180ac7bfb8926dbbd8835fecc07fad 03-Aug-2005 Luming Yu <luming.yu@intel.com> [ACPI] revert Embedded Controller to polling-mode by default (ala 2.6.12)
Burst mode isn't ready for prime time,
but can be enabled for test via "ec_burst=1"

Signed-off-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
45bea1555f5bf0cd5871b208b4b02d188f106861 23-Jul-2005 Luming Yu <luming.yu@intel.com> [ACPI] Add "ec_polling" boot option

EC burst mode benefits many machines, some of
them significantly. However, our current
implementation fails on some machines such
as Rafael's Asus L5D.

This patch restores the alternative EC polling code,
which can be enabled at boot time via "ec_polling"

http://bugzilla.kernel.org/show_bug.cgi?id=4665

Signed-off-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
668d74c04c16bb69de564e25e85dd94eeb0175d9 23-Jul-2005 Luming Yu <luming.yu@intel.com> ACPI: delete unnecessary EC console messages

http://bugzilla.kernel.org/show_bug.cgi?id=4534

Signed-off-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
17e9c78a75ce9eacd61200f9e1f1924012e28846 23-Apr-2005 Luming Yu <luming.yu@intel.com> [ACPI] EC GPE-disabled issue
http://bugzilla.kernel.org/show_bug.cgi?id=3851

Signed-off-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
83ea7445221651dc43cf8d22f81089e0cbccf22b 31-Mar-2005 Andrew Morton <akpm@osdl.org> [ACPI] fix build warning

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Len Brown <len.brown@intel.com>
fa9cd547e097df4966b8bd5c94aeed953e32b14d 19-Mar-2005 Luming Yu <luming.yu@intel.com> [ACPI] fix EC access width
http://bugzilla.kernel.org/show_bug.cgi?id=4346

Written-by: David Shaohua Li and Luming Yu
Signed-off-by: Len Brown <len.brown@intel.com>
451566f45a2e6cd10ba56e7220a9dd84ba3ef550 19-Mar-2005 Dmitry Torokhov <dtor@mail.ru> [ACPI] Enable EC Burst Mode

Fixes several Embedded Controller issues, including
button failure and battery status AE_TIME failure.

http://bugzilla.kernel.org/show_bug.cgi?id=3851

Based on patch by: Andi Kleen <ak@suse.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Luming Yu <luming.yu@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org> Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!