Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jan 2024 22:33:47 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 468fb2f4f2c6 - stable/13 - acpi: Only reserve resources enumerated via _CRS
Message-ID:  <202401182233.40IMXl8J007672@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=468fb2f4f2c611e12de40b8661db629a2b63dd01

commit 468fb2f4f2c611e12de40b8661db629a2b63dd01
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-01-09 19:23:10 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-01-18 22:33:14 +0000

    acpi: Only reserve resources enumerated via _CRS
    
    In particular, don't reserve resources added by drivers via other
    means (e.g. acpi_bus_alloc_gas which calls bus_alloc_resource
    right after adding the resource).
    
    The intention of reserved resources is to ensure that a resource range
    that a bus driver knows is assigned to a device is reserved by the
    system even if no driver is attached to the device.  This prevents
    other "wildcard" resource requests from conflicting with these
    resources.  For ACPI, the only resources the bus driver knows about
    for unattached devices are the resources returned from _CRS.  All of
    these resources are already reserved now via acpi_reserve_resources
    called from acpi_probe_children.
    
    As such, remove the logic from acpi_set_resource to try to reserve
    resources when they are set.  This permits RF_SHAREABLE to work with
    acpi_bus_alloc_gas without requiring hacks like the current one for
    CPU device resources in acpi_set_resource.
    
    Reported by:    gallatin (RF_SHAREABLE not working)
    Diagnosed by:   jrtc27
    
    (cherry picked from commit c6a488511ab1fbae8d16264b9e83c85024c9e1ce)
---
 sys/dev/acpica/acpi.c    | 36 ------------------------------------
 sys/dev/acpica/acpivar.h |  1 -
 2 files changed, 37 deletions(-)

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index d0d2f9ddc1cd..ca88acb60966 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -1277,11 +1277,9 @@ acpi_reserve_resources(device_t dev)
     struct resource_list_entry *rle;
     struct resource_list *rl;
     struct acpi_device *ad;
-    struct acpi_softc *sc;
     device_t *children;
     int child_count, i;
 
-    sc = device_get_softc(dev);
     if (device_get_children(dev, &children, &child_count) != 0)
 	return;
     for (i = 0; i < child_count; i++) {
@@ -1323,14 +1321,12 @@ acpi_reserve_resources(device_t dev)
 	}
     }
     free(children, M_TEMP);
-    sc->acpi_resources_reserved = 1;
 }
 
 static int
 acpi_set_resource(device_t dev, device_t child, int type, int rid,
     rman_res_t start, rman_res_t count)
 {
-    struct acpi_softc *sc = device_get_softc(dev);
     struct acpi_device *ad = device_get_ivars(child);
     struct resource_list *rl = &ad->ad_rl;
     ACPI_DEVICE_INFO *devinfo;
@@ -1386,38 +1382,6 @@ acpi_set_resource(device_t dev, device_t child, int type, int rid,
     /* Add the resource. */
     end = (start + count - 1);
     resource_list_add(rl, type, rid, start, end, count);
-
-    /* Don't reserve resources until the system resources are allocated. */
-    if (!sc->acpi_resources_reserved)
-	return (0);
-
-    /* Don't reserve system resources. */
-    if (ACPI_ID_PROBE(dev, child, sysres_ids, NULL) <= 0)
-	return (0);
-
-    /*
-     * Don't reserve IRQ resources.  There are many sticky things to
-     * get right otherwise (e.g. IRQs for psm, atkbd, and HPET when
-     * using legacy routing).
-     */
-    if (type == SYS_RES_IRQ)
-	return (0);
-
-    /*
-     * Don't reserve resources for CPU devices.  Some of these
-     * resources need to be allocated as shareable, but reservations
-     * are always non-shareable.
-     */
-    if (device_get_devclass(child) == devclass_find("cpu"))
-	return (0);
-
-    /*
-     * Reserve the resource.
-     *
-     * XXX: Ignores failure for now.  Failure here is probably a
-     * BIOS/firmware bug?
-     */
-    resource_list_reserve(rl, dev, child, type, &rid, start, end, count, 0);
     return (0);
 }
 
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 896fc0c5a224..362538e47bfc 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -55,7 +55,6 @@ struct acpi_softc {
     int			acpi_enabled;
     int			acpi_sstate;
     int			acpi_sleep_disabled;
-    int			acpi_resources_reserved;
 
     struct sysctl_ctx_list acpi_sysctl_ctx;
     struct sysctl_oid	*acpi_sysctl_tree;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401182233.40IMXl8J007672>