From nobody Thu Dec 8 20:03:55 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NSlTm1YMTz4kJNv; Thu, 8 Dec 2022 20:03:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NSlTm0zPyz3H3P; Thu, 8 Dec 2022 20:03:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670529836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zwYgSI5oVEkJL/0q9kWm2WHq9yq1st4vIl5ZQzlcnlg=; b=cVdFLf+v/J9VIhpz/bZ4onu6doJnmAFeyKfNAjhLSLIyFh+roCbcBdbc2knCWB031YN7s4 bjro9OhEc/JfFHgeQlEq7kQpmkNwMsQDDPmdboz8r5sIQnJIocduke8HGusWhL4nttIZss /RacAx5RO6gi3Ie5l1QK6NTdRKcoTV/AhKAjrYcXtWX7nJyQ0skIucy4I5e/ar7vzOZ6ME qOJ1SYMTr2H5JiusQK8JvoiYqenPfKuyg9i3khIcmVaRuHdBaaVbX9QZHe0FC7tT8QB3gK H+zJQy/Kii9YJrbqiSk51cg1vakTByUjfVWMwznv8Mg4DhfYNv4F5YEjXlJAHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670529836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zwYgSI5oVEkJL/0q9kWm2WHq9yq1st4vIl5ZQzlcnlg=; b=PK3+X8uHNH57YFvzQJWxx8S9bKf8SgAgSY8icRyG1hDcZ9dv1KLyIl5lBFnzvbJXenTM7H E4ekPf/2Cjb/991X7SnbAvA3GYyCmaoLJzoYOyEMhPwl8S0lE/2fuBFVzW5QklnMraqt2W PutBPviDIlR3RRjdOxMquanGGebyFzGuabf5SRFGYLJPlhod6K6sluyqgZB+XpJ7VgVkRJ nUcX2SH/AucWkJp2Iu384PPNgeeM9GLdJQF2VQNqp5ZATusxYto8o/igXnpd5MvoQSiL26 n0s6z7slXgkILJdgRMMrJvBooQldyhs8BIFARoe8a5j4FJTojzk1sGa93c0VZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670529836; a=rsa-sha256; cv=none; b=mJfgBKJ+tBsbpi7o+m8qhNreni2cE3lFAjiMA5vQhPjla/Wri1H8jO0yHQnkCji6N0PD8d 6OhO2bEd3DUZ09UjjXo9Q0oSYwaqrxIMXaOnuhTzaSwL8jHhqS4EoZIBt92R60D0/5QcCl XvGTs0PVRoh+RXCAThc/JckO6PqyOHBLhSWZs+M+HO86dOWM0ib7+RlaA/LmhM6ZzGWhga 10dKKRJDEAKi9ul7Nu9/CwdtxvgFo86pBiLfRA02cwwSCO0pJaSRu762Vk2zX3nFsPCXxf Vt9PC/v7z94FtgQF20NnMr8OUUCRiMrq+syFPZzzWT8DgFCgHj5CqVJhc11XDw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NSlTl6q1qz17hL; Thu, 8 Dec 2022 20:03:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2B8K3tDg000458; Thu, 8 Dec 2022 20:03:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B8K3tb2000457; Thu, 8 Dec 2022 20:03:55 GMT (envelope-from git) Date: Thu, 8 Dec 2022 20:03:55 GMT Message-Id: <202212082003.2B8K3tb2000457@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Tom Jones Subject: git: 308d3d6be6da - stable/13 - acpi: Tell SMM we will handle CPPC notifications List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: thj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 308d3d6be6da1df4a47e641b5e0cedeccea7b09f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by thj: URL: https://cgit.FreeBSD.org/src/commit/?id=308d3d6be6da1df4a47e641b5e0cedeccea7b09f commit 308d3d6be6da1df4a47e641b5e0cedeccea7b09f Author: Tom Jones AuthorDate: 2022-10-10 13:46:25 +0000 Commit: Tom Jones 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) {