* [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden
@ 2020-03-27 16:06 John Garry
2020-03-27 16:06 ` [PATCH v2 1/3] io: Provide _inX() and _outX() John Garry
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: John Garry @ 2020-03-27 16:06 UTC (permalink / raw)
To: xuwei5, arnd
Cc: linux-arch, John Garry, okaya, linux-kernel, jiaxun.yang,
linuxarm, olof, bhelgaas, linux-arm-kernel
Since commits a7851aa54c0c ("io: change outX() to have their own IO
barrier overrides") and 87fe2d543f81 ("io: change inX() to have their own
IO barrier overrides"), the outX() and inX() functions have memory
barriers which can be overridden per-arch.
However, under CONFIG_INDIRECT_PIO, logic_pio defines its own version of
inX() and outX(), which still use readb et al. For these, the barrier
after a raw read is weaker than it otherwise would be.
This series generates consistent behaviour for logic_pio, by defining
generic _inX() and _outX() in asm-generic/io.h, and using those in
logic_pio. Generic _inX() and _outX() have per-arch overrideable
barriers.
The topic was discussed there originally:
https://lore.kernel.org/lkml/2e80d7bc-32a0-cc40-00a9-8a383a1966c2@huawei.com/
A small tidy-up patch is included.
I hope that series can go through the arm-soc tree, as with other recent
logic_pio changes.
Hi Arnd,
I added your tag, but please let me know if you have any issue with the
updated change in patch #1.
cheers
- Differences to v1
- fix x86 clang build by adding extra build swicth for _{in,out}X
- added Arnd's RB tag
John Garry (3):
io: Provide _inX() and _outX()
logic_pio: Improve macro argument name
logic_pio: Use _inX() and _outX()
include/asm-generic/io.h | 64 +++++++++++++++++++++++++++++++++---------------
lib/logic_pio.c | 22 ++++++++---------
2 files changed, 55 insertions(+), 31 deletions(-)
--
2.16.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/3] io: Provide _inX() and _outX()
2020-03-27 16:06 [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden John Garry
@ 2020-03-27 16:06 ` John Garry
2020-03-27 16:06 ` [PATCH v2 2/3] logic_pio: Improve macro argument name John Garry
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: John Garry @ 2020-03-27 16:06 UTC (permalink / raw)
To: xuwei5, arnd
Cc: linux-arch, John Garry, okaya, linux-kernel, jiaxun.yang,
linuxarm, olof, bhelgaas, linux-arm-kernel
Since commit a7851aa54c0c ("io: change outX() to have their own IO barrier
overrides") and commit 87fe2d543f81 ("io: change inX() to have their own
IO barrier overrides"), the outX and inX functions have memory barriers
which can be overridden.
However, the generic logic_pio lib has continued to use readl/writel et al
for IO port accesses, which has weaker barriers on arm64.
Provide generic _inX() and _outX(), which can be used by logic pio.
For consistency, we check for !defined({in,out}X) && !defined(_{in,out}X),
for defining _{in,out}X, while a check for just !defined({in,out}X) should
suffice.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Garry <john.garry@huawei.com>
---
include/asm-generic/io.h | 64 +++++++++++++++++++++++++++++++++---------------
1 file changed, 44 insertions(+), 20 deletions(-)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index d39ac997dda8..3a7871130112 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -448,17 +448,15 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
#define IO_SPACE_LIMIT 0xffff
#endif
-#include <linux/logic_pio.h>
-
/*
* {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be
* implemented on hardware that needs an additional delay for I/O accesses to
* take effect.
*/
-#ifndef inb
-#define inb inb
-static inline u8 inb(unsigned long addr)
+#if !defined(inb) && !defined(_inb)
+#define _inb _inb
+static inline u16 _inb(unsigned long addr)
{
u8 val;
@@ -469,9 +467,9 @@ static inline u8 inb(unsigned long addr)
}
#endif
-#ifndef inw
-#define inw inw
-static inline u16 inw(unsigned long addr)
+#if !defined(inw) && !defined(_inw)
+#define _inw _inw
+static inline u16 _inw(unsigned long addr)
{
u16 val;
@@ -482,9 +480,9 @@ static inline u16 inw(unsigned long addr)
}
#endif
-#ifndef inl
-#define inl inl
-static inline u32 inl(unsigned long addr)
+#if !defined(inl) && !defined(_inl)
+#define _inl _inl
+static inline u16 _inl(unsigned long addr)
{
u32 val;
@@ -495,9 +493,9 @@ static inline u32 inl(unsigned long addr)
}
#endif
-#ifndef outb
-#define outb outb
-static inline void outb(u8 value, unsigned long addr)
+#if !defined(outb) && !defined(_outb)
+#define _outb _outb
+static inline void _outb(u8 value, unsigned long addr)
{
__io_pbw();
__raw_writeb(value, PCI_IOBASE + addr);
@@ -505,9 +503,9 @@ static inline void outb(u8 value, unsigned long addr)
}
#endif
-#ifndef outw
-#define outw outw
-static inline void outw(u16 value, unsigned long addr)
+#if !defined(outw) && !defined(_outw)
+#define _outw _outw
+static inline void _outw(u16 value, unsigned long addr)
{
__io_pbw();
__raw_writew(cpu_to_le16(value), PCI_IOBASE + addr);
@@ -515,9 +513,9 @@ static inline void outw(u16 value, unsigned long addr)
}
#endif
-#ifndef outl
-#define outl outl
-static inline void outl(u32 value, unsigned long addr)
+#if !defined(outl) && !defined(_outl)
+#define _outl _outl
+static inline void _outl(u32 value, unsigned long addr)
{
__io_pbw();
__raw_writel(cpu_to_le32(value), PCI_IOBASE + addr);
@@ -525,6 +523,32 @@ static inline void outl(u32 value, unsigned long addr)
}
#endif
+#include <linux/logic_pio.h>
+
+#ifndef inb
+#define inb _inb
+#endif
+
+#ifndef inw
+#define inw _inw
+#endif
+
+#ifndef inl
+#define inl _inl
+#endif
+
+#ifndef outb
+#define outb _outb
+#endif
+
+#ifndef outw
+#define outw _outw
+#endif
+
+#ifndef outl
+#define outl _outl
+#endif
+
#ifndef inb_p
#define inb_p inb_p
static inline u8 inb_p(unsigned long addr)
--
2.16.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] logic_pio: Improve macro argument name
2020-03-27 16:06 [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden John Garry
2020-03-27 16:06 ` [PATCH v2 1/3] io: Provide _inX() and _outX() John Garry
@ 2020-03-27 16:06 ` John Garry
2020-03-27 16:06 ` [PATCH v2 3/3] logic_pio: Use _inX() and _outX() John Garry
2020-05-15 7:07 ` [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden Wei Xu
3 siblings, 0 replies; 5+ messages in thread
From: John Garry @ 2020-03-27 16:06 UTC (permalink / raw)
To: xuwei5, arnd
Cc: linux-arch, John Garry, okaya, linux-kernel, jiaxun.yang,
linuxarm, olof, bhelgaas, linux-arm-kernel
Macro argument "bw" is used for building byte, word, and long-based
functions. Use "bwl" instead, to include long.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Garry <john.garry@huawei.com>
---
lib/logic_pio.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/logic_pio.c b/lib/logic_pio.c
index f511a99bb389..21dc731bec88 100644
--- a/lib/logic_pio.c
+++ b/lib/logic_pio.c
@@ -229,13 +229,13 @@ unsigned long logic_pio_trans_cpuaddr(resource_size_t addr)
}
#if defined(CONFIG_INDIRECT_PIO) && defined(PCI_IOBASE)
-#define BUILD_LOGIC_IO(bw, type) \
-type logic_in##bw(unsigned long addr) \
+#define BUILD_LOGIC_IO(bwl, type) \
+type logic_in##bwl(unsigned long addr) \
{ \
type ret = (type)~0; \
\
if (addr < MMIO_UPPER_LIMIT) { \
- ret = read##bw(PCI_IOBASE + addr); \
+ ret = read##bwl(PCI_IOBASE + addr); \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \
\
@@ -248,10 +248,10 @@ type logic_in##bw(unsigned long addr) \
return ret; \
} \
\
-void logic_out##bw(type value, unsigned long addr) \
+void logic_out##bwl(type value, unsigned long addr) \
{ \
if (addr < MMIO_UPPER_LIMIT) { \
- write##bw(value, PCI_IOBASE + addr); \
+ write##bwl(value, PCI_IOBASE + addr); \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \
\
@@ -263,11 +263,11 @@ void logic_out##bw(type value, unsigned long addr) \
} \
} \
\
-void logic_ins##bw(unsigned long addr, void *buffer, \
- unsigned int count) \
+void logic_ins##bwl(unsigned long addr, void *buffer, \
+ unsigned int count) \
{ \
if (addr < MMIO_UPPER_LIMIT) { \
- reads##bw(PCI_IOBASE + addr, buffer, count); \
+ reads##bwl(PCI_IOBASE + addr, buffer, count); \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \
\
@@ -280,11 +280,11 @@ void logic_ins##bw(unsigned long addr, void *buffer, \
\
} \
\
-void logic_outs##bw(unsigned long addr, const void *buffer, \
- unsigned int count) \
+void logic_outs##bwl(unsigned long addr, const void *buffer, \
+ unsigned int count) \
{ \
if (addr < MMIO_UPPER_LIMIT) { \
- writes##bw(PCI_IOBASE + addr, buffer, count); \
+ writes##bwl(PCI_IOBASE + addr, buffer, count); \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \
\
--
2.16.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] logic_pio: Use _inX() and _outX()
2020-03-27 16:06 [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden John Garry
2020-03-27 16:06 ` [PATCH v2 1/3] io: Provide _inX() and _outX() John Garry
2020-03-27 16:06 ` [PATCH v2 2/3] logic_pio: Improve macro argument name John Garry
@ 2020-03-27 16:06 ` John Garry
2020-05-15 7:07 ` [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden Wei Xu
3 siblings, 0 replies; 5+ messages in thread
From: John Garry @ 2020-03-27 16:06 UTC (permalink / raw)
To: xuwei5, arnd
Cc: linux-arch, John Garry, okaya, linux-kernel, jiaxun.yang,
linuxarm, olof, bhelgaas, linux-arm-kernel
Use _inX() and _outX(), which include memory barriers which may be
overridden per arch.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Garry <john.garry@huawei.com>
---
lib/logic_pio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/logic_pio.c b/lib/logic_pio.c
index 21dc731bec88..f32fe481b492 100644
--- a/lib/logic_pio.c
+++ b/lib/logic_pio.c
@@ -235,7 +235,7 @@ type logic_in##bwl(unsigned long addr) \
type ret = (type)~0; \
\
if (addr < MMIO_UPPER_LIMIT) { \
- ret = read##bwl(PCI_IOBASE + addr); \
+ ret = _in##bwl(addr); \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \
\
@@ -251,7 +251,7 @@ type logic_in##bwl(unsigned long addr) \
void logic_out##bwl(type value, unsigned long addr) \
{ \
if (addr < MMIO_UPPER_LIMIT) { \
- write##bwl(value, PCI_IOBASE + addr); \
+ _out##bwl(value, addr); \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \
\
--
2.16.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden
2020-03-27 16:06 [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden John Garry
` (2 preceding siblings ...)
2020-03-27 16:06 ` [PATCH v2 3/3] logic_pio: Use _inX() and _outX() John Garry
@ 2020-05-15 7:07 ` Wei Xu
3 siblings, 0 replies; 5+ messages in thread
From: Wei Xu @ 2020-05-15 7:07 UTC (permalink / raw)
To: John Garry, xuwei5, arnd
Cc: linux-arch, okaya, linux-kernel, jiaxun.yang, linuxarm, olof,
bhelgaas, linux-arm-kernel
Hi John,
On 2020/3/28 0:06, John Garry wrote:
> Since commits a7851aa54c0c ("io: change outX() to have their own IO
> barrier overrides") and 87fe2d543f81 ("io: change inX() to have their own
> IO barrier overrides"), the outX() and inX() functions have memory
> barriers which can be overridden per-arch.
>
> However, under CONFIG_INDIRECT_PIO, logic_pio defines its own version of
> inX() and outX(), which still use readb et al. For these, the barrier
> after a raw read is weaker than it otherwise would be.
>
> This series generates consistent behaviour for logic_pio, by defining
> generic _inX() and _outX() in asm-generic/io.h, and using those in
> logic_pio. Generic _inX() and _outX() have per-arch overrideable
> barriers.
>
> The topic was discussed there originally:
> https://lore.kernel.org/lkml/2e80d7bc-32a0-cc40-00a9-8a383a1966c2@huawei.com/
>
> A small tidy-up patch is included.
>
> I hope that series can go through the arm-soc tree, as with other recent
> logic_pio changes.
>
> Hi Arnd,
>
> I added your tag, but please let me know if you have any issue with the
> updated change in patch #1.
>
> cheers
>
> - Differences to v1
> - fix x86 clang build by adding extra build swicth for _{in,out}X
> - added Arnd's RB tag
>
> John Garry (3):
> io: Provide _inX() and _outX()
> logic_pio: Improve macro argument name
> logic_pio: Use _inX() and _outX()
>
> include/asm-generic/io.h | 64 +++++++++++++++++++++++++++++++++---------------
> lib/logic_pio.c | 22 ++++++++---------
> 2 files changed, 55 insertions(+), 31 deletions(-)
>
Thanks!
Series applied to the hisilicon SoC tree.
Best Regards,
Wei
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-05-15 7:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 16:06 [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden John Garry
2020-03-27 16:06 ` [PATCH v2 1/3] io: Provide _inX() and _outX() John Garry
2020-03-27 16:06 ` [PATCH v2 2/3] logic_pio: Improve macro argument name John Garry
2020-03-27 16:06 ` [PATCH v2 3/3] logic_pio: Use _inX() and _outX() John Garry
2020-05-15 7:07 ` [PATCH v2 0/3] io.h, logic_pio: Allow barriers for inX() and outX() be overridden Wei Xu
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).