Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Dec 2022 20:03:55 GMT
From:      Tom Jones <thj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 308d3d6be6da - stable/13 - acpi: Tell SMM we will handle CPPC notifications
Message-ID:  <202212082003.2B8K3tb2000457@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by thj:

URL: https://cgit.FreeBSD.org/src/commit/?id=308d3d6be6da1df4a47e641b5e0cedeccea7b09f

commit 308d3d6be6da1df4a47e641b5e0cedeccea7b09f
Author:     Tom Jones <thj@FreeBSD.org>
AuthorDate: 2022-10-10 13:46:25 +0000
Commit:     Tom Jones <thj@FreeBSD.org>
CommitDate: 2022-12-08 20:02:39 +0000

    acpi: Tell SMM we will handle CPPC notifications
    
    Buggy SMM implementations can hang while processing CPPC notifications.
    This leads to some laptops (notably Thinkpads) hanging when the
    hwpstate_intel driver is loaded.
    
    Tell the SMM that we will handle CPPC notifications as described in:
    
    - Intel® Processor Vendor-Specific ACPI
    - Intel® 64 and IA-32 Architectures Software Developer’s Manual
    
    CPPC events default to masked (disabled) so while we do not do any
    handling right now this does not seem to lead to any issues.
    
    This approach was found via this Linux Kernel patch:
    https://lkml.org/lkml/2016/3/17/563
    
    PR:             253288
    Reviewed by:    imp, jhb
    Sponsored by:   Modirum
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D36699
    
    (cherry picked from commit 67f2a563bfcad75c16536ca500b06ddc9306dfa0)
    (cherry picked from commit eee0f7aea42564fe005c74f004d63f8cc170ef59)
    (cherry picked from commit 15bd2f366d3e878f5a8bc1628368d59ef318af5f)
---
 sys/dev/acpica/acpi_cpu.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index 3cff973ef212..3c160e1c5cdd 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -153,6 +153,9 @@ static struct sysctl_ctx_list cpu_sysctl_ctx;
 static struct sysctl_oid *cpu_sysctl_tree;
 static int		 cpu_cx_generic;
 static int		 cpu_cx_lowest_lim;
+#if defined(__i386__) || defined(__amd64__)
+static bool		 cppc_notify;
+#endif
 
 static struct acpi_cpu_softc **cpu_softc;
 ACPI_SERIAL_DECL(cpu, "ACPI CPU");
@@ -379,6 +382,14 @@ acpi_cpu_attach(device_t dev)
 	cpu_sysctl_tree = SYSCTL_ADD_NODE(&cpu_sysctl_ctx,
 	    SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO, "cpu",
 	    CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "node for CPU children");
+
+#if defined(__i386__) || defined(__amd64__)
+	/* Add sysctl handler to control registering for CPPC notifications */
+	cppc_notify = 1;
+	SYSCTL_ADD_BOOL(&cpu_sysctl_ctx, SYSCTL_CHILDREN(cpu_sysctl_tree),
+	    OID_AUTO, "cppc_notify", CTLFLAG_RDTUN | CTLFLAG_MPSAFE,
+	    &cppc_notify, 0, "Register for CPPC Notifications");
+#endif
     }
 
     /*
@@ -397,6 +408,13 @@ acpi_cpu_attach(device_t dev)
      */
     if (!acpi_disabled("mwait") && cpu_mwait_usable())
 	sc->cpu_features |= ACPI_CAP_SMP_C1_NATIVE | ACPI_CAP_SMP_C3_NATIVE;
+
+    /*
+     * Work around a lingering SMM bug which leads to freezes when handling
+     * CPPC notifications. Tell the SMM we will handle any CPPC notifications.
+     */
+    if ((cpu_power_eax & CPUTPM1_HWP_NOTIFICATION) && cppc_notify)
+	    sc->cpu_features |= ACPI_CAP_INTR_CPPC;
 #endif
 
     if (devclass_get_drivers(acpi_cpu_devclass, &drivers, &drv_count) == 0) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202212082003.2B8K3tb2000457>