All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: UV SGI, Don't track GRU space in PAT
@ 2009-10-29 18:47 Jack Steiner
  2009-11-08 12:06 ` Ingo Molnar
  0 siblings, 1 reply; 13+ messages in thread
From: Jack Steiner @ 2009-10-29 18:47 UTC (permalink / raw)
  To: mingo, tglx; +Cc: linux-kernel


GRU space is always mapped as WB in the page table. There is
no need to track the mappings in the PAT. This also eliminates
the "freeing invalid memtype" messages when the GRU space is unmapped.

Signed-off-by: Jack Steiner <steiner@sgi.com>

---

(resend of patch sent on 9/9. Seems to have fallen thru the cracks...)


 arch/x86/include/asm/uv/uv.h       |    2 ++
 arch/x86/kernel/apic/x2apic_uv_x.c |   11 ++++++++++-
 arch/x86/mm/pat.c                  |    5 +++--
 3 files changed, 15 insertions(+), 3 deletions(-)

Index: linux/arch/x86/include/asm/uv/uv.h
===================================================================
--- linux.orig/arch/x86/include/asm/uv/uv.h	2009-10-05 08:12:09.000000000 -0500
+++ linux/arch/x86/include/asm/uv/uv.h	2009-10-05 08:36:59.000000000 -0500
@@ -8,6 +8,7 @@ struct mm_struct;
 
 #ifdef CONFIG_X86_UV
 
+extern int is_GRU_range(u64 start, u64 end);
 extern enum uv_system_type get_uv_system_type(void);
 extern int is_uv_system(void);
 extern void uv_cpu_init(void);
@@ -19,6 +20,7 @@ extern const struct cpumask *uv_flush_tl
 
 #else	/* X86_UV */
 
+static inline int is_GRU_range(u64 start, u64 end)	{ return 0; }
 static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; }
 static inline int is_uv_system(void)	{ return 0; }
 static inline void uv_cpu_init(void)	{ }
Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c	2009-10-05 08:12:09.000000000 -0500
+++ linux/arch/x86/kernel/apic/x2apic_uv_x.c	2009-10-05 08:36:59.000000000 -0500
@@ -34,6 +34,7 @@
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
 
 static int early_get_nodeid(void)
 {
@@ -68,6 +69,11 @@ enum uv_system_type get_uv_system_type(v
 	return uv_system_type;
 }
 
+int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
 int is_uv_system(void)
 {
 	return uv_system_type != UV_NONE;
@@ -385,8 +391,11 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
Index: linux/arch/x86/mm/pat.c
===================================================================
--- linux.orig/arch/x86/mm/pat.c	2009-10-05 08:12:09.000000000 -0500
+++ linux/arch/x86/mm/pat.c	2009-10-05 08:36:59.000000000 -0500
@@ -28,6 +28,7 @@
 #include <asm/msr.h>
 #include <asm/pat.h>
 #include <asm/io.h>
+#include <asm/uv/uv.h>
 
 #ifdef CONFIG_X86_PAT
 int __read_mostly pat_enabled = 1;
@@ -388,7 +389,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -499,7 +500,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);

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

* Re: [PATCH] x86: UV SGI, Don't track GRU space in PAT
  2009-10-29 18:47 [PATCH] x86: UV SGI, Don't track GRU space in PAT Jack Steiner
@ 2009-11-08 12:06 ` Ingo Molnar
  2009-11-11 18:30   ` Jack Steiner
  2009-11-17 21:23   ` [PATCH v2] " Jack Steiner
  0 siblings, 2 replies; 13+ messages in thread
From: Ingo Molnar @ 2009-11-08 12:06 UTC (permalink / raw)
  To: Jack Steiner, H. Peter Anvin; +Cc: tglx, linux-kernel


* Jack Steiner <steiner@sgi.com> wrote:

> 
> GRU space is always mapped as WB in the page table. There is
> no need to track the mappings in the PAT. This also eliminates
> the "freeing invalid memtype" messages when the GRU space is unmapped.
> 
> Signed-off-by: Jack Steiner <steiner@sgi.com>
> 
> ---
> 
> (resend of patch sent on 9/9. Seems to have fallen thru the cracks...)
> 
> 
>  arch/x86/include/asm/uv/uv.h       |    2 ++
>  arch/x86/kernel/apic/x2apic_uv_x.c |   11 ++++++++++-
>  arch/x86/mm/pat.c                  |    5 +++--
>  3 files changed, 15 insertions(+), 3 deletions(-)
> 
> Index: linux/arch/x86/include/asm/uv/uv.h
> ===================================================================
> --- linux.orig/arch/x86/include/asm/uv/uv.h	2009-10-05 08:12:09.000000000 -0500
> +++ linux/arch/x86/include/asm/uv/uv.h	2009-10-05 08:36:59.000000000 -0500
> @@ -8,6 +8,7 @@ struct mm_struct;
>  
>  #ifdef CONFIG_X86_UV
>  
> +extern int is_GRU_range(u64 start, u64 end);
>  extern enum uv_system_type get_uv_system_type(void);
>  extern int is_uv_system(void);
>  extern void uv_cpu_init(void);
> @@ -19,6 +20,7 @@ extern const struct cpumask *uv_flush_tl
>  
>  #else	/* X86_UV */
>  
> +static inline int is_GRU_range(u64 start, u64 end)	{ return 0; }
>  static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; }
>  static inline int is_uv_system(void)	{ return 0; }
>  static inline void uv_cpu_init(void)	{ }
> Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
> ===================================================================
> --- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c	2009-10-05 08:12:09.000000000 -0500
> +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c	2009-10-05 08:36:59.000000000 -0500
> @@ -34,6 +34,7 @@
>  DEFINE_PER_CPU(int, x2apic_extra_bits);
>  
>  static enum uv_system_type uv_system_type;
> +static u64 gru_start_paddr, gru_end_paddr;
>  
>  static int early_get_nodeid(void)
>  {
> @@ -68,6 +69,11 @@ enum uv_system_type get_uv_system_type(v
>  	return uv_system_type;
>  }
>  
> +int is_GRU_range(u64 start, u64 end)
> +{
> +	return start >= gru_start_paddr && end < gru_end_paddr;
> +}
> +
>  int is_uv_system(void)
>  {
>  	return uv_system_type != UV_NONE;
> @@ -385,8 +391,11 @@ static __init void map_gru_high(int max_
>  	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
>  
>  	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
> -	if (gru.s.enable)
> +	if (gru.s.enable) {
>  		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
> +		gru_start_paddr = ((u64)gru.s.base << shift);
> +		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
> +	}
>  }
>  
>  static __init void map_mmr_high(int max_pnode)
> Index: linux/arch/x86/mm/pat.c
> ===================================================================
> --- linux.orig/arch/x86/mm/pat.c	2009-10-05 08:12:09.000000000 -0500
> +++ linux/arch/x86/mm/pat.c	2009-10-05 08:36:59.000000000 -0500
> @@ -28,6 +28,7 @@
>  #include <asm/msr.h>
>  #include <asm/pat.h>
>  #include <asm/io.h>
> +#include <asm/uv/uv.h>
>  
>  #ifdef CONFIG_X86_PAT
>  int __read_mostly pat_enabled = 1;
> @@ -388,7 +389,7 @@ int reserve_memtype(u64 start, u64 end, 
>  	}
>  
>  	/* Low ISA region is always mapped WB in page table. No need to track */
> -	if (is_ISA_range(start, end - 1)) {
> +	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1)) {
>  		if (new_type)
>  			*new_type = _PAGE_CACHE_WB;
>  		return 0;
> @@ -499,7 +500,7 @@ int free_memtype(u64 start, u64 end)
>  		return 0;
>  
>  	/* Low ISA region is always mapped WB. No need to track */
> -	if (is_ISA_range(start, end - 1))
> +	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1))
>  		return 0;

Hm, that's quite ugly - we used to have is_ISA_range() exceptions, now 
is_GRU_range() is added too.

We should instead have an x86_platform vector for PAT exceptions, which 
SGI/UV (and ISA) would fill in automatically, agreed?

	Ingo

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

* Re: [PATCH] x86: UV SGI, Don't track GRU space in PAT
  2009-11-08 12:06 ` Ingo Molnar
@ 2009-11-11 18:30   ` Jack Steiner
  2009-11-17 21:23   ` [PATCH v2] " Jack Steiner
  1 sibling, 0 replies; 13+ messages in thread
From: Jack Steiner @ 2009-11-11 18:30 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: H. Peter Anvin, tglx, linux-kernel

...
> >  	/* Low ISA region is always mapped WB. No need to track */
> > -	if (is_ISA_range(start, end - 1))
> > +	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1))
> >  		return 0;
> 
> Hm, that's quite ugly - we used to have is_ISA_range() exceptions, now 
> is_GRU_range() is added too.
> 
> We should instead have an x86_platform vector for PAT exceptions, which 
> SGI/UV (and ISA) would fill in automatically, agreed?

Could you point me to some code to clone - I'm not sure exactly what you
have in mind.

Is this close (untested)?? If so, I'll clean it up,test it & post a real patch.

--- jack



Index: linux/arch/x86/mm/pat.c
===================================================================
--- linux.orig/arch/x86/mm/pat.c	2009-11-11 12:09:59.000000000 -0600
+++ linux/arch/x86/mm/pat.c	2009-11-11 12:25:50.000000000 -0600
@@ -353,6 +353,12 @@ static int free_ram_pages_type(u64 start
 	return 0;
 }
 
+static int default_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end);
+}
+int (*is_untracked_pat_range)(u64 start, u64 end) = default_is_untracked_pat_range;
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -393,7 +399,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (is_untracked_pat_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -504,7 +510,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (default_is_untracked_pat_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -587,7 +593,7 @@ static unsigned long lookup_memtype(u64 
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
+	if (is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {
Index: linux/arch/x86/include/asm/pat.h
===================================================================
--- linux.orig/arch/x86/include/asm/pat.h	2009-10-26 19:39:06.000000000 -0500
+++ linux/arch/x86/include/asm/pat.h	2009-11-11 12:19:26.000000000 -0600
@@ -24,4 +24,6 @@ int io_reserve_memtype(resource_size_t s
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
+extern int (*is_untracked_pat_range)(u64 start, u64 end);
+
 #endif /* _ASM_X86_PAT_H */
Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c	2009-11-11 12:09:59.000000000 -0600
+++ linux/arch/x86/kernel/apic/x2apic_uv_x.c	2009-11-11 12:24:26.000000000 -0600
@@ -30,10 +30,22 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 #include <asm/smp.h>
+#include <asm/pat.h>
 
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
+
+static int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
+static int uv_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end) || is_GRU_range(start, end);
+}
 
 static int early_get_nodeid(void)
 {
@@ -49,6 +61,7 @@ static int early_get_nodeid(void)
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
 	if (!strcmp(oem_id, "SGI")) {
+		is_untracked_pat_range =  uv_is_untracked_pat_range;
 		if (!strcmp(oem_table_id, "UVL"))
 			uv_system_type = UV_LEGACY_APIC;
 		else if (!strcmp(oem_table_id, "UVX"))
@@ -388,8 +401,12 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)

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

* Re: [PATCH v2] x86: UV SGI, Don't track GRU space in PAT
  2009-11-08 12:06 ` Ingo Molnar
  2009-11-11 18:30   ` Jack Steiner
@ 2009-11-17 21:23   ` Jack Steiner
  2009-11-17 22:21     ` H. Peter Anvin
  1 sibling, 1 reply; 13+ messages in thread
From: Jack Steiner @ 2009-11-17 21:23 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: H. Peter Anvin, tglx, linux-kernel

GRU space is always mapped as WB in the page table. There is
no need to track the mappings in the PAT. This also eliminates
the "freeing invalid memtype" messages when the GRU space is unmapped.

Signed-off-by: Jack Steiner <steiner@sgi.com>

---
Version 2 with changes suggested by Ingo (at least I think I understood what
he wanted).


 arch/x86/include/asm/pat.h         |    2 ++
 arch/x86/kernel/apic/x2apic_uv_x.c |   19 ++++++++++++++++++-
 arch/x86/mm/pat.c                  |   12 +++++++++---
 3 files changed, 29 insertions(+), 4 deletions(-)

Index: linux/arch/x86/include/asm/pat.h
===================================================================
--- linux.orig/arch/x86/include/asm/pat.h	2009-11-17 01:26:59.000000000 -0600
+++ linux/arch/x86/include/asm/pat.h	2009-11-17 15:13:17.000000000 -0600
@@ -24,4 +24,6 @@ int io_reserve_memtype(resource_size_t s
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
+extern int (*is_untracked_pat_range)(u64 start, u64 end);
+
 #endif /* _ASM_X86_PAT_H */
Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c	2009-11-17 15:13:14.000000000 -0600
+++ linux/arch/x86/kernel/apic/x2apic_uv_x.c	2009-11-17 15:13:17.000000000 -0600
@@ -30,10 +30,22 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 #include <asm/smp.h>
+#include <asm/pat.h>
 
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
+
+static int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
+static int uv_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end) || is_GRU_range(start, end);
+}
 
 static int early_get_nodeid(void)
 {
@@ -49,6 +61,7 @@ static int early_get_nodeid(void)
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
 	if (!strcmp(oem_id, "SGI")) {
+		is_untracked_pat_range =  uv_is_untracked_pat_range;
 		if (!strcmp(oem_table_id, "UVL"))
 			uv_system_type = UV_LEGACY_APIC;
 		else if (!strcmp(oem_table_id, "UVX"))
@@ -386,8 +399,12 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
Index: linux/arch/x86/mm/pat.c
===================================================================
--- linux.orig/arch/x86/mm/pat.c	2009-11-17 15:13:14.000000000 -0600
+++ linux/arch/x86/mm/pat.c	2009-11-17 15:13:17.000000000 -0600
@@ -348,6 +348,12 @@ static int free_ram_pages_type(u64 start
 	return 0;
 }
 
+static int default_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end);
+}
+int (*is_untracked_pat_range)(u64 start, u64 end) = default_is_untracked_pat_range;
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -383,7 +389,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (is_untracked_pat_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -494,7 +500,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (default_is_untracked_pat_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -577,7 +583,7 @@ static unsigned long lookup_memtype(u64 
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
+	if (is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {

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

* Re: [PATCH v2] x86: UV SGI, Don't track GRU space in PAT
  2009-11-17 21:23   ` [PATCH v2] " Jack Steiner
@ 2009-11-17 22:21     ` H. Peter Anvin
  2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
  0 siblings, 1 reply; 13+ messages in thread
From: H. Peter Anvin @ 2009-11-17 22:21 UTC (permalink / raw)
  To: Jack Steiner; +Cc: Ingo Molnar, tglx, linux-kernel, Thomas Gleixner

On 11/17/2009 01:23 PM, Jack Steiner wrote:
> GRU space is always mapped as WB in the page table. There is
> no need to track the mappings in the PAT. This also eliminates
> the "freeing invalid memtype" messages when the GRU space is unmapped.
> 
> Signed-off-by: Jack Steiner <steiner@sgi.com>
> 
> ---
> Version 2 with changes suggested by Ingo (at least I think I understood what
> he wanted).

Looks good, except I think is_untracked_pat_range() probably should me a
member in the x86_platform structure -- as, probably, should
x86_platform_ipi_callback.

	-hpa

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

* [PATCH v3] x86: UV SGI, Don't track GRU space in PAT
  2009-11-17 22:21     ` H. Peter Anvin
@ 2009-11-19 20:23       ` Jack Steiner
  2009-11-23 18:25         ` Ingo Molnar
                           ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Jack Steiner @ 2009-11-19 20:23 UTC (permalink / raw)
  To: H. Peter Anvin, mingo, tglx; +Cc: linux-kernel

GRU space is always mapped as WB in the page table. There is
no need to track the mappings in the PAT. This also eliminates
the "freeing invalid memtype" messages when the GRU space is unmapped.

Signed-off-by: Jack Steiner <steiner@sgi.com>

---
Version 2 with changes suggested by Ingo (at least I think I understood what
he wanted).

Version 3 with changes suggested by Peter to make the new function
a member of the x86_platform structure.



 arch/x86/include/asm/pat.h         |    2 ++
 arch/x86/include/asm/x86_init.h    |    1 +
 arch/x86/kernel/apic/x2apic_uv_x.c |   19 ++++++++++++++++++-
 arch/x86/kernel/x86_init.c         |    2 ++
 arch/x86/mm/pat.c                  |   11 ++++++++---
 5 files changed, 31 insertions(+), 4 deletions(-)

Index: linux/arch/x86/include/asm/pat.h
===================================================================
--- linux.orig/arch/x86/include/asm/pat.h	2009-11-19 01:39:52.000000000 -0600
+++ linux/arch/x86/include/asm/pat.h	2009-11-19 11:13:35.000000000 -0600
@@ -24,4 +24,6 @@ int io_reserve_memtype(resource_size_t s
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
+int default_is_untracked_pat_range(u64 start, u64 end);
+
 #endif /* _ASM_X86_PAT_H */
Index: linux/arch/x86/include/asm/x86_init.h
===================================================================
--- linux.orig/arch/x86/include/asm/x86_init.h	2009-11-19 01:39:52.000000000 -0600
+++ linux/arch/x86/include/asm/x86_init.h	2009-11-19 11:19:38.000000000 -0600
@@ -131,6 +131,7 @@ struct x86_platform_ops {
 	unsigned long (*get_wallclock)(void);
 	int (*set_wallclock)(unsigned long nowtime);
 	void (*iommu_shutdown)(void);
+	int (*is_untracked_pat_range)(u64 start, u64 end);
 };
 
 extern struct x86_init_ops x86_init;
Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c	2009-11-19 11:09:47.000000000 -0600
+++ linux/arch/x86/kernel/apic/x2apic_uv_x.c	2009-11-19 11:21:09.000000000 -0600
@@ -30,10 +30,22 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 #include <asm/smp.h>
+#include <asm/x86_init.h>
 
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
+
+static int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
+static int uv_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end) || is_GRU_range(start, end);
+}
 
 static int early_get_nodeid(void)
 {
@@ -49,6 +61,7 @@ static int early_get_nodeid(void)
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
 	if (!strcmp(oem_id, "SGI")) {
+		x86_platform.is_untracked_pat_range =  uv_is_untracked_pat_range;
 		if (!strcmp(oem_table_id, "UVL"))
 			uv_system_type = UV_LEGACY_APIC;
 		else if (!strcmp(oem_table_id, "UVX"))
@@ -386,8 +399,12 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
Index: linux/arch/x86/kernel/x86_init.c
===================================================================
--- linux.orig/arch/x86/kernel/x86_init.c	2009-11-19 01:39:52.000000000 -0600
+++ linux/arch/x86/kernel/x86_init.c	2009-11-19 11:12:45.000000000 -0600
@@ -15,6 +15,7 @@
 #include <asm/irq.h>
 #include <asm/tsc.h>
 #include <asm/iommu.h>
+#include <asm/pat.h>
 
 void __cpuinit x86_init_noop(void) { }
 void __init x86_init_uint_noop(unsigned int unused) { }
@@ -80,4 +81,5 @@ struct x86_platform_ops x86_platform = {
 	.get_wallclock			= mach_get_cmos_time,
 	.set_wallclock			= mach_set_rtc_mmss,
 	.iommu_shutdown			= iommu_shutdown_noop,
+	.is_untracked_pat_range		= default_is_untracked_pat_range,
 };
Index: linux/arch/x86/mm/pat.c
===================================================================
--- linux.orig/arch/x86/mm/pat.c	2009-11-19 11:09:47.000000000 -0600
+++ linux/arch/x86/mm/pat.c	2009-11-19 11:20:26.000000000 -0600
@@ -348,6 +348,11 @@ static int free_ram_pages_type(u64 start
 	return 0;
 }
 
+int default_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end);
+}
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -383,7 +388,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (x86_platform.is_untracked_pat_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -494,7 +499,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (x86_platform.is_untracked_pat_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -577,7 +582,7 @@ static unsigned long lookup_memtype(u64 
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {

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

* Re: [PATCH v3] x86: UV SGI, Don't track GRU space in PAT
  2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
@ 2009-11-23 18:25         ` Ingo Molnar
  2009-11-23 18:55         ` [tip:x86/mm] x86: UV SGI: " tip-bot for Jack Steiner
                           ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Ingo Molnar @ 2009-11-23 18:25 UTC (permalink / raw)
  To: Jack Steiner; +Cc: H. Peter Anvin, tglx, linux-kernel


* Jack Steiner <steiner@sgi.com> wrote:

> GRU space is always mapped as WB in the page table. There is
> no need to track the mappings in the PAT. This also eliminates
> the "freeing invalid memtype" messages when the GRU space is unmapped.
> 
> Signed-off-by: Jack Steiner <steiner@sgi.com>
> 
> ---
> Version 2 with changes suggested by Ingo (at least I think I understood what
> he wanted).
> 
> Version 3 with changes suggested by Peter to make the new function
> a member of the x86_platform structure.

thanks, it looks much cleaner now. I've applied it to tip:x86/mm.

	Ingo

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

* [tip:x86/mm] x86: UV SGI: Don't track GRU space in PAT
  2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
  2009-11-23 18:25         ` Ingo Molnar
@ 2009-11-23 18:55         ` tip-bot for Jack Steiner
  2009-11-24  1:12         ` [tip:x86/mm] x86, mm: Call is_untracked_pat_range() rather than is_ISA_range() tip-bot for H. Peter Anvin
                           ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Jack Steiner @ 2009-11-23 18:55 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, steiner, tglx, mingo

Commit-ID:  fd12a0d69aee6d90fa9b9890db24368a897f8423
Gitweb:     http://git.kernel.org/tip/fd12a0d69aee6d90fa9b9890db24368a897f8423
Author:     Jack Steiner <steiner@sgi.com>
AuthorDate: Thu, 19 Nov 2009 14:23:41 -0600
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 23 Nov 2009 19:47:42 +0100

x86: UV SGI: Don't track GRU space in PAT

GRU space is always mapped as WB in the page table. There is
no need to track the mappings in the PAT. This also eliminates
the "freeing invalid memtype" messages when the GRU space is
unmapped.

Signed-off-by: Jack Steiner <steiner@sgi.com>
LKML-Reference: <20091119202341.GA4420@sgi.com>
[ v2: fix build failure ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/include/asm/pat.h         |    2 ++
 arch/x86/include/asm/x86_init.h    |    2 ++
 arch/x86/kernel/apic/x2apic_uv_x.c |   19 ++++++++++++++++++-
 arch/x86/kernel/x86_init.c         |    2 ++
 arch/x86/mm/pat.c                  |   12 +++++++++---
 5 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h
index e2c1668..4c35dd0 100644
--- a/arch/x86/include/asm/pat.h
+++ b/arch/x86/include/asm/pat.h
@@ -24,4 +24,6 @@ int io_reserve_memtype(resource_size_t start, resource_size_t end,
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
+int default_is_untracked_pat_range(u64 start, u64 end);
+
 #endif /* _ASM_X86_PAT_H */
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 2c756fd..8112ed7 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -113,11 +113,13 @@ struct x86_cpuinit_ops {
 
 /**
  * struct x86_platform_ops - platform specific runtime functions
+ * @is_untracked_pat_range	exclude from PAT logic
  * @calibrate_tsc:		calibrate TSC
  * @get_wallclock:		get time from HW clock like RTC etc.
  * @set_wallclock:		set time back to HW clock
  */
 struct x86_platform_ops {
+	int (*is_untracked_pat_range)(u64 start, u64 end);
 	unsigned long (*calibrate_tsc)(void);
 	unsigned long (*get_wallclock)(void);
 	int (*set_wallclock)(unsigned long nowtime);
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index f5f5886..2477c9f 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -30,10 +30,22 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 #include <asm/smp.h>
+#include <asm/x86_init.h>
 
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
+
+static int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
+static int uv_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end) || is_GRU_range(start, end);
+}
 
 static int early_get_nodeid(void)
 {
@@ -49,6 +61,7 @@ static int early_get_nodeid(void)
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
 	if (!strcmp(oem_id, "SGI")) {
+		x86_platform.is_untracked_pat_range =  uv_is_untracked_pat_range;
 		if (!strcmp(oem_table_id, "UVL"))
 			uv_system_type = UV_LEGACY_APIC;
 		else if (!strcmp(oem_table_id, "UVX"))
@@ -385,8 +398,12 @@ static __init void map_gru_high(int max_pnode)
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 4449a4a..bcc749e 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -13,6 +13,7 @@
 #include <asm/e820.h>
 #include <asm/time.h>
 #include <asm/irq.h>
+#include <asm/pat.h>
 #include <asm/tsc.h>
 
 void __cpuinit x86_init_noop(void) { }
@@ -69,6 +70,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
 };
 
 struct x86_platform_ops x86_platform = {
+	.is_untracked_pat_range		= default_is_untracked_pat_range,
 	.calibrate_tsc			= native_calibrate_tsc,
 	.get_wallclock			= mach_get_cmos_time,
 	.set_wallclock			= mach_set_rtc_mmss,
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index e78cd0e..38a66ef 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -20,6 +20,7 @@
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
 #include <asm/tlbflush.h>
+#include <asm/x86_init.h>
 #include <asm/pgtable.h>
 #include <asm/fcntl.h>
 #include <asm/e820.h>
@@ -348,6 +349,11 @@ static int free_ram_pages_type(u64 start, u64 end)
 	return 0;
 }
 
+int default_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end);
+}
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -388,7 +394,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (x86_platform.is_untracked_pat_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -499,7 +505,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (x86_platform.is_untracked_pat_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -582,7 +588,7 @@ static unsigned long lookup_memtype(u64 paddr)
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {

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

* [tip:x86/mm] x86, mm: Call is_untracked_pat_range() rather than is_ISA_range()
  2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
  2009-11-23 18:25         ` Ingo Molnar
  2009-11-23 18:55         ` [tip:x86/mm] x86: UV SGI: " tip-bot for Jack Steiner
@ 2009-11-24  1:12         ` tip-bot for H. Peter Anvin
  2009-11-24  1:13         ` [tip:x86/mm] x86, mm: is_untracked_pat_range() takes a normal semiclosed range tip-bot for H. Peter Anvin
                           ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: tip-bot for H. Peter Anvin @ 2009-11-24  1:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, steiner, suresh.b.siddha, tglx

Commit-ID:  55a6ca25472ee01574bfc24d23b7f5fa09cc38cf
Gitweb:     http://git.kernel.org/tip/55a6ca25472ee01574bfc24d23b7f5fa09cc38cf
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Mon, 23 Nov 2009 15:12:07 -0800
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Mon, 23 Nov 2009 17:09:59 -0800

x86, mm: Call is_untracked_pat_range() rather than is_ISA_range()

Checkin fd12a0d69aee6d90fa9b9890db24368a897f8423 made the PAT
untracked range a platform configurable, but missed on occurrence of
is_ISA_range() which still refers to PAT-untracked memory, and
therefore should be using the configurable.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jack Steiner <steiner@sgi.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <20091119202341.GA4420@sgi.com>
---
 arch/x86/include/asm/pgtable.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index af6fd36..1de2094 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -16,6 +16,8 @@
 
 #ifndef __ASSEMBLY__
 
+#include <asm/x86_init.h>
+
 /*
  * ZERO_PAGE is a global shared page that is always zero: used
  * for zero-mapped memory areas etc..
@@ -270,9 +272,9 @@ static inline int is_new_memtype_allowed(u64 paddr, unsigned long size,
 					 unsigned long new_flags)
 {
 	/*
-	 * PAT type is always WB for ISA. So no need to check.
+	 * PAT type is always WB for untracked ranges, so no need to check.
 	 */
-	if (is_ISA_range(paddr, paddr + size - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + size - 1))
 		return 1;
 
 	/*

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

* [tip:x86/mm] x86, mm: is_untracked_pat_range() takes a normal semiclosed range
  2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
                           ` (2 preceding siblings ...)
  2009-11-24  1:12         ` [tip:x86/mm] x86, mm: Call is_untracked_pat_range() rather than is_ISA_range() tip-bot for H. Peter Anvin
@ 2009-11-24  1:13         ` tip-bot for H. Peter Anvin
  2009-11-24  1:13         ` [tip:x86/mm] x86: Change is_ISA_range() into an inline function tip-bot for H. Peter Anvin
                           ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: tip-bot for H. Peter Anvin @ 2009-11-24  1:13 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, suresh.b.siddha, tglx

Commit-ID:  8a27138924f64d2f30c1022f909f74480046bc3f
Gitweb:     http://git.kernel.org/tip/8a27138924f64d2f30c1022f909f74480046bc3f
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Mon, 23 Nov 2009 14:49:20 -0800
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Mon, 23 Nov 2009 17:09:59 -0800

x86, mm: is_untracked_pat_range() takes a normal semiclosed range

is_untracked_pat_range() -- like its components, is_ISA_range() and
is_GRU_range(), takes a normal semiclosed interval (>=, <) whereas the
PAT code called it as if it took a closed range (>=, <=).  Fix.

Although this is a bug, I believe it is non-manifest, simply because
none of the callers will call this with non-page-aligned addresses.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <20091119202341.GA4420@sgi.com>
---
 arch/x86/include/asm/pgtable.h |    2 +-
 arch/x86/mm/pat.c              |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 1de2094..a34c785 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -274,7 +274,7 @@ static inline int is_new_memtype_allowed(u64 paddr, unsigned long size,
 	/*
 	 * PAT type is always WB for untracked ranges, so no need to check.
 	 */
-	if (x86_platform.is_untracked_pat_range(paddr, paddr + size - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + size))
 		return 1;
 
 	/*
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 38a66ef..b5bc08c 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -394,7 +394,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (x86_platform.is_untracked_pat_range(start, end - 1)) {
+	if (x86_platform.is_untracked_pat_range(start, end)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -505,7 +505,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (x86_platform.is_untracked_pat_range(start, end - 1))
+	if (x86_platform.is_untracked_pat_range(start, end))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -588,7 +588,7 @@ static unsigned long lookup_memtype(u64 paddr)
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {

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

* [tip:x86/mm] x86: Change is_ISA_range() into an inline function
  2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
                           ` (3 preceding siblings ...)
  2009-11-24  1:13         ` [tip:x86/mm] x86, mm: is_untracked_pat_range() takes a normal semiclosed range tip-bot for H. Peter Anvin
@ 2009-11-24  1:13         ` tip-bot for H. Peter Anvin
  2009-11-24  1:13         ` [tip:x86/mm] x86, platform: Change is_untracked_pat_range() to bool; cleanup init tip-bot for H. Peter Anvin
  2009-12-01  7:36         ` [tip:x86/mm] x86, mm: Correct the implementation of is_untracked_pat_range() tip-bot for H. Peter Anvin
  6 siblings, 0 replies; 13+ messages in thread
From: tip-bot for H. Peter Anvin @ 2009-11-24  1:13 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx

Commit-ID:  65f116f5f16dc3371fce24fb24bc4843b5380ba5
Gitweb:     http://git.kernel.org/tip/65f116f5f16dc3371fce24fb24bc4843b5380ba5
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Mon, 23 Nov 2009 14:44:39 -0800
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Mon, 23 Nov 2009 17:09:59 -0800

x86: Change is_ISA_range() into an inline function

Change is_ISA_range() from a macro to an inline function.  This makes
it type safe, and also allows it to be assigned to a function pointer
if necessary.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
LKML-Reference: <20091119202341.GA4420@sgi.com>
---
 arch/x86/include/asm/e820.h |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index 40b4e61..68b4e0e 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -61,6 +61,12 @@ struct e820map {
 	struct e820entry map[E820_X_MAX];
 };
 
+#define ISA_START_ADDRESS	0xa0000
+#define ISA_END_ADDRESS		0x100000
+
+#define BIOS_BEGIN		0x000a0000
+#define BIOS_END		0x00100000
+
 #ifdef __KERNEL__
 /* see comment in arch/x86/kernel/e820.c */
 extern struct e820map e820;
@@ -126,15 +132,14 @@ 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);
-#endif /* __KERNEL__ */
-#endif /* __ASSEMBLY__ */
 
-#define ISA_START_ADDRESS	0xa0000
-#define ISA_END_ADDRESS		0x100000
-#define is_ISA_range(s, e) ((s) >= ISA_START_ADDRESS && (e) < ISA_END_ADDRESS)
+static inline bool is_ISA_range(u64 s, u64 e)
+{
+	return s >= ISA_START_ADDRESS && e < ISA_END_ADDRESS;
+}
 
-#define BIOS_BEGIN		0x000a0000
-#define BIOS_END		0x00100000
+#endif /* __KERNEL__ */
+#endif /* __ASSEMBLY__ */
 
 #ifdef __KERNEL__
 #include <linux/ioport.h>

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

* [tip:x86/mm] x86, platform: Change is_untracked_pat_range() to bool; cleanup init
  2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
                           ` (4 preceding siblings ...)
  2009-11-24  1:13         ` [tip:x86/mm] x86: Change is_ISA_range() into an inline function tip-bot for H. Peter Anvin
@ 2009-11-24  1:13         ` tip-bot for H. Peter Anvin
  2009-12-01  7:36         ` [tip:x86/mm] x86, mm: Correct the implementation of is_untracked_pat_range() tip-bot for H. Peter Anvin
  6 siblings, 0 replies; 13+ messages in thread
From: tip-bot for H. Peter Anvin @ 2009-11-24  1:13 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, steiner, tglx

Commit-ID:  eb41c8be89dbe079f49202774e04a79ccac48a09
Gitweb:     http://git.kernel.org/tip/eb41c8be89dbe079f49202774e04a79ccac48a09
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Mon, 23 Nov 2009 14:46:07 -0800
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Mon, 23 Nov 2009 17:09:59 -0800

x86, platform: Change is_untracked_pat_range() to bool; cleanup init

- Change is_untracked_pat_range() to return bool.
- Clean up the initialization of is_untracked_pat_range() -- by default,
  we simply point it at is_ISA_range() directly.
- Move is_untracked_pat_range to the end of struct x86_platform, since
  it is the newest field.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Jack Steiner <steiner@sgi.com>
LKML-Reference: <20091119202341.GA4420@sgi.com>
---
 arch/x86/include/asm/pat.h         |    2 --
 arch/x86/include/asm/x86_init.h    |    4 ++--
 arch/x86/kernel/apic/x2apic_uv_x.c |    4 ++--
 arch/x86/kernel/x86_init.c         |    2 +-
 arch/x86/mm/pat.c                  |    5 -----
 5 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h
index 4c35dd0..e2c1668 100644
--- a/arch/x86/include/asm/pat.h
+++ b/arch/x86/include/asm/pat.h
@@ -24,6 +24,4 @@ int io_reserve_memtype(resource_size_t start, resource_size_t end,
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
-int default_is_untracked_pat_range(u64 start, u64 end);
-
 #endif /* _ASM_X86_PAT_H */
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 8112ed7..024cf3c 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -113,16 +113,16 @@ struct x86_cpuinit_ops {
 
 /**
  * struct x86_platform_ops - platform specific runtime functions
- * @is_untracked_pat_range	exclude from PAT logic
  * @calibrate_tsc:		calibrate TSC
  * @get_wallclock:		get time from HW clock like RTC etc.
  * @set_wallclock:		set time back to HW clock
+ * @is_untracked_pat_range	exclude from PAT logic
  */
 struct x86_platform_ops {
-	int (*is_untracked_pat_range)(u64 start, u64 end);
 	unsigned long (*calibrate_tsc)(void);
 	unsigned long (*get_wallclock)(void);
 	int (*set_wallclock)(unsigned long nowtime);
+	bool (*is_untracked_pat_range)(u64 start, u64 end);
 };
 
 extern struct x86_init_ops x86_init;
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 2477c9f..597a47b 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -37,12 +37,12 @@ DEFINE_PER_CPU(int, x2apic_extra_bits);
 static enum uv_system_type uv_system_type;
 static u64 gru_start_paddr, gru_end_paddr;
 
-static int is_GRU_range(u64 start, u64 end)
+static inline bool is_GRU_range(u64 start, u64 end)
 {
 	return start >= gru_start_paddr && end < gru_end_paddr;
 }
 
-static int uv_is_untracked_pat_range(u64 start, u64 end)
+static bool uv_is_untracked_pat_range(u64 start, u64 end)
 {
 	return is_ISA_range(start, end) || is_GRU_range(start, end);
 }
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index bcc749e..861b8b5 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -70,8 +70,8 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
 };
 
 struct x86_platform_ops x86_platform = {
-	.is_untracked_pat_range		= default_is_untracked_pat_range,
 	.calibrate_tsc			= native_calibrate_tsc,
 	.get_wallclock			= mach_get_cmos_time,
 	.set_wallclock			= mach_set_rtc_mmss,
+	.is_untracked_pat_range		= is_ISA_range,
 };
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index b5bc08c..ef71251 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -349,11 +349,6 @@ static int free_ram_pages_type(u64 start, u64 end)
 	return 0;
 }
 
-int default_is_untracked_pat_range(u64 start, u64 end)
-{
-	return is_ISA_range(start, end);
-}
-
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB

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

* [tip:x86/mm] x86, mm: Correct the implementation of is_untracked_pat_range()
  2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
                           ` (5 preceding siblings ...)
  2009-11-24  1:13         ` [tip:x86/mm] x86, platform: Change is_untracked_pat_range() to bool; cleanup init tip-bot for H. Peter Anvin
@ 2009-12-01  7:36         ` tip-bot for H. Peter Anvin
  6 siblings, 0 replies; 13+ messages in thread
From: tip-bot for H. Peter Anvin @ 2009-12-01  7:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, steiner, suresh.b.siddha, tglx, mingo

Commit-ID:  ccef086454d4c97e7b722e9303390207d681cb4c
Gitweb:     http://git.kernel.org/tip/ccef086454d4c97e7b722e9303390207d681cb4c
Author:     H. Peter Anvin <hpa@zytor.com>
AuthorDate: Mon, 30 Nov 2009 21:33:51 -0800
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Mon, 30 Nov 2009 21:33:51 -0800

x86, mm: Correct the implementation of is_untracked_pat_range()

The semantics the PAT code expect of is_untracked_pat_range() is "is
this range completely contained inside the untracked region."  This
means that checkin 8a27138924f64d2f30c1022f909f74480046bc3f was
technically wrong, because the implementation needlessly confusing.

The sane interface is for it to take a semiclosed range like just
about everything else (as evidenced by the sheer number of "- 1"'s
removed by that patch) so change the actual implementation to match.

Reported-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jack Steiner <steiner@sgi.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
LKML-Reference: <20091119202341.GA4420@sgi.com>
---
 arch/x86/include/asm/e820.h        |    6 +++++-
 arch/x86/kernel/apic/x2apic_uv_x.c |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index 68b4e0e..761249e 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -133,9 +133,13 @@ extern void e820_reserve_resources_late(void);
 extern void setup_memory_map(void);
 extern char *default_machine_specific_memory_setup(void);
 
+/*
+ * Returns true iff the specified range [s,e) is completely contained inside
+ * the ISA region.
+ */
 static inline bool is_ISA_range(u64 s, u64 e)
 {
-	return s >= ISA_START_ADDRESS && e < ISA_END_ADDRESS;
+	return s >= ISA_START_ADDRESS && e <= ISA_END_ADDRESS;
 }
 
 #endif /* __KERNEL__ */
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 597a47b..1e09417 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -39,7 +39,7 @@ static u64 gru_start_paddr, gru_end_paddr;
 
 static inline bool is_GRU_range(u64 start, u64 end)
 {
-	return start >= gru_start_paddr && end < gru_end_paddr;
+	return start >= gru_start_paddr && end <= gru_end_paddr;
 }
 
 static bool uv_is_untracked_pat_range(u64 start, u64 end)

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

end of thread, other threads:[~2009-12-01  7:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-29 18:47 [PATCH] x86: UV SGI, Don't track GRU space in PAT Jack Steiner
2009-11-08 12:06 ` Ingo Molnar
2009-11-11 18:30   ` Jack Steiner
2009-11-17 21:23   ` [PATCH v2] " Jack Steiner
2009-11-17 22:21     ` H. Peter Anvin
2009-11-19 20:23       ` [PATCH v3] " Jack Steiner
2009-11-23 18:25         ` Ingo Molnar
2009-11-23 18:55         ` [tip:x86/mm] x86: UV SGI: " tip-bot for Jack Steiner
2009-11-24  1:12         ` [tip:x86/mm] x86, mm: Call is_untracked_pat_range() rather than is_ISA_range() tip-bot for H. Peter Anvin
2009-11-24  1:13         ` [tip:x86/mm] x86, mm: is_untracked_pat_range() takes a normal semiclosed range tip-bot for H. Peter Anvin
2009-11-24  1:13         ` [tip:x86/mm] x86: Change is_ISA_range() into an inline function tip-bot for H. Peter Anvin
2009-11-24  1:13         ` [tip:x86/mm] x86, platform: Change is_untracked_pat_range() to bool; cleanup init tip-bot for H. Peter Anvin
2009-12-01  7:36         ` [tip:x86/mm] x86, mm: Correct the implementation of is_untracked_pat_range() tip-bot for H. Peter Anvin

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.