From patchwork Thu Oct 14 23:18:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 254911 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9ENJoL1028412 for ; Thu, 14 Oct 2010 23:19:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755644Ab0JNXSr (ORCPT ); Thu, 14 Oct 2010 19:18:47 -0400 Received: from g5t0008.atlanta.hp.com ([15.192.0.45]:34079 "EHLO g5t0008.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755567Ab0JNXSn (ORCPT ); Thu, 14 Oct 2010 19:18:43 -0400 Received: from g5t0029.atlanta.hp.com (g5t0029.atlanta.hp.com [16.228.8.141]) by g5t0008.atlanta.hp.com (Postfix) with ESMTP id ECFA5245B5; Thu, 14 Oct 2010 23:18:42 +0000 (UTC) Received: from ldl (ldl.usa.hp.com [16.125.112.222]) by g5t0029.atlanta.hp.com (Postfix) with ESMTP id C132120138; Thu, 14 Oct 2010 23:18:42 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 9528D1A7E028; Thu, 14 Oct 2010 17:18:42 -0600 (MDT) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qgxx2XJLZrYR; Thu, 14 Oct 2010 17:18:42 -0600 (MDT) Received: from eh.fc.hp.com (bob.lnx.usa.hp.com [16.125.112.218]) by ldl (Postfix) with ESMTP id 78D5B1A7E025; Thu, 14 Oct 2010 17:18:42 -0600 (MDT) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id 6D15326132; Thu, 14 Oct 2010 17:18:42 -0600 (MDT) Subject: [PATCH v4 4/6] x86/PCI: allocate space from the end of a region, not the beginning To: Jesse Barnes From: Bjorn Helgaas Cc: Bob Picco , Brian Bloniarz , Charles Butterfield , Denys Vlasenko , linux-pci@vger.kernel.org, "Horst H. von Brand" , Ingo Molnar , linux-kernel@vger.kernel.org, Stefan Becker , "H. Peter Anvin" , Yinghai Lu , Leann Ogasawara , Linus Torvalds , Thomas Gleixner Date: Thu, 14 Oct 2010 17:18:42 -0600 Message-ID: <20101014231842.536.35121.stgit@bob.kio> In-Reply-To: <20101014231804.536.62138.stgit@bob.kio> References: <20101014231804.536.62138.stgit@bob.kio> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 14 Oct 2010 23:19:52 +0000 (UTC) diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 5525309..826140a 100644 --- a/arch/x86/pci/i386.c +++ b/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; }