From nobody Wed May 13 12:40:03 2026 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 4gFtMm2xLTz6dLV3 for ; Wed, 13 May 2026 12:40:04 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gFtMl6NR3z3w6P for ; Wed, 13 May 2026 12:40:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778676003; 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=+5OzVmBXPuBqH/fa7aNFoyFgNTQ7V5qsJD/wGuipYe8=; b=ZnccIY2JYNrJBZjhE0yZ2u9yiF8D15Cw+tvqKM+aZyWhRe4ULmTxSNvCrGXjaw929qm1oi o1FYzgOwI6cXNdANF1B7FiXgRbyWxEefL/v8cukUqpBygpFujODVj8RMzcQEmOQ2SMcErp xXw98ZQtSgBHQZ1VsoBzx9NmhIDBnTnovJrdfsdYaEIqdXWTHYhwRZ5oFvkaiAoZLQeQdQ LriShR31bvzZkGTfbacvzysVTcdirhq7i+mxNMJIHLoZXBHvpaQwot4+gp3zfsNz71WdzB 197KmPplvnPw1uZkJG9wvjOkfUTwzFzSr/QUHoT0f8pnG/pm1cqoQoBFyBmCFg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1778676003; a=rsa-sha256; cv=none; b=dIOB6389bnYsiD0n97slOesXMzjU/Lt78DHHsRRi+JVHVfy8Yqq+VTlpyx30MQle4WvAwa eaMFI2me8Sa01c0FNHdyMLEYa5gYM3S1jQbl1LnZ4I4eLnlMx2SjmG8pYBSaYdv/rtTD44 amNnN/jHI3PVVoWJ3HLpT8t7Eke5mLftHAr0hJFqlxgh0EUdQewnY3u2RNrBKbETkZsNmw hGdsVZ1HfXtt9wZ8EHRXWOuM0pvSB0fAmr4lrTS3hTNsQIb5M+EymJpaVujahQsXBGoEsV dvWp1NHAIm+fszz2VtD+w5OLn+Rjp3R1fN4qkPc5r0AJ+J3wtrAiEougJsbEHA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778676003; 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=+5OzVmBXPuBqH/fa7aNFoyFgNTQ7V5qsJD/wGuipYe8=; b=WwnzRam42b4dBHQ2egscEEe5WL1qfm+oCK4rqbQuSCKKCLHSg/v3xJgdDAOScvQNSZG2yL NSJY0/nwHMsuuKu68E1aurxiUiEOtDY0DiYZgJTyJ/wwBiV//gZudNsxPb57L+EcDpQXGi NK6hu+6vz15iGTv18wBbnx6YaOAl6m7xFzqeDnPOkZpSrcNyCmtCBS2j9n1pkTVJdnJ1LH JJ+2IxsXm5sHVaJF1sDrG+j7ZEI1pX1qXnYLADjawaMmK/4mvkim5Lq+Nej8CkhVcxBH1p N3XpwpttnkLK2UrSdWWheGrN35RsICvcR86eS/RukeaZPPhaQkilb1JybTKaow== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gFtMl5xCDzr9c for ; Wed, 13 May 2026 12:40:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1c88f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 13 May 2026 12:40:03 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 65ecfb4a66f3 - main - acpi_spmc(4): Only run DSM functions reported present 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 65ecfb4a66f377ca72569d7a96de0347b4541b52 Auto-Submitted: auto-generated Date: Wed, 13 May 2026 12:40:03 +0000 Message-Id: <6a047123.1c88f.689dad22@gitrepo.freebsd.org> The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=65ecfb4a66f377ca72569d7a96de0347b4541b52 commit 65ecfb4a66f377ca72569d7a96de0347b4541b52 Author: Olivier Certner AuthorDate: 2026-05-06 11:53:02 +0000 Commit: Olivier Certner CommitDate: 2026-05-13 12:38:25 +0000 acpi_spmc(4): Only run DSM functions reported present Examination of the DSDT in a Framework laptop generally hints at firmware designers sometimes providing ACPI methods for convenience (e.g., same firmware for multiple models) but not using them (or not expecting them to be used) depending on tweaks or the actual hardware platform. On an Intel Framework laptop, we specifically observe the presence of a Microsoft DSM that just reports availability of the SLEEP_ENTRY and SLEEP_EXIT (7 and 8) functions although the Microsoft specification requires other functions, whose purpose is similar to corresponding Intel DSM's ones (such as DISPLAY_OFF). However, we currently always call the latter even on the Microsoft DSM. On that laptop, fortunately, the way the code is structured in the _DSM method leads to nothing being executed on this call. Given the similarity of intent between most functions from the Microsoft DSM on one side and those of ADM and Intel on the other, it is imaginable that other firmware developers could use a strategy where functions are in fact aliased, in which case insisting on calling the Microsoft's DSM function even if not enumerated would cause the action to be performed twice (because we also call the corresponding function on the Intel/AMD DSM), which may or may not cause other problems and in any case seems a waste. So, by default, do not try to run any function that is not enumerated, as that looks like the safest approach. Add a debug sysctl(8) knob to revert to the previous behavior, just in case ('debug.acpi.spmc.force_call_expected_functions'). acpi_spmc_run() now checks if a DSM/function combination has been enumerated, and skips the actual call if it does not. This allows to remove all checks from the acpi_spmc_*_notif() functions, making the code much more compact. acpi_spmc_get_constraints() now checks whether DSM_GET_DEVICE_CONSTRAINTS is supported in order to determine which DSM to use and whether to call the function at all. Reviewed by: obiwac Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D56879 --- sys/dev/acpica/acpi_spmc.c | 89 +++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 52 deletions(-) diff --git a/sys/dev/acpica/acpi_spmc.c b/sys/dev/acpica/acpi_spmc.c index da9c80266952..c33336d10ec3 100644 --- a/sys/dev/acpica/acpi_spmc.c +++ b/sys/dev/acpica/acpi_spmc.c @@ -206,6 +206,11 @@ SYSCTL_INT(_debug_acpi_spmc, OID_AUTO, verbose, CTLFLAG_RW, #define VERBOSE() (verbose || bootverbose) +static bool force_call_expected_functions; +SYSCTL_BOOL(_debug_acpi_spmc, OID_AUTO, always_call_expected_functions, + CTLFLAG_RW, &force_call_expected_functions, 0, + "Call all expected functions on a present DSM, even those not enumerated."); + struct acpi_spmc_constraint { bool enabled; char *name; @@ -461,7 +466,7 @@ acpi_spmc_dsm_print_functions(const struct acpi_spmc_softc *const sc, print_bit_field(buf, sizeof(buf), missing, "FUNC", pbf_function_name, dsm); device_printf(sc->dev, "DSM %s: Does not enumerate expected " - "functions %#" PRIx64 "%s. Calls to them may fail.\n", + "functions %#" PRIx64 "%s. Will skip calling them.\n", dsm->name, missing, buf); } @@ -635,14 +640,14 @@ acpi_spmc_get_constraints(struct acpi_spmc_softc *const sc) * report that condition to us, and somewhat arbitrarily favor the Intel * one because it at least has a written specification. */ - if (has_dsm(sc, DSM_INTEL)) { + if (supports_function(sc, DSM_INTEL, DSM_GET_DEVICE_CONSTRAINTS)) { dsm = &dsm_intel; - if (has_dsm(sc, DSM_AMD)) + if (supports_function(sc, DSM_AMD, DSM_GET_DEVICE_CONSTRAINTS)) device_printf(sc->dev, "Constraints: Both Intel and " - "AMD DSMs are present!\n" + "AMD DSMs support getting them!\n" "Using constraints from Intel.\nPlease report.\n"); - } else if (has_dsm(sc, DSM_AMD)) + } else if (supports_function(sc, DSM_AMD, DSM_GET_DEVICE_CONSTRAINTS)) dsm = &dsm_amd; else return (0); @@ -690,8 +695,9 @@ acpi_spmc_get_constraints(struct acpi_spmc_softc *const sc) } static void -acpi_spmc_check_constraints(struct acpi_spmc_softc *sc) +acpi_spmc_check_constraints(device_t dev) { + const struct acpi_spmc_softc *const sc = device_get_softc(dev); #ifdef notyet bool violation = false; #endif @@ -703,7 +709,8 @@ acpi_spmc_check_constraints(struct acpi_spmc_softc *sc) if (sc->constraint_count == 0) return; for (size_t i = 0; i < sc->constraint_count; i++) { - struct acpi_spmc_constraint *constraint = &sc->constraints[i]; + const struct acpi_spmc_constraint *constraint = + &sc->constraints[i]; if (!constraint->enabled) continue; @@ -738,6 +745,7 @@ acpi_spmc_check_constraints(struct acpi_spmc_softc *sc) /* * Run a single DSM function. * + * Only runs the function if it was reported present during enumeration. * Discards the result, but prints a message on error. */ static void @@ -748,6 +756,10 @@ acpi_spmc_run(device_t dev, const struct dsm_desc *const dsm, ACPI_STATUS status; ACPI_BUFFER result; + if (!(supports_function(sc, dsm->index, function_index) || + (force_call_expected_functions && has_dsm(sc, dsm->index)))) + return; + status = acpi_EvaluateDSMTyped(sc->handle, (const uint8_t *)&dsm->uuid, dsm->revision, function_index, NULL, &result, ACPI_TYPE_ANY); @@ -767,67 +779,40 @@ acpi_spmc_run(device_t dev, const struct dsm_desc *const dsm, static void acpi_spmc_display_off_notif(device_t dev) { - struct acpi_spmc_softc *sc = device_get_softc(dev); - - if (has_dsm(sc, DSM_INTEL)) - acpi_spmc_run(dev, &dsm_intel, - DSM_INTEL_MS_DISPLAY_OFF_NOTIF); - if (has_dsm(sc, DSM_MS)) - acpi_spmc_run(dev, &dsm_ms, - DSM_INTEL_MS_DISPLAY_OFF_NOTIF); - if (has_dsm(sc, DSM_AMD)) - acpi_spmc_run(dev, &dsm_amd, DSM_AMD_DISPLAY_OFF_NOTIF); + acpi_spmc_run(dev, &dsm_intel, DSM_INTEL_MS_DISPLAY_OFF_NOTIF); + acpi_spmc_run(dev, &dsm_ms, DSM_INTEL_MS_DISPLAY_OFF_NOTIF); + acpi_spmc_run(dev, &dsm_amd, DSM_AMD_DISPLAY_OFF_NOTIF); } static void acpi_spmc_display_on_notif(device_t dev) { - struct acpi_spmc_softc *sc = device_get_softc(dev); - - if (has_dsm(sc, DSM_INTEL)) - acpi_spmc_run(dev, &dsm_intel, - DSM_INTEL_MS_DISPLAY_ON_NOTIF); - if (has_dsm(sc, DSM_MS)) - acpi_spmc_run(dev, &dsm_ms, - DSM_INTEL_MS_DISPLAY_ON_NOTIF); - if (has_dsm(sc, DSM_AMD)) - acpi_spmc_run(dev, &dsm_amd, DSM_AMD_DISPLAY_ON_NOTIF); + acpi_spmc_run(dev, &dsm_intel, DSM_INTEL_MS_DISPLAY_ON_NOTIF); + acpi_spmc_run(dev, &dsm_ms, DSM_INTEL_MS_DISPLAY_ON_NOTIF); + acpi_spmc_run(dev, &dsm_amd, DSM_AMD_DISPLAY_ON_NOTIF); } static void acpi_spmc_entry_notif(device_t dev) { - struct acpi_spmc_softc *sc = device_get_softc(dev); + /* XXX - No real check currently. Check return code when it does. */ + acpi_spmc_check_constraints(dev); - acpi_spmc_check_constraints(sc); - - if (has_dsm(sc, DSM_AMD)) - acpi_spmc_run(dev, &dsm_amd, DSM_AMD_LPI_ENTRY_NOTIF); - if (has_dsm(sc, DSM_MS)) { - acpi_spmc_run(dev, &dsm_ms, DSM_MS_SLEEP_ENTRY_NOTIF); - acpi_spmc_run(dev, &dsm_ms, DSM_INTEL_MS_LPI_ENTRY_NOTIF); - } - if (has_dsm(sc, DSM_INTEL)) - acpi_spmc_run(dev, &dsm_intel, - DSM_INTEL_MS_LPI_ENTRY_NOTIF); + acpi_spmc_run(dev, &dsm_amd, DSM_AMD_LPI_ENTRY_NOTIF); + acpi_spmc_run(dev, &dsm_ms, DSM_MS_SLEEP_ENTRY_NOTIF); + acpi_spmc_run(dev, &dsm_ms, DSM_INTEL_MS_LPI_ENTRY_NOTIF); + acpi_spmc_run(dev, &dsm_intel, DSM_INTEL_MS_LPI_ENTRY_NOTIF); } static void acpi_spmc_exit_notif(device_t dev) { - struct acpi_spmc_softc *sc = device_get_softc(dev); - - if (has_dsm(sc, DSM_INTEL)) - acpi_spmc_run(dev, &dsm_intel, DSM_INTEL_MS_LPI_EXIT_NOTIF); - if (has_dsm(sc, DSM_AMD)) - acpi_spmc_run(dev, &dsm_amd, DSM_AMD_LPI_EXIT_NOTIF); - if (has_dsm(sc, DSM_MS)) { - acpi_spmc_run(dev, &dsm_ms, DSM_INTEL_MS_LPI_EXIT_NOTIF); - if (supports_function(sc, DSM_MS, DSM_MS_TURN_ON_DISPLAY)) - acpi_spmc_run(dev, &dsm_ms, - DSM_MS_TURN_ON_DISPLAY); - acpi_spmc_run(dev, &dsm_ms, DSM_MS_SLEEP_EXIT_NOTIF); - } + acpi_spmc_run(dev, &dsm_intel, DSM_INTEL_MS_LPI_EXIT_NOTIF); + acpi_spmc_run(dev, &dsm_amd, DSM_AMD_LPI_EXIT_NOTIF); + acpi_spmc_run(dev, &dsm_ms, DSM_INTEL_MS_LPI_EXIT_NOTIF); + /* Hint to the platform we are soon going to turn on the display. */ + acpi_spmc_run(dev, &dsm_ms, DSM_MS_TURN_ON_DISPLAY); + acpi_spmc_run(dev, &dsm_ms, DSM_MS_SLEEP_EXIT_NOTIF); } static void