forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
asm-generic: architecture independent readq/writeq for 32bit environment
This provides unified readq()/writeq() helper functions for 32-bit drivers. For some cases, readq/writeq without atomicity is harmful, and order of io access has to be specified explicitly. So in this patch, new two header files which contain non-atomic readq/writeq are added. - <asm-generic/io-64-nonatomic-lo-hi.h> provides non-atomic readq/ writeq with the order of lower address -> higher address - <asm-generic/io-64-nonatomic-hi-lo.h> provides non-atomic readq/ writeq with reversed order This allows us to remove some readq()s that were added drivers when the default non-atomic ones were removed in commit dbee8a0 ("x86: remove 32-bit versions of readq()/writeq()") The drivers which need readq/writeq but can do with the non-atomic ones must add the line: #include <asm-generic/io-64-nonatomic-lo-hi.h> /* or hi-lo.h */ But this will be nop in 64-bit environments, and no other #ifdefs are required. So I believe that this patch can solve the problem of 1. driver-specific readq/writeq 2. atomicity and order of io access This patch is tested with building allyesconfig and allmodconfig as ARCH=x86 and ARCH=i386 on top of tip/master. Cc: Kashyap Desai <[email protected]> Cc: Len Brown <[email protected]> Cc: Ravi Anand <[email protected]> Cc: Vikas Chaudhary <[email protected]> Cc: Matthew Garrett <[email protected]> Cc: Jason Uhlenkott <[email protected]> Cc: James Bottomley <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Roland Dreier <[email protected]> Cc: James Bottomley <[email protected]> Cc: Alan Cox <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Hitoshi Mitake <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
Showing
7 changed files
with
66 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef _ASM_IO_64_NONATOMIC_HI_LO_H_ | ||
#define _ASM_IO_64_NONATOMIC_HI_LO_H_ | ||
|
||
#include <linux/io.h> | ||
#include <asm-generic/int-ll64.h> | ||
|
||
#ifndef readq | ||
static inline __u64 readq(const volatile void __iomem *addr) | ||
{ | ||
const volatile u32 __iomem *p = addr; | ||
u32 low, high; | ||
|
||
high = readl(p + 1); | ||
low = readl(p); | ||
|
||
return low + ((u64)high << 32); | ||
} | ||
#endif | ||
|
||
#ifndef writeq | ||
static inline void writeq(__u64 val, volatile void __iomem *addr) | ||
{ | ||
writel(val >> 32, addr + 4); | ||
writel(val, addr); | ||
} | ||
#endif | ||
|
||
#endif /* _ASM_IO_64_NONATOMIC_HI_LO_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef _ASM_IO_64_NONATOMIC_LO_HI_H_ | ||
#define _ASM_IO_64_NONATOMIC_LO_HI_H_ | ||
|
||
#include <linux/io.h> | ||
#include <asm-generic/int-ll64.h> | ||
|
||
#ifndef readq | ||
static inline __u64 readq(const volatile void __iomem *addr) | ||
{ | ||
const volatile u32 __iomem *p = addr; | ||
u32 low, high; | ||
|
||
low = readl(p); | ||
high = readl(p + 1); | ||
|
||
return low + ((u64)high << 32); | ||
} | ||
#endif | ||
|
||
#ifndef writeq | ||
static inline void writeq(__u64 val, volatile void __iomem *addr) | ||
{ | ||
writel(val, addr); | ||
writel(val >> 32, addr + 4); | ||
} | ||
#endif | ||
|
||
#endif /* _ASM_IO_64_NONATOMIC_LO_HI_H_ */ |