Skip to content

Commit

Permalink
acpi: Only reserve resources enumerated via _CRS
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bsdjhb committed Mar 14, 2024
2 parents a0f8166 + c6a4885 commit 3dd2566
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
36 changes: 0 additions & 36 deletions sys/dev/acpica/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
1 change: 0 additions & 1 deletion sys/dev/acpica/acpivar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3dd2566

Please sign in to comment.