x86: increase MAX_EARLY_RES
PATCH 7/7 x86: increase MAX_EARLY_RES
In reply to a message not in the archive32bit numa run out of it, because recent change with wakeup and mptable.
--- arch/x86/kernel/e820.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/e820.c +1 -1
@@ -724,7 +724,7 @@ core_initcall(e820_mark_nvs_memory);/* * Early reserved memory areas. */ -#define MAX_EARLY_RES 20 +#define MAX_EARLY_RES 32struct early_res {u64 start, end;
PATCH 3/7 x86/pci: use resource_size_t in update_res
In reply to a message not in the archiveprepare to enable 32bit intel and amd bus
--- arch/x86/pci/bus_numa.c | 16 ++++++++-------- arch/x86/pci/bus_numa.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-)
arch/x86/pci/bus_numa.c +8 -8
@@ -51,8 +51,8 @@ void x86_pci_root_bus_res_quirks(struct } } -void __init update_res (struct pci_root_info *info,size_t start, -size_t end,unsigned long flags,int merge) +void __init update_res (struct pci_root_info *info,resource_size_t start, +resource_size_t end,unsigned long flags,int merge) {int i;struct resource *res;
@@ -65,20 +65,20 @@ void __init update_res(struct pci_root_i/* try to merge it with old one */ for (i =0 ; i < info->res_num; i++) { -size_t final_start, final_end; -size_t common_start, common_end; +resource_size_t final_start, final_end; +resource_size_t common_start, common_end; res = &info->res[i];if (res->flags != flags)continue ; - common_start =max ((size_t )res->start, start); - common_end =min ((size_t )res->end, end); + common_start =max (res->start, start); + common_end =min (res->end, end);if (common_start > common_end +1 )continue ; - final_start =min ((size_t )res->start, start); - final_end =max ((size_t )res->end, end); + final_start =min (res->start, start); + final_end =max (res->end, end); res->start = final_start; res->end = final_end;
arch/x86/pci/bus_numa.h +2 -2
@@ -22,6 +22,6 @@ extern int pci_root_num;extern struct pci_root_info pci_root_info[PCI_ROOT_NR ];extern int found_all_numa_early; -extern void update_res (struct pci_root_info *info,size_t start, -size_t end,unsigned long flags,int merge); +extern void update_res (struct pci_root_info *info,resource_size_t start, +resource_size_t end,unsigned long flags,int merge);#endif
PATCH 5/7 x86/pci: use u64 instead of size_t in amd_bus.c
In reply to a message not in the archiveprepare to enable it for 32bit
--- arch/x86/pci/amd_bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/pci/amd_bus.c +2 -2
@@ -82,8 +82,8 @@ static int __init early_fill_mp_bus_infostruct pci_root_info *info;u32 reg;struct resource *res; -size_t start; -size_t end; +u64 start; +u64 end;struct range range[RANGE_NUM ];u64 val;u32 address;
PATCH 4/7 x86/pci: amd one chain system to use pci read out res
In reply to a message not in the archivefound MSI amd k8 based laptops is hiding [0x70000000, 0x80000000) RAM from e820.
enable amd one chain even for all.
--- arch/x86/pci/amd_bus.c | 7 ++++--- arch/x86/pci/bus_numa.c | 5 ----- arch/x86/pci/bus_numa.h | 1 - 3 files changed, 4 insertions(+), 9 deletions(-)
arch/x86/pci/amd_bus.c +4 -3
@@ -87,11 +87,12 @@ static int __init early_fill_mp_bus_infostruct range range[RANGE_NUM ];u64 val;u32 address; +int found;if (!early_pci_allowed ())return -1 ; - found_all_numa_early =0 ; + found =0 ;for (i =0 ; i <ARRAY_SIZE (pci_probes); i++) {u32 id;u16 device;
@@ -105,12 +106,12 @@ static int __init early_fill_mp_bus_info device = (id>>16 ) &0xffff ;if (pci_probes[i].vendor == vendor && pci_probes[i].device == device) { - found_all_numa_early =1 ; + found =1 ;break ; } } -if (!found_all_numa_early) +if (!found)return 0 ; pci_root_num =0 ;
arch/x86/pci/bus_numa.c +0 -5
@@ -5,7 +5,6 @@int pci_root_num;struct pci_root_info pci_root_info[PCI_ROOT_NR ]; -int found_all_numa_early;void x86_pci_root_bus_res_quirks (struct pci_bus *b) {
@@ -21,10 +20,6 @@ void x86_pci_root_bus_res_quirks(structif (!pci_root_num)return ; -/* for amd, if only one root bus, don't need to do anything */ -if (pci_root_num <2 && found_all_numa_early) -return ; -for (i =0 ; i < pci_root_num; i++) {if (pci_root_info[i].bus_min == b->number)break ;
arch/x86/pci/bus_numa.h +0 -1
@@ -20,7 +20,6 @@ struct pci_root_info {#define PCI_ROOT_NR 4extern int pci_root_num;extern struct pci_root_info pci_root_info[PCI_ROOT_NR ]; -extern int found_all_numa_early;extern void update_res (struct pci_root_info *info,resource_size_t start,resource_size_t end,unsigned long flags,int merge);
PATCH 2/7 x86/range: check range in update range
In reply to a message not in the archivefend off wrong range
--- kernel/range.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/range.c +9 -0
@@ -13,6 +13,9 @@int add_range (struct range *range,int az,int nr_range,u64 start,u64 end) { +if (start > end) +return nr_range; +/* Out of slots: */ if (nr_range >= az)return nr_range;
@@ -30,6 +33,9 @@ int add_range_with_merge(struct range *r {int i; +if (start > end) +return nr_range; +/* Try to merge it with old one: */ for (i =0 ; i < nr_range; i++) {u64 final_start, final_end;
@@ -59,6 +65,9 @@ void subtract_range(struct range *range, {int i, j; +if (start > end) +return ; +for (j =0 ; j < az; j++) {if (!range[j].end)continue ;
PATCH 6/7 x86/pci: enable pci root res read out for 32bit too
In reply to a message not in the archiveshould be good for 32bit too.
--- arch/x86/pci/Makefile | 3 +-- arch/x86/pci/amd_bus.c | 17 +++-------------- arch/x86/pci/bus_numa.h | 4 ++-- arch/x86/pci/i386.c | 4 ---- 4 files changed, 6 insertions(+), 22 deletions(-)
arch/x86/pci/Makefile +1 -2
@@ -14,8 +14,7 @@ obj-$(CONFIG_X86_VISWS) += visws.o obj-$(CONFIG_X86_NUMAQ) += numaq_32.o obj-y += common.o early.o -obj-y += amd_bus.o -obj-$(CONFIG_X86_64) += bus_numa.o intel_bus.o +obj-y += amd_bus.o bus_numa.o intel_bus.o ifeq ($(CONFIG_PCI_DEBUG),y) EXTRA_CFLAGS += -DDEBUG
arch/x86/pci/amd_bus.c +3 -14
@@ -6,9 +6,7 @@#include <asm/pci_x86.h> -#ifdef CONFIG_X86_64 #include <asm/pci-direct.h> -#endif #include "bus_numa.h"
@@ -17,8 +15,6 @@* also get peer root bus resource for io,mmio */ -#ifdef CONFIG_X86_64 -struct pci_hostbridge_probe {u32 bus;u32 slot;
@@ -207,7 +203,7 @@ static int __init early_fill_mp_bus_info address =MSR_K8_TOP_MEM1 ;rdmsrl (address, val); end = (val &0xffffff800000ULL ); -printk (KERN_INFO "TOM: %016lx aka %ldM\n" , end, end>>20 ); +printk (KERN_INFO "TOM: %016llx aka %lldM\n" , (u64 )end, (u64 )end>>20 );if (end < (1ULL <<32 ))subtract_range (range,RANGE_NUM ,0 , end -1 );
@@ -301,7 +297,8 @@ static int __init early_fill_mp_bus_info address =MSR_K8_TOP_MEM2 ;rdmsrl (address, val); end = (val &0xffffff800000ULL ); -printk (KERN_INFO "TOM2: %016lx aka %ldM\n" , end, end>>20 ); +printk (KERN_INFO "TOM2: %016llx aka %lldM\n" , (u64 )end, + (u64 )end>>20 );subtract_range (range,RANGE_NUM ,1ULL <<32 , end -1 ); }
@@ -347,14 +344,6 @@ static int __init early_fill_mp_bus_inforeturn 0 ; } -#else /* !CONFIG_X86_64 */ - -static int __init early_fill_mp_bus_info (void ) {return 0 ; } - -#endif /* !CONFIG_X86_64 */ - -/* common 32/64 bit code */ -#define ENABLE_CF8_EXT_CFG (1ULL << 46)static void enable_pci_io_ecs (void *unused)
arch/x86/pci/i386.c +0 -4
@@ -257,10 +257,6 @@ void __init pcibios_resource_survey(void*/ fs_initcall (pcibios_assign_resources); -void __weak x86_pci_root_bus_res_quirks (struct pci_bus *b) -{ -} -/* * If we set up a device for bus mastering, we need to check the latency * timer as certain crappy BIOSes forget to set it properly.
arch/x86/pci/bus_numa.h +2 -2
@@ -1,5 +1,5 @@ -#ifdef CONFIG_X86_64 - +#ifndef __BUS_NUMA_H +#define __BUS_NUMA_H/* * sub bus (transparent) will use entres from 3 to store extra from * root, so need to make sure we have enough slot there, Should we
H. Peter Anvin
reviewerRe: [PATCH 5/7] x86/pci: use u64 instead of size_t in amd_bus.c
In reply to Yinghai LuQuoted 16 lines · Yinghai Lu
prepare to enable it for 32bit
Signed-off-by Yinghai Lu <[email protected]>--- arch/x86/pci/amd_bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Index:
linux-2.6/arch/x86/pci/amd_bus.c
===================================================================
arch/x86/pci/amd_bus.c static int __init early_fill_mp_bus_info · line 89
Quoted 10 lines
arch/x86/pci/amd_bus.c +2
-2@@ -82,8 +82,8 @@ static int __init early_fill_mp_bus_infostruct pci_root_info *info;u32 reg;struct resource *res; -size_t start; -size_t end; +u64 start; +u64 end;struct range range[RANGE_NUM ];u64 val;u32 address;
Shouldn't this be resource_size_t?
-hpa
Re: [PATCH 5/7] x86/pci: use u64 instead of size_t in amd_bus.c
Quoted 20 lines · H. Peter Anvin
Quoted 19 lines · Yinghai Lu
prepare to enable it for 32bit
Signed-off-by Yinghai Lu <[email protected]>--- arch/x86/pci/amd_bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Index:
linux-2.6/arch/x86/pci/amd_bus.c
===================================================================arch/x86/pci/amd_bus.c +0
-2@@ -82,8 +82,8 @@ static int __init early_fill_mp_bus_infostruct pci_root_info *info;u32 reg;struct resource *res; -size_t start; -size_t end;
Quoted 8 lines
arch/x86/pci/amd_bus.c static int __init early_fill_mp_bus_info · line 89
Quoted 6 lines
arch/x86/pci/amd_bus.c +2
-0+u64 start; +u64 end;struct range range[RANGE_NUM ];u64 val;u32 address;Shouldn't this be
resource_size_t?
it seems we should use u64, and check the if the sizeof(resource_size_t) != sizeof(u64) and cap some vale.
YH
PATCH 5/7 x86/pci: use u64 instead of size_t in amd_bus.c -v2
In reply to Yinghai Luprepare to enable it for 32bit
-v2: remove not needed cast
--- arch/x86/pci/amd_bus.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/x86/pci/amd_bus.c +8 -8
@@ -82,8 +82,8 @@ static int __init early_fill_mp_bus_infostruct pci_root_info *info;u32 reg;struct resource *res; -size_t start; -size_t end; +u64 start; +u64 end;struct range range[RANGE_NUM ];u64 val;u32 address;
@@ -173,7 +173,7 @@ static int __init early_fill_mp_bus_info info = &pci_root_info[j];printk (KERN_DEBUG "node %d link %d: io port [%llx, %llx]\n" , - node, link, (u64 )start, (u64 )end); + node, link, start, end);/* kernel only handle 16 bit only */ if (end >0xffff )
@@ -207,7 +207,7 @@ static int __init early_fill_mp_bus_info address =MSR_K8_TOP_MEM1 ;rdmsrl (address, val); end = (val &0xffffff800000ULL ); -printk (KERN_INFO "TOM: %016lx aka %ldM\n" , end, end>>20 ); +printk (KERN_INFO "TOM: %016llx aka %lldM\n" , end, end>>20 );if (end < (1ULL <<32 ))subtract_range (range,RANGE_NUM ,0 , end -1 );
@@ -246,7 +246,7 @@ static int __init early_fill_mp_bus_info info = &pci_root_info[j];printk (KERN_DEBUG "node %d link %d: mmio [%llx, %llx]" , - node, link, (u64 )start, (u64 )end); + node, link, start, end);/* * some sick allocation would have range overlap with fam10h * mmconf range, so need to update start and end.
@@ -272,13 +272,13 @@ static int __init early_fill_mp_bus_info endx = fam10h_mmconf_start -1 ;update_res (info, start, endx,IORESOURCE_MEM ,0 );subtract_range (range,RANGE_NUM , start, endx); -printk (KERN_CONT " ==> [%llx, %llx]" , (u64 )start, endx); +printk (KERN_CONT " ==> [%llx, %llx]" , start, endx); start = fam10h_mmconf_end +1 ; changed =1 ; }if (changed) {if (start <= end) { -printk (KERN_CONT " %s [%llx, %llx]" , endx?"and" :"==>" , (u64 )start, (u64 )end); +printk (KERN_CONT " %s [%llx, %llx]" , endx?"and" :"==>" , start, end); }else {printk (KERN_CONT "%s\n" , endx?"" :" ==> none" );continue ;
@@ -301,7 +301,7 @@ static int __init early_fill_mp_bus_info address =MSR_K8_TOP_MEM2 ;rdmsrl (address, val); end = (val &0xffffff800000ULL ); -printk (KERN_INFO "TOM2: %016lx aka %ldM\n" , end, end>>20 ); +printk (KERN_INFO "TOM2: %016llx aka %lldM\n" , end, end>>20 );subtract_range (range,RANGE_NUM ,1ULL <<32 , end -1 ); }
[PATCH 61/7] x86/pci: add cap_4g
In reply to Yinghai Luprepare for 32bit pci root bus
--- arch/x86/pci/amd_bus.c | 7 ++++--- arch/x86/pci/bus_numa.c | 4 ++++ arch/x86/pci/intel_bus.c | 5 ++++- include/linux/range.h | 10 ++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-)
arch/x86/pci/amd_bus.c +4 -3
@@ -201,7 +201,7 @@ static int __init early_fill_mp_bus_infomemset (range,0 ,sizeof (range));/* 0xfd00000000-0xffffffffff for HT */ - range[0 ].end = (0xfdULL <<32 ) -1 ; + range[0 ].end =cap_4g ((0xfdULL <<32 ) -1 );/* need to take out [0, TOM) for RAM*/ address =MSR_K8_TOP_MEM1 ;
@@ -286,7 +286,7 @@ static int __init early_fill_mp_bus_info } } -update_res (info, start, end,IORESOURCE_MEM ,1 ); +update_res (info,cap_4g (start),cap_4g (end),IORESOURCE_MEM ,1 );subtract_range (range,RANGE_NUM , start, end);printk (KERN_CONT "\n" ); }
@@ -321,7 +321,8 @@ static int __init early_fill_mp_bus_infoif (!range[i].end)continue ; -update_res (info, range[i].start, range[i].end, +update_res (info,cap_4g (range[i].start), +cap_4g (range[i].end),IORESOURCE_MEM ,1 ); } }
arch/x86/pci/bus_numa.c +4 -0
@@ -55,6 +55,10 @@ void __init update_res(struct pci_root_iif (start > end)return ; +if (sizeof (resource_size_t) <sizeof (u64) && + start ==0xffffffff ) +return ; +if (!merge) goto addit;
arch/x86/pci/intel_bus.c +4 -1
@@ -6,6 +6,8 @@#include <linux/dmi.h> #include <linux/pci.h> #include <linux/init.h> +#include <linux/range.h> +#include <asm/pci_x86.h> #include "bus_numa.h"
@@ -81,7 +83,8 @@ static void __devinit pci_root_bus_res(s mmioh_base |= ((u64)(dword &0x7ffff )) <<32 ;pci_read_config_dword (dev,IOH_LMMIOH_LIMITU , &dword); mmioh_end |= ((u64)(dword &0x7ffff )) <<32 ; -update_res (info, mmioh_base, mmioh_end,IORESOURCE_MEM ,0 ); +update_res (info,cap_4g (mmioh_base),cap_4g (mmioh_end), +IORESOURCE_MEM ,0 );print_ioh_resources (info); }
include/linux/range.h +10 -0
@@ -19,4 +19,14 @@ int clean_sort_range(struct range *rangevoid sort_range (struct range *range,int nr_range); +static inline u64 cap_4g (u64 val) +{ +if (sizeof (resource_size_t) >=sizeof (u64)) +return val; + +if (val <1ULL ) +return val; + +return 0xffffffff ; +}#endif
PATCH 6/7 x86/pci: enable pci root res read out for 32bit too -v2
In reply to Yinghai Lushould be good for 32bit too.
v2: split out cap_4g to 61
--- arch/x86/pci/Makefile | 3 +-- arch/x86/pci/amd_bus.c | 12 ------------ arch/x86/pci/bus_numa.h | 4 ++-- arch/x86/pci/i386.c | 4 ---- 4 files changed, 3 insertions(+), 20 deletions(-)
arch/x86/pci/Makefile +1 -2
@@ -14,8 +14,7 @@ obj-$(CONFIG_X86_VISWS) += visws.o obj-$(CONFIG_X86_NUMAQ) += numaq_32.o obj-y += common.o early.o -obj-y += amd_bus.o -obj-$(CONFIG_X86_64) += bus_numa.o intel_bus.o +obj-y += amd_bus.o bus_numa.o intel_bus.o ifeq ($(CONFIG_PCI_DEBUG),y) EXTRA_CFLAGS += -DDEBUG
arch/x86/pci/amd_bus.c +0 -12
@@ -6,9 +6,7 @@#include <asm/pci_x86.h> -#ifdef CONFIG_X86_64 #include <asm/pci-direct.h> -#endif #include "bus_numa.h"
@@ -17,8 +15,6 @@* also get peer root bus resource for io,mmio */ -#ifdef CONFIG_X86_64 -struct pci_hostbridge_probe {u32 bus;u32 slot;
@@ -348,14 +344,6 @@ static int __init early_fill_mp_bus_inforeturn 0 ; } -#else /* !CONFIG_X86_64 */ - -static int __init early_fill_mp_bus_info (void ) {return 0 ; } - -#endif /* !CONFIG_X86_64 */ - -/* common 32/64 bit code */ -#define ENABLE_CF8_EXT_CFG (1ULL << 46)static void enable_pci_io_ecs (void *unused)
arch/x86/pci/i386.c +0 -4
@@ -257,10 +257,6 @@ void __init pcibios_resource_survey(void*/ fs_initcall (pcibios_assign_resources); -void __weak x86_pci_root_bus_res_quirks (struct pci_bus *b) -{ -} -/* * If we set up a device for bus mastering, we need to check the latency * timer as certain crappy BIOSes forget to set it properly.
arch/x86/pci/bus_numa.h +2 -2
@@ -1,5 +1,5 @@ -#ifdef CONFIG_X86_64 - +#ifndef __BUS_NUMA_H +#define __BUS_NUMA_H/* * sub bus (transparent) will use entres from 3 to store extra from * root, so need to make sure we have enough slot there, Should we
H. Peter Anvin
reviewerRe: [PATCH 61/7] x86/pci: add cap_4g
In reply to Yinghai Luinclude/linux/range.h int clean_sort_range(struct range *range · line 32
Quoted 12 lines · Yinghai Lu
include/linux/range.h +10
-0+static inline u64 cap_4g (u64 val) +{ +if (sizeof (resource_size_t) >=sizeof (u64)) +return val; + +if (val <1ULL ) +return val; + +return 0xffffffff ; +}#endif
How about:
static inline resource_size_t cap_resource(u64 val)
{
if (val > ~(resource_size_t)0)
return ~(resource_size_t)0;
else
return val;
}Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Re: [PATCH 61/7] x86/pci: add cap_4g
Quoted 16 lines · H. Peter Anvin
include/linux/range.h int clean_sort_range(struct range *range · line 32
Quoted 12 lines · Yinghai Lu
include/linux/range.h +10
-0+static inline u64 cap_4g (u64 val) +{ +if (sizeof (resource_size_t) >=sizeof (u64)) +return val; + +if (val <1ULL ) +return val; + +return 0xffffffff ; +}#endif How about:
Quoted 7 lines
static inline
resource_size_tcap_resource(u64 val){ if (val > ~(resource_size_t)0) return ~(resource_size_t)0; else return val; }
ok
H. Peter Anvin
reviewerRe: [PATCH 61/7] x86/pci: add cap_4g
Quoted 11 lines · Yinghai Lu
Quoted 10 lines
How about:
static inline
resource_size_tcap_resource(u64 val){ if (val > ~(resource_size_t)0) return ~(resource_size_t)0; else return val; }
Quoted 1 line
ok
Stylisically I guess the idiom:
(resource_size_t)~0
... is better, not that it matters in this case, but the (type)~0 idiom gets the correct answer even when sizeof(type) < sizeof(int).
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
PATCH 6/7 x86/pci: enable pci root res read out for 32bit too -v3
In reply to Yinghai Lushould be good for 32bit too.
-v3: cast res->start
--- arch/x86/pci/Makefile | 3 +-- arch/x86/pci/amd_bus.c | 14 +------------- arch/x86/pci/bus_numa.h | 4 ++-- arch/x86/pci/i386.c | 4 ---- arch/x86/pci/intel_bus.c | 2 +- 5 files changed, 5 insertions(+), 22 deletions(-)
arch/x86/pci/Makefile +1 -2
@@ -14,8 +14,7 @@ obj-$(CONFIG_X86_VISWS) += visws.o obj-$(CONFIG_X86_NUMAQ) += numaq_32.o obj-y += common.o early.o -obj-y += amd_bus.o -obj-$(CONFIG_X86_64) += bus_numa.o intel_bus.o +obj-y += amd_bus.o bus_numa.o intel_bus.o ifeq ($(CONFIG_PCI_DEBUG),y) EXTRA_CFLAGS += -DDEBUG
arch/x86/pci/amd_bus.c +1 -13
@@ -6,9 +6,7 @@#include <asm/pci_x86.h> -#ifdef CONFIG_X86_64 #include <asm/pci-direct.h> -#endif #include "bus_numa.h"
@@ -17,8 +15,6 @@* also get peer root bus resource for io,mmio */ -#ifdef CONFIG_X86_64 -struct pci_hostbridge_probe {u32 bus;u32 slot;
@@ -342,21 +338,13 @@ static int __init early_fill_mp_bus_infoprintk (KERN_DEBUG "bus: %02x index %x %s: [%llx, %llx]\n" , busnum, j, (res->flags &IORESOURCE_IO )?"io port" :"mmio" , - res->start, res->end); + (u64 )res->start, (u64 )res->end); } }return 0 ; } -#else /* !CONFIG_X86_64 */ - -static int __init early_fill_mp_bus_info (void ) {return 0 ; } - -#endif /* !CONFIG_X86_64 */ - -/* common 32/64 bit code */ -#define ENABLE_CF8_EXT_CFG (1ULL << 46)static void enable_pci_io_ecs (void *unused)
arch/x86/pci/i386.c +0 -4
@@ -257,10 +257,6 @@ void __init pcibios_resource_survey(void*/ fs_initcall (pcibios_assign_resources); -void __weak x86_pci_root_bus_res_quirks (struct pci_bus *b) -{ -} -/* * If we set up a device for bus mastering, we need to check the latency * timer as certain crappy BIOSes forget to set it properly.
arch/x86/pci/bus_numa.h +2 -2
@@ -1,5 +1,5 @@ -#ifdef CONFIG_X86_64 - +#ifndef __BUS_NUMA_H +#define __BUS_NUMA_H/* * sub bus (transparent) will use entres from 3 to store extra from * root, so need to make sure we have enough slot there, Should we
arch/x86/pci/intel_bus.c +1 -1
@@ -30,7 +30,7 @@ static inline void print_ioh_resources(s busnum, i, (res->flags &IORESOURCE_IO ) ?"io port" :"mmio" , - res->start, res->end); + (u64)res->start, (u64)res->end); } }
[PATCH 61/7] x86/pci: add cap_resource -v2
In reply to H. Peter Anvinprepare for 32bit pci root bus
-v2: hpa said we should compare with (resource_size_t)~0
--- arch/x86/pci/amd_bus.c | 8 +++++--- arch/x86/pci/bus_numa.c | 3 +++ arch/x86/pci/intel_bus.c | 5 ++++- include/linux/range.h | 8 ++++++++ 4 files changed, 20 insertions(+), 4 deletions(-)
arch/x86/pci/amd_bus.c +5 -3
@@ -201,7 +201,7 @@ static int __init early_fill_mp_bus_infomemset (range,0 ,sizeof (range));/* 0xfd00000000-0xffffffffff for HT */ - range[0 ].end = (0xfdULL <<32 ) -1 ; + range[0 ].end =cap_resource ((0xfdULL <<32 ) -1 );/* need to take out [0, TOM) for RAM*/ address =MSR_K8_TOP_MEM1 ;
@@ -286,7 +286,8 @@ static int __init early_fill_mp_bus_info } } -update_res (info, start, end,IORESOURCE_MEM ,1 ); +update_res (info,cap_resource (start),cap_resource (end), +IORESOURCE_MEM ,1 );subtract_range (range,RANGE_NUM , start, end);printk (KERN_CONT "\n" ); }
@@ -321,7 +322,8 @@ static int __init early_fill_mp_bus_infoif (!range[i].end)continue ; -update_res (info, range[i].start, range[i].end, +update_res (info,cap_resource (range[i].start), +cap_resource (range[i].end),IORESOURCE_MEM ,1 ); } }
arch/x86/pci/bus_numa.c +3 -0
@@ -55,6 +55,9 @@ void __init update_res(struct pci_root_iif (start > end)return ; +if (start == (resource_size_t )~0 ) +return ; +if (!merge) goto addit;
arch/x86/pci/intel_bus.c +4 -1
@@ -6,6 +6,8 @@#include <linux/dmi.h> #include <linux/pci.h> #include <linux/init.h> +#include <linux/range.h> +#include <asm/pci_x86.h> #include "bus_numa.h"
@@ -81,7 +83,8 @@ static void __devinit pci_root_bus_res(s mmioh_base |= ((u64)(dword &0x7ffff )) <<32 ;pci_read_config_dword (dev,IOH_LMMIOH_LIMITU , &dword); mmioh_end |= ((u64)(dword &0x7ffff )) <<32 ; -update_res (info, mmioh_base, mmioh_end,IORESOURCE_MEM ,0 ); +update_res (info,cap_resource (mmioh_base),cap_resource (mmioh_end), +IORESOURCE_MEM ,0 );print_ioh_resources (info); }
include/linux/range.h +8 -0
@@ -19,4 +19,12 @@ int clean_sort_range(struct range *rangevoid sort_range (struct range *range,int nr_range); + +static inline resource_size_t cap_resource (u64 val) +{ +if (val > (resource_size_t )~0 ) +return (resource_size_t )~0 ; +else +return val; +}#endif
PATCH 1/3 x86: call early_res_to_bootmem one time
In reply to Yinghai Lusimplify setup_node_mem, do use bootmem from other node. instead just find_e820_area in early_node_mem.
so we can keep the boundary between early_res and boot mem more clear. and only call civertion one time instead of for all nodes.
--- arch/x86/kernel/setup.c | 1 arch/x86/mm/init_32.c | 1 arch/x86/mm/init_64.c | 3 -- arch/x86/mm/numa_64.c | 62 +++++++++++++++--------------------------------- 4 files changed, 22 insertions(+), 45 deletions(-)
arch/x86/kernel/setup.c +1 -0
@@ -942,6 +942,7 @@ void __init setup_arch(char **cmdline_p)#endif initmem_init (0 , max_pfn, acpi, k8); +early_res_to_bootmem (0 , max_low_pfn<<PAGE_SHIFT );#ifdef CONFIG_X86_64 /*
arch/x86/mm/init_32.c +0 -1
@@ -764,7 +764,6 @@ static unsigned long __init setup_node_bprintk (KERN_INFO " node %d bootmap %08lx - %08lx\n" , nodeid, bootmap, bootmap + bootmap_size);free_bootmem_with_active_regions (nodeid, end_pfn); -early_res_to_bootmem (start_pfn<<PAGE_SHIFT , end_pfn<<PAGE_SHIFT );return bootmap + bootmap_size; }
arch/x86/mm/init_64.c +1 -2
@@ -578,13 +578,12 @@ void __init initmem_init(unsigned long s PAGE_SIZE);if (bootmap ==-1L )panic ("Cannot find bootmem map of size %ld\n" , bootmap_size); +reserve_early (bootmap, bootmap + bootmap_size,"BOOTMAP" );/* don't touch min_low_pfn */ bootmap_size =init_bootmem_node (NODE_DATA (0 ), bootmap >>PAGE_SHIFT ,0 , end_pfn);e820_register_active_regions (0 , start_pfn, end_pfn); free_bootmem_with_active_regions(0, end_pfn); -early_res_to_bootmem (0 , end_pfn<<PAGE_SHIFT ); - reserve_bootmem(bootmap, bootmap_size, BOOTMEM_DEFAULT); }#endif
arch/x86/mm/numa_64.c +20 -42
106 lines not on this page · raw message
PATCH 2/3 x86: introduce max_early_res and early_res_count
to prepare allocate early res array from fine_e820_area
--- arch/x86/kernel/e820.c | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-)
arch/x86/kernel/e820.c +32 -15
@@ -724,14 +724,18 @@ core_initcall(e820_mark_nvs_memory);/* * Early reserved memory areas. */ -#define MAX_EARLY_RES 32 +/* +* need to make sure this one is bigger enough before +* find_e820_area could be used +*/ +#define MAX_EARLY_RES_X 32struct early_res {u64 start, end; -char name[16 ]; +char name[15 ];char overlap_ok; }; -static struct early_res early_res[MAX_EARLY_RES ]__initdata = { +static struct early_res early_res_x[MAX_EARLY_RES_X ]__initdata = { {0 ,PAGE_SIZE ,"BIOS data page" ,1 },/* BIOS data page */ #ifdef CONFIG_X86_32/*
@@ -745,12 +749,22 @@ static struct early_res early_res[MAX_EA {} }; +static int max_early_res__initdata =MAX_EARLY_RES_X ; +static struct early_res *early_res__initdata = &early_res_x[0 ]; +static int early_res_count __initdata = +#ifdef CONFIG_X86_32 + 2 +#else + 1 +#endif + ; +static int __init find_overlapped_early (u64 start,u64 end) {int i;struct early_res *r; -for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) { +for (i =0 ; i < max_early_res && early_res[i].end; i++) { r = &early_res[i];if (end > r->start && start < r->end)break ;
@@ -768,13 +782,14 @@ static void __init drop_range(int i) {int j; -for (j = i +1 ; j <MAX_EARLY_RES && early_res[j].end; j++) +for (j = i +1 ; j < max_early_res && early_res[j].end; j++) ;memmove (&early_res[i], &early_res[i +1 ], (j -1 - i) *sizeof (struct early_res )); early_res[j -1 ].end =0 ; + early_res_count--; }/*
@@ -793,9 +808,9 @@ static void __init drop_overlaps_that_arstruct early_res *r;u64 lower_start, lower_end;u64 upper_start, upper_end; -char name[16 ]; +char name[15 ]; -for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) { +for (i =0 ; i < max_early_res && early_res[i].end; i++) { r = &early_res[i];/* Continue past non-overlapping ranges */
@@ -851,7 +866,7 @@ static void __init __reserve_early(u64 sstruct early_res *r; i =find_overlapped_early (start, end); -if (i >=MAX_EARLY_RES ) +if (i >= max_early_res)panic ("Too many early reservations" ); r = &early_res[i];if (r->end)
@@ -864,6 +879,7 @@ static void __init __reserve_early(u64 s r->overlap_ok = overlap_ok;if (name)strncpy (r->name, name,sizeof (r->name) -1 ); + early_res_count++; }/*
@@ -916,7 +932,7 @@ void __init free_early(u64 start, u64 en i =find_overlapped_early (start, end); r = &early_res[i]; -if (i >=MAX_EARLY_RES || r->end != end || r->start != start) +if (i >= max_early_res || r->end != end || r->start != start)panic ("free_early on not reserved area: %llx-%llx!" , start, end -1 );
@@ -927,14 +943,15 @@ void __init early_res_to_bootmem(u64 sta {int i, count;u64 final_start, final_end; +int idx =0 ; count =0 ; -for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) +for (i =0 ; i < max_early_res && early_res[i].end; i++) count++; -printk (KERN_INFO "(%d early reservations) ==> bootmem [%010llx - %010llx]\n" , - count, start, end); -for (i =0 ; i < count; i++) { +printk (KERN_INFO "(%d/%d early reservations) ==> bootmem [%010llx - %010llx]\n" , + count - idx, max_early_res, start, end); +for (i = idx; i < count; i++) {struct early_res *r = &early_res[i];printk (KERN_INFO " #%d [%010llx - %010llx] %16s" , i, r->start, r->end, r->name);
@@ -961,7 +978,7 @@ static inline int __init bad_addr(u64 *a again: i =find_overlapped_early (addr, addr + size); r = &early_res[i]; -if (i <MAX_EARLY_RES && r->end) { +if (i < max_early_res && r->end) { *addrp = addr =round_up (r->end, align); changed =1 ; goto again;
@@ -978,7 +995,7 @@ static inline int __init bad_addr_size(uint changed =0 ; again: last = addr + size; -for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) { +for (i =0 ; i < max_early_res && early_res[i].end; i++) {struct early_res *r = &early_res[i];if (last > r->start && addr < r->start) { size = r->start - addr;
PATCH 3/3 x86: dynamic increase early_res array size
use early_res_count to track the num, and use find_e820 to get new buffer. and copy from old to new one.
also clear early_res to prevent later invalid using
--- arch/x86/kernel/e820.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
arch/x86/kernel/e820.c +54 -0
@@ -908,6 +908,49 @@ void __init reserve_early_overlap_ok(u64__reserve_early (start, end, name,1 ); } +static void __init __check_and_double_early_res (void ) +{ +u64 size; +u64 mem; +struct early_res *new; + +/* do we have enough slots left ? */ +if ((max_early_res - early_res_count) >max (max_early_res/8 ,2 )) +return ; + +/* double it */ + size =sizeof (struct early_res ) * max_early_res *2 ; + mem =find_e820_area (0 , max_pfn_mapped <<PAGE_SHIFT , size, +sizeof (struct early_res )); + +if (mem ==-1ULL ) +panic ("can not find more space for early_res array" ); + + new =__va (mem); +/* save the first one for own */ + new[0 ].start = mem; + new[0 ].end = mem + size; + new[0 ].overlap_ok =0 ; +/* copy old to new */ +if (early_res == early_res_x) { +memcpy (&new[1 ], &early_res[0 ], +sizeof (struct early_res ) * max_early_res); +memset (&new[max_early_res+1 ],0 , +sizeof (struct early_res ) * (max_early_res -1 )); + early_res_count++; + }else { +memcpy (&new[1 ], &early_res[1 ], +sizeof (struct early_res ) * (max_early_res -1 )); +memset (&new[max_early_res],0 , +sizeof (struct early_res ) * max_early_res); + } +memset (&early_res[0 ],0 ,sizeof (struct early_res ) * max_early_res); + early_res = new; + max_early_res *=2 ; +printk (KERN_DEBUG "early_res array is doubled to %d at [%llx - %llx]\n" , + max_early_res, mem, mem + size -1 ); +} +/* * Most early reservations come here. *
@@ -921,6 +964,8 @@ void __init reserve_early(u64 start, u64if (start >= end)return ; +__check_and_double_early_res (); +drop_overlaps_that_are_ok (start, end);__reserve_early (start, end, name,0 ); }
@@ -949,6 +994,10 @@ void __init early_res_to_bootmem(u64 stafor (i =0 ; i < max_early_res && early_res[i].end; i++) count++; +/* need to skip first one ?*/ +if (early_res != early_res_x) + idx =1 ; +printk (KERN_INFO "(%d/%d early reservations) ==> bootmem [%010llx - %010llx]\n" , count - idx, max_early_res, start, end);for (i = idx; i < count; i++) {
@@ -966,6 +1015,11 @@ void __init early_res_to_bootmem(u64 stareserve_bootmem_generic (final_start, final_end - final_start,BOOTMEM_DEFAULT ); } +/* clear them */ +memset (&early_res[0 ],0 ,sizeof (struct early_res ) * max_early_res); + early_res =NULL ; + max_early_res =0 ; + early_res_count =0 ; }/* Check for already reserved areas */
[PATCH 4/3] x86: make early_node_mem get mem > 4g if possible -v2
so we could put pgdata for the node high, and later sparse vmmap will get the section nr that need.
with this patch will make <4g ram will not use sparse vmmap
before this patch, will get, before swiotlb try get bootmem
[ 0.000000] nid=1 start=0 end=2080000 aligned=1 [ 0.000000] free [10 - 96] [ 0.000000] free [b12 - 1000] [ 0.000000] free [359f - 38a3] [ 0.000000] free [38b5 - 3a00] [ 0.000000] free [41e01 - 42000] [ 0.000000] free [73dde - 73e00] [ 0.000000] free [73fdd - 74000] [ 0.000000] free [741dd - 74200] [ 0.000000] free [743dd - 74400] [ 0.000000] free [745dd - 74600] [ 0.000000] free [747dd - 74800] [ 0.000000] free [749dd - 74a00] [ 0.000000] free [74bdd - 74c00] [ 0.000000] free [74ddd - 74e00] [ 0.000000] free [74fdd - 75000] [ 0.000000] free [751dd - 75200] [ 0.000000] free [753dd - 75400] [ 0.000000] free [755dd - 75600] [ 0.000000] free [757dd - 75800] [ 0.000000] free [759dd - 75a00] [ 0.000000] free [75bdd - 7bf5f] [ 0.000000] free [7f730 - 7f750] [ 0.000000] free [100000 - 2080000] [ 0.000000] total free 1f87170 [ 93.301474] Placing 64MB software IO TLB between ffff880075bdd000 - ffff880079bdd000 [ 93.311814] software IO TLB at phys 0x75bdd000 - 0x79bdd000
with this patch will get: before swiotlb try get bootmem
[ 0.000000] nid=1 start=0 end=2080000 aligned=1 [ 0.000000] free [a - 96] [ 0.000000] free [702 - 1000] [ 0.000000] free [359f - 3600] [ 0.000000] free [37de - 3800] [ 0.000000] free [39dd - 3a00] [ 0.000000] free [3bdd - 3c00] [ 0.000000] free [3ddd - 3e00] [ 0.000000] free [3fdd - 4000] [ 0.000000] free [41dd - 4200] [ 0.000000] free [43dd - 4400] [ 0.000000] free [45dd - 4600] [ 0.000000] free [47dd - 4800] [ 0.000000] free [49dd - 4a00] [ 0.000000] free [4bdd - 4c00] [ 0.000000] free [4ddd - 4e00] [ 0.000000] free [4fdd - 5000] [ 0.000000] free [51dd - 5200] [ 0.000000] free [53dd - 5400] [ 0.000000] free [55dd - 7bf5f] [ 0.000000] free [7f730 - 7f750] [ 0.000000] free [100428 - 100600] [ 0.000000] free [13ea01 - 13ec00] [ 0.000000] free [170800 - 2080000] [ 0.000000] total free 1f87170
[ 92.689485] PCI-DMA: Using software bounce buffering for IO (SWIOTLB) [ 92.699799] Placing 64MB software IO TLB between ffff8800055dd000 - ffff8800095dd000 [ 92.710916] software IO TLB at phys 0x55dd000 - 0x95dd000
so will get enough space below 4G, aka pfn 0x100000
--- arch/x86/mm/numa_64.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
arch/x86/mm/numa_64.c +16 -3
@@ -163,14 +163,27 @@ static void * __init early_node_mem(int unsigned long end, unsigned long size, unsigned long align) { - unsigned long mem = find_e820_area(start, end, size, align); + unsigned long mem; +/* +* put it on high as possible +* something will go with NODE_DATA +*/ +if (start < (MAX_DMA_PFN <<PAGE_SHIFT )) + start =MAX_DMA_PFN <<PAGE_SHIFT ; +if (start < (MAX_DMA32_PFN <<PAGE_SHIFT ) && + end > (MAX_DMA32_PFN <<PAGE_SHIFT )) + start =MAX_DMA32_PFN <<PAGE_SHIFT ; + mem =find_e820_area (start, end, size, align);if (mem !=-1L )return __va (mem); - start =__pa (MAX_DMA_ADDRESS ); - end = max_low_pfn_mapped <<PAGE_SHIFT ; + end = max_pfn_mapped <<PAGE_SHIFT ; +if (end > (MAX_DMA32_PFN <<PAGE_SHIFT )) + start =MAX_DMA32_PFN <<PAGE_SHIFT ; +else + start =MAX_DMA_PFN <<PAGE_SHIFT ; mem =find_e820_area (start, end, size, align);if (mem !=-1L )return __va (mem);
[tip:x86/urgent] x86: Increase MAX_EARLY_RES; insufficient on 32-bit NUMA
In reply to Yinghai LuCommit-ID: 6a1e008a0915f502eb026fb995ea3e49d5b017f7 Gitweb: http://git.kernel.org/tip/6a1e008a0915f502eb026fb995ea3e49d5b017f7 Author: Yinghai Lu <[email protected]> AuthorDate: Tue, 15 Dec 2009 17:59:03 -0800 Committer: H. Peter Anvin <[email protected]> CommitDate: Wed, 16 Dec 2009 16:46:23 -0800
x86: Increase MAX_EARLY_RES; insufficient on 32-bit NUMA
Due to recent changes wakeup and mptable, we run out of early reservations on 32-bit NUMA. Thus, adjust the available number.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/e820.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/e820.c +1 -1
@@ -724,7 +724,7 @@ core_initcall(e820_mark_nvs_memory);/* * Early reserved memory areas. */ -#define MAX_EARLY_RES 20 +#define MAX_EARLY_RES 32struct early_res {u64 start, end;