aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r--drivers/acpi/ec.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index d6471bb6852f..27e0b92b2e39 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -307,7 +307,11 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
307 pr_debug(PREFIX "transaction start\n"); 307 pr_debug(PREFIX "transaction start\n");
308 /* disable GPE during transaction if storm is detected */ 308 /* disable GPE during transaction if storm is detected */
309 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { 309 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
310 acpi_disable_gpe(NULL, ec->gpe); 310 /*
311 * It has to be disabled at the hardware level regardless of the
312 * GPE reference counting, so that it doesn't trigger.
313 */
314 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE);
311 } 315 }
312 316
313 status = acpi_ec_transaction_unlocked(ec, t); 317 status = acpi_ec_transaction_unlocked(ec, t);
@@ -316,8 +320,12 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
316 ec_check_sci_sync(ec, acpi_ec_read_status(ec)); 320 ec_check_sci_sync(ec, acpi_ec_read_status(ec));
317 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { 321 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
318 msleep(1); 322 msleep(1);
319 /* it is safe to enable GPE outside of transaction */ 323 /*
320 acpi_enable_gpe(NULL, ec->gpe); 324 * It is safe to enable the GPE outside of the transaction. Use
325 * acpi_set_gpe() for that, since we used it to disable the GPE
326 * above.
327 */
328 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE);
321 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) { 329 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) {
322 pr_info(PREFIX "GPE storm detected, " 330 pr_info(PREFIX "GPE storm detected, "
323 "transactions will use polling mode\n"); 331 "transactions will use polling mode\n");
@@ -788,8 +796,8 @@ static int ec_install_handlers(struct acpi_ec *ec)
788 &acpi_ec_gpe_handler, ec); 796 &acpi_ec_gpe_handler, ec);
789 if (ACPI_FAILURE(status)) 797 if (ACPI_FAILURE(status))
790 return -ENODEV; 798 return -ENODEV;
791 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); 799
792 acpi_enable_gpe(NULL, ec->gpe); 800 acpi_enable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
793 status = acpi_install_address_space_handler(ec->handle, 801 status = acpi_install_address_space_handler(ec->handle,
794 ACPI_ADR_SPACE_EC, 802 ACPI_ADR_SPACE_EC,
795 &acpi_ec_space_handler, 803 &acpi_ec_space_handler,
@@ -806,6 +814,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
806 } else { 814 } else {
807 acpi_remove_gpe_handler(NULL, ec->gpe, 815 acpi_remove_gpe_handler(NULL, ec->gpe,
808 &acpi_ec_gpe_handler); 816 &acpi_ec_gpe_handler);
817 acpi_disable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
809 return -ENODEV; 818 return -ENODEV;
810 } 819 }
811 } 820 }
@@ -816,6 +825,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
816 825
817static void ec_remove_handlers(struct acpi_ec *ec) 826static void ec_remove_handlers(struct acpi_ec *ec)
818{ 827{
828 acpi_disable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
819 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, 829 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
820 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) 830 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
821 pr_err(PREFIX "failed to remove space handler\n"); 831 pr_err(PREFIX "failed to remove space handler\n");
@@ -1057,16 +1067,16 @@ error:
1057static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state) 1067static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
1058{ 1068{
1059 struct acpi_ec *ec = acpi_driver_data(device); 1069 struct acpi_ec *ec = acpi_driver_data(device);
1060 /* Stop using GPE */ 1070 /* Stop using the GPE, but keep it reference counted. */
1061 acpi_disable_gpe(NULL, ec->gpe); 1071 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE);
1062 return 0; 1072 return 0;
1063} 1073}
1064 1074
1065static int acpi_ec_resume(struct acpi_device *device) 1075static int acpi_ec_resume(struct acpi_device *device)
1066{ 1076{
1067 struct acpi_ec *ec = acpi_driver_data(device); 1077 struct acpi_ec *ec = acpi_driver_data(device);
1068 /* Enable use of GPE back */ 1078 /* Enable the GPE again, but don't reference count it once more. */
1069 acpi_enable_gpe(NULL, ec->gpe); 1079 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE);
1070 return 0; 1080 return 0;
1071} 1081}
1072 1082