* [PATCH] PNPACPI: truncate _CRS windows with _LEN > _MAX - _MIN + 1
@ 2010-03-25 16:32 Bjorn Helgaas
2010-03-25 20:19 ` Rafael J. Wysocki
2010-04-04 4:39 ` Len Brown
0 siblings, 2 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2010-03-25 16:32 UTC (permalink / raw)
To: Len Brown; +Cc: rjw, Matthew Garrett, Bob Moore, Adam Belay, linux-acpi
The ACPI spec (sec 6.4.3.5 in v4.0) requires that for Address Space Resource
Descriptors, _LEN <= _MAX - _MIN + 1 in all cases, but there are BIOSes that
violate this. We experimentally determined that Windows truncates the
resource so it doesn't extend past _MAX, so let's do the same thing in
Linux.
http://bugzilla.kernel.org/show_bug.cgi?id=15480
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
drivers/pnp/pnpacpi/rsparser.c | 42 +++++++++++++++++++++++++++++-----------
1 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 54514aa..fe5bfa9 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -273,12 +273,33 @@ static void pnpacpi_parse_allocated_busresource(struct pnp_dev *dev,
pnp_add_bus_resource(dev, start, end);
}
+static u64 addr_space_length(struct pnp_dev *dev, u64 min, u64 max, u64 len)
+{
+ u64 max_len;
+
+ max_len = max - min + 1;
+ if (len <= max_len)
+ return len;
+
+ /*
+ * Per 6.4.3.5, _LEN cannot exceed _MAX - _MIN + 1, but some BIOSes
+ * don't do this correctly, e.g.,
+ * https://bugzilla.kernel.org/show_bug.cgi?id=15480
+ */
+ dev_info(&dev->dev,
+ "resource length %#llx doesn't fit in %#llx-%#llx, trimming\n",
+ (unsigned long long) len, (unsigned long long) min,
+ (unsigned long long) max);
+ return max_len;
+}
+
static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
struct acpi_resource *res)
{
struct acpi_resource_address64 addr, *p = &addr;
acpi_status status;
int window;
+ u64 len;
status = acpi_resource_to_address64(res, p);
if (!ACPI_SUCCESS(status)) {
@@ -287,20 +308,18 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
return;
}
+ len = addr_space_length(dev, p->minimum, p->maximum, p->address_length);
window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
if (p->resource_type == ACPI_MEMORY_RANGE)
- pnpacpi_parse_allocated_memresource(dev,
- p->minimum, p->address_length,
+ pnpacpi_parse_allocated_memresource(dev, p->minimum, len,
p->info.mem.write_protect, window);
else if (p->resource_type == ACPI_IO_RANGE)
- pnpacpi_parse_allocated_ioresource(dev,
- p->minimum, p->address_length,
+ pnpacpi_parse_allocated_ioresource(dev, p->minimum, len,
p->granularity == 0xfff ? ACPI_DECODE_10 :
ACPI_DECODE_16, window);
else if (p->resource_type == ACPI_BUS_NUMBER_RANGE)
- pnpacpi_parse_allocated_busresource(dev, p->minimum,
- p->address_length);
+ pnpacpi_parse_allocated_busresource(dev, p->minimum, len);
}
static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev,
@@ -308,21 +327,20 @@ static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev,
{
struct acpi_resource_extended_address64 *p = &res->data.ext_address64;
int window;
+ u64 len;
+ len = addr_space_length(dev, p->minimum, p->maximum, p->address_length);
window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
if (p->resource_type == ACPI_MEMORY_RANGE)
- pnpacpi_parse_allocated_memresource(dev,
- p->minimum, p->address_length,
+ pnpacpi_parse_allocated_memresource(dev, p->minimum, len,
p->info.mem.write_protect, window);
else if (p->resource_type == ACPI_IO_RANGE)
- pnpacpi_parse_allocated_ioresource(dev,
- p->minimum, p->address_length,
+ pnpacpi_parse_allocated_ioresource(dev, p->minimum, len,
p->granularity == 0xfff ? ACPI_DECODE_10 :
ACPI_DECODE_16, window);
else if (p->resource_type == ACPI_BUS_NUMBER_RANGE)
- pnpacpi_parse_allocated_busresource(dev, p->minimum,
- p->address_length);
+ pnpacpi_parse_allocated_busresource(dev, p->minimum, len);
}
static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PNPACPI: truncate _CRS windows with _LEN > _MAX - _MIN + 1
2010-03-25 16:32 [PATCH] PNPACPI: truncate _CRS windows with _LEN > _MAX - _MIN + 1 Bjorn Helgaas
@ 2010-03-25 20:19 ` Rafael J. Wysocki
2010-04-04 4:39 ` Len Brown
1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2010-03-25 20:19 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Len Brown, Matthew Garrett, Bob Moore, Adam Belay, linux-acpi
On Thursday 25 March 2010, Bjorn Helgaas wrote:
>
> The ACPI spec (sec 6.4.3.5 in v4.0) requires that for Address Space Resource
> Descriptors, _LEN <= _MAX - _MIN + 1 in all cases, but there are BIOSes that
> violate this. We experimentally determined that Windows truncates the
> resource so it doesn't extend past _MAX, so let's do the same thing in
> Linux.
>
> http://bugzilla.kernel.org/show_bug.cgi?id=15480
>
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
>
> drivers/pnp/pnpacpi/rsparser.c | 42 +++++++++++++++++++++++++++++-----------
> 1 files changed, 30 insertions(+), 12 deletions(-)
>
>
> diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
> index 54514aa..fe5bfa9 100644
> --- a/drivers/pnp/pnpacpi/rsparser.c
> +++ b/drivers/pnp/pnpacpi/rsparser.c
> @@ -273,12 +273,33 @@ static void pnpacpi_parse_allocated_busresource(struct pnp_dev *dev,
> pnp_add_bus_resource(dev, start, end);
> }
>
> +static u64 addr_space_length(struct pnp_dev *dev, u64 min, u64 max, u64 len)
> +{
> + u64 max_len;
> +
> + max_len = max - min + 1;
> + if (len <= max_len)
> + return len;
> +
> + /*
> + * Per 6.4.3.5, _LEN cannot exceed _MAX - _MIN + 1, but some BIOSes
> + * don't do this correctly, e.g.,
> + * https://bugzilla.kernel.org/show_bug.cgi?id=15480
> + */
> + dev_info(&dev->dev,
> + "resource length %#llx doesn't fit in %#llx-%#llx, trimming\n",
> + (unsigned long long) len, (unsigned long long) min,
> + (unsigned long long) max);
> + return max_len;
> +}
> +
> static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
> struct acpi_resource *res)
> {
> struct acpi_resource_address64 addr, *p = &addr;
> acpi_status status;
> int window;
> + u64 len;
>
> status = acpi_resource_to_address64(res, p);
> if (!ACPI_SUCCESS(status)) {
> @@ -287,20 +308,18 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
> return;
> }
>
> + len = addr_space_length(dev, p->minimum, p->maximum, p->address_length);
> window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
>
> if (p->resource_type == ACPI_MEMORY_RANGE)
> - pnpacpi_parse_allocated_memresource(dev,
> - p->minimum, p->address_length,
> + pnpacpi_parse_allocated_memresource(dev, p->minimum, len,
> p->info.mem.write_protect, window);
> else if (p->resource_type == ACPI_IO_RANGE)
> - pnpacpi_parse_allocated_ioresource(dev,
> - p->minimum, p->address_length,
> + pnpacpi_parse_allocated_ioresource(dev, p->minimum, len,
> p->granularity == 0xfff ? ACPI_DECODE_10 :
> ACPI_DECODE_16, window);
> else if (p->resource_type == ACPI_BUS_NUMBER_RANGE)
> - pnpacpi_parse_allocated_busresource(dev, p->minimum,
> - p->address_length);
> + pnpacpi_parse_allocated_busresource(dev, p->minimum, len);
> }
>
> static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev,
> @@ -308,21 +327,20 @@ static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev,
> {
> struct acpi_resource_extended_address64 *p = &res->data.ext_address64;
> int window;
> + u64 len;
>
> + len = addr_space_length(dev, p->minimum, p->maximum, p->address_length);
> window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
>
> if (p->resource_type == ACPI_MEMORY_RANGE)
> - pnpacpi_parse_allocated_memresource(dev,
> - p->minimum, p->address_length,
> + pnpacpi_parse_allocated_memresource(dev, p->minimum, len,
> p->info.mem.write_protect, window);
> else if (p->resource_type == ACPI_IO_RANGE)
> - pnpacpi_parse_allocated_ioresource(dev,
> - p->minimum, p->address_length,
> + pnpacpi_parse_allocated_ioresource(dev, p->minimum, len,
> p->granularity == 0xfff ? ACPI_DECODE_10 :
> ACPI_DECODE_16, window);
> else if (p->resource_type == ACPI_BUS_NUMBER_RANGE)
> - pnpacpi_parse_allocated_busresource(dev, p->minimum,
> - p->address_length);
> + pnpacpi_parse_allocated_busresource(dev, p->minimum, len);
> }
>
> static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PNPACPI: truncate _CRS windows with _LEN > _MAX - _MIN + 1
2010-03-25 16:32 [PATCH] PNPACPI: truncate _CRS windows with _LEN > _MAX - _MIN + 1 Bjorn Helgaas
2010-03-25 20:19 ` Rafael J. Wysocki
@ 2010-04-04 4:39 ` Len Brown
1 sibling, 0 replies; 3+ messages in thread
From: Len Brown @ 2010-04-04 4:39 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: rjw, Matthew Garrett, Bob Moore, Adam Belay, linux-acpi
applied
thanks,
Len Brown, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-04 4:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-25 16:32 [PATCH] PNPACPI: truncate _CRS windows with _LEN > _MAX - _MIN + 1 Bjorn Helgaas
2010-03-25 20:19 ` Rafael J. Wysocki
2010-04-04 4:39 ` Len Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox