public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] alpha: Use generic <asm-generic/io.h>
@ 2022-08-18  9:20 Linus Walleij
  2022-08-18 10:28 ` Arnd Bergmann
  2022-10-02 22:45 ` Guenter Roeck
  0 siblings, 2 replies; 14+ messages in thread
From: Linus Walleij @ 2022-08-18  9:20 UTC (permalink / raw)
  To: Richard Henderson, Ivan Kokshaysky, Matt Turner, Arnd Bergmann
  Cc: linux-alpha, Linus Walleij, kernel test robot, Mark Brown,
	linux-arch

This enables the alpha to use <asm-generic/io.h> to fill in the
missing (undefined) I/O accessor functions.

This is needed if Alpha ever wants to uses CONFIG_REGMAP_MMIO
which has been patches to use accelerated _noinc accessors
such as readsq/writesq that Alpha, while being a 64bit platform,
as of now not yet provide. readq/writeq is however provided
so the machine can do 64bit I/O.

This comes with the requirement that everything the architecture
already provides needs to be defined, rather than just being,
say, static inline functions.

Bite the bullet and just provide the definitions and make it work.

Alternative approaches:

- Implement proper readsq/writesq inline accessors for alpha
- Rewrite the whole world of io.h to use something like __weak
  instead of relying on defines
- Leave regmap MMIO broken on Alpha because none of its drivers
  use it
- Make regmap MMIO depend of !ARCH_ALPHA

The latter seems a bit over the top. First option to implement
readsq/writesq seems possible but I cannot test it (no hardware)
so using the generic fallbacks seems like a better idea, also in
general that will provide future defaults for accelerated defines.

Leaving regmap MMIO broken or disabling it for Alpha feels bad
because it breaks compiler coverage.

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/linux-mm/202208181447.G9FLcMkI-lkp@intel.com/
Cc: Mark Brown <broonie@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-arch@vger.kernel.org
Cc: linux-alpha@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
I'd like this applied to the alpha tree if there is such a
thing otherwise maybe Arnd can apply it to the arch generic
tree?
---
 arch/alpha/include/asm/io.h | 76 ++++++++++++++++++++++++++++++++-----
 1 file changed, 66 insertions(+), 10 deletions(-)

diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index d277189b2677..53f1312d394e 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -586,22 +586,78 @@ extern void outsl (unsigned long port, const void *src, unsigned long count);
 #endif
 #define RTC_ALWAYS_BCD	0
 
-/*
- * Some mucking forons use if[n]def writeq to check if platform has it.
- * It's a bloody bad idea and we probably want ARCH_HAS_WRITEQ for them
- * to play with; for now just use cpp anti-recursion logics and make sure
- * that damn thing is defined and expands to itself.
- */
-
-#define writeq writeq
-#define readq readq
-
 /*
  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  * access
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
+/*
+ * These defines are necessary to use the generic io.h for filling in
+ * the missing parts of the API contract. This is because the platform
+ * uses (inline) functions rather than defines and the generic helper
+ * fills in the undefined.
+ */
+#define virt_to_phys virt_to_phys
+#define phys_to_virt phys_to_virt
+#define memset_io memset_io
+#define memcpy_fromio memcpy_fromio
+#define memcpy_toio memcpy_toio
+#define __raw_readb __raw_readb
+#define __raw_readw __raw_readw
+#define __raw_readl __raw_readl
+#define __raw_readq __raw_readq
+#define __raw_writeb __raw_writeb
+#define __raw_writew __raw_writew
+#define __raw_writel __raw_writel
+#define __raw_writeq __raw_writeq
+#define readb readb
+#define readw readw
+#define readl readl
+#define readq readq
+#define writeb writeb
+#define writew writew
+#define writel writel
+#define writeq writeq
+#define readb_relaxed readb_relaxed
+#define readw_relaxed readw_relaxed
+#define readl_relaxed readl_relaxed
+#define readq_relaxed readq_relaxed
+/* Relaxed writes are already defines */
+#define ioport_map ioport_map
+#define ioport_unmap ioport_unmap
+#define inb inb
+#define inw inw
+#define inl inl
+#define outb outb
+#define outw outw
+#define outl outl
+#define insb insb
+#define insw insw
+#define insl insl
+#define outsb outsb
+#define outsw outsw
+#define outsl outsl
+#define ioread8 ioread8
+#define ioread16 ioread16
+#define ioread32 ioread32
+#define ioread64 ioread64
+#define iowrite8 iowrite8
+#define iowrite16 iowrite16
+#define iowrite32 iowrite32
+#define iowrite64 iowrite64
+#define ioread64be ioread64be
+#define iowrite64be iowrite64be
+#define ioread8_rep ioread8_rep
+#define ioread16_rep ioread16_rep
+#define ioread32_rep ioread32_rep
+#define iowrite8_rep iowrite8_rep
+#define iowrite16_rep iowrite16_rep
+#define iowrite32_rep iowrite32_rep
+#define pci_iounmap pci_iounmap
+
+#include <asm-generic/io.h>
+
 #endif /* __KERNEL__ */
 
 #endif /* __ALPHA_IO_H */
-- 
2.37.2


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

end of thread, other threads:[~2022-10-13 12:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-18  9:20 [PATCH] alpha: Use generic <asm-generic/io.h> Linus Walleij
2022-08-18 10:28 ` Arnd Bergmann
2022-09-05 19:30   ` Linus Walleij
2022-09-05 20:52     ` Arnd Bergmann
2022-09-06 14:59       ` Matt Turner
2022-10-02 22:45 ` Guenter Roeck
2022-10-03 13:03   ` Arnd Bergmann
2022-10-03 15:07     ` Guenter Roeck
2022-10-03 18:49     ` Linus Walleij
2022-10-04 19:42     ` Guenter Roeck
2022-10-04 20:28       ` Arnd Bergmann
2022-10-12 14:05         ` Guenter Roeck
2022-10-12 15:32           ` Arnd Bergmann
2022-10-13 12:36             ` [PATCH] alpha: Use generic <asm-generic/io.h> #forregzbot Thorsten Leemhuis

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