diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2006-03-15 06:36:31 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2006-03-18 11:59:28 -0500 |
commit | 966f4406d903a4214fdc74bec54710c6232a95b8 (patch) | |
tree | 20d7f57eae99fe83b8fbdae112a6a0facc5b552d /include/asm-mips/io.h | |
parent | 66a9a4ffda3474b193f36ed579cee06c597952f3 (diff) |
[MIPS] Work around bad code generation for <asm/io.h>.
If a call to set_io_port_base() was being followed by usage of
mips_io_port_base in the same function gcc was possibly using the old
value due to some clever abuse of const. Adding a barrier will keep
the optimization and result in correct code with latest gcc.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'include/asm-mips/io.h')
-rw-r--r-- | include/asm-mips/io.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h index 8c011aa61af..ba1d7bbc15d 100644 --- a/include/asm-mips/io.h +++ b/include/asm-mips/io.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * for more details. | 4 | * for more details. |
5 | * | 5 | * |
6 | * Copyright (C) 1994, 1995 Waldorf GmbH | 6 | * Copyright (C) 1994, 1995 Waldorf GmbH |
7 | * Copyright (C) 1994 - 2000 Ralf Baechle | 7 | * Copyright (C) 1994 - 2000, 06 Ralf Baechle |
8 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. | 8 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. |
9 | * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved. | 9 | * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved. |
10 | * Author: Maciej W. Rozycki <macro@mips.com> | 10 | * Author: Maciej W. Rozycki <macro@mips.com> |
@@ -103,8 +103,20 @@ | |||
103 | */ | 103 | */ |
104 | extern const unsigned long mips_io_port_base; | 104 | extern const unsigned long mips_io_port_base; |
105 | 105 | ||
106 | #define set_io_port_base(base) \ | 106 | /* |
107 | do { * (unsigned long *) &mips_io_port_base = (base); } while (0) | 107 | * Gcc will generate code to load the value of mips_io_port_base after each |
108 | * function call which may be fairly wasteful in some cases. So we don't | ||
109 | * play quite by the book. We tell gcc mips_io_port_base is a long variable | ||
110 | * which solves the code generation issue. Now we need to violate the | ||
111 | * aliasing rules a little to make initialization possible and finally we | ||
112 | * will need the barrier() to fight side effects of the aliasing chat. | ||
113 | * This trickery will eventually collapse under gcc's optimizer. Oh well. | ||
114 | */ | ||
115 | static inline void set_io_port_base(unsigned long base) | ||
116 | { | ||
117 | * (unsigned long *) &mips_io_port_base = base; | ||
118 | barrier(); | ||
119 | } | ||
108 | 120 | ||
109 | /* | 121 | /* |
110 | * Thanks to James van Artsdalen for a better timing-fix than | 122 | * Thanks to James van Artsdalen for a better timing-fix than |