Commit 4a9af6c
committed
ACPI: EC: Rework flushing of EC work while suspended to idle
The flushing of pending work in the EC driver uses drain_workqueue()
to flush the event handling work that can requeue itself via
advance_transaction(), but this is problematic, because that
work may also be requeued from the query workqueue.
Namely, if an EC transaction is carried out during the execution of
a query handler, it involves calling advance_transaction() which
may queue up the event handling work again. This causes the kernel
to complain about attempts to add a work item to the EC event
workqueue while it is being drained and worst-case it may cause a
valid event to be skipped.
To avoid this problem, introduce two new counters, events_in_progress
and queries_in_progress, incremented when a work item is queued on
the event workqueue or the query workqueue, respectively, and
decremented at the end of the corresponding work function, and make
acpi_ec_dispatch_gpe() the workqueues in a loop until the both of
these counters are zero (or system wakeup is pending) instead of
calling acpi_ec_flush_work().
At the same time, change __acpi_ec_flush_work() to call
flush_workqueue() instead of drain_workqueue() to flush the event
workqueue.
While at it, use the observation that the work item queued in
acpi_ec_query() cannot be pending at that time, because it is used
only once, to simplify the code in there.
Additionally, clean up a comment in acpi_ec_query() and adjust white
space in acpi_ec_event_processor().
Fixes: f0ac20c ("ACPI: EC: Fix flushing of pending work")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>1 parent d58071a commit 4a9af6c
2 files changed
Lines changed: 45 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| |||
452 | 453 | | |
453 | 454 | | |
454 | 455 | | |
| 456 | + | |
455 | 457 | | |
456 | 458 | | |
457 | 459 | | |
| |||
518 | 520 | | |
519 | 521 | | |
520 | 522 | | |
521 | | - | |
| 523 | + | |
522 | 524 | | |
523 | 525 | | |
524 | 526 | | |
| |||
1103 | 1105 | | |
1104 | 1106 | | |
1105 | 1107 | | |
1106 | | - | |
| 1108 | + | |
1107 | 1109 | | |
1108 | 1110 | | |
1109 | 1111 | | |
1110 | 1112 | | |
1111 | 1113 | | |
1112 | 1114 | | |
1113 | 1115 | | |
| 1116 | + | |
1114 | 1117 | | |
1115 | 1118 | | |
1116 | 1119 | | |
1117 | 1120 | | |
1118 | 1121 | | |
| 1122 | + | |
1119 | 1123 | | |
1120 | 1124 | | |
1121 | 1125 | | |
| |||
1132 | 1136 | | |
1133 | 1137 | | |
1134 | 1138 | | |
| 1139 | + | |
1135 | 1140 | | |
1136 | 1141 | | |
| 1142 | + | |
1137 | 1143 | | |
1138 | 1144 | | |
1139 | 1145 | | |
1140 | 1146 | | |
| 1147 | + | |
1141 | 1148 | | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
1142 | 1154 | | |
1143 | 1155 | | |
1144 | 1156 | | |
| |||
1148 | 1160 | | |
1149 | 1161 | | |
1150 | 1162 | | |
1151 | | - | |
| 1163 | + | |
1152 | 1164 | | |
1153 | 1165 | | |
1154 | 1166 | | |
| |||
1170 | 1182 | | |
1171 | 1183 | | |
1172 | 1184 | | |
1173 | | - | |
1174 | | - | |
| 1185 | + | |
1175 | 1186 | | |
1176 | 1187 | | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
| 1188 | + | |
| 1189 | + | |
1180 | 1190 | | |
1181 | 1191 | | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
1186 | 1199 | | |
1187 | 1200 | | |
1188 | 1201 | | |
| |||
1240 | 1253 | | |
1241 | 1254 | | |
1242 | 1255 | | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
1243 | 1260 | | |
1244 | 1261 | | |
1245 | 1262 | | |
| |||
2021 | 2038 | | |
2022 | 2039 | | |
2023 | 2040 | | |
| 2041 | + | |
2024 | 2042 | | |
2025 | 2043 | | |
2026 | 2044 | | |
| |||
2041 | 2059 | | |
2042 | 2060 | | |
2043 | 2061 | | |
2044 | | - | |
2045 | | - | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
2046 | 2075 | | |
2047 | 2076 | | |
2048 | 2077 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | 190 | | |
| |||
0 commit comments