From patchwork Wed Apr 15 00:29:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 18253 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3F0WEI1021803 for ; Wed, 15 Apr 2009 00:32:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754435AbZDOAbe (ORCPT ); Tue, 14 Apr 2009 20:31:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753761AbZDOAbd (ORCPT ); Tue, 14 Apr 2009 20:31:33 -0400 Received: from hera.kernel.org ([140.211.167.34]:36393 "EHLO hera.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752013AbZDOAbc (ORCPT ); Tue, 14 Apr 2009 20:31:32 -0400 Received: from [10.6.76.26] (sca-ea-fw-1.Sun.COM [192.18.43.225]) (authenticated bits=0) by hera.kernel.org (8.14.2/8.13.8) with ESMTP id n3F0Tn7Y015601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 15 Apr 2009 00:29:53 GMT Message-ID: <49E52A7A.4070607@kernel.org> Date: Tue, 14 Apr 2009 17:29:46 -0700 From: Yinghai Lu User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: Linus Torvalds , Jesse Barnes , Ingo Molnar , Andrew Morton , Thomas Gleixner , "H. Peter Anvin" CC: "linux-kernel@vger.kernel.org" , linux-pci@vger.kernel.org, yannick.roehlly@free.fr Subject: [PATCH] x86/pci: make pci_mem_start to be aligned only -v2 References: <200904101913.n3AJDhMm018684@demeter.kernel.org> <49DFABCC.3070001@kernel.org> <49E00E9F.8030605@kernel.org> <49E4F6D6.6030709@kernel.org> <49E4F71F.10107@kernel.org> In-Reply-To: X-Virus-Scanned: ClamAV 0.93.3/9236/Tue Apr 14 18:51:03 2009 on hera.kernel.org X-Virus-Status: Clean Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Impact: make more big space below 4g for assigning to unassigned pci devices don't need to reserved one round after the gapstart. v2: Linus said: " We've definitely seen ACPI code or integrated graphics stuff that steals a lot of memory at the end, which means that end-of-RAM might be not at 2GB, but at 2GB-16MB-1MB, for example (1MB of "ACPI data", and 16MB of "stolen video ram"). At a minimum, if we do this, I'd like to make sure we round up to a big boundary (eg 32MB or something - exactly because a missing 16MB can easily be some integrated stolen video memory). Sure, we do that whole while ((gapsize >> 4) > round) round += round; thing, so that if the gap is large, then we'll certainly get to 32MB too, but I think your patch matters the most exactly when the gap is small. Maybe we could just raise the initial minimum rounding from 1MB to 32MB? ... Alternatively, maybe we can make sure that we round up to at least X bytes from the end of RAM, and to at least Y bytes from the end of some RESERVED thing." Reported-and-tested-by: Yannick Signed-off-by: Yinghai Lu --- arch/x86/kernel/e820.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/arch/x86/kernel/e820.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/e820.c +++ linux-2.6/arch/x86/kernel/e820.c @@ -619,6 +619,7 @@ __init void e820_setup_gap(void) { unsigned long gapstart, gapsize, round; int found; + unsigned long low_top_ram; gapstart = 0x10000000; gapsize = 0x400000; @@ -636,14 +637,32 @@ __init void e820_setup_gap(void) /* * See how much we want to round up: start off with - * rounding to the next 1MB area. + * rounding to the next 32MB area. */ - round = 0x100000; + round = 0x2000000; while ((gapsize >> 4) > round) round += round; + + pci_mem_start = roundup(gapstart, round); + + low_top_ram = e820_end_of_low_ram_pfn() << PAGE_SHIFT; + /* try to check if there is gap between last RAM below 4g to that start */ + if (pci_mem_start > low_top_ram) { + if (e820_any_mapped(low_top_ram, pci_mem_start, E820_RESERVED)) + goto out; + if (e820_any_mapped(low_top_ram, pci_mem_start, E820_ACPI)) + goto out; + if (e820_any_mapped(low_top_ram, pci_mem_start, E820_NVS)) + goto out; + + if ((pci_mem_start - low_top_ram) > round) + goto out; + } + /* Fun with two's complement */ pci_mem_start = (gapstart + round) & -round; +out: printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n", pci_mem_start, gapstart, gapsize);