Skip to content

Commit 8993531

Browse files
zhang-ruirafaeljw
authored andcommitted
PNP / ACPI: proper handling of ACPI IO/Memory resource parsing failures
Before commit b355cee (ACPI / resources: ignore invalid ACPI device resources), if acpi_dev_resource_memory()/acpi_dev_resource_io() returns false, it means the the resource is not a memeory/IO resource. But after commit b355cee, those functions return false if the given memory/IO resource entry is invalid (the length of the resource is zero). This breaks pnpacpi_allocated_resource(), because it now recognizes the invalid memory/io resources as resources of unknown type. Thus users see confusing warning messages on machines with zero length ACPI memory/IO resources. Fix the problem by rearranging pnpacpi_allocated_resource() so that it calls acpi_dev_resource_memory() for memory type and IO type resources only, respectively. Fixes: b355cee (ACPI / resources: ignore invalid ACPI device resources) Signed-off-by: Zhang Rui <[email protected]> Reported-and-tested-by: Markus Trippelsdorf <[email protected]> Reported-and-tested-by: Julian Wollrath <[email protected]> Reported-and-tested-by: Paul Bolle <[email protected]> [rjw: Changelog] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent fa389e2 commit 8993531

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/pnp/pnpacpi/rsparser.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
183183
struct resource r = {0};
184184
int i, flags;
185185

186-
if (acpi_dev_resource_memory(res, &r)
187-
|| acpi_dev_resource_io(res, &r)
188-
|| acpi_dev_resource_address_space(res, &r)
186+
if (acpi_dev_resource_address_space(res, &r)
189187
|| acpi_dev_resource_ext_address_space(res, &r)) {
190188
pnp_add_resource(dev, &r);
191189
return AE_OK;
@@ -217,6 +215,17 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
217215
}
218216

219217
switch (res->type) {
218+
case ACPI_RESOURCE_TYPE_MEMORY24:
219+
case ACPI_RESOURCE_TYPE_MEMORY32:
220+
case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
221+
if (acpi_dev_resource_memory(res, &r))
222+
pnp_add_resource(dev, &r);
223+
break;
224+
case ACPI_RESOURCE_TYPE_IO:
225+
case ACPI_RESOURCE_TYPE_FIXED_IO:
226+
if (acpi_dev_resource_io(res, &r))
227+
pnp_add_resource(dev, &r);
228+
break;
220229
case ACPI_RESOURCE_TYPE_DMA:
221230
dma = &res->data.dma;
222231
if (dma->channel_count > 0 && dma->channels[0] != (u8) -1)

0 commit comments

Comments
 (0)