ACPI: EC: Refuse attempt to lock Global Lock if suspended From: Alexey Starikovskiy Signed-off-by: Alexey Starikovskiy --- drivers/acpi/ec.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 75b147f..cdbc713 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -76,8 +76,9 @@ enum ec_command { enum { EC_FLAGS_QUERY_PENDING, /* Query is pending */ EC_FLAGS_GPE_STORM, /* GPE storm detected */ - EC_FLAGS_HANDLERS_INSTALLED /* Handlers for GPE and + EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and * OpReg are installed */ + EC_FLAGS_SUSPENDED, /* Driver is suspended */ }; /* If we find an EC via the ECDT, we need to keep a ptr to its context */ @@ -309,6 +310,10 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) memset(t->rdata, 0, t->rlen); mutex_lock(&ec->lock); if (ec->global_lock) { + if (test_bit(EC_FLAGS_SUSPENDED, &ec->flags)) { + status = -EAGAIN; + goto unlock; + } status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) { status = -ENODEV; @@ -1018,6 +1023,7 @@ static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state) { struct acpi_ec *ec = acpi_driver_data(device); /* Stop using GPE */ + set_bit(EC_FLAGS_SUSPENDED, &ec->flags); acpi_disable_gpe(NULL, ec->gpe); return 0; } @@ -1026,6 +1032,7 @@ static int acpi_ec_resume(struct acpi_device *device) { struct acpi_ec *ec = acpi_driver_data(device); /* Enable use of GPE back */ + clear_bit(EC_FLAGS_SUSPENDED, &ec->flags); acpi_enable_gpe(NULL, ec->gpe); return 0; }