From f872b7ca718e34eabdf2b2ece571bff7db6bf164 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 22 May 2019 23:27:57 -0700 Subject: [PATCH] kernel - Reduce acpi_ec timeout after failure, silence errors * Reduce the acpi_ec timeout from 750ms to 100ms after a failure. * Automatically silence... well, all acpi error messages, after 10 acpi_ec errors. * This allows the dell xps-13 to boot in a more reasonable period of time and not spew EC errors to the console all the time, as a default, without us having to disable EC manually.. --- sys/dev/acpica/Osd/OsdStream.c | 6 ++++-- sys/dev/acpica/acpi_ec.c | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/sys/dev/acpica/Osd/OsdStream.c b/sys/dev/acpica/Osd/OsdStream.c index 06defd5022..b8d91032fe 100644 --- a/sys/dev/acpica/Osd/OsdStream.c +++ b/sys/dev/acpica/Osd/OsdStream.c @@ -39,7 +39,7 @@ #include -static int acpi_silence_all = 0; +int acpi_silence_all = 0; TUNABLE_INT("debug.acpi.silence_all", &acpi_silence_all); SYSCTL_INT(_debug_acpi, OID_AUTO, silence_all, CTLFLAG_RW, &acpi_silence_all, 0, "Silence ACPI messages"); @@ -59,5 +59,7 @@ AcpiOsPrintf(const char *Format, ...) void AcpiOsVprintf(const char *Format, va_list Args) { - kvprintf(Format, Args); + if (acpi_silence_all == 0) { + kvprintf(Format, Args); + } } diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index d586376507..88d0d585de 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -166,7 +166,8 @@ struct acpi_ec_softc { #define EC_POLL_DELAY 50 /* Total time in ms spent waiting for a response from EC. */ -#define EC_TIMEOUT 750 +#define EC_TIMEOUT 750 +#define EC_TIMEOUT_BACKOFF 100 #define EVENT_READY(event, status) \ (((event) == EC_EVENT_OUTPUT_BUFFER_FULL && \ @@ -176,6 +177,8 @@ struct acpi_ec_softc { ACPI_SERIAL_DECL(ec, "ACPI embedded controller"); +extern int acpi_silence_all; + static SYSCTL_NODE(_debug_acpi, OID_AUTO, ec, CTLFLAG_RD, NULL, "EC debugging"); static int ec_burst_mode; @@ -190,6 +193,16 @@ static int ec_timeout = EC_TIMEOUT; TUNABLE_INT("debug.acpi.ec.timeout", &ec_timeout); SYSCTL_INT(_debug_acpi_ec, OID_AUTO, timeout, CTLFLAG_RW, &ec_timeout, EC_TIMEOUT, "Total time spent waiting for a response (poll+sleep)"); +static int ec_timeout_backoff = EC_TIMEOUT_BACKOFF; +TUNABLE_INT("debug.acpi.ec.timeout_backoff", &ec_timeout); +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, timeout_backoff, CTLFLAG_RW, + &ec_timeout_backoff, EC_TIMEOUT_BACKOFF, + "Total time spent waiting for a response (poll+sleep)"); +static int ec_auto_silence = 10; /* silence after 10 errors */ +TUNABLE_INT("debug.acpi.ec.auto_silence", &ec_auto_silence); +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, auto_silence, CTLFLAG_RW, + &ec_auto_silence, 1, + "Total time spent waiting for a response (poll+sleep)"); #ifndef KTR_ACPI_EC #define KTR_ACPI_EC KTR_ALL @@ -934,8 +947,14 @@ EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event, u_int gen_count) "not getting interrupts, switched to polled mode\n"); ec_polled_mode = 1; } - if (ACPI_FAILURE(Status)) + if (ACPI_FAILURE(Status)) { + ec_timeout = ec_timeout_backoff; + if (ec_auto_silence > 0) { + if (--ec_auto_silence <= 0) + acpi_silence_all = 1; + } KTR_LOG(acpi_ec_timeout); + } return (Status); } -- 2.41.0