From: Alexey Starikovskiy <astarikovskiy@suse.de>
To: LenBrown <lenb@kernel.org>
Cc: Linux-acpi@vger.kernel.org
Subject: [PATCH] ACPI: EC: wait for last write gpe
Date: Sat, 08 Nov 2008 21:42:30 +0300 [thread overview]
Message-ID: <20081108184228.7154.51815.stgit@thinkpad> (raw)
In-Reply-To: <4915C296.9030903@suse.de>
There is a possibility that EC might break if next command is
issued within 1 us after write or burst-disable command.
This "possibility" was in EC driver for 3.5 years, after
451566f45a2e6cd10ba56e7220a9dd84ba3ef550.
References: http://marc.info/?l=linux-acpi&m=122616284402886&w=4
Cc: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---
drivers/acpi/ec.c | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e5dbe21..d6007ac 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -102,6 +102,7 @@ struct transaction {
u8 command;
u8 wlen;
u8 rlen;
+ bool done;
};
static struct acpi_ec {
@@ -178,7 +179,7 @@ static int ec_transaction_done(struct acpi_ec *ec)
unsigned long flags;
int ret = 0;
spin_lock_irqsave(&ec->curr_lock, flags);
- if (!ec->curr || (!ec->curr->wlen && !ec->curr->rlen))
+ if (!ec->curr || ec->curr->done)
ret = 1;
spin_unlock_irqrestore(&ec->curr_lock, flags);
return ret;
@@ -195,17 +196,20 @@ static void gpe_transaction(struct acpi_ec *ec, u8 status)
acpi_ec_write_data(ec, *(ec->curr->wdata++));
--ec->curr->wlen;
} else
- /* false interrupt, state didn't change */
- ++ec->curr->irq_count;
-
+ goto err;
} else if (ec->curr->rlen > 0) {
if ((status & ACPI_EC_FLAG_OBF) == 1) {
*(ec->curr->rdata++) = acpi_ec_read_data(ec);
- --ec->curr->rlen;
+ if (--ec->curr->rlen == 0)
+ ec->curr->done = true;
} else
- /* false interrupt, state didn't change */
- ++ec->curr->irq_count;
- }
+ goto err;
+ } else if (ec->curr->wlen == 0 && (status & ACPI_EC_FLAG_IBF) == 0)
+ ec->curr->done = true;
+ goto unlock;
+err:
+ /* false interrupt, state didn't change */
+ ++ec->curr->irq_count;
unlock:
spin_unlock_irqrestore(&ec->curr_lock, flags);
}
@@ -265,6 +269,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
spin_lock_irqsave(&ec->curr_lock, tmp);
/* following two actions should be kept atomic */
t->irq_count = 0;
+ t->done = false;
ec->curr = t;
acpi_ec_write_cmd(ec, ec->curr->command);
if (ec->curr->command == ACPI_EC_COMMAND_QUERY)
next prev parent reply other threads:[~2008-11-08 18:42 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-07 4:39 ACPI patches for 2.6.28-rc3 Len Brown
2008-11-07 4:39 ` [PATCH 01/21] i7300_idle: Kconfig, show menu only on x86_64 Len Brown
2008-11-07 4:39 ` [PATCH 02/21] ACPI: EC: revert msleep patch Len Brown
2008-11-07 4:39 ` [PATCH 03/21] sony-laptop: Ignore missing _DIS method on pic device Len Brown
2008-11-07 4:39 ` [PATCH 04/21] ACPI: fix de-reference bug in power resource driver Len Brown
2008-11-07 4:39 ` [PATCH 05/21] ACPI: fan: Delete the strict check in power transition Len Brown
2008-11-07 4:39 ` [PATCH 06/21] ACPI: bugfix reporting of event handler status Len Brown
2008-11-07 4:39 ` [PATCH 07/21] ACPI EC: Fix regression due to use of uninitialized variable Len Brown
2008-11-07 6:13 ` Zhao Yakui
2008-11-07 19:45 ` Len Brown
2008-11-08 14:04 ` The fatal logic error in EC write transaction(EC transaction is done in interrupt context) Zhao, Yakui
2008-11-08 15:33 ` Alexey Starikovskiy
2008-11-08 15:58 ` Zhao, Yakui
2008-11-08 16:47 ` Alexey Starikovskiy
2008-11-08 18:42 ` Alexey Starikovskiy [this message]
2008-11-09 12:45 ` [PATCH] ACPI: EC: wait for last write gpe Zhao Yakui
2008-11-09 13:11 ` The fatal logic error in EC write transaction(EC transaction is done in interrupt context) Zhao Yakui
2008-11-09 15:27 ` Spreading FUD [was: The fatal logic error in EC write transaction(EC transaction is done in interrupt context)] Alexey Starikovskiy
2008-11-10 1:01 ` Zhao Yakui
2008-11-10 18:48 ` Alexey Starikovskiy
2008-11-07 4:39 ` [PATCH 08/21] intel_menlow: don't set max_state a negative value Len Brown
2008-11-07 4:39 ` [PATCH 09/21] ACPI: remove comments about debug layer/level to use Len Brown
2008-11-07 4:39 ` [PATCH 10/21] ACPI: SBS: remove useless acpi_cm_sbs_init() initcall Len Brown
2008-11-07 4:39 ` [PATCH 11/21] ACPI: remove CONFIG_ACPI_POWER Len Brown
2008-11-07 4:39 ` [PATCH 12/21] ACPI: remove CONFIG_ACPI_EC Len Brown
2008-11-07 4:39 ` [PATCH 13/21] intel_menlow: Add comment documenting legal GTHS values Len Brown
2008-11-07 4:39 ` [PATCH 14/21] intel_menlow: MAINTAINERS Len Brown
2008-11-07 4:39 ` [PATCH 15/21] Revert "ACPI: Ingore the RESET_REG_SUP bit when using ACPI reset mechanism" Len Brown
2008-11-07 4:39 ` [PATCH 16/21] PNP: add Bjorn Helgaas as PNP co-maintainer Len Brown
2008-11-07 4:39 ` [PATCH 17/21] ACPI: struct device - replace bus_id with dev_name(), dev_set_name() Len Brown
2008-11-07 4:39 ` [PATCH 18/21] fujitsu-laptop: fix section mismatch warning Len Brown
2008-11-07 4:39 ` [PATCH 19/21] ACPI: use macro to replace hard number Len Brown
2008-11-07 4:39 ` [PATCH 20/21] ACPI: avoid empty file name in sysfs Len Brown
2008-11-07 4:39 ` [PATCH 21/21] ACPI: EC: make kernel messages more useful when GPE storm is detected Len Brown
2008-11-07 9:18 ` Alan Jenkins
2008-11-07 13:54 ` Rafael J. Wysocki
2008-11-07 18:49 ` [stable] " Greg KH
2008-11-07 22:15 ` Rafael J. Wysocki
2008-11-11 21:23 ` Greg KH
2008-11-12 23:34 ` Rafael J. Wysocki
2008-11-13 21:46 ` Greg KH
2008-11-07 17:41 ` ACPI patches for 2.6.28-rc3 Andrey Borzenkov
2008-11-08 2:48 ` Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081108184228.7154.51815.stgit@thinkpad \
--to=astarikovskiy@suse.de \
--cc=Linux-acpi@vger.kernel.org \
--cc=lenb@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox