mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] include: <io.h>: define (read|write)[bwlq]_relaxed
@ 2021-06-11  8:01 Ahmad Fatoum
  2021-06-11 11:30 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2021-06-11  8:01 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For Linux, It's always correct to substitute any of the read or
write _relaxed functions with their non relaxed counterpart.
Define functions that do this.

Unlike with Linux, they doesn't per se affect performance: barebox
writel doesn't imply memory barriers, instead it depends on
the architecture support to map IO memory regions as non-bufferable.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/clk/rockchip/clk.h        |  3 ---
 drivers/gpio/gpio-davinci.c       |  3 ---
 drivers/regulator/stm32-vrefbuf.c |  4 +---
 drivers/spi/atmel-quadspi.c       |  3 ---
 include/io.h                      | 32 +++++++++++++++++++++++++++++++
 5 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h
index 5b5bc8c23137..a3db88dfc890 100644
--- a/drivers/clk/rockchip/clk.h
+++ b/drivers/clk/rockchip/clk.h
@@ -21,9 +21,6 @@
 #include <linux/clk.h>
 #include <restart.h>
 
-#define writel_relaxed	writel
-#define readl_relaxed	readl
-
 #define HIWORD_UPDATE(val, mask, shift) \
 		((val) << (shift) | (mask) << ((shift) + 16))
 
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 20311d968b82..b4f217660691 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -13,9 +13,6 @@
 #include <io.h>
 #include <linux/err.h>
 
-#define readl_relaxed	readl
-#define writel_relaxed	writel
-
 struct davinci_gpio_regs {
 	u32	dir;
 	u32	out_data;
diff --git a/drivers/regulator/stm32-vrefbuf.c b/drivers/regulator/stm32-vrefbuf.c
index 3956b1f64f6e..77287c2b0e82 100644
--- a/drivers/regulator/stm32-vrefbuf.c
+++ b/drivers/regulator/stm32-vrefbuf.c
@@ -10,6 +10,7 @@
 #include <linux/clk.h>
 #include <linux/iopoll.h>
 #include <of.h>
+#include <io.h>
 #include <regulator.h>
 
 /* STM32 VREFBUF registers */
@@ -23,9 +24,6 @@
 
 #define STM32_VREFBUF_AUTO_SUSPEND_DELAY_MS	10
 
-#define readl_relaxed readl
-#define writel_relaxed writel
-
 struct stm32_vrefbuf {
 	void __iomem *base;
 	struct clk *clk;
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 6799f95ea33e..af2191726fe9 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -34,9 +34,6 @@
 #include <of_device.h>
 #include <linux/iopoll.h>
 
-#define writel_relaxed   writel
-#define readl_relaxed   readl
-
 /* QSPI register offsets */
 #define QSPI_CR      0x0000  /* Control Register */
 #define QSPI_MR      0x0004  /* Mode Register */
diff --git a/include/io.h b/include/io.h
index 79d8b56c4e3f..6a74246ea777 100644
--- a/include/io.h
+++ b/include/io.h
@@ -6,4 +6,36 @@
 
 #define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
 
+#ifndef readq_relaxed
+#define readq_relaxed(addr) readq(addr)
+#endif
+
+#ifndef readl_relaxed
+#define readl_relaxed(addr) readl(addr)
+#endif
+
+#ifndef readw_relaxed
+#define readw_relaxed(addr) readw(addr)
+#endif
+
+#ifndef readb_relaxed
+#define readb_relaxed(addr) readb(addr)
+#endif
+
+#ifndef writeq_relaxed
+#define writeq_relaxed(val, addr) writeq((val), (addr))
+#endif
+
+#ifndef writel_relaxed
+#define writel_relaxed(val, addr) writel((val), (addr))
+#endif
+
+#ifndef writew_relaxed
+#define writew_relaxed(val, addr) writew((val), (addr))
+#endif
+
+#ifndef writeb_relaxed
+#define writeb_relaxed(val, addr) writeb((val), (addr))
+#endif
+
 #endif /* __IO_H */
-- 
2.32.0.rc0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] include: <io.h>: define (read|write)[bwlq]_relaxed
  2021-06-11  8:01 [PATCH] include: <io.h>: define (read|write)[bwlq]_relaxed Ahmad Fatoum
@ 2021-06-11 11:30 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2021-06-11 11:30 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Fri, Jun 11, 2021 at 10:01:55AM +0200, Ahmad Fatoum wrote:
> For Linux, It's always correct to substitute any of the read or
> write _relaxed functions with their non relaxed counterpart.
> Define functions that do this.
> 
> Unlike with Linux, they doesn't per se affect performance: barebox
> writel doesn't imply memory barriers, instead it depends on
> the architecture support to map IO memory regions as non-bufferable.
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
>  drivers/clk/rockchip/clk.h        |  3 ---
>  drivers/gpio/gpio-davinci.c       |  3 ---
>  drivers/regulator/stm32-vrefbuf.c |  4 +---
>  drivers/spi/atmel-quadspi.c       |  3 ---
>  include/io.h                      | 32 +++++++++++++++++++++++++++++++
>  5 files changed, 33 insertions(+), 12 deletions(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-11 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11  8:01 [PATCH] include: <io.h>: define (read|write)[bwlq]_relaxed Ahmad Fatoum
2021-06-11 11:30 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox