mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alok Kataria <akataria@vmware.com>
To: "Brown, Len" <len.brown@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-acpi@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] cleanup e820_setup_gap
Date: Thu, 19 Jun 2008 15:57:30 -0700	[thread overview]
Message-ID: <1213916250.27983.35.camel@promb-2n-dhcp368.eng.vmware.com> (raw)

This is a preparatory patch for the next patch in series.
Moves some code from e820_setup_gap to a new function e820_search_gap.
This function will be used by the next patch in the series.

Signed-off-by: Alok N Kataria <akataria@vmware.com>

Index: linux-2.6/arch/x86/kernel/e820_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/e820_64.c	2008-06-12 10:42:22.000000000 -0700
+++ linux-2.6/arch/x86/kernel/e820_64.c	2008-06-13 14:05:18.000000000 -0700
@@ -872,26 +872,20 @@
 EXPORT_SYMBOL(pci_mem_start);
 
 /*
- * Search for the biggest gap in the low 32 bits of the e820
- * memory space.  We pass this space to PCI to assign MMIO resources
- * for hotplug or unconfigured devices in.
- * Hopefully the BIOS let enough space left.
+ * Search for a gap in the e820 memory space from start_addr to 2^32.
  */
-__init void e820_setup_gap(void)
+__init void e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
+			unsigned long start_addr)
 {
-	unsigned long gapstart, gapsize, round;
-	unsigned long last;
-	int i;
-	int found = 0;
+	unsigned long last = 0x100000000ull;
+	int i = e820.nr_map;
 
-	last = 0x100000000ull;
-	gapstart = 0x10000000;
-	gapsize = 0x400000;
-	i = e820.nr_map;
 	while (--i >= 0) {
 		unsigned long long start = e820.map[i].addr;
 		unsigned long long end = start + e820.map[i].size;
 
+		if (end < start_addr)
+			continue;
 		/*
 		 * Since "last" is at most 4GB, we know we'll
 		 * fit in 32 bits if this condition is true
@@ -899,17 +893,32 @@
 		if (last > end) {
 			unsigned long gap = last - end;
 
-			if (gap > gapsize) {
-				gapsize = gap;
-				gapstart = end;
-				found = 1;
+			if (gap >= *gapsize) {
+				*gapsize = gap;
+				*gapstart = end;
 			}
 		}
 		if (start < last)
 			last = start;
 	}
+}
+
+/*
+ * Search for the biggest gap in the low 32 bits of the e820
+ * memory space.  We pass this space to PCI to assign MMIO resources
+ * for hotplug or unconfigured devices in.
+ * Hopefully the BIOS let enough space left.
+ */
+__init void e820_setup_gap(void)
+{
+	unsigned long gapstart, gapsize, round;
+
+	gapstart = 0;
+	gapsize = 0x400000;
+
+	e820_search_gap(&gapstart, &gapsize, 0);
 
-	if (!found) {
+	if (!gapstart) {
 		gapstart = (end_pfn << PAGE_SHIFT) + 1024*1024;
 		printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit "
 		       "address range\n"
Index: linux-2.6/include/asm-x86/e820_64.h
===================================================================
--- linux-2.6.orig/include/asm-x86/e820_64.h	2008-06-12 10:42:22.000000000 -0700
+++ linux-2.6/include/asm-x86/e820_64.h	2008-06-12 10:55:09.000000000 -0700
@@ -39,6 +39,7 @@
 extern unsigned long e820_hole_size(unsigned long start, unsigned long end);
 
 extern void e820_setup_gap(void);
+extern void e820_search_gap(unsigned long *, unsigned long *, unsigned long);
 extern void e820_register_active_regions(int nid, unsigned long start_pfn,
 					 unsigned long end_pfn);
 



             reply	other threads:[~2008-06-19 22:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-19 22:57 Alok Kataria [this message]
2008-06-20 15:32 ` Ingo Molnar
2008-06-20 19:38   ` Alok Kataria
2008-06-20 19:50     ` Yinghai Lu
2008-06-20 20:28       ` Alok Kataria
2008-06-24 12:08         ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1213916250.27983.35.camel@promb-2n-dhcp368.eng.vmware.com \
    --to=akataria@vmware.com \
    --cc=akpm@linux-foundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®