* [PATCH] x86: SGU UV Add volatile to macros that access chipset registers
@ 2009-09-09 15:42 Jack Steiner
2009-09-09 16:10 ` Daniel Walker
0 siblings, 1 reply; 14+ messages in thread
From: Jack Steiner @ 2009-09-09 15:42 UTC (permalink / raw)
To: mingo, tglx; +Cc: linux-kernel
Add "volatile" to the SGI UV read/write macros that are used to access chipset
memory mapped registers.
Signed-off-by: Jack Steiner <steiner@sgi.com>
---
arch/x86/include/asm/uv/uv_hub.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
Index: linux/arch/x86/include/asm/uv/uv_hub.h
===================================================================
--- linux.orig/arch/x86/include/asm/uv/uv_hub.h 2009-08-10 01:45:42.000000000 -0500
+++ linux/arch/x86/include/asm/uv/uv_hub.h 2009-08-10 11:43:39.000000000 -0500
@@ -248,7 +248,7 @@ static inline int uv_apicid_to_pnode(int
* Access global MMRs using the low memory MMR32 space. This region supports
* faster MMR access but not all MMRs are accessible in this space.
*/
-static inline unsigned long *uv_global_mmr32_address(int pnode,
+static inline volatile unsigned long *uv_global_mmr32_address(int pnode,
unsigned long offset)
{
return __va(UV_GLOBAL_MMR32_BASE |
@@ -271,7 +271,7 @@ static inline unsigned long uv_read_glob
* Access Global MMR space using the MMR space located at the top of physical
* memory.
*/
-static inline unsigned long *uv_global_mmr64_address(int pnode,
+static inline volatile unsigned long *uv_global_mmr64_address(int pnode,
unsigned long offset)
{
return __va(UV_GLOBAL_MMR64_BASE |
@@ -294,7 +294,7 @@ static inline unsigned long uv_read_glob
* Access hub local MMRs. Faster than using global space but only local MMRs
* are accessible.
*/
-static inline unsigned long *uv_local_mmr_address(unsigned long offset)
+static inline volatile unsigned long *uv_local_mmr_address(unsigned long offset)
{
return __va(UV_LOCAL_MMR_BASE | offset);
}
@@ -311,12 +311,12 @@ static inline void uv_write_local_mmr(un
static inline unsigned char uv_read_local_mmr8(unsigned long offset)
{
- return *((unsigned char *)uv_local_mmr_address(offset));
+ return *((volatile unsigned char *)uv_local_mmr_address(offset));
}
static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val)
{
- *((unsigned char *)uv_local_mmr_address(offset)) = val;
+ *((volatile unsigned char *)uv_local_mmr_address(offset)) = val;
}
/*
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] x86: SGU UV Add volatile to macros that access chipset registers 2009-09-09 15:42 [PATCH] x86: SGU UV Add volatile to macros that access chipset registers Jack Steiner @ 2009-09-09 16:10 ` Daniel Walker 2009-09-09 18:01 ` Jack Steiner 0 siblings, 1 reply; 14+ messages in thread From: Daniel Walker @ 2009-09-09 16:10 UTC (permalink / raw) To: Jack Steiner; +Cc: mingo, tglx, linux-kernel On Wed, 2009-09-09 at 10:42 -0500, Jack Steiner wrote: > Add "volatile" to the SGI UV read/write macros that are used to access chipset > memory mapped registers. There is a considerable document regarding the usage of volatile in the kernel (Documentation/volatile-considered-harmful.txt). Considering that document, can you give a more descriptive reason why your using "volatile" here ? Daniel ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] x86: SGU UV Add volatile to macros that access chipset registers 2009-09-09 16:10 ` Daniel Walker @ 2009-09-09 18:01 ` Jack Steiner 2009-09-09 18:11 ` Daniel Walker 0 siblings, 1 reply; 14+ messages in thread From: Jack Steiner @ 2009-09-09 18:01 UTC (permalink / raw) To: Daniel Walker; +Cc: mingo, tglx, linux-kernel On Wed, Sep 09, 2009 at 09:10:00AM -0700, Daniel Walker wrote: > On Wed, 2009-09-09 at 10:42 -0500, Jack Steiner wrote: > > Add "volatile" to the SGI UV read/write macros that are used to access chipset > > memory mapped registers. > > There is a considerable document regarding the usage of volatile in the > kernel (Documentation/volatile-considered-harmful.txt). Considering that > document, can you give a more descriptive reason why your using > "volatile" here ? > I knew that "volatile" would catch someone's attention :-) Volatile is being added to the accessor functions that are used to read/write memory-mapped I/O registers located within the UV chipset. The use of volatile is hidden within the functions and is not exposed to the users of the functions. Note that the use is limited to the accessor functions in the header file. No .c files are changed or need to know about volatile. This seems to be consistent with other uses of volatile within the kernel. --- jack ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] x86: SGU UV Add volatile to macros that access chipset registers 2009-09-09 18:01 ` Jack Steiner @ 2009-09-09 18:11 ` Daniel Walker 2009-09-09 18:54 ` Chris Friesen 2009-09-09 19:20 ` [PATCH] x86: SGU UV Add volatile " Jack Steiner 0 siblings, 2 replies; 14+ messages in thread From: Daniel Walker @ 2009-09-09 18:11 UTC (permalink / raw) To: Jack Steiner; +Cc: mingo, tglx, linux-kernel On Wed, 2009-09-09 at 13:01 -0500, Jack Steiner wrote: > On Wed, Sep 09, 2009 at 09:10:00AM -0700, Daniel Walker wrote: > > On Wed, 2009-09-09 at 10:42 -0500, Jack Steiner wrote: > > > Add "volatile" to the SGI UV read/write macros that are used to access chipset > > > memory mapped registers. > > > > There is a considerable document regarding the usage of volatile in the > > kernel (Documentation/volatile-considered-harmful.txt). Considering that > > document, can you give a more descriptive reason why your using > > "volatile" here ? > > > > I knew that "volatile" would catch someone's attention :-) > > > Volatile is being added to the accessor functions that are used to > read/write memory-mapped I/O registers located within the UV chipset. > The use of volatile is hidden within the functions and is not exposed > to the users of the functions. > > Note that the use is limited to the accessor functions in the header > file. No .c files are changed or need to know about volatile. > > > This seems to be consistent with other uses of volatile within the kernel. The document that I cited specifically addresses memory accessors as not needing the volatile keyword .. So your still not addressing exactly why your code needs it .. Are your accessors special in some way? Is there some defect your seeing without the volatile keyword? Daniel ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] x86: SGU UV Add volatile to macros that access chipset registers 2009-09-09 18:11 ` Daniel Walker @ 2009-09-09 18:54 ` Chris Friesen 2009-09-09 19:38 ` Jack Steiner 2009-09-09 19:20 ` [PATCH] x86: SGU UV Add volatile " Jack Steiner 1 sibling, 1 reply; 14+ messages in thread From: Chris Friesen @ 2009-09-09 18:54 UTC (permalink / raw) To: Daniel Walker; +Cc: Jack Steiner, mingo, tglx, linux-kernel On 09/09/2009 12:11 PM, Daniel Walker wrote: > On Wed, 2009-09-09 at 13:01 -0500, Jack Steiner wrote: >> Volatile is being added to the accessor functions that are used to >> read/write memory-mapped I/O registers located within the UV chipset. >> The use of volatile is hidden within the functions and is not exposed >> to the users of the functions. >> >> Note that the use is limited to the accessor functions in the header >> file. No .c files are changed or need to know about volatile. >> >> >> This seems to be consistent with other uses of volatile within the kernel. > > The document that I cited specifically addresses memory accessors as not > needing the volatile keyword .. So your still not addressing exactly why > your code needs it .. Are your accessors special in some way? Is there > some defect your seeing without the volatile keyword? >From that document: "There are still a few rare situations where volatile makes sense in the kernel: - The above-mentioned accessor functions might use volatile on architectures where direct I/O memory access does work. Essentially, each accessor call becomes a little critical section on its own and ensures that the access happens as expected by the programmer." However, the fact that these functions are returning volatile pointers is a bit sketchy. Normally accesses to such memory would be wrapped entirely in a read/write function which would handle the volatility internally to the function. In this case there's no point in the function returning a "volatile unsigned long *" if it's going to be cast to a volatile pointer before being dereferenced. Chris ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] x86: SGU UV Add volatile to macros that access chipset registers 2009-09-09 18:54 ` Chris Friesen @ 2009-09-09 19:38 ` Jack Steiner 2009-09-10 0:44 ` H. Peter Anvin 0 siblings, 1 reply; 14+ messages in thread From: Jack Steiner @ 2009-09-09 19:38 UTC (permalink / raw) To: Chris Friesen; +Cc: Daniel Walker, mingo, tglx, linux-kernel On Wed, Sep 09, 2009 at 12:54:29PM -0600, Chris Friesen wrote: > On 09/09/2009 12:11 PM, Daniel Walker wrote: > > On Wed, 2009-09-09 at 13:01 -0500, Jack Steiner wrote: > >> Volatile is being added to the accessor functions that are used to > >> read/write memory-mapped I/O registers located within the UV chipset. > >> The use of volatile is hidden within the functions and is not exposed > >> to the users of the functions. > >> > >> Note that the use is limited to the accessor functions in the header > >> file. No .c files are changed or need to know about volatile. > >> > >> > >> This seems to be consistent with other uses of volatile within the kernel. > > > > The document that I cited specifically addresses memory accessors as not > > needing the volatile keyword .. So your still not addressing exactly why > > your code needs it .. Are your accessors special in some way? Is there > > some defect your seeing without the volatile keyword? > > > >From that document: > > "There are still a few rare situations where volatile makes sense in the > kernel: > > - The above-mentioned accessor functions might use volatile on > architectures where direct I/O memory access does work. > Essentially, each accessor call becomes a little critical section > on its own and ensures that the access happens as expected by the > programmer." > > > However, the fact that these functions are returning volatile pointers > is a bit sketchy. Normally accesses to such memory would be wrapped > entirely in a read/write function which would handle the volatility > internally to the function. > > In this case there's no point in the function returning a "volatile > unsigned long *" if it's going to be cast to a volatile pointer before > being dereferenced. make sense. How is this..... Avoids adding volatile to any return types. -------------------------------------------------------- Add "volatile" to the SGI UV read/write macros that are used to access chipset memory mapped registers. Signed-off-by: Jack Steiner <steiner@sgi.com> --- arch/x86/include/asm/uv/uv_hub.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) Index: linux/arch/x86/include/asm/uv/uv_hub.h =================================================================== --- linux.orig/arch/x86/include/asm/uv/uv_hub.h 2009-09-09 01:34:02.000000000 -0500 +++ linux/arch/x86/include/asm/uv/uv_hub.h 2009-09-09 14:36:23.000000000 -0500 @@ -258,13 +258,13 @@ static inline unsigned long *uv_global_m static inline void uv_write_global_mmr32(int pnode, unsigned long offset, unsigned long val) { - *uv_global_mmr32_address(pnode, offset) = val; + *(volatile unsigned long *)uv_global_mmr32_address(pnode, offset) = val; } static inline unsigned long uv_read_global_mmr32(int pnode, unsigned long offset) { - return *uv_global_mmr32_address(pnode, offset); + return *(volatile unsigned long *)uv_global_mmr32_address(pnode, offset); } /* @@ -281,13 +281,13 @@ static inline unsigned long *uv_global_m static inline void uv_write_global_mmr64(int pnode, unsigned long offset, unsigned long val) { - *uv_global_mmr64_address(pnode, offset) = val; + *(volatile unsigned long *)uv_global_mmr64_address(pnode, offset) = val; } static inline unsigned long uv_read_global_mmr64(int pnode, unsigned long offset) { - return *uv_global_mmr64_address(pnode, offset); + return *(volatile unsigned long *)uv_global_mmr64_address(pnode, offset); } /* @@ -301,22 +301,22 @@ static inline unsigned long *uv_local_mm static inline unsigned long uv_read_local_mmr(unsigned long offset) { - return *uv_local_mmr_address(offset); + return *(volatile unsigned char *)uv_local_mmr_address(offset); } static inline void uv_write_local_mmr(unsigned long offset, unsigned long val) { - *uv_local_mmr_address(offset) = val; + *(volatile unsigned char *)uv_local_mmr_address(offset) = val; } static inline unsigned char uv_read_local_mmr8(unsigned long offset) { - return *((unsigned char *)uv_local_mmr_address(offset)); + return *((volatile unsigned char *)uv_local_mmr_address(offset)); } static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val) { - *((unsigned char *)uv_local_mmr_address(offset)) = val; + *((volatile unsigned char *)uv_local_mmr_address(offset)) = val; } /* ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] x86: SGU UV Add volatile to macros that access chipset registers 2009-09-09 19:38 ` Jack Steiner @ 2009-09-10 0:44 ` H. Peter Anvin 2009-09-10 2:21 ` Jack Steiner 2009-09-10 2:22 ` [PATCH V2] x86: SGU UV Add volatile semantics " Jack Steiner 0 siblings, 2 replies; 14+ messages in thread From: H. Peter Anvin @ 2009-09-10 0:44 UTC (permalink / raw) To: Jack Steiner; +Cc: Chris Friesen, Daniel Walker, mingo, tglx, linux-kernel On 09/09/2009 12:38 PM, Jack Steiner wrote: > > static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val) > { > - *((unsigned char *)uv_local_mmr_address(offset)) = val; > + *((volatile unsigned char *)uv_local_mmr_address(offset)) = val; > } > Why aren't you simply using __writeb() here, and the other memory accessors we already have in the other places? -hpa ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] x86: SGU UV Add volatile to macros that access chipset registers 2009-09-10 0:44 ` H. Peter Anvin @ 2009-09-10 2:21 ` Jack Steiner 2009-09-10 2:22 ` [PATCH V2] x86: SGU UV Add volatile semantics " Jack Steiner 1 sibling, 0 replies; 14+ messages in thread From: Jack Steiner @ 2009-09-10 2:21 UTC (permalink / raw) To: H. Peter Anvin; +Cc: Chris Friesen, Daniel Walker, mingo, tglx, linux-kernel On Wed, Sep 09, 2009 at 05:44:23PM -0700, H. Peter Anvin wrote: > On 09/09/2009 12:38 PM, Jack Steiner wrote: > > > > static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val) > > { > > - *((unsigned char *)uv_local_mmr_address(offset)) = val; > > + *((volatile unsigned char *)uv_local_mmr_address(offset)) = val; > > } > > > > Why aren't you simply using __writeb() here, and the other memory > accessors we already have in the other places? Excellent idea. New patch to follow... --- jack ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH V2] x86: SGU UV Add volatile semantics to macros that access chipset registers 2009-09-10 0:44 ` H. Peter Anvin 2009-09-10 2:21 ` Jack Steiner @ 2009-09-10 2:22 ` Jack Steiner 2009-09-10 3:05 ` H. Peter Anvin 1 sibling, 1 reply; 14+ messages in thread From: Jack Steiner @ 2009-09-10 2:22 UTC (permalink / raw) To: H. Peter Anvin; +Cc: Chris Friesen, Daniel Walker, mingo, tglx, linux-kernel Add volatile-semantics to the SGI UV read/write macros that are used to access chipset memory mapped registers. No direct references to volatile are made. Instead the readq/writeq macros are used. Signed-off-by: Jack Steiner <steiner@sgi.com> --- arch/x86/include/asm/uv/uv_hub.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) Index: linux/arch/x86/include/asm/uv/uv_hub.h =================================================================== --- linux.orig/arch/x86/include/asm/uv/uv_hub.h 2009-09-09 01:34:02.000000000 -0500 +++ linux/arch/x86/include/asm/uv/uv_hub.h 2009-09-09 20:51:53.000000000 -0500 @@ -15,6 +15,7 @@ #include <linux/numa.h> #include <linux/percpu.h> #include <linux/timer.h> +#include <linux/io.h> #include <asm/types.h> #include <asm/percpu.h> #include <asm/uv/uv_mmrs.h> @@ -258,13 +259,13 @@ static inline unsigned long *uv_global_m static inline void uv_write_global_mmr32(int pnode, unsigned long offset, unsigned long val) { - *uv_global_mmr32_address(pnode, offset) = val; + writeq(val, uv_global_mmr32_address(pnode, offset)); } static inline unsigned long uv_read_global_mmr32(int pnode, unsigned long offset) { - return *uv_global_mmr32_address(pnode, offset); + return readq(uv_global_mmr32_address(pnode, offset)); } /* @@ -281,13 +282,13 @@ static inline unsigned long *uv_global_m static inline void uv_write_global_mmr64(int pnode, unsigned long offset, unsigned long val) { - *uv_global_mmr64_address(pnode, offset) = val; + writeq(val, uv_global_mmr64_address(pnode, offset)); } static inline unsigned long uv_read_global_mmr64(int pnode, unsigned long offset) { - return *uv_global_mmr64_address(pnode, offset); + return readq(uv_global_mmr64_address(pnode, offset)); } /* @@ -301,22 +302,22 @@ static inline unsigned long *uv_local_mm static inline unsigned long uv_read_local_mmr(unsigned long offset) { - return *uv_local_mmr_address(offset); + return readq(uv_local_mmr_address(offset)); } static inline void uv_write_local_mmr(unsigned long offset, unsigned long val) { - *uv_local_mmr_address(offset) = val; + writeq(val, uv_local_mmr_address(offset)); } static inline unsigned char uv_read_local_mmr8(unsigned long offset) { - return *((unsigned char *)uv_local_mmr_address(offset)); + return readq(uv_local_mmr_address(offset)); } static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val) { - *((unsigned char *)uv_local_mmr_address(offset)) = val; + writeq(val, uv_local_mmr_address(offset)); } /* ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2] x86: SGU UV Add volatile semantics to macros that access chipset registers 2009-09-10 2:22 ` [PATCH V2] x86: SGU UV Add volatile semantics " Jack Steiner @ 2009-09-10 3:05 ` H. Peter Anvin 2009-09-10 3:23 ` Jack Steiner 2009-09-10 14:31 ` [PATCH V3] " Jack Steiner 0 siblings, 2 replies; 14+ messages in thread From: H. Peter Anvin @ 2009-09-10 3:05 UTC (permalink / raw) To: Jack Steiner; +Cc: Chris Friesen, Daniel Walker, mingo, tglx, linux-kernel On 09/09/2009 07:22 PM, Jack Steiner wrote: > Add volatile-semantics to the SGI UV read/write macros that are > used to access chipset memory mapped registers. No direct > references to volatile are made. Instead the readq/writeq > macros are used. > > Signed-off-by: Jack Steiner <steiner@sgi.com> The -q part of readq/writeq is qword, 64 bits. It looks like you're replacing references of other sizes with qword references; was that intended? -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V2] x86: SGU UV Add volatile semantics to macros that access chipset registers 2009-09-10 3:05 ` H. Peter Anvin @ 2009-09-10 3:23 ` Jack Steiner 2009-09-10 14:31 ` [PATCH V3] " Jack Steiner 1 sibling, 0 replies; 14+ messages in thread From: Jack Steiner @ 2009-09-10 3:23 UTC (permalink / raw) To: H. Peter Anvin; +Cc: Chris Friesen, Daniel Walker, mingo, tglx, linux-kernel On Wed, Sep 09, 2009 at 08:05:30PM -0700, H. Peter Anvin wrote: > On 09/09/2009 07:22 PM, Jack Steiner wrote: > > Add volatile-semantics to the SGI UV read/write macros that are > > used to access chipset memory mapped registers. No direct > > references to volatile are made. Instead the readq/writeq > > macros are used. > > > > Signed-off-by: Jack Steiner <steiner@sgi.com> > > The -q part of readq/writeq is qword, 64 bits. It looks like you're > replacing references of other sizes with qword references; was that > intended? No, it was not. Most macros are quad-word but I see one that should have been "char". Thanks for catching that. New patch in the morning. --- jack ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH V3] x86: SGU UV Add volatile semantics to macros that access chipset registers 2009-09-10 3:05 ` H. Peter Anvin 2009-09-10 3:23 ` Jack Steiner @ 2009-09-10 14:31 ` Jack Steiner 2009-09-18 12:06 ` [tip:x86/urgent] x86: SGI UV: " tip-bot for Jack Steiner 1 sibling, 1 reply; 14+ messages in thread From: Jack Steiner @ 2009-09-10 14:31 UTC (permalink / raw) To: mingo, tglx; +Cc: linux-mm, linux-kernel, hpa, dwalker, cfriesen Add volatile-semantics to the SGI UV read/write macros that are used to access chipset memory mapped registers. No direct references to volatile are made. Instead the readq/writeq macros are used. Signed-off-by: Jack Steiner <steiner@sgi.com> --- arch/x86/include/asm/uv/uv_hub.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) Index: linux/arch/x86/include/asm/uv/uv_hub.h =================================================================== --- linux.orig/arch/x86/include/asm/uv/uv_hub.h 2009-09-09 01:34:02.000000000 -0500 +++ linux/arch/x86/include/asm/uv/uv_hub.h 2009-09-09 20:51:53.000000000 -0500 @@ -15,6 +15,7 @@ #include <linux/numa.h> #include <linux/percpu.h> #include <linux/timer.h> +#include <linux/io.h> #include <asm/types.h> #include <asm/percpu.h> #include <asm/uv/uv_mmrs.h> @@ -258,13 +259,13 @@ static inline unsigned long *uv_global_m static inline void uv_write_global_mmr32(int pnode, unsigned long offset, unsigned long val) { - *uv_global_mmr32_address(pnode, offset) = val; + writeq(val, uv_global_mmr32_address(pnode, offset)); } static inline unsigned long uv_read_global_mmr32(int pnode, unsigned long offset) { - return *uv_global_mmr32_address(pnode, offset); + return readq(uv_global_mmr32_address(pnode, offset)); } /* @@ -281,13 +282,13 @@ static inline unsigned long *uv_global_m static inline void uv_write_global_mmr64(int pnode, unsigned long offset, unsigned long val) { - *uv_global_mmr64_address(pnode, offset) = val; + writeq(val, uv_global_mmr64_address(pnode, offset)); } static inline unsigned long uv_read_global_mmr64(int pnode, unsigned long offset) { - return *uv_global_mmr64_address(pnode, offset); + return readq(uv_global_mmr64_address(pnode, offset)); } /* @@ -301,22 +302,22 @@ static inline unsigned long *uv_local_mm static inline unsigned long uv_read_local_mmr(unsigned long offset) { - return *uv_local_mmr_address(offset); + return readq(uv_local_mmr_address(offset)); } static inline void uv_write_local_mmr(unsigned long offset, unsigned long val) { - *uv_local_mmr_address(offset) = val; + writeq(val, uv_local_mmr_address(offset)); } static inline unsigned char uv_read_local_mmr8(unsigned long offset) { - return *((unsigned char *)uv_local_mmr_address(offset)); + return readb(uv_local_mmr_address(offset)); } static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val) { - *((unsigned char *)uv_local_mmr_address(offset)) = val; + writeb(val, uv_local_mmr_address(offset)); } /* ^ permalink raw reply [flat|nested] 14+ messages in thread
* [tip:x86/urgent] x86: SGI UV: Add volatile semantics to macros that access chipset registers 2009-09-10 14:31 ` [PATCH V3] " Jack Steiner @ 2009-09-18 12:06 ` tip-bot for Jack Steiner 0 siblings, 0 replies; 14+ messages in thread From: tip-bot for Jack Steiner @ 2009-09-18 12:06 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, steiner, tglx, mingo Commit-ID: 8dc579e868addafd24c0a015c12f0e536b1084b1 Gitweb: http://git.kernel.org/tip/8dc579e868addafd24c0a015c12f0e536b1084b1 Author: Jack Steiner <steiner@sgi.com> AuthorDate: Thu, 10 Sep 2009 09:31:49 -0500 Committer: Ingo Molnar <mingo@elte.hu> CommitDate: Fri, 18 Sep 2009 14:05:32 +0200 x86: SGI UV: Add volatile semantics to macros that access chipset registers Add volatile-semantics to the SGI UV read/write macros that are used to access chipset memory mapped registers. No direct references to volatile are made. Instead the readq/writeq macros are used. Signed-off-by: Jack Steiner <steiner@sgi.com> Cc: linux-mm@kvack.org Cc: dwalker@fifo99.com Cc: cfriesen@nortel.com LKML-Reference: <20090910143149.GA14273@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> --- arch/x86/include/asm/uv/uv_hub.h | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h index 03a0cbd..04eb6c9 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h @@ -15,6 +15,7 @@ #include <linux/numa.h> #include <linux/percpu.h> #include <linux/timer.h> +#include <linux/io.h> #include <asm/types.h> #include <asm/percpu.h> #include <asm/uv/uv_mmrs.h> @@ -258,13 +259,13 @@ static inline unsigned long *uv_global_mmr32_address(int pnode, static inline void uv_write_global_mmr32(int pnode, unsigned long offset, unsigned long val) { - *uv_global_mmr32_address(pnode, offset) = val; + writeq(val, uv_global_mmr32_address(pnode, offset)); } static inline unsigned long uv_read_global_mmr32(int pnode, unsigned long offset) { - return *uv_global_mmr32_address(pnode, offset); + return readq(uv_global_mmr32_address(pnode, offset)); } /* @@ -281,13 +282,13 @@ static inline unsigned long *uv_global_mmr64_address(int pnode, static inline void uv_write_global_mmr64(int pnode, unsigned long offset, unsigned long val) { - *uv_global_mmr64_address(pnode, offset) = val; + writeq(val, uv_global_mmr64_address(pnode, offset)); } static inline unsigned long uv_read_global_mmr64(int pnode, unsigned long offset) { - return *uv_global_mmr64_address(pnode, offset); + return readq(uv_global_mmr64_address(pnode, offset)); } /* @@ -301,22 +302,22 @@ static inline unsigned long *uv_local_mmr_address(unsigned long offset) static inline unsigned long uv_read_local_mmr(unsigned long offset) { - return *uv_local_mmr_address(offset); + return readq(uv_local_mmr_address(offset)); } static inline void uv_write_local_mmr(unsigned long offset, unsigned long val) { - *uv_local_mmr_address(offset) = val; + writeq(val, uv_local_mmr_address(offset)); } static inline unsigned char uv_read_local_mmr8(unsigned long offset) { - return *((unsigned char *)uv_local_mmr_address(offset)); + return readb(uv_local_mmr_address(offset)); } static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val) { - *((unsigned char *)uv_local_mmr_address(offset)) = val; + writeb(val, uv_local_mmr_address(offset)); } /* ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] x86: SGU UV Add volatile to macros that access chipset registers 2009-09-09 18:11 ` Daniel Walker 2009-09-09 18:54 ` Chris Friesen @ 2009-09-09 19:20 ` Jack Steiner 1 sibling, 0 replies; 14+ messages in thread From: Jack Steiner @ 2009-09-09 19:20 UTC (permalink / raw) To: Daniel Walker; +Cc: mingo, tglx, linux-kernel On Wed, Sep 09, 2009 at 11:11:25AM -0700, Daniel Walker wrote: > On Wed, 2009-09-09 at 13:01 -0500, Jack Steiner wrote: > > On Wed, Sep 09, 2009 at 09:10:00AM -0700, Daniel Walker wrote: > > > On Wed, 2009-09-09 at 10:42 -0500, Jack Steiner wrote: > > > > Add "volatile" to the SGI UV read/write macros that are used to access chipset > > > > memory mapped registers. > > > > > > There is a considerable document regarding the usage of volatile in the > > > kernel (Documentation/volatile-considered-harmful.txt). Considering that > > > document, can you give a more descriptive reason why your using > > > "volatile" here ? > > > > > > > I knew that "volatile" would catch someone's attention :-) > > > > > > Volatile is being added to the accessor functions that are used to > > read/write memory-mapped I/O registers located within the UV chipset. > > The use of volatile is hidden within the functions and is not exposed > > to the users of the functions. > > > > Note that the use is limited to the accessor functions in the header > > file. No .c files are changed or need to know about volatile. > > > > > > This seems to be consistent with other uses of volatile within the kernel. > > The document that I cited specifically addresses memory accessors as not > needing the volatile keyword .. So your still not addressing exactly why > your code needs it .. Are your accessors special in some way? Is there > some defect your seeing without the volatile keyword? The code is not yet in the kernel but the function that exposed the bug was one that had multiple access to the chipset RTC clock. This is a free running clock that counts at nsec rate. The compiler optimized the function so that a single read of the clock was done. This broken the timing that was trying to measure elapsed time. I scanned the standard header files and see numerous instances where inline functions use volatile. The usage of volatile in the UV macros (at least to me) seems consistent: mmio_config_xxx() native_apic_mem_xxx() readb(), etc. bit_ops functions etc... What am I missing? ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2009-09-18 12:07 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-09-09 15:42 [PATCH] x86: SGU UV Add volatile to macros that access chipset registers Jack Steiner 2009-09-09 16:10 ` Daniel Walker 2009-09-09 18:01 ` Jack Steiner 2009-09-09 18:11 ` Daniel Walker 2009-09-09 18:54 ` Chris Friesen 2009-09-09 19:38 ` Jack Steiner 2009-09-10 0:44 ` H. Peter Anvin 2009-09-10 2:21 ` Jack Steiner 2009-09-10 2:22 ` [PATCH V2] x86: SGU UV Add volatile semantics " Jack Steiner 2009-09-10 3:05 ` H. Peter Anvin 2009-09-10 3:23 ` Jack Steiner 2009-09-10 14:31 ` [PATCH V3] " Jack Steiner 2009-09-18 12:06 ` [tip:x86/urgent] x86: SGI UV: " tip-bot for Jack Steiner 2009-09-09 19:20 ` [PATCH] x86: SGU UV Add volatile " Jack Steiner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox