From nobody Mon Oct 10 13:53:43 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 4MmL3q4XYkz4fTZP; Mon, 10 Oct 2022 13:53:43 +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 4MmL3q42x6z41Jg; Mon, 10 Oct 2022 13:53:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665410023; 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=ZgMu5Rh+0Hf8/M/tChFL7I77Ka7wrT5AuQsSLm+Hbqs=; b=sM8QdDu3mfihwlCnrx3+FQR4rePa5NzwHumsq2pt8ymZ6753X1gogC6nhRl9jTKICc9uUP jFAydb9AjUDcylusaeIzl6ywrCMzICZUtmvHeTKiujF6tFLL3k/8CNllvc1qyqOR41aPBC c+o4QFnq88zMUhsASKFBvN1eY9AZhWws7izQwVWUEjMcYjM7WwgKtjkZK3uq8QALayjFrC FT2GnU1JpIm3w9Qq3wQamo1+YA9dzgodAfsxPUb3jbr7c1cETN11U9Jy7I5zZhY1rIndhj cQW/8TUK5VDFYqui5I8B/89FyBzs+jljEgCxgywmIaMmng8Oon+F3LTX5h+mPg== 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 4MmL3q35djzfBX; Mon, 10 Oct 2022 13:53:43 +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 29ADrhcH012591; Mon, 10 Oct 2022 13:53:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29ADrhXG012590; Mon, 10 Oct 2022 13:53:43 GMT (envelope-from git) Date: Mon, 10 Oct 2022 13:53:43 GMT Message-Id: <202210101353.29ADrhXG012590@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Tom Jones Subject: git: 67f2a563bfca - main - 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/main X-Git-Reftype: branch X-Git-Commit: 67f2a563bfcad75c16536ca500b06ddc9306dfa0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665410023; 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=ZgMu5Rh+0Hf8/M/tChFL7I77Ka7wrT5AuQsSLm+Hbqs=; b=opa3OtJvQ8YBLuVU1Apz0ZhkRn0oe9GZ4jI+r+n9KOqMTkMiGiH57Yi6e9G7bDKd1Ol50D CrQCtLSwYUK5ALHX2hCe5CnM+iH+sPJRS4N3u6uTlsoqYVuBxq22TghKsAS59bSzRGMQ2Y e3BT+vsXg83iE1p9fEPT0uKHjhHEVjb0rRZn9VabrX5I27oE8bTe0NKtcRKwWREfxyhHu2 FlflRYHf+6HnWE+Kwe+QSYyHTyjlIYZHBE8vpcKb410lNvonWGs82SUbH9miQO2fQj2qX3 WmZlIMWRg2izjYQ3bZTL17HT3YerNSWKNI/QgN4aw3G6ls9gIPDJcdIlCwLsUg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665410023; a=rsa-sha256; cv=none; b=EOz34tU33H2Ov2tFO/yrvW4/SX1dYcpT02SY/46l9iyXD7PTWlzD5xDrlrRf1rTwkXlMir eCwvw6jTln6NmvN0ENaSbFTnCnrf8F0+mt2zOwv/i8GqQILwHSsMfyNYcZZv1eR2yDvofr tpV8GRG9Y1QjdSqxyCKRzCfQKxVYrdZ52qW0i6kgWRwI9F2ggVTsB2v20WUdeUjPz7VDpo MpEf+p6oqoG15veNl0sc0OYHNA+HH0waDm+qBxS+rC4YMPvtuHynVHA3bQFkWDcLeO4Doc nXz9oFC5AyWloOafKbwbGH0et4p5qZsBK2UfWwMKmzrhoueVUPoJlJxsmCCVgg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by thj: URL: https://cgit.FreeBSD.org/src/commit/?id=67f2a563bfcad75c16536ca500b06ddc9306dfa0 commit 67f2a563bfcad75c16536ca500b06ddc9306dfa0 Author: Tom Jones AuthorDate: 2022-10-10 13:46:25 +0000 Commit: Tom Jones CommitDate: 2022-10-10 13:53:15 +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 --- sys/dev/acpica/acpi_cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 762ea37cfa34..49d2bd11fdaa 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -153,6 +153,7 @@ 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; +static bool cppc_notify; static struct acpi_cpu_softc **cpu_softc; ACPI_SERIAL_DECL(cpu, "ACPI CPU"); @@ -396,6 +397,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(device_get_devclass(dev), &drivers, @@ -977,6 +985,12 @@ acpi_cpu_startup(void *arg) NULL, 0, acpi_cpu_global_cx_lowest_sysctl, "A", "Global lowest Cx sleep state to use"); + /* 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"); + /* Take over idling from cpu_idle_default(). */ cpu_cx_lowest_lim = 0; CPU_FOREACH(i) {