diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2021-11-23 19:44:46 +0100 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2021-12-01 20:17:32 +0100 |
commit | c33676aa48249b007d55198dc8348cd117e3d8cc (patch) | |
tree | 44d64b8bd5081c87832b94440b323cf5ea184a22 /drivers/acpi/internal.h | |
parent | c793570d8725e44b64dbe466eb8ecda34c5eb8ac (diff) | |
download | linux-stable-c33676aa48249b007d55198dc8348cd117e3d8cc.tar.gz linux-stable-c33676aa48249b007d55198dc8348cd117e3d8cc.tar.bz2 linux-stable-c33676aa48249b007d55198dc8348cd117e3d8cc.zip |
ACPI: EC: Make the event work state machine visible
The EC driver uses a relatively simple state machine for the event
work handling, but it is not really straightforward to figure out.
The states are as follows:
"Ready": The event handling work can be submitted.
In this state, the EC_FLAGS_QUERY_PENDING flag is clear.
"In progress": The event handling work is pending or is being
processed. It cannot be submitted again.
In ths state, the EC_FLAGS_QUERY_PENDING flag is set and both the
events_to_process count is nonzero and the EC_FLAGS_QUERY_GUARDING
flag is clear.
"Complete": The event handling work has been completed, but it still
cannot be submitted again.
In ths state, the EC_FLAGS_QUERY_PENDING flag is set and the
events_to_process count is zero or the EC_FLAGS_QUERY_GUARDING
flag is set.
The state changes from "Ready" to "In progress" when new event is
detected by advance_transaction() and acpi_ec_submit_event() is
called by it.
Next, the state can change from "In progress" directly to "Ready" in
the following situations:
* ec_event_clearing is ACPI_EC_EVT_TIMING_STATUS and the state of
an ACPI_EC_COMMAND_QUERY transaction becomes ACPI_EC_COMMAND_POLL.
* ec_event_clearing is ACPI_EC_EVT_TIMING_QUERY and the state of
an ACPI_EC_COMMAND_QUERY transaction becomes
ACPI_EC_COMMAND_COMPLETE.
* ec_event_clearing is either ACPI_EC_EVT_TIMING_STATUS or
ACPI_EC_EVT_TIMING_QUERY and there are no more events to
process (ie. ec->events_to_process becomes 0).
If ec_event_clearing is ACPI_EC_EVT_TIMING_EVENT, however, the
state must change from "In progress" to "Complete" before it
can change to "Ready". The changes from "In progress" to
"Complete" in that case occur in the following situations:
* The state of an ACPI_EC_COMMAND_QUERY transaction becomes
ACPI_EC_COMMAND_COMPLETE.
* There are no more events to process (ie. ec->events_to_process
becomes 0).
Finally, the state changes from "Complete" to "Ready" when
advance_transaction() is invoked when the state is "Complete" and
the state of the current transaction is not ACPI_EC_COMMAND_POLL.
To make this state machine visible in the code, add a new
event_state field to struct acpi_ec and modify the code to use
it istead the EC_FLAGS_QUERY_PENDING and EC_FLAGS_QUERY_GUARDING
flags.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/internal.h')
-rw-r--r-- | drivers/acpi/internal.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index de546be3bc6a..1db3a2f81763 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -166,6 +166,13 @@ static inline void acpi_early_processor_osc(void) {} /* -------------------------------------------------------------------------- Embedded Controller -------------------------------------------------------------------------- */ + +enum acpi_ec_event_state { + EC_EVENT_READY = 0, /* Event work can be submitted */ + EC_EVENT_IN_PROGRESS, /* Event work is pending or being processed */ + EC_EVENT_COMPLETE, /* Event work processing has completed */ +}; + struct acpi_ec { acpi_handle handle; int gpe; @@ -182,6 +189,7 @@ struct acpi_ec { spinlock_t lock; struct work_struct work; unsigned long timestamp; + enum acpi_ec_event_state event_state; unsigned int events_to_process; unsigned int events_in_progress; unsigned int queries_in_progress; |