Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Jan 2024 19:29:02 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: c6a488511ab1 - main - acpi: Only reserve resources enumerated via _CRS
Message-ID:  <202401091929.409JT2F2032972@gitrepo.freebsd.org>

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

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

commit c6a488511ab1fbae8d16264b9e83c85024c9e1ce
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-01-09 19:23:10 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-01-09 19:23:10 +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
---
 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 22d2b10ff905..9196c446ae80 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -1376,11 +1376,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++) {
@@ -1422,14 +1420,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;
@@ -1485,38 +1481,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 5be0939ee6bb..4d76a77cdbf8 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?202401091929.409JT2F2032972>