Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi acpiec(4): Set sc_got_sci only when a transacti...



details:   https://anonhg.NetBSD.org/src/rev/4eae614f639e
branches:  trunk
changeset: 377584:4eae614f639e
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Jul 18 10:04:14 2023 +0000

description:
acpiec(4): Set sc_got_sci only when a transaction is over.

Before, when the acpiec thread noticed an SCI had been requested and
entered acpiec_gpe_state_machine to send the query command, it would
see the SCI is still requested -- because it had yet to acknowledge
it by setting the query command! -- and think the EC was asking for a
_second_ SCI.

So once the first SCI transaction was over, it would start a second
one, even though the EC hadn't asked for another -- and this would
wedge on some ECs.

Now, acpiec_gpe_state_machine waits to see what state we transition
to before taking the SCI bit to mean we need to notify the acpiec
thread to handle another query.

That way, when the acpiec thread enters acpiec_gpe_state_machine with
EC_STATE_QUERY, it can send the query command first, with the side
effect of clearing the SCI bit in subsequent reads of the status
register, and it won't think another SCI has been requested until it
returns to EC_STATE_FREE and sees the SCI bit set again in the status
register.

Possibly relevant PRs:

PR kern/53135
PR kern/52763
PR kern/57162

diffstat:

 sys/dev/acpi/acpi_ec.c |  25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diffs (60 lines):

diff -r 55f98a7c5c38 -r 4eae614f639e sys/dev/acpi/acpi_ec.c
--- a/sys/dev/acpi/acpi_ec.c    Tue Jul 18 10:03:59 2023 +0000
+++ b/sys/dev/acpi/acpi_ec.c    Tue Jul 18 10:04:14 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_ec.c,v 1.91 2023/07/18 10:03:59 riastradh Exp $   */
+/*     $NetBSD: acpi_ec.c,v 1.92 2023/07/18 10:04:14 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.91 2023/07/18 10:03:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.92 2023/07/18 10:04:14 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_acpi_ec.h"
@@ -962,9 +962,6 @@ acpiec_gpe_state_machine(device_t dv)
        }
 #endif
 
-       if (reg & EC_STATUS_SCI)
-               sc->sc_got_sci = true;
-
        switch (sc->sc_state) {
        case EC_STATE_QUERY:
                if ((reg & EC_STATUS_IBF) != 0)
@@ -1026,11 +1023,6 @@ acpiec_gpe_state_machine(device_t dv)
                break;
 
        case EC_STATE_FREE:
-               if (sc->sc_got_sci) {
-                       DPRINTF(ACPIEC_DEBUG_TRANSITION, sc,
-                           "wake SCI thread\n");
-                       cv_signal(&sc->sc_cv_sci);
-               }
                break;
 
        default:
@@ -1038,6 +1030,19 @@ acpiec_gpe_state_machine(device_t dv)
        }
 
        /*
+        * If we just ended a transaction, and an SCI was requested,
+        * notify the SCI thread.
+        */
+       if (sc->sc_state == EC_STATE_FREE) {
+               if (reg & EC_STATUS_SCI) {
+                       DPRINTF(ACPIEC_DEBUG_TRANSITION, sc,
+                           "wake SCI thread\n");
+                       sc->sc_got_sci = true;
+                       cv_signal(&sc->sc_cv_sci);
+               }
+       }
+
+       /*
         * In case GPE interrupts are broken, poll once per tick for EC
         * status updates while a transaction is still pending.
         */



Home | Main Index | Thread Index | Old Index