linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib: 64bit IO
@ 2019-01-29 15:41 Vladimir Kondratiev
  2019-01-29 16:01 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Kondratiev @ 2019-01-29 15:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Linus Torvalds; +Cc: linux-kernel, Vladimir Kondratiev

implement missing io{read|write}64

For 64-bit platforms, these 64-bit io functions are defined in
include/asm-generic/iomap.h,
but actual implementation missing. Provide it.

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@linux.intel.com>
---
 lib/iomap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/lib/iomap.c b/lib/iomap.c
index 541d926da95e..5e2b0bcc5561 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -62,11 +62,17 @@ static void bad_io_access(unsigned long port, const char *access)
 #ifndef pio_read16be
 #define pio_read16be(port) swab16(inw(port))
 #define pio_read32be(port) swab32(inl(port))
+#ifdef CONFIG_64BIT
+#define pio_read64be(port) swab64(inq(port))
+#endif
 #endif
 
 #ifndef mmio_read16be
 #define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr))
 #define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr))
+#ifdef CONFIG_64BIT
+#define mmio_read64be(addr) be64_to_cpu(__raw_readq(addr))
+#endif
 #endif
 
 unsigned int ioread8(void __iomem *addr)
@@ -100,14 +106,38 @@ EXPORT_SYMBOL(ioread16be);
 EXPORT_SYMBOL(ioread32);
 EXPORT_SYMBOL(ioread32be);
 
+#ifdef CONFIG_64BIT
+
+u64 ioread64(void __iomem *addr)
+{
+	IO_COND(addr, return inq(port), return readq(addr));
+	return 0xffffffffffffffffULL;
+}
+EXPORT_SYMBOL(ioread64);
+
+u64 ioread64be(void __iomem *addr)
+{
+	IO_COND(addr, return pio_read64be(port), return mmio_read64be(addr));
+	return 0xffffffffffffffffULL;
+}
+EXPORT_SYMBOL(ioread64be);
+
+#endif /* CONFIG_64BIT */
+
 #ifndef pio_write16be
 #define pio_write16be(val,port) outw(swab16(val),port)
 #define pio_write32be(val,port) outl(swab32(val),port)
+#ifdef CONFIG_64BIT
+#define pio_write64be(val, port) outq(swab64(val), port)
+#endif
 #endif
 
 #ifndef mmio_write16be
 #define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port)
 #define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port)
+#ifdef CONFIG_64BIT
+#define mmio_write64be(val, port) __raw_writeq(be64_to_cpu(val), port)
+#endif
 #endif
 
 void iowrite8(u8 val, void __iomem *addr)
@@ -136,6 +166,22 @@ EXPORT_SYMBOL(iowrite16be);
 EXPORT_SYMBOL(iowrite32);
 EXPORT_SYMBOL(iowrite32be);
 
+#ifdef CONFIG_64BIT
+
+void iowrite64(u64 val, void __iomem *addr)
+{
+	IO_COND(addr, outq(val, port), writeq(val, addr));
+}
+EXPORT_SYMBOL(iowrite64);
+
+void iowrite64be(u64 val, void __iomem *addr)
+{
+	IO_COND(addr, pio_write64be(val, port), mmio_write64be(val, addr));
+}
+EXPORT_SYMBOL(iowrite64be);
+
+#endif /* CONFIG_64BIT */
+
 /*
  * These are the "repeat MMIO read/write" functions.
  * Note the "__raw" accesses, since we don't want to
-- 
2.19.1


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

* Re: [PATCH] lib: 64bit IO
  2019-01-29 15:41 [PATCH] lib: 64bit IO Vladimir Kondratiev
@ 2019-01-29 16:01 ` Greg Kroah-Hartman
  2019-01-30  7:56   ` Vladimir Kondratiev
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-01-29 16:01 UTC (permalink / raw)
  To: Vladimir Kondratiev; +Cc: Linus Torvalds, linux-kernel

On Tue, Jan 29, 2019 at 05:41:02PM +0200, Vladimir Kondratiev wrote:
> implement missing io{read|write}64
> 
> For 64-bit platforms, these 64-bit io functions are defined in
> include/asm-generic/iomap.h,
> but actual implementation missing. Provide it.

What is in include/asm-generic/io.h?

$ git grep iowrite64be | grep generic
include/asm-generic/io.h:#ifndef iowrite64be
include/asm-generic/io.h:#define iowrite64be iowrite64be
include/asm-generic/io.h:static inline void iowrite64be(u64 value, volatile void __iomem *addr)
include/asm-generic/iomap.h:extern void iowrite64be(u64, void __iomem *);

so are you sure this is needed?

What code is failing to build for you?

thanks,

greg k-h

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

* Re: [PATCH] lib: 64bit IO
  2019-01-29 16:01 ` Greg Kroah-Hartman
@ 2019-01-30  7:56   ` Vladimir Kondratiev
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Kondratiev @ 2019-01-30  7:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Linus Torvalds, linux-kernel



On 1/29/19 6:01 PM, Greg Kroah-Hartman wrote:
> On Tue, Jan 29, 2019 at 05:41:02PM +0200, Vladimir Kondratiev wrote:
>> implement missing io{read|write}64
>>
>> For 64-bit platforms, these 64-bit io functions are defined in
>> include/asm-generic/iomap.h,
>> but actual implementation missing. Provide it.
> 
> What is in include/asm-generic/io.h?
> 
> $ git grep iowrite64be | grep generic
> include/asm-generic/io.h:#ifndef iowrite64be
> include/asm-generic/io.h:#define iowrite64be iowrite64be
> include/asm-generic/io.h:static inline void iowrite64be(u64 value, volatile void __iomem *addr)
> include/asm-generic/iomap.h:extern void iowrite64be(u64, void __iomem *);
> 
> so are you sure this is needed?
> 
> What code is failing to build for you?

The code you mentioned is under
#ifndef CONFIG_GENERIC_IOMAP

i.e. it works for platforms that does not define CONFIG_GENERIC_IOMAP
This currently defined for quite a lot of platforms, all these should 
not use these inlines and use lib/iomap.c - it selected by the same 
symbol, from lib/Makefile:

obj-$(CONFIG_GENERIC_IOMAP) += iomap.o


linux$ git grep GENERIC_IOMAP | grep Kconfig
arch/hexagon/Kconfig:	select GENERIC_IOMAP
arch/ia64/Kconfig:	select GENERIC_IOMAP
arch/m68k/Kconfig:	select GENERIC_IOMAP
arch/mips/Kconfig:	select GENERIC_IOMAP
arch/openrisc/Kconfig:	select GENERIC_IOMAP
arch/powerpc/platforms/Kconfig:	select GENERIC_IOMAP
arch/unicore32/Kconfig:	select GENERIC_IOMAP
arch/x86/Kconfig:	select GENERIC_IOMAP
lib/Kconfig:config GENERIC_IOMAP

Actually, I am using 64-bit MIPS platform for now, and some pieces of 
code was not compiling without this patch; but this looks like code all 
platforms above need in order to use 64-bit transactions in 
"io{redd|write}xx" style

Also, I figured out most platforms does not bother providing PIO in 
64-bit quantities, so see below version 2 with MMIO-only implementation.

> 
> thanks,
> 
> greg k-h
> 


 From 7f0d31a7cdcc535e0248cb4c4cf8f1d16dc0133d Mon Sep 17 00:00:00 2001
From: Vladimir Kondratiev <vladimir.kondratiev@linux.intel.com>
Date: Thu, 24 Jan 2019 16:59:20 +0200
Subject: [PATCH v2] lib: 64bit IO

implement missing io{read|write}64

For 64-bit platforms, these 64-bit io functions are defined in
include/asm-generic/iomap.h,
but actual implementation missing. Provide it.
Most platforms does not provide 64-bit PIO functions, thus
implement 64-bit transactions as MMIO only

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@linux.intel.com>
---
  lib/iomap.c | 38 ++++++++++++++++++++++++++++++++++++++
  1 file changed, 38 insertions(+)

diff --git a/lib/iomap.c b/lib/iomap.c
index 541d926da95e..86501bccdf72 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -67,6 +67,9 @@ static void bad_io_access(unsigned long port, const 
char *access)
  #ifndef mmio_read16be
  #define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr))
  #define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr))
+#ifdef CONFIG_64BIT
+#define mmio_read64be(addr) be64_to_cpu(__raw_readq(addr))
+#endif
  #endif

  unsigned int ioread8(void __iomem *addr)
@@ -100,6 +103,22 @@ EXPORT_SYMBOL(ioread16be);
  EXPORT_SYMBOL(ioread32);
  EXPORT_SYMBOL(ioread32be);

+#ifdef CONFIG_64BIT
+
+u64 ioread64(void __iomem *addr)
+{
+	return readq(addr);
+}
+EXPORT_SYMBOL(ioread64);
+
+u64 ioread64be(void __iomem *addr)
+{
+	return mmio_read64be(addr);
+}
+EXPORT_SYMBOL(ioread64be);
+
+#endif /* CONFIG_64BIT */
+
  #ifndef pio_write16be
  #define pio_write16be(val,port) outw(swab16(val),port)
  #define pio_write32be(val,port) outl(swab32(val),port)
@@ -108,6 +127,9 @@ EXPORT_SYMBOL(ioread32be);
  #ifndef mmio_write16be
  #define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port)
  #define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port)
+#ifdef CONFIG_64BIT
+#define mmio_write64be(val, port) __raw_writeq(be64_to_cpu(val), port)
+#endif
  #endif

  void iowrite8(u8 val, void __iomem *addr)
@@ -136,6 +158,22 @@ EXPORT_SYMBOL(iowrite16be);
  EXPORT_SYMBOL(iowrite32);
  EXPORT_SYMBOL(iowrite32be);

+#ifdef CONFIG_64BIT
+
+void iowrite64(u64 val, void __iomem *addr)
+{
+	writeq(val, addr);
+}
+EXPORT_SYMBOL(iowrite64);
+
+void iowrite64be(u64 val, void __iomem *addr)
+{
+	mmio_write64be(val, addr);
+}
+EXPORT_SYMBOL(iowrite64be);
+
+#endif /* CONFIG_64BIT */
+
  /*
   * These are the "repeat MMIO read/write" functions.
   * Note the "__raw" accesses, since we don't want to
-- 
2.19.1

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

end of thread, other threads:[~2019-01-30  7:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 15:41 [PATCH] lib: 64bit IO Vladimir Kondratiev
2019-01-29 16:01 ` Greg Kroah-Hartman
2019-01-30  7:56   ` Vladimir Kondratiev

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).