aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2014-06-14 20:41:48 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-07-07 06:54:03 -0400
commit9b80f0f73ae1583c22325ede341c74195847618c (patch)
treea3360379990e269775cbd8b8aa0d42bb18f0abb5
parentf92fca0060fc4dc9227342d0072d75df98c1e5a5 (diff)
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>
-rw-r--r--drivers/acpi/ec.c27
1 files changed, 1 insertions, 26 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index f09386e9745f..d016ea31b8e9 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -281,23 +281,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
281 return ret; 281 return ret;
282} 282}
283 283
284static int ec_check_ibf0(struct acpi_ec *ec)
285{
286 u8 status = acpi_ec_read_status(ec);
287 return (status & ACPI_EC_FLAG_IBF) == 0;
288}
289
290static int ec_wait_ibf0(struct acpi_ec *ec)
291{
292 unsigned long delay = jiffies + msecs_to_jiffies(ec_delay);
293 /* interrupt wait manually if GPE mode is not active */
294 while (time_before(jiffies, delay))
295 if (wait_event_timeout(ec->wait, ec_check_ibf0(ec),
296 msecs_to_jiffies(1)))
297 return 0;
298 return -ETIME;
299}
300
301static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) 284static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
302{ 285{
303 int status; 286 int status;
@@ -318,12 +301,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
318 goto unlock; 301 goto unlock;
319 } 302 }
320 } 303 }
321 if (ec_wait_ibf0(ec)) {
322 pr_err("input buffer is not empty, "
323 "aborting transaction\n");
324 status = -ETIME;
325 goto end;
326 }
327 pr_debug("transaction start (cmd=0x%02x, addr=0x%02x)\n", 304 pr_debug("transaction start (cmd=0x%02x, addr=0x%02x)\n",
328 t->command, t->wdata ? t->wdata[0] : 0); 305 t->command, t->wdata ? t->wdata[0] : 0);
329 /* disable GPE during transaction if storm is detected */ 306 /* disable GPE during transaction if storm is detected */
@@ -347,7 +324,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
347 set_bit(EC_FLAGS_GPE_STORM, &ec->flags); 324 set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
348 } 325 }
349 pr_debug("transaction end\n"); 326 pr_debug("transaction end\n");
350end:
351 if (ec->global_lock) 327 if (ec->global_lock)
352 acpi_release_global_lock(glk); 328 acpi_release_global_lock(glk);
353unlock: 329unlock:
@@ -653,8 +629,7 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device,
653 spin_lock_irqsave(&ec->lock, flags); 629 spin_lock_irqsave(&ec->lock, flags);
654 advance_transaction(ec); 630 advance_transaction(ec);
655 spin_unlock_irqrestore(&ec->lock, flags); 631 spin_unlock_irqrestore(&ec->lock, flags);
656 if (ec_transaction_completed(ec) && 632 if (ec_transaction_completed(ec)) {
657 (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) {
658 wake_up(&ec->wait); 633 wake_up(&ec->wait);
659 ec_check_sci(ec, acpi_ec_read_status(ec)); 634 ec_check_sci(ec, acpi_ec_read_status(ec));
660 } 635 }