From nobody Fri Feb 23 05:26:18 2024 X-Original-To: dev-commits-src-branches@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 4Tgz563tVqz5Blk5; Fri, 23 Feb 2024 05:26:18 +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 4Tgz5630kGz4slw; Fri, 23 Feb 2024 05:26:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708665978; 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=J4ISOT9S8tUKIRm9WR2D74GQ5oeqpbSxU3wDM+AZjl0=; b=GTEPRaNdjg5QccNFW+B4R9hmIagnkg8USPwkmjC/DWufzRA9A0I4LIoGxU61k2VWfrcWAd DfVZ2cd6Yf6fdY/JLtW5apJMEM1aKheGBBDXXy4OcSODPEtOK3NYP0G4qvylPyteDlWxxh j+lP0MCMYzCiN8foCVuJD3CbRyFXm1NQfNWHRVCycp656T7vvwvMbOS1OH9dSdU7E3HVN5 raj+SHMvT4USYI/EWR2XDl38ExUodzzsQTNG500hzPvC0+ibSJ0LM23mhAbuWGUInkRp+F u1bpc9eldArP7Gf1Qtz/us9EHJ5YmtWLuoW4bjapviXIgE692Nn4FZZxqtG8gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708665978; 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=J4ISOT9S8tUKIRm9WR2D74GQ5oeqpbSxU3wDM+AZjl0=; b=LgArgA8x26Srh0Vi/w4DAYQli5a54TmOGp7/RgCDLjWmRo01UnhiC+uhS0hYWD/3rCDk9R vpyMnykVPUVFx3RtxXtl5KQw7VBge8qmGSeMS6pHwdDhnkjps6XH5SYhb6evdDS70NmYlI YD1mEq3yaCyG2gQy2CJ0pLVs5yUfNJQcCtoGk2zqRZw+M9ydZPEWnHfYZzJdMJYnk2JC/N IB4moTFd84af0we+ocvSysEk1AzxflkeJ/+AJnU4RFeCzgQ/ND98eZvFGMktn6W/veWjym dcL7cME7xzvKZOhALu+9x+neCBAiOAX/dkZOsOvvBkU3fcMx9eFxMecg+dOwQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708665978; a=rsa-sha256; cv=none; b=D98lTKw+Q0wfI/qShf1blvfnkek66TEWldQ7PFql25RWcqEuypDjsrT/sn9upQkK3BkiKJ VdxntJ1Eu4+9LE0FCnVrmqVnAxxhEpbfR6UpDq3fsEhZLkNtFNQgPUPEHlAsjfwB1+hM+k GKL7xhn230LdmjTUkIZDbzlY4bgnqRS/dB3c68afTe725PxKOMz66v+TgmgfDQucObmSf7 obfI/Ml9KgR1trhfScgeloI1Vda+dQjgWhnnZmJ9KnSk2diRb4hwhPWK68JFdX7p63sqWD pVPrbWH1+ofDvx5RvLN4iGVHLMbd6zAsX7f91cFn2Zh1UgyVNXsiVdQHg/tsiQ== 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 4Tgz5624bbz12rX; Fri, 23 Feb 2024 05:26:18 +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 41N5QIgt036542; Fri, 23 Feb 2024 05:26:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41N5QIF1036539; Fri, 23 Feb 2024 05:26:18 GMT (envelope-from git) Date: Fri, 23 Feb 2024 05:26:18 GMT Message-Id: <202402230526.41N5QIF1036539@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: f15ff67ef937 - releng/13.3 - acpi: Defer reserving resources for ACPI devices List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/releng/13.3 X-Git-Reftype: branch X-Git-Commit: f15ff67ef9379e2fe4909c96fb8e4153c32bafe1 Auto-Submitted: auto-generated The branch releng/13.3 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f15ff67ef9379e2fe4909c96fb8e4153c32bafe1 commit f15ff67ef9379e2fe4909c96fb8e4153c32bafe1 Author: John Baldwin AuthorDate: 2024-02-22 18:43:43 +0000 Commit: John Baldwin CommitDate: 2024-02-23 05:23:38 +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) (cherry picked from commit eaa51e59e560c556d0a8273d29eea4309e6b6a4f) Approved by: re (cperciva) --- 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 fbb3c2bc7c1c..01b2b1c06566 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);