diff options
author | Ralf Baechle | 2006-03-15 12:36:31 +0100 |
---|---|---|
committer | Ralf Baechle | 2006-03-18 17:59:28 +0100 |
commit | 966f4406d903a4214fdc74bec54710c6232a95b8 (patch) | |
tree | 20d7f57eae99fe83b8fbdae112a6a0facc5b552d | |
parent | [MIPS] Simple patch to power off DBAU1200 (diff) | |
download | kernel-qcow2-linux-966f4406d903a4214fdc74bec54710c6232a95b8.tar.gz kernel-qcow2-linux-966f4406d903a4214fdc74bec54710c6232a95b8.tar.xz kernel-qcow2-linux-966f4406d903a4214fdc74bec54710c6232a95b8.zip |
[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>
-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 8c011aa61afa..ba1d7bbc15d2 100644 --- a/include/asm-mips/io.h +++ b/include/asm-mips/io.h @@ -4,7 +4,7 @@ * for more details. * * Copyright (C) 1994, 1995 Waldorf GmbH - * Copyright (C) 1994 - 2000 Ralf Baechle + * Copyright (C) 1994 - 2000, 06 Ralf Baechle * Copyright (C) 1999, 2000 Silicon Graphics, Inc. * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved. * Author: Maciej W. Rozycki <macro@mips.com> @@ -103,8 +103,20 @@ */ extern const unsigned long mips_io_port_base; -#define set_io_port_base(base) \ - do { * (unsigned long *) &mips_io_port_base = (base); } while (0) +/* + * Gcc will generate code to load the value of mips_io_port_base after each + * function call which may be fairly wasteful in some cases. So we don't + * play quite by the book. We tell gcc mips_io_port_base is a long variable + * which solves the code generation issue. Now we need to violate the + * aliasing rules a little to make initialization possible and finally we + * will need the barrier() to fight side effects of the aliasing chat. + * This trickery will eventually collapse under gcc's optimizer. Oh well. + */ +static inline void set_io_port_base(unsigned long base) +{ + * (unsigned long *) &mips_io_port_base = base; + barrier(); +} /* * Thanks to James van Artsdalen for a better timing-fix than |