From nobody Wed May 13 12:39:49 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 4gFtMV2WXgz6dLBg for ; Wed, 13 May 2026 12:39:50 +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 4gFtMT58jPz3vwZ for ; Wed, 13 May 2026 12:39:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778675989; 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=uGcCzeE4V4vt9KULNs1x8NYBh3g8e03W9kv8mX/JyHg=; b=kqHqDYMwq9lMSphnnR4mxOaQg41Wq1nTHWsImcgUVekR7uDjVuLrvcrqEbfb89QtV4DnGt d3m/o/F5x5ra6Q2i04xOuDT/zVsX6RwRK1UcE5ayZq6KONahXqQRwqirVIpGmcARHXe3HG UyMVgu7AAFkk/cUeWdk0ThG6CirgSl2rKmrohWY7Lnfm3Kftc7dHXEWQfYpXsWJVCu39as vEgT+RgRwLcCYK4EmWypj4BGO1Y8LO5Eh+OBYZvJAi0w6UFXv3Qgj5C/WJcht5wv/ChHIh jG3i58SND2WegFukrQhwea0rWiOMZLfjmgkhZYI9SXzroDHMHtNCGV2iW4GwyQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1778675989; a=rsa-sha256; cv=none; b=OGPrKM+YlJxEfyksBT/K19TDbqCHNC2wg5oIN/TMOVfVQTkq/L8JRF6yzBwqSge53wZaeL F052rLdXdRM0SR5SWrPuy+MNkNIfnqjfqEprgaGy/UxneVLZOQ2HRxFG+xDSDswp4fH63l ZW4WWStjq5W7eYUztEGl/WXWctUyI0n0OxKg1H6NCLRV8m3LuTYDicl+ke32z1+fONsKV+ TbFAOe2baUAHzPufJT/OfjbKh3WocaCF8QZSuJDRehjkCkOKHuo1IRcmWokdAoBVtaAVPe tLnzHOQseGtS5R9DoZNXFMol5bM5LbydIs6jYn3UyTWi6kllJeoM2XHqK09JaA== 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=1778675989; 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=uGcCzeE4V4vt9KULNs1x8NYBh3g8e03W9kv8mX/JyHg=; b=T6iu9Di3XoaD6/Qk5fELSDfchkano5YrTQaq9WRcIXCBMgxEOoQBZWU31LSsioXav4xwzC snkfj3s4epLTwBpwJjptz4JRRSX1jkhMu3zEn/gzeta+Ei448fxQz5nR7FYrcYdP65Kvjf 33osWbX1crzdneAgGdrpXiGQaTdNFVSDwVJK2h0okivm0ssR+Eut0LGsgHg+Q0SyqA2phK 1v+c+l8fvzkMpqaEZB6Trxg1Inm4qDs1OpWeFNZCSRHayAY1XnXvkg3vEgP+vmfEcvPCDj OQeLLgHq/XTUd1dKL+JEGHwLFHgC3AFQONjDSVRwS50khii5qg3uPrqz3WLn/w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gFtMT4jz9zrR5 for ; Wed, 13 May 2026 12:39:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1a5a8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 13 May 2026 12:39:49 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 6bd543f7a82a - main - acpi_spmc(4): Check DSMs only on attach, do not return 0 on probe 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: 6bd543f7a82a3cbb10db3a79590d5179be403660 Auto-Submitted: auto-generated Date: Wed, 13 May 2026 12:39:49 +0000 Message-Id: <6a047115.1a5a8.2a65c03@gitrepo.freebsd.org> The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=6bd543f7a82a3cbb10db3a79590d5179be403660 commit 6bd543f7a82a3cbb10db3a79590d5179be403660 Author: Olivier Certner AuthorDate: 2026-05-04 12:40:44 +0000 Commit: Olivier Certner CommitDate: 2026-05-13 12:38:21 +0000 acpi_spmc(4): Check DSMs only on attach, do not return 0 on probe Once we have recognized a device by PNP ID, declare support unconditionally on probe, and only check for DSMs in attach. We do this for these reasons: 1. PNP0D80 is de-facto a device supposed to hold DSMs related to suspend-to-idle, so we assume it cannot be used for other purposes. And if that changes, we need another architecture anyway (e.g., have a new driver claiming those devices and behaving like a bus, to which this driver would be a sub-driver). 2. If there are no DSMs that we support on such a device, then a new DSM was added that the driver does not know about and which "replaces" (in terms of functionality) the known ones, or the firmware is buggy. In both cases, failing the attach instead of the probe is reasonable, as that leads to printing some error which we (and probably users too) would like to know about. 3. This is a step to enable multiple instances of this driver (just to be a good citizen, and also to be future proof against weird firmwares that would, e.g., implement the Microsoft DSM on another device than the Intel one). Reviewed by: imp (older version), obiwac Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D56810 --- sys/dev/acpica/acpi_spmc.c | 56 ++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/sys/dev/acpica/acpi_spmc.c b/sys/dev/acpica/acpi_spmc.c index 58197242ff92..939f254fbf7f 100644 --- a/sys/dev/acpica/acpi_spmc.c +++ b/sys/dev/acpica/acpi_spmc.c @@ -340,10 +340,7 @@ static void acpi_spmc_resume(device_t dev, enum power_stype stype); static int acpi_spmc_probe(device_t dev) { - char *name; - ACPI_HANDLE handle; - struct acpi_spmc_softc *sc; - char buf[32]; + char *name; /* Check that this is an enabled device. */ if (acpi_get_type(dev) != ACPI_TYPE_DEVICE || acpi_disabled("spmc")) @@ -357,41 +354,42 @@ acpi_spmc_probe(device_t dev) return (ENXIO); } - handle = acpi_get_handle(dev); - /* ACPI_ID_PROBE() above cannot succeed without a handle. */ + device_set_desc(dev, "System Power Management Controller"); + + return (BUS_PROBE_DEFAULT); +} + +static int +acpi_spmc_attach(device_t dev) +{ + struct acpi_spmc_softc *const sc = device_get_softc(dev); + const ACPI_HANDLE handle = acpi_get_handle(dev); + char buf[32]; + + /* + * ACPI_ID_PROBE() in acpi_spmc_probe() cannot succeed without a handle. + */ MPASS(handle != NULL); - sc = device_get_softc(dev); sc->dev = dev; + sc->handle = handle; - /* Check which DSMs are supported. */ - sc->dsms = 0; + for (int i = 0; i < nitems(dsms); ++i) { + KASSERT(dsms[i] != NULL, ("%s: Sparse dsms[]!", __func__)); + KASSERT(dsms[i]->index == i, + ("%s: Inconsistent indices for DSM %s", __func__, + dsms[i]->name)); - for (int i = 0; i < nitems(dsms); ++i) acpi_spmc_check_dsm(sc, handle, dsms[i]); + } - if (sc->dsms == 0) + if (sc->dsms == 0) { + device_printf(dev, "No DSM supported!"); return (ENXIO); + } print_bit_field(buf, sizeof(buf), sc->dsms, "DSM", pbf_dsm_name, NULL); - device_set_descf(dev, "System Power Management Controller (DSMs %s)", - buf); - - return (0); -} - -static int -acpi_spmc_attach(device_t dev) -{ - struct acpi_spmc_softc *sc = device_get_softc(dev); - - sc->handle = acpi_get_handle(dev); - if (sc->handle == NULL) - return (ENXIO); - - sc->constraints_populated = false; - sc->constraint_count = 0; - sc->constraints = NULL; + device_printf(dev, "DSMs supported: %s\n", buf); /* Get device constraints. We can only call this once so do this now. */ acpi_spmc_get_constraints(dev);