diff options
author | Lv Zheng <lv.zheng@intel.com> | 2015-06-11 01:21:51 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-06-15 08:35:59 -0400 |
commit | 66db383439b51b1aa920f3579da644fb5fdb2b7c (patch) | |
tree | b233971244466cbbd9546b3d48400efb96837a87 | |
parent | 3cb02aeb28dd3f1b8a132fa3ecf6db17afd518d6 (diff) |
ACPI / EC: Fix a code coverity issue when QR_EC transactions are failed.
When the QR_EC transaction fails, the EC_FLAGS_QUERY_PENDING flag prevents
the event handling work queue from being scheduled again.
Though there shouldn't be failed QR_EC transactions, and this gap was
efficiently used for catching and learning the SCI_EVT clearing timing
compliance issues, we need to fix this as we are not fully compatible
with all platforms/Windows to handle SCI_EVT clearing timing correctly.
Fixing this gives the EC driver the chances to recover from a state machine
failure.
So this patch fixes this issue. When nr_pending_queries drops to 0, it
clears EC_FLAGS_QUERY_PENDING at the proper position for different modes in
order to ensure that the SCI_EVT handling can proceed.
In order to be clearer for future ec_event_clearing modes, all checks in
this patch are written in the inclusive style, not the exclusive style.
Cc: 3.16+ <stable@vger.kernel.org> # 3.16+
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/ec.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 79817ce164c1..9d4761d2f6b7 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -512,7 +512,8 @@ static void advance_transaction(struct acpi_ec *ec) | |||
512 | */ | 512 | */ |
513 | if (!t || !(t->flags & ACPI_EC_COMMAND_POLL)) { | 513 | if (!t || !(t->flags & ACPI_EC_COMMAND_POLL)) { |
514 | if (ec_event_clearing == ACPI_EC_EVT_TIMING_EVENT && | 514 | if (ec_event_clearing == ACPI_EC_EVT_TIMING_EVENT && |
515 | test_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags)) { | 515 | (!ec->nr_pending_queries || |
516 | test_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags))) { | ||
516 | clear_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags); | 517 | clear_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags); |
517 | acpi_ec_complete_query(ec); | 518 | acpi_ec_complete_query(ec); |
518 | } | 519 | } |
@@ -1065,6 +1066,17 @@ static void acpi_ec_event_handler(struct work_struct *work) | |||
1065 | (void)acpi_ec_query(ec, NULL); | 1066 | (void)acpi_ec_query(ec, NULL); |
1066 | spin_lock_irqsave(&ec->lock, flags); | 1067 | spin_lock_irqsave(&ec->lock, flags); |
1067 | ec->nr_pending_queries--; | 1068 | ec->nr_pending_queries--; |
1069 | /* | ||
1070 | * Before exit, make sure that this work item can be | ||
1071 | * scheduled again. There might be QR_EC failures, leaving | ||
1072 | * EC_FLAGS_QUERY_PENDING uncleared and preventing this work | ||
1073 | * item from being scheduled again. | ||
1074 | */ | ||
1075 | if (!ec->nr_pending_queries) { | ||
1076 | if (ec_event_clearing == ACPI_EC_EVT_TIMING_STATUS || | ||
1077 | ec_event_clearing == ACPI_EC_EVT_TIMING_QUERY) | ||
1078 | acpi_ec_complete_query(ec); | ||
1079 | } | ||
1068 | } | 1080 | } |
1069 | spin_unlock_irqrestore(&ec->lock, flags); | 1081 | spin_unlock_irqrestore(&ec->lock, flags); |
1070 | 1082 | ||