All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: split e820 reserved entries record to late v3
@ 2008-08-29  0:41 Yinghai Lu
  2008-08-29  0:53 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Yinghai Lu @ 2008-08-29  0:41 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
	Jesse Barnes, Linus Torvalds
  Cc: linux-kernel, Yinghai Lu

so could let BAR res register at first, or even pnp?

v2: insert e820 reserve resources before pnp_system_init
v3: fix merging problem in tip/x86/core
    please drop the one in tip/x86/core use this one instead

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

---
 arch/x86/kernel/e820.c |   20 ++++++++++++++++++--
 arch/x86/pci/i386.c    |    3 +++
 include/asm-x86/e820.h |    1 +
 3 files changed, 22 insertions(+), 2 deletions(-)

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
@@ -1271,13 +1271,15 @@ static inline const char *e820_type_to_s
 /*
  * Mark e820 reserved areas as busy for the resource manager.
  */
+struct resource __initdata *e820_res;
 void __init e820_reserve_resources(void)
 {
 	int i;
-	struct resource *res;
 	u64 end;
+	struct resource *res;
 
 	res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map);
+	e820_res = res;
 	for (i = 0; i < e820.nr_map; i++) {
 		end = e820.map[i].addr + e820.map[i].size - 1;
 #ifndef CONFIG_RESOURCES_64BIT
@@ -1291,7 +1293,8 @@ void __init e820_reserve_resources(void)
 		res->end = end;
 
 		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-		insert_resource(&iomem_resource, res);
+		if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20))
+			insert_resource(&iomem_resource, res);
 		res++;
 	}
 
@@ -1303,6 +1306,19 @@ void __init e820_reserve_resources(void)
 	}
 }
 
+void __init e820_reserve_resources_late(void)
+{
+	int i;
+	struct resource *res;
+
+	res = e820_res;
+	for (i = 0; i < e820.nr_map; i++) {
+		if (e820.map[i].type == E820_RESERVED && res->start >= (1ULL<<20))
+			insert_resource(&iomem_resource, res);
+		res++;
+	}
+}
+
 char *__init default_machine_specific_memory_setup(void)
 {
 	char *who = "BIOS-e820";
Index: linux-2.6/arch/x86/pci/i386.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/i386.c
+++ linux-2.6/arch/x86/pci/i386.c
@@ -33,6 +33,7 @@
 #include <linux/bootmem.h>
 
 #include <asm/pat.h>
+#include <asm/e820.h>
 
 #include "pci.h"
 
@@ -230,6 +231,8 @@ void __init pcibios_resource_survey(void
 	pcibios_allocate_bus_resources(&pci_root_buses);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
+
+	e820_reserve_resources_late();
 }
 
 /**
Index: linux-2.6/include/asm-x86/e820.h
===================================================================
--- linux-2.6.orig/include/asm-x86/e820.h
+++ linux-2.6/include/asm-x86/e820.h
@@ -122,6 +122,7 @@ extern void e820_register_active_regions
 extern u64 e820_hole_size(u64 start, u64 end);
 extern void finish_e820_parsing(void);
 extern void e820_reserve_resources(void);
+extern void e820_reserve_resources_late(void);
 extern void setup_memory_map(void);
 extern char *default_machine_specific_memory_setup(void);
 extern char *machine_specific_memory_setup(void);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86: split e820 reserved entries record to late v3
  2008-08-29  0:41 [PATCH] x86: split e820 reserved entries record to late v3 Yinghai Lu
@ 2008-08-29  0:53 ` Linus Torvalds
  2008-08-29  1:02   ` Yinghai Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2008-08-29  0:53 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
	Jesse Barnes, linux-kernel



On Thu, 28 Aug 2008, Yinghai Lu wrote:
>  /*
>   * Mark e820 reserved areas as busy for the resource manager.
>   */
> +struct resource __initdata *e820_res;

Btw, make this one "static" - I don't think anybody outside of this file 
should ever use it anyway.

And this:

> +		if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20))
> +			insert_resource(&iomem_resource, res);

is probably worthy of a comment. 

And finally:

> +void __init e820_reserve_resources_late(void)
> +{
> +	int i;
> +	struct resource *res;
> +
> +	res = e820_res;
> +	for (i = 0; i < e820.nr_map; i++) {
> +		if (e820.map[i].type == E820_RESERVED && res->start >= (1ULL<<20))
> +			insert_resource(&iomem_resource, res);

instead of duplicating the conditional and always having to worry about it 
matching, how about just making it

		if (!res->parent)
			insert_resource(&iomem_resource, res);

which basically says that "if it's not already inserted, try to re-insert 
it now".

		Linus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86: split e820 reserved entries record to late v3
  2008-08-29  0:53 ` Linus Torvalds
@ 2008-08-29  1:02   ` Yinghai Lu
  0 siblings, 0 replies; 3+ messages in thread
From: Yinghai Lu @ 2008-08-29  1:02 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
	Jesse Barnes, linux-kernel

On Thu, Aug 28, 2008 at 5:53 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
>
> On Thu, 28 Aug 2008, Yinghai Lu wrote:
>>  /*
>>   * Mark e820 reserved areas as busy for the resource manager.
>>   */
>> +struct resource __initdata *e820_res;
>
> Btw, make this one "static" - I don't think anybody outside of this file
> should ever use it anyway.

yes

>
> And this:
>
>> +             if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20))
>> +                     insert_resource(&iomem_resource, res);
>
> is probably worthy of a comment.

how about
/*
 * don't register the region that could be conflicted with pci device
BAR resource
 * and insert them later.
 */


>
> And finally:
>
>> +void __init e820_reserve_resources_late(void)
>> +{
>> +     int i;
>> +     struct resource *res;
>> +
>> +     res = e820_res;
>> +     for (i = 0; i < e820.nr_map; i++) {
>> +             if (e820.map[i].type == E820_RESERVED && res->start >= (1ULL<<20))
>> +                     insert_resource(&iomem_resource, res);
>
> instead of duplicating the conditional and always having to worry about it
> matching, how about just making it
>
>                if (!res->parent)
>                        insert_resource(&iomem_resource, res);
>
> which basically says that "if it's not already inserted, try to re-insert
> it now".
there could be one is all zero, when 32bit/!64_RESOURCE.
so could change it to
                if (!res->parent && res->end)
                       insert_resource(&iomem_resource, res);

YH

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-29  1:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-29  0:41 [PATCH] x86: split e820 reserved entries record to late v3 Yinghai Lu
2008-08-29  0:53 ` Linus Torvalds
2008-08-29  1:02   ` Yinghai Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.