From 6bb8d8aebc305fbbac9488f4d1c792f35cbe2375 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 26 Oct 2010 15:41:44 -0600 Subject: [PATCH] --- yaml --- r: 219566 b: refs/heads/master c: dc9887dc02e37bcf83f4e792aa14b07782ef54cf h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/arch/x86/pci/i386.c | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index a583b35997e1..b92512bccf56 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b126b4703afa4010b161784a43650337676dd03b +refs/heads/master: dc9887dc02e37bcf83f4e792aa14b07782ef54cf diff --git a/trunk/arch/x86/pci/i386.c b/trunk/arch/x86/pci/i386.c index 55253095be84..826140af3c3c 100644 --- a/trunk/arch/x86/pci/i386.c +++ b/trunk/arch/x86/pci/i386.c @@ -65,16 +65,21 @@ pcibios_align_resource(void *data, const struct resource *res, resource_size_t size, resource_size_t align) { struct pci_dev *dev = data; - resource_size_t start = res->start; + resource_size_t start = round_down(res->end - size + 1, align); if (res->flags & IORESOURCE_IO) { - if (skip_isa_ioresource_align(dev)) - return start; - if (start & 0x300) - start = (start + 0x3ff) & ~0x3ff; + + /* + * If we're avoiding ISA aliases, the largest contiguous I/O + * port space is 256 bytes. Clearing bits 9 and 10 preserves + * all 256-byte and smaller alignments, so the result will + * still be correctly aligned. + */ + if (!skip_isa_ioresource_align(dev)) + start &= ~0x300; } else if (res->flags & IORESOURCE_MEM) { if (start < BIOS_END) - start = BIOS_END; + start = res->end; /* fail; no space */ } return start; }