Skip to content

Commit 37d1139

Browse files
committed
Revert "ACPI / EC: Add query flushing support"
Revert commit f252cb0 (ACPI / EC: Add query flushing support), because it breaks system suspend on Acer Aspire S5. The machine just hangs solid at the last stage of suspend (after taking non-boot CPUs offline). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent e06bf91 commit 37d1139

1 file changed

Lines changed: 16 additions & 85 deletions

File tree

‎drivers/acpi/ec.c‎

Lines changed: 16 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ enum ec_command {
7676
* when trying to clear the EC */
7777

7878
enum {
79-
EC_FLAGS_EVENT_ENABLED, /* Event is enabled */
80-
EC_FLAGS_EVENT_PENDING, /* Event is pending */
81-
EC_FLAGS_EVENT_DETECTED, /* Event is detected */
79+
EC_FLAGS_QUERY_PENDING, /* Query is pending */
8280
EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and
8381
* OpReg are installed */
8482
EC_FLAGS_STARTED, /* Driver is started */
@@ -153,12 +151,6 @@ static bool acpi_ec_flushed(struct acpi_ec *ec)
153151
return ec->reference_count == 1;
154152
}
155153

156-
static bool acpi_ec_has_pending_event(struct acpi_ec *ec)
157-
{
158-
return test_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags) ||
159-
test_bit(EC_FLAGS_EVENT_PENDING, &ec->flags);
160-
}
161-
162154
/* --------------------------------------------------------------------------
163155
* EC Registers
164156
* -------------------------------------------------------------------------- */
@@ -326,93 +318,36 @@ static void acpi_ec_clear_storm(struct acpi_ec *ec, u8 flag)
326318
* the flush operation is not in
327319
* progress
328320
* @ec: the EC device
329-
* @allow_event: whether event should be handled
330321
*
331322
* This function must be used before taking a new action that should hold
332323
* the reference count. If this function returns false, then the action
333324
* must be discarded or it will prevent the flush operation from being
334325
* completed.
335-
*
336-
* During flushing, QR_EC command need to pass this check when there is a
337-
* pending event, so that the reference count held for the pending event
338-
* can be decreased by the completion of the QR_EC command.
339326
*/
340-
static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec,
341-
bool allow_event)
327+
static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec)
342328
{
343-
if (!acpi_ec_started(ec)) {
344-
if (!allow_event || !acpi_ec_has_pending_event(ec))
345-
return false;
346-
}
329+
if (!acpi_ec_started(ec))
330+
return false;
347331
acpi_ec_submit_request(ec);
348332
return true;
349333
}
350334

351-
static void acpi_ec_submit_event(struct acpi_ec *ec)
335+
static void acpi_ec_submit_query(struct acpi_ec *ec)
352336
{
353-
if (!test_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags) ||
354-
!test_bit(EC_FLAGS_EVENT_ENABLED, &ec->flags))
355-
return;
356-
/* Hold reference for pending event */
357-
if (!acpi_ec_submit_flushable_request(ec, true))
358-
return;
359-
if (!test_and_set_bit(EC_FLAGS_EVENT_PENDING, &ec->flags)) {
360-
pr_debug("***** Event query started *****\n");
337+
if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) {
338+
pr_debug("***** Event started *****\n");
361339
schedule_work(&ec->work);
362-
return;
363-
}
364-
acpi_ec_complete_request(ec);
365-
}
366-
367-
static void acpi_ec_complete_event(struct acpi_ec *ec)
368-
{
369-
if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
370-
clear_bit(EC_FLAGS_EVENT_PENDING, &ec->flags);
371-
pr_debug("***** Event query stopped *****\n");
372-
/* Unhold reference for pending event */
373-
acpi_ec_complete_request(ec);
374-
/* Check if there is another SCI_EVT detected */
375-
acpi_ec_submit_event(ec);
376-
}
377-
}
378-
379-
static void acpi_ec_submit_detection(struct acpi_ec *ec)
380-
{
381-
/* Hold reference for query submission */
382-
if (!acpi_ec_submit_flushable_request(ec, false))
383-
return;
384-
if (!test_and_set_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags)) {
385-
pr_debug("***** Event detection blocked *****\n");
386-
acpi_ec_submit_event(ec);
387-
return;
388340
}
389-
acpi_ec_complete_request(ec);
390341
}
391342

392-
static void acpi_ec_complete_detection(struct acpi_ec *ec)
343+
static void acpi_ec_complete_query(struct acpi_ec *ec)
393344
{
394345
if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
395-
clear_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags);
396-
pr_debug("***** Event detetion unblocked *****\n");
397-
/* Unhold reference for query submission */
398-
acpi_ec_complete_request(ec);
346+
clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
347+
pr_debug("***** Event stopped *****\n");
399348
}
400349
}
401350

402-
static void acpi_ec_enable_event(struct acpi_ec *ec)
403-
{
404-
unsigned long flags;
405-
406-
spin_lock_irqsave(&ec->lock, flags);
407-
set_bit(EC_FLAGS_EVENT_ENABLED, &ec->flags);
408-
/*
409-
* An event may be pending even with SCI_EVT=0, so QR_EC should
410-
* always be issued right after started.
411-
*/
412-
acpi_ec_submit_detection(ec);
413-
spin_unlock_irqrestore(&ec->lock, flags);
414-
}
415-
416351
static int ec_transaction_completed(struct acpi_ec *ec)
417352
{
418353
unsigned long flags;
@@ -454,7 +389,6 @@ static void advance_transaction(struct acpi_ec *ec)
454389
t->rdata[t->ri++] = acpi_ec_read_data(ec);
455390
if (t->rlen == t->ri) {
456391
t->flags |= ACPI_EC_COMMAND_COMPLETE;
457-
acpi_ec_complete_event(ec);
458392
if (t->command == ACPI_EC_COMMAND_QUERY)
459393
pr_debug("***** Command(%s) hardware completion *****\n",
460394
acpi_ec_cmd_string(t->command));
@@ -465,7 +399,6 @@ static void advance_transaction(struct acpi_ec *ec)
465399
} else if (t->wlen == t->wi &&
466400
(status & ACPI_EC_FLAG_IBF) == 0) {
467401
t->flags |= ACPI_EC_COMMAND_COMPLETE;
468-
acpi_ec_complete_event(ec);
469402
wakeup = true;
470403
}
471404
goto out;
@@ -474,17 +407,16 @@ static void advance_transaction(struct acpi_ec *ec)
474407
!(status & ACPI_EC_FLAG_SCI) &&
475408
(t->command == ACPI_EC_COMMAND_QUERY)) {
476409
t->flags |= ACPI_EC_COMMAND_POLL;
477-
acpi_ec_complete_detection(ec);
410+
acpi_ec_complete_query(ec);
478411
t->rdata[t->ri++] = 0x00;
479412
t->flags |= ACPI_EC_COMMAND_COMPLETE;
480-
acpi_ec_complete_event(ec);
481413
pr_debug("***** Command(%s) software completion *****\n",
482414
acpi_ec_cmd_string(t->command));
483415
wakeup = true;
484416
} else if ((status & ACPI_EC_FLAG_IBF) == 0) {
485417
acpi_ec_write_cmd(ec, t->command);
486418
t->flags |= ACPI_EC_COMMAND_POLL;
487-
acpi_ec_complete_detection(ec);
419+
acpi_ec_complete_query(ec);
488420
} else
489421
goto err;
490422
goto out;
@@ -505,7 +437,7 @@ static void advance_transaction(struct acpi_ec *ec)
505437
}
506438
out:
507439
if (status & ACPI_EC_FLAG_SCI)
508-
acpi_ec_submit_detection(ec);
440+
acpi_ec_submit_query(ec);
509441
if (wakeup && in_interrupt())
510442
wake_up(&ec->wait);
511443
}
@@ -566,7 +498,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
566498
/* start transaction */
567499
spin_lock_irqsave(&ec->lock, tmp);
568500
/* Enable GPE for command processing (IBF=0/OBF=1) */
569-
if (!acpi_ec_submit_flushable_request(ec, true)) {
501+
if (!acpi_ec_submit_flushable_request(ec)) {
570502
ret = -EINVAL;
571503
goto unlock;
572504
}
@@ -947,9 +879,7 @@ static void acpi_ec_gpe_poller(struct work_struct *work)
947879
{
948880
struct acpi_ec *ec = container_of(work, struct acpi_ec, work);
949881

950-
pr_debug("***** Event poller started *****\n");
951882
acpi_ec_query(ec, NULL);
952-
pr_debug("***** Event poller stopped *****\n");
953883
}
954884

955885
static u32 acpi_ec_gpe_handler(acpi_handle gpe_device,
@@ -1019,6 +949,7 @@ static struct acpi_ec *make_acpi_ec(void)
1019949

1020950
if (!ec)
1021951
return NULL;
952+
ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
1022953
mutex_init(&ec->mutex);
1023954
init_waitqueue_head(&ec->wait);
1024955
INIT_LIST_HEAD(&ec->list);
@@ -1169,7 +1100,7 @@ static int acpi_ec_add(struct acpi_device *device)
11691100
ret = ec_install_handlers(ec);
11701101

11711102
/* EC is fully operational, allow queries */
1172-
acpi_ec_enable_event(ec);
1103+
clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
11731104

11741105
/* Clear stale _Q events if hardware might require that */
11751106
if (EC_FLAGS_CLEAR_ON_RESUME)

0 commit comments

Comments
 (0)