Skip to content

Commit f238b41

Browse files
Bjorn Helgaaslenb
authored andcommitted
PNPACPI: compute Address Space length rather than using _LEN
ACPI _CRS Address Space Descriptors have _MIN, _MAX, and _LEN. Linux has been computing Address Spaces as [_MIN to _MIN + _LEN - 1]. Based on the tests in the bug reports below, Windows apparently uses [_MIN to _MAX]. Per spec (ACPI 4.0, Table 6-40), for _CRS fixed-size, fixed location descriptors, "_LEN must be (_MAX - _MIN + 1)", and when that's true, it doesn't matter which way we compute the end. But of course, there are BIOSes that don't follow this rule, and we're better off if Linux handles those exceptions the same way as Windows. This patch makes Linux use [_MIN to _MAX], as Windows seems to do. This effectively reverts 3162b6f and replaces it with simpler code. https://bugzilla.kernel.org/show_bug.cgi?id=14337 (round) https://bugzilla.kernel.org/show_bug.cgi?id=15480 (truncate) Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 01bf0b6 commit f238b41

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

drivers/pnp/pnpacpi/rsparser.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -274,26 +274,6 @@ static void pnpacpi_parse_allocated_busresource(struct pnp_dev *dev,
274274
pnp_add_bus_resource(dev, start, end);
275275
}
276276

277-
static u64 addr_space_length(struct pnp_dev *dev, u64 min, u64 max, u64 len)
278-
{
279-
u64 max_len;
280-
281-
max_len = max - min + 1;
282-
if (len <= max_len)
283-
return len;
284-
285-
/*
286-
* Per 6.4.3.5, _LEN cannot exceed _MAX - _MIN + 1, but some BIOSes
287-
* don't do this correctly, e.g.,
288-
* https://bugzilla.kernel.org/show_bug.cgi?id=15480
289-
*/
290-
dev_info(&dev->dev,
291-
"resource length %#llx doesn't fit in %#llx-%#llx, trimming\n",
292-
(unsigned long long) len, (unsigned long long) min,
293-
(unsigned long long) max);
294-
return max_len;
295-
}
296-
297277
static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
298278
struct acpi_resource *res)
299279
{
@@ -309,7 +289,8 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
309289
return;
310290
}
311291

312-
len = addr_space_length(dev, p->minimum, p->maximum, p->address_length);
292+
/* Windows apparently computes length rather than using _LEN */
293+
len = p->maximum - p->minimum + 1;
313294
window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
314295

315296
if (p->resource_type == ACPI_MEMORY_RANGE)
@@ -330,7 +311,8 @@ static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev,
330311
int window;
331312
u64 len;
332313

333-
len = addr_space_length(dev, p->minimum, p->maximum, p->address_length);
314+
/* Windows apparently computes length rather than using _LEN */
315+
len = p->maximum - p->minimum + 1;
334316
window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
335317

336318
if (p->resource_type == ACPI_MEMORY_RANGE)

0 commit comments

Comments
 (0)