From nobody Fri Feb 23 05:20:47 2024 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 4Tgyym0ngTz5Bl7C; Fri, 23 Feb 2024 05:20:48 +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 4Tgyym00L4z4rhR; Fri, 23 Feb 2024 05:20:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708665648; 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=7UES41y1bdgKxOphLufZbGoX/hVLDgyg3cpF1m2aDew=; b=Pj5IVqQ4kAIaOPrGVCzPFM+9FLFYHJDdDhPjmtII2Fy9bdhWgjcR45wSNW8TSx8j1Tlux0 c/2f4KOxJP55Aba3YlHyCpusg15FaK2Wn5VhQSamaUp6eFWncpdD6ymHVbvFXrUM/EZXUB UDOIw/ad8yVzz00p9wcikoVtZb+0I34Hn91/6Q9fA0qP5SEhUMgxbz1eS88HwBvs6NdONN VeHsHxng3eOhRu/wYIoFQpy4xHuz7rA0VejVkQkY4KPKeQrDXhq52tx27/5FOlToB0jDjz QH/3tLd+6HiEdkrCzsXq2cagn455wWPJKFAckwnxXzz1yt7dXnAg7e3kSZE6Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708665648; 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=7UES41y1bdgKxOphLufZbGoX/hVLDgyg3cpF1m2aDew=; b=xEDwfRxB4Zk5xRBAeuT8tGSCpOiITeGM4cfB4lSGneKHNfGdzJfvQdothHRSYMx7DZDEDo yab/b1vP/qRAC5BZ5Aawlu+qwyvNctqaHnytj1/QV6Q2wjpVn+726U0+2HA2jseB1RzTcP l45WuPX/g8+8K6wjLMnbUm/FCt15fV3YJAXWl8pOgzT0Acp302ayhkGKNLgLr3UfhAElOY xEiz9WU7YOGOXO/+Nh5qPDYiWE/sflwtEuLFYmQl8tR86TkFFjovk0aAaXUjS3xmrismSZ 7bKad3aJnmq26zrjhS6EufpQxy+DsQGZMfB+rzcKRAnY5Ynh+vfTck82dJCNfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708665648; a=rsa-sha256; cv=none; b=cmqOfkZ3oTpegx3QpxEGZIaY2ShLPFy2S66TL3K/5LMwpvD1PV3eTKytQ1upamioZrK94/ EV1RJgpFiOTUnkA9iwSc6gfz/mz3Pu5pHCtXQEbdm+HdIgqMZtzknf7WDl1VxIlT10pt3r gA6wJIVIkAwVeKo2qcOuYg0wdz05pNU/gGBLGfFW3p+RlAw4Pj3YAq39aEk6gI0oUS37dl H0DdKjAXcjCy/FhAuIrtS0gWaApcgBdFrCLNb9w0i50F6f4ViPRwndGoWfEoSEx0Wke8wN sgSY3aCH+ryWPSWJHY8M3Mdk5mXY48SiXRLDydT9tzzu2K1Ct1srIn67SpBOxw== 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 4Tgyyl6DSDz12ql; Fri, 23 Feb 2024 05:20:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41N5Kl26030141; Fri, 23 Feb 2024 05:20:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41N5KlcI030138; Fri, 23 Feb 2024 05:20:47 GMT (envelope-from git) Date: Fri, 23 Feb 2024 05:20:47 GMT Message-Id: <202402230520.41N5KlcI030138@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: eaa51e59e560 - stable/13 - acpi: Defer reserving resources for ACPI devices 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: eaa51e59e560c556d0a8273d29eea4309e6b6a4f Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=eaa51e59e560c556d0a8273d29eea4309e6b6a4f commit eaa51e59e560c556d0a8273d29eea4309e6b6a4f Author: John Baldwin AuthorDate: 2024-02-22 18:43:43 +0000 Commit: John Baldwin CommitDate: 2024-02-23 00:48:39 +0000 acpi: Defer reserving resources for ACPI devices The goal of reserving firmware-assigned resources is to ensure that "wildcard" resource allocation requests will not claim an address range that is actually in use even if no attached driver is actively using that range. However, the current approach can break in some cases. In particular, ACPI can enumerate devices behind PCI bridges that don't show up in a normal PCI scan, but those device_t objects can end up as direct children of acpi0. Reserving resources for those devices directly from acpi0 ends up conflicting with later attempts to reserve the PCI bridge windows. As a workaround, defer reserving unclaimed resources until after the initial probe and attach scan. Eventually this pass of reserving unclaimed resources can be moved earlier, but it requires changes to other drivers in the tree to permit enumerating devices and reserving firmware-assigned resources in a depth-first traversal before attaching devices whose drivers request wildcard allocations. PR: 272507 Reported by: Justin Tocci Reported by: john@feith.com, many others Tested by: Oleg Sidorkin , dch (cherry picked from commit f2fcb68074a51a8b399dc80d4c03fbe98a0ab92c) --- sys/dev/acpica/acpi.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index cd390ada512c..49153eedbcc0 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1268,8 +1268,17 @@ acpi_sysres_alloc(device_t dev) } /* - * Reserve declared resources for devices found during attach once system - * resources have been allocated. + * Reserve declared resources for active devices found during the + * namespace scan once the boot-time attach of devices has completed. + * + * Ideally reserving firmware-assigned resources would work in a + * depth-first traversal of the device namespace, but this is + * complicated. In particular, not all resources are enumerated by + * ACPI (e.g. PCI bridges and devices enumerate their resources via + * other means). Some systems also enumerate devices via ACPI behind + * PCI bridges but without a matching a PCI device_t enumerated via + * PCI bus scanning, the device_t's end up as direct children of + * acpi0. Doing this scan late is not ideal, but works for now. */ static void acpi_reserve_resources(device_t dev) @@ -2157,9 +2166,6 @@ acpi_probe_children(device_t bus) /* Pre-allocate resources for our rman from any sysresource devices. */ acpi_sysres_alloc(bus); - /* Reserve resources already allocated to children. */ - acpi_reserve_resources(bus); - /* Create any static children by calling device identify methods. */ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "device identify routines\n")); bus_generic_probe(bus); @@ -2168,6 +2174,12 @@ acpi_probe_children(device_t bus) ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "acpi bus_generic_attach\n")); bus_generic_attach(bus); + /* + * Reserve resources allocated to children but not yet allocated + * by a driver. + */ + acpi_reserve_resources(bus); + /* Attach wake sysctls. */ acpi_wake_sysctl_walk(bus);