From nobody Thu Feb 22 18:43:55 2024 X-Original-To: dev-commits-src-main@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 4Tghqv6NdLz5B9lg; Thu, 22 Feb 2024 18:43:55 +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 4Tghqv5pTHz4jxp; Thu, 22 Feb 2024 18:43:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708627435; 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=vQg6tamwgKK4w29TIsv210V3JQYcupjgwYfLJPGdeEY=; b=i6NGNOTdEt/e8LUJ696KNpUqqelFnCEaHtEuwkGDE7G+/nezcnLQupLxQZH0p6X9vLUPvJ 5faPw5OR1D7xEfwy9nAkxu1PrBe3QN83aoOuGQ4L+mTkMXfImCP+38lJ4pmucNMv+Qv9pM XjkzMPDJHN0FXf53b/dkvynllcOC297CbH4HIN0BR8CFP9MEBk7UUhqDijGXe1Nst+3yeN bVKeqgiN3h20/XdNsIL3FH55xS9dmW2AjP08mcBwQ2iHtC/oXewB7NVdQlsbafPu2F3pvw DdURodY/elsnkfIHa89bp4BOZ/tDKdL7YrS1dqlLX4ge6VjjeMJuxw3t2l3u5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708627435; 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=vQg6tamwgKK4w29TIsv210V3JQYcupjgwYfLJPGdeEY=; b=VXavkxG5hZS4C4LaL3MKFob3TPUjEbtxxlEyvJxjODVpSmUzREwGBW1uiEfJtlwZX4Ikmx h3Pws+nfPUazwE74KsC9QJuEHCEvjgoD1/y9QdnTopXbPh23xIxOReSpJK/KUTPjimsilL jNcATSH4g0S7EPG1Ge3/pYf8TJcLrHWvAXCmGHtDTZrKXGDBosWoToK8snfWuQ4beV9lqo s8Etc131Y31aMxO3pIaJzUJjLyyHuwometQmd4m5Or8q9y5av7HHkIo91dat3xOs6W+UAp i7lEeXio01HjFrta65EDuffOeepYn/FtlaJ/3yI9gh0MRu9D/xF6KFkG17AAfw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708627435; a=rsa-sha256; cv=none; b=YDoYxs4GuTTC5yHH/qRmvM6Gc5I0+xDex6A9dhTTi/4poeFpnT1mdXknMjRbiOXbT5S8SZ 7Vv1EW83SWLD4uwxeMfqbZL7neICXhIDRsdGLA031OAuWH26fUrsUCkyh5RtWFYzPmT2iC vlsxwSSOck4b47Aldj7/8xw07KMjcvvc4elxFiIcUI20tB4jSE6L9+YaFq8xN9wqMk1mOi i4Gi+XULsigK0pdSkDwjJEVzWecdf+2nNuzZykb2+D6SPcxXMMGibLlD+3ezBQVkPLnZQF piblmLwn3xo1p4pkx+fPWeJ7A0C3jv1dtO3+Rcj9M2AUpMH68/yN/BRDvq133Q== 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 4Tghqv4lfYzjjs; Thu, 22 Feb 2024 18:43:55 +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 41MIht5r052652; Thu, 22 Feb 2024 18:43:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41MIhtVO052649; Thu, 22 Feb 2024 18:43:55 GMT (envelope-from git) Date: Thu, 22 Feb 2024 18:43:55 GMT Message-Id: <202402221843.41MIhtVO052649@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: f2fcb68074a5 - main - acpi: Defer reserving resources for ACPI devices List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: f2fcb68074a51a8b399dc80d4c03fbe98a0ab92c Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f2fcb68074a51a8b399dc80d4c03fbe98a0ab92c commit f2fcb68074a51a8b399dc80d4c03fbe98a0ab92c Author: John Baldwin AuthorDate: 2024-02-22 18:43:43 +0000 Commit: John Baldwin CommitDate: 2024-02-22 18:43:43 +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 --- 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 43aed279ab35..defca923e36c 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1369,8 +1369,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) @@ -2257,9 +2266,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); @@ -2268,6 +2274,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);