Skip to content

Commit 48728e0

Browse files
Bjorn Helgaasjbarnes993
authored andcommitted
x86/PCI: 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 d558b48 and 03db42a and replaces them 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: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent 55051fe commit 48728e0

1 file changed

Lines changed: 2 additions & 38 deletions

File tree

‎arch/x86/pci/acpi.c‎

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -121,30 +121,6 @@ count_resource(struct acpi_resource *acpi_res, void *data)
121121
return AE_OK;
122122
}
123123

124-
static void
125-
align_resource(struct acpi_device *bridge, struct resource *res)
126-
{
127-
int align = (res->flags & IORESOURCE_MEM) ? 16 : 4;
128-
129-
/*
130-
* Host bridge windows are not BARs, but the decoders on the PCI side
131-
* that claim this address space have starting alignment and length
132-
* constraints, so fix any obvious BIOS goofs.
133-
*/
134-
if (!IS_ALIGNED(res->start, align)) {
135-
dev_printk(KERN_DEBUG, &bridge->dev,
136-
"host bridge window %pR invalid; "
137-
"aligning start to %d-byte boundary\n", res, align);
138-
res->start &= ~(align - 1);
139-
}
140-
if (!IS_ALIGNED(res->end + 1, align)) {
141-
dev_printk(KERN_DEBUG, &bridge->dev,
142-
"host bridge window %pR invalid; "
143-
"aligning end to %d-byte boundary\n", res, align);
144-
res->end = ALIGN(res->end, align) - 1;
145-
}
146-
}
147-
148124
static acpi_status
149125
setup_resource(struct acpi_resource *acpi_res, void *data)
150126
{
@@ -154,7 +130,7 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
154130
acpi_status status;
155131
unsigned long flags;
156132
struct resource *root, *conflict;
157-
u64 start, end, max_len;
133+
u64 start, end;
158134

159135
status = resource_to_addr(acpi_res, &addr);
160136
if (!ACPI_SUCCESS(status))
@@ -171,27 +147,15 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
171147
} else
172148
return AE_OK;
173149

174-
max_len = addr.maximum - addr.minimum + 1;
175-
if (addr.address_length > max_len) {
176-
dev_printk(KERN_DEBUG, &info->bridge->dev,
177-
"host bridge window length %#llx doesn't fit in "
178-
"%#llx-%#llx, trimming\n",
179-
(unsigned long long) addr.address_length,
180-
(unsigned long long) addr.minimum,
181-
(unsigned long long) addr.maximum);
182-
addr.address_length = max_len;
183-
}
184-
185150
start = addr.minimum + addr.translation_offset;
186-
end = start + addr.address_length - 1;
151+
end = addr.maximum + addr.translation_offset;
187152

188153
res = &info->res[info->res_num];
189154
res->name = info->name;
190155
res->flags = flags;
191156
res->start = start;
192157
res->end = end;
193158
res->child = NULL;
194-
align_resource(info->bridge, res);
195159

196160
if (!pci_use_crs) {
197161
dev_printk(KERN_DEBUG, &info->bridge->dev,

0 commit comments

Comments
 (0)