* [PATCH] fix gcc4 warning in asm-ppc/time.h
@ 2005-08-02 9:55 Christoph Hellwig
2005-08-04 5:15 ` Andrew Morton
2005-08-04 5:17 ` Andrew Morton
0 siblings, 2 replies; 7+ messages in thread
From: Christoph Hellwig @ 2005-08-02 9:55 UTC (permalink / raw)
To: paulus, akpm; +Cc: linuxppc-dev
A function must not return a const value, instead use
__attribute_const__.
Index: linux-2.6/include/asm/time.h
===================================================================
--- linux-2.6.orig/include/asm/time.h 2005-04-30 10:17:19.000000000 +0200
+++ linux-2.6/include/asm/time.h 2005-08-01 11:57:12.000000000 +0200
@@ -10,6 +10,7 @@
#define __ASM_TIME_H__
#include <linux/config.h>
+#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/rtc.h>
#include <linux/threads.h>
@@ -58,7 +59,7 @@
/* Accessor functions for the timebase (RTC on 601) registers. */
/* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
#ifdef CONFIG_6xx
-extern __inline__ int const __USE_RTC(void) {
+extern __inline__ int __attribute_const__ __USE_RTC(void) {
return (mfspr(SPRN_PVR)>>16) == 1;
}
#else
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix gcc4 warning in asm-ppc/time.h
2005-08-02 9:55 [PATCH] fix gcc4 warning in asm-ppc/time.h Christoph Hellwig
@ 2005-08-04 5:15 ` Andrew Morton
2005-08-04 5:54 ` Gabriel Paubert
2005-08-04 22:19 ` Paul Mackerras
2005-08-04 5:17 ` Andrew Morton
1 sibling, 2 replies; 7+ messages in thread
From: Andrew Morton @ 2005-08-04 5:15 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linuxppc-dev
Christoph Hellwig <hch@lst.de> wrote:
>
> A function must not return a const value, instead use
> __attribute_const__.
>
>
> Index: linux-2.6/include/asm/time.h
> ===================================================================
> --- linux-2.6.orig/include/asm/time.h 2005-04-30 10:17:19.000000000 +0200
> +++ linux-2.6/include/asm/time.h 2005-08-01 11:57:12.000000000 +0200
> @@ -10,6 +10,7 @@
> #define __ASM_TIME_H__
>
> #include <linux/config.h>
> +#include <linux/compiler.h>
> #include <linux/types.h>
> #include <linux/rtc.h>
> #include <linux/threads.h>
> @@ -58,7 +59,7 @@
> /* Accessor functions for the timebase (RTC on 601) registers. */
> /* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
> #ifdef CONFIG_6xx
> -extern __inline__ int const __USE_RTC(void) {
> +extern __inline__ int __attribute_const__ __USE_RTC(void) {
> return (mfspr(SPRN_PVR)>>16) == 1;
> }
> #else
Do we really want to do this? The above implies that mfspr(SPRN_PVR) will
return the same value across the entire uptime of the kernel. Is that
true?
Why is this function paying with const anyway?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix gcc4 warning in asm-ppc/time.h
2005-08-02 9:55 [PATCH] fix gcc4 warning in asm-ppc/time.h Christoph Hellwig
2005-08-04 5:15 ` Andrew Morton
@ 2005-08-04 5:17 ` Andrew Morton
1 sibling, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2005-08-04 5:17 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linuxppc-dev
Christoph Hellwig <hch@lst.de> wrote:
>
> A function must not return a const value, instead use
> __attribute_const__.
>
>
> Index: linux-2.6/include/asm/time.h
> ===================================================================
> --- linux-2.6.orig/include/asm/time.h 2005-04-30 10:17:19.000000000 +0200
> +++ linux-2.6/include/asm/time.h 2005-08-01 11:57:12.000000000 +0200
asm-ppc, please. That didn't apply very well on an x86 tree...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix gcc4 warning in asm-ppc/time.h
2005-08-04 5:15 ` Andrew Morton
@ 2005-08-04 5:54 ` Gabriel Paubert
2005-08-04 9:46 ` Benjamin Herrenschmidt
2005-08-04 22:19 ` Paul Mackerras
1 sibling, 1 reply; 7+ messages in thread
From: Gabriel Paubert @ 2005-08-04 5:54 UTC (permalink / raw)
To: Andrew Morton; +Cc: linuxppc-dev
On Wed, Aug 03, 2005 at 10:15:17PM -0700, Andrew Morton wrote:
> Christoph Hellwig <hch@lst.de> wrote:
> >
> > A function must not return a const value, instead use
> > __attribute_const__.
> >
> >
> > Index: linux-2.6/include/asm/time.h
> > ===================================================================
> > --- linux-2.6.orig/include/asm/time.h 2005-04-30 10:17:19.000000000 +0200
> > +++ linux-2.6/include/asm/time.h 2005-08-01 11:57:12.000000000 +0200
> > @@ -10,6 +10,7 @@
> > #define __ASM_TIME_H__
> >
> > #include <linux/config.h>
> > +#include <linux/compiler.h>
> > #include <linux/types.h>
> > #include <linux/rtc.h>
> > #include <linux/threads.h>
> > @@ -58,7 +59,7 @@
> > /* Accessor functions for the timebase (RTC on 601) registers. */
> > /* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
> > #ifdef CONFIG_6xx
> > -extern __inline__ int const __USE_RTC(void) {
> > +extern __inline__ int __attribute_const__ __USE_RTC(void) {
> > return (mfspr(SPRN_PVR)>>16) == 1;
> > }
> > #else
>
> Do we really want to do this? The above implies that mfspr(SPRN_PVR) will
> return the same value across the entire uptime of the kernel. Is that
> true?
Yes, it is a read-only register. PVR means processor version register
and is linked to the revision of the silicon. Besides that it is
only used in this context to check for processors of the 601 family
(the very first PPC processors). Nobody expects them to be hotpluggable,
nor even used in SMP systems for the matter.
>
> Why is this function paying with const anyway?
I believe that it was originally to tell the compiler to be
able to cache it across several tests (a good compiler
on PPC would even cache the result of the test in a condition
register to allow branch prediction to work optimally).
Otherwise the compiler would never cache it since mfspr
is a volatile asm.
However this was written in pre gcc2.95 days so my
memory may be failing.
Gabriel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix gcc4 warning in asm-ppc/time.h
2005-08-04 5:54 ` Gabriel Paubert
@ 2005-08-04 9:46 ` Benjamin Herrenschmidt
2005-08-04 10:19 ` Gabriel Paubert
0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2005-08-04 9:46 UTC (permalink / raw)
To: Gabriel Paubert; +Cc: Andrew Morton, linuxppc-dev
On Thu, 2005-08-04 at 07:54 +0200, Gabriel Paubert wrote:
> On Wed, Aug 03, 2005 at 10:15:17PM -0700, Andrew Morton wrote:
> > Christoph Hellwig <hch@lst.de> wrote:
> > >
> > > A function must not return a const value, instead use
> > > __attribute_const__.
> > >
> > >
> > > Index: linux-2.6/include/asm/time.h
> > > ===================================================================
> > > --- linux-2.6.orig/include/asm/time.h 2005-04-30 10:17:19.000000000 +0200
> > > +++ linux-2.6/include/asm/time.h 2005-08-01 11:57:12.000000000 +0200
> > > @@ -10,6 +10,7 @@
> > > #define __ASM_TIME_H__
> > >
> > > #include <linux/config.h>
> > > +#include <linux/compiler.h>
> > > #include <linux/types.h>
> > > #include <linux/rtc.h>
> > > #include <linux/threads.h>
> > > @@ -58,7 +59,7 @@
> > > /* Accessor functions for the timebase (RTC on 601) registers. */
> > > /* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
> > > #ifdef CONFIG_6xx
> > > -extern __inline__ int const __USE_RTC(void) {
> > > +extern __inline__ int __attribute_const__ __USE_RTC(void) {
> > > return (mfspr(SPRN_PVR)>>16) == 1;
> > > }
> > > #else
> >
> > Do we really want to do this? The above implies that mfspr(SPRN_PVR) will
> > return the same value across the entire uptime of the kernel. Is that
> > true?
>
> Yes, it is a read-only register. PVR means processor version register
> and is linked to the revision of the silicon. Besides that it is
> only used in this context to check for processors of the 601 family
> (the very first PPC processors). Nobody expects them to be hotpluggable,
> nor even used in SMP systems for the matter.
Yes ... However, we want to get rid of PVR accesses. They are a problem
for Xen-like virtualization without HW support (that is running the
kernel actually in user space) among other things.
The above should be replaced by a test of CPU features.
Ben.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix gcc4 warning in asm-ppc/time.h
2005-08-04 9:46 ` Benjamin Herrenschmidt
@ 2005-08-04 10:19 ` Gabriel Paubert
0 siblings, 0 replies; 7+ messages in thread
From: Gabriel Paubert @ 2005-08-04 10:19 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: Andrew Morton, linuxppc-dev
On Thu, Aug 04, 2005 at 11:46:38AM +0200, Benjamin Herrenschmidt wrote:
> On Thu, 2005-08-04 at 07:54 +0200, Gabriel Paubert wrote:
> > On Wed, Aug 03, 2005 at 10:15:17PM -0700, Andrew Morton wrote:
> > > Christoph Hellwig <hch@lst.de> wrote:
> > > >
> > > > A function must not return a const value, instead use
> > > > __attribute_const__.
> > > >
> > > >
> > > > Index: linux-2.6/include/asm/time.h
> > > > ===================================================================
> > > > --- linux-2.6.orig/include/asm/time.h 2005-04-30 10:17:19.000000000 +0200
> > > > +++ linux-2.6/include/asm/time.h 2005-08-01 11:57:12.000000000 +0200
> > > > @@ -10,6 +10,7 @@
> > > > #define __ASM_TIME_H__
> > > >
> > > > #include <linux/config.h>
> > > > +#include <linux/compiler.h>
> > > > #include <linux/types.h>
> > > > #include <linux/rtc.h>
> > > > #include <linux/threads.h>
> > > > @@ -58,7 +59,7 @@
> > > > /* Accessor functions for the timebase (RTC on 601) registers. */
> > > > /* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
> > > > #ifdef CONFIG_6xx
> > > > -extern __inline__ int const __USE_RTC(void) {
> > > > +extern __inline__ int __attribute_const__ __USE_RTC(void) {
> > > > return (mfspr(SPRN_PVR)>>16) == 1;
> > > > }
> > > > #else
> > >
> > > Do we really want to do this? The above implies that mfspr(SPRN_PVR) will
> > > return the same value across the entire uptime of the kernel. Is that
> > > true?
> >
> > Yes, it is a read-only register. PVR means processor version register
> > and is linked to the revision of the silicon. Besides that it is
> > only used in this context to check for processors of the 601 family
> > (the very first PPC processors). Nobody expects them to be hotpluggable,
> > nor even used in SMP systems for the matter.
>
> Yes ... However, we want to get rid of PVR accesses. They are a problem
> for Xen-like virtualization without HW support (that is running the
> kernel actually in user space) among other things.
>
> The above should be replaced by a test of CPU features.
I agree, this is old code that predates CPU features
(the first version was written in 1998), when the things
were simple: no PM, no Altivec, no really available 64 bit
machines.
Now I wonder whether current kernels really boot reliably on
601 (after all even something as stupid as the RI bit in the
MSR is marked as non implemented on my 601 doc).
Gabriel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix gcc4 warning in asm-ppc/time.h
2005-08-04 5:15 ` Andrew Morton
2005-08-04 5:54 ` Gabriel Paubert
@ 2005-08-04 22:19 ` Paul Mackerras
1 sibling, 0 replies; 7+ messages in thread
From: Paul Mackerras @ 2005-08-04 22:19 UTC (permalink / raw)
To: Andrew Morton; +Cc: linuxppc-dev
Andrew Morton writes:
> Do we really want to do this? The above implies that mfspr(SPRN_PVR) will
> return the same value across the entire uptime of the kernel. Is that
> true?
Yes, the PVR is the processor version register, and it would be quite
disturbing if the silicon changed underneath us. :)
> Why is this function paying with const anyway?
It seemed like a good idea at the time? :)
Paul.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-08-04 22:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-02 9:55 [PATCH] fix gcc4 warning in asm-ppc/time.h Christoph Hellwig
2005-08-04 5:15 ` Andrew Morton
2005-08-04 5:54 ` Gabriel Paubert
2005-08-04 9:46 ` Benjamin Herrenschmidt
2005-08-04 10:19 ` Gabriel Paubert
2005-08-04 22:19 ` Paul Mackerras
2005-08-04 5:17 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).