All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h
@ 2017-06-30 17:09 Andy Shevchenko
  2017-06-30 17:09   ` Andy Shevchenko
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

The series brings a bit of order to arch/x86/include/asm/io.h by re-using
definitions in the generic header.

The series has been tested on Intel Broxton hardware in 32- and 64-bit modes.

Since v2:
- add cleanup patches in accordance to re-use what's defined in generic header
- split to few patches
- hopefully nail down an issue kbuild bot complained about
- append tags (Wolfram)

Andy Shevchenko (5):
  x86/io: Define IO accessors by preprocessor
  x86/io: Include asm-generic/io.h to architectural code
  x86/io: Remove mem*io() duplications
  x86/io: Remove xlate_dev_kmem_ptr() duplication
  x86/io: Make readq() / writeq() API consistent

 arch/x86/include/asm/io.h | 98 +++++++++++++++++++++++------------------------
 include/asm-generic/io.h  | 27 +++++++++++++
 2 files changed, 74 insertions(+), 51 deletions(-)

-- 
2.11.0

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

* [PATCH v2 1/5] x86/io: Define IO accessors by preprocessor
  2017-06-30 17:09 [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko
@ 2017-06-30 17:09   ` Andy Shevchenko
  2017-06-30 17:09   ` Andy Shevchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

As a preparatory to use generic IO accessor helpers we need to define
architecture dependent functions via preprocessor to let world know we
have them.

Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 7afb0e2f07f4..c1c0880768f7 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -69,6 +69,9 @@ build_mmio_write(__writeb, "b", unsigned char, "q", )
 build_mmio_write(__writew, "w", unsigned short, "r", )
 build_mmio_write(__writel, "l", unsigned int, "r", )
 
+#define readb readb
+#define readw readw
+#define readl readl
 #define readb_relaxed(a) __readb(a)
 #define readw_relaxed(a) __readw(a)
 #define readl_relaxed(a) __readl(a)
@@ -76,6 +79,9 @@ build_mmio_write(__writel, "l", unsigned int, "r", )
 #define __raw_readw __readw
 #define __raw_readl __readl
 
+#define writeb writeb
+#define writew writew
+#define writel writel
 #define writeb_relaxed(v, a) __writeb(v, a)
 #define writew_relaxed(v, a) __writew(v, a)
 #define writel_relaxed(v, a) __writel(v, a)
@@ -119,6 +125,7 @@ static inline phys_addr_t virt_to_phys(volatile void *address)
 {
 	return __pa(address);
 }
+#define virt_to_phys virt_to_phys
 
 /**
  *	phys_to_virt	-	map physical address to virtual
@@ -137,6 +144,7 @@ static inline void *phys_to_virt(phys_addr_t address)
 {
 	return __va(address);
 }
+#define phys_to_virt phys_to_virt
 
 /*
  * Change "struct page" to physical address.
@@ -169,11 +177,14 @@ static inline unsigned int isa_virt_to_bus(volatile void *address)
  * else, you probably want one of the following.
  */
 extern void __iomem *ioremap_nocache(resource_size_t offset, unsigned long size);
+#define ioremap_nocache ioremap_nocache
 extern void __iomem *ioremap_uc(resource_size_t offset, unsigned long size);
 #define ioremap_uc ioremap_uc
 
 extern void __iomem *ioremap_cache(resource_size_t offset, unsigned long size);
+#define ioremap_cache ioremap_cache
 extern void __iomem *ioremap_prot(resource_size_t offset, unsigned long size, unsigned long prot_val);
+#define ioremap_prot ioremap_prot
 
 /**
  * ioremap     -   map bus memory into CPU space
@@ -193,8 +204,10 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
 {
 	return ioremap_nocache(offset, size);
 }
+#define ioremap ioremap
 
 extern void iounmap(volatile void __iomem *addr);
+#define iounmap iounmap
 
 extern void set_iounmap_nonlazy(void);
 
@@ -220,6 +233,7 @@ memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
 {
 	memset((void __force *)addr, val, count);
 }
+#define memset_io(dst,c,count) memset_io(dst,c,count)
 
 /**
  * memcpy_fromio	Copy a block of data from I/O memory
@@ -234,6 +248,7 @@ memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
 {
 	memcpy(dst, (const void __force *)src, count);
 }
+#define memcpy_fromio(to,from,count) memcpy_fromio(to,from,count)
 
 /**
  * memcpy_toio		Copy a block of data into I/O memory
@@ -248,6 +263,7 @@ memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
 {
 	memcpy((void __force *)dst, src, count);
 }
+#define memcpy_toio(to,from,count) memcpy_toio(to,from,count)
 
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
@@ -341,13 +357,38 @@ BUILDIO(b, b, char)
 BUILDIO(w, w, short)
 BUILDIO(l, , int)
 
+#define inb inb
+#define inw inw
+#define inl inl
+#define inb_p inb_p
+#define inw_p inw_p
+#define inl_p inl_p
+#define insb insb
+#define insw insw
+#define insl insl
+
+#define outb outb
+#define outw outw
+#define outl outl
+#define outb_p outb_p
+#define outw_p outw_p
+#define outl_p outl_p
+#define outsb outsb
+#define outsw outsw
+#define outsl outsl
+
 extern void *xlate_dev_mem_ptr(phys_addr_t phys);
 extern void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
 
+#define xlate_dev_mem_ptr xlate_dev_mem_ptr
+#define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
+
 extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
 				enum page_cache_mode pcm);
 extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size);
+#define ioremap_wc ioremap_wc
 extern void __iomem *ioremap_wt(resource_size_t offset, unsigned long size);
+#define ioremap_wt ioremap_wt
 
 extern bool is_early_ioremap_ptep(pte_t *ptep);
 
-- 
2.11.0

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

* [PATCH v2 1/5] x86/io: Define IO accessors by preprocessor
@ 2017-06-30 17:09   ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

As a preparatory to use generic IO accessor helpers we need to define
architecture dependent functions via preprocessor to let world know we
have them.

Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 7afb0e2f07f4..c1c0880768f7 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -69,6 +69,9 @@ build_mmio_write(__writeb, "b", unsigned char, "q", )
 build_mmio_write(__writew, "w", unsigned short, "r", )
 build_mmio_write(__writel, "l", unsigned int, "r", )
 
+#define readb readb
+#define readw readw
+#define readl readl
 #define readb_relaxed(a) __readb(a)
 #define readw_relaxed(a) __readw(a)
 #define readl_relaxed(a) __readl(a)
@@ -76,6 +79,9 @@ build_mmio_write(__writel, "l", unsigned int, "r", )
 #define __raw_readw __readw
 #define __raw_readl __readl
 
+#define writeb writeb
+#define writew writew
+#define writel writel
 #define writeb_relaxed(v, a) __writeb(v, a)
 #define writew_relaxed(v, a) __writew(v, a)
 #define writel_relaxed(v, a) __writel(v, a)
@@ -119,6 +125,7 @@ static inline phys_addr_t virt_to_phys(volatile void *address)
 {
 	return __pa(address);
 }
+#define virt_to_phys virt_to_phys
 
 /**
  *	phys_to_virt	-	map physical address to virtual
@@ -137,6 +144,7 @@ static inline void *phys_to_virt(phys_addr_t address)
 {
 	return __va(address);
 }
+#define phys_to_virt phys_to_virt
 
 /*
  * Change "struct page" to physical address.
@@ -169,11 +177,14 @@ static inline unsigned int isa_virt_to_bus(volatile void *address)
  * else, you probably want one of the following.
  */
 extern void __iomem *ioremap_nocache(resource_size_t offset, unsigned long size);
+#define ioremap_nocache ioremap_nocache
 extern void __iomem *ioremap_uc(resource_size_t offset, unsigned long size);
 #define ioremap_uc ioremap_uc
 
 extern void __iomem *ioremap_cache(resource_size_t offset, unsigned long size);
+#define ioremap_cache ioremap_cache
 extern void __iomem *ioremap_prot(resource_size_t offset, unsigned long size, unsigned long prot_val);
+#define ioremap_prot ioremap_prot
 
 /**
  * ioremap     -   map bus memory into CPU space
@@ -193,8 +204,10 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
 {
 	return ioremap_nocache(offset, size);
 }
+#define ioremap ioremap
 
 extern void iounmap(volatile void __iomem *addr);
+#define iounmap iounmap
 
 extern void set_iounmap_nonlazy(void);
 
@@ -220,6 +233,7 @@ memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
 {
 	memset((void __force *)addr, val, count);
 }
+#define memset_io(dst,c,count) memset_io(dst,c,count)
 
 /**
  * memcpy_fromio	Copy a block of data from I/O memory
@@ -234,6 +248,7 @@ memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
 {
 	memcpy(dst, (const void __force *)src, count);
 }
+#define memcpy_fromio(to,from,count) memcpy_fromio(to,from,count)
 
 /**
  * memcpy_toio		Copy a block of data into I/O memory
@@ -248,6 +263,7 @@ memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
 {
 	memcpy((void __force *)dst, src, count);
 }
+#define memcpy_toio(to,from,count) memcpy_toio(to,from,count)
 
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
@@ -341,13 +357,38 @@ BUILDIO(b, b, char)
 BUILDIO(w, w, short)
 BUILDIO(l, , int)
 
+#define inb inb
+#define inw inw
+#define inl inl
+#define inb_p inb_p
+#define inw_p inw_p
+#define inl_p inl_p
+#define insb insb
+#define insw insw
+#define insl insl
+
+#define outb outb
+#define outw outw
+#define outl outl
+#define outb_p outb_p
+#define outw_p outw_p
+#define outl_p outl_p
+#define outsb outsb
+#define outsw outsw
+#define outsl outsl
+
 extern void *xlate_dev_mem_ptr(phys_addr_t phys);
 extern void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
 
+#define xlate_dev_mem_ptr xlate_dev_mem_ptr
+#define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
+
 extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
 				enum page_cache_mode pcm);
 extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size);
+#define ioremap_wc ioremap_wc
 extern void __iomem *ioremap_wt(resource_size_t offset, unsigned long size);
+#define ioremap_wt ioremap_wt
 
 extern bool is_early_ioremap_ptep(pte_t *ptep);
 
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH v2 2/5] x86/io: Include asm-generic/io.h to architectural code
  2017-06-30 17:09 [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko
@ 2017-06-30 17:09   ` Andy Shevchenko
  2017-06-30 17:09   ` Andy Shevchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

asm-generic/io.h defines few helpers which would be useful in the drivers,
such as writesb() and readsb().

Include it to the asm/io.h in architectural folder.

Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index c1c0880768f7..0558d81c177e 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -406,6 +406,9 @@ extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 
 #define IO_SPACE_LIMIT 0xffff
 
+#include <asm-generic/io.h>
+#undef PCI_IOBASE
+
 #ifdef CONFIG_MTRR
 extern int __must_check arch_phys_wc_index(int handle);
 #define arch_phys_wc_index arch_phys_wc_index
-- 
2.11.0

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

* [PATCH v2 2/5] x86/io: Include asm-generic/io.h to architectural code
@ 2017-06-30 17:09   ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

asm-generic/io.h defines few helpers which would be useful in the drivers,
such as writesb() and readsb().

Include it to the asm/io.h in architectural folder.

Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index c1c0880768f7..0558d81c177e 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -406,6 +406,9 @@ extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 
 #define IO_SPACE_LIMIT 0xffff
 
+#include <asm-generic/io.h>
+#undef PCI_IOBASE
+
 #ifdef CONFIG_MTRR
 extern int __must_check arch_phys_wc_index(int handle);
 #define arch_phys_wc_index arch_phys_wc_index
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH v2 3/5] x86/io: Remove mem*io() duplications
  2017-06-30 17:09 [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko
@ 2017-06-30 17:09   ` Andy Shevchenko
  2017-06-30 17:09   ` Andy Shevchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

Generic header defines memset_io, memcpy_fromio(). and memcpy_toio().

Reuse them from generic header and remove in x86 code.
Move the descriptions to the generic header as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 45 ---------------------------------------------
 include/asm-generic/io.h  | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 45 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 0558d81c177e..252434b00fdb 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -220,51 +220,6 @@ extern void set_iounmap_nonlazy(void);
  */
 #define xlate_dev_kmem_ptr(p)	p
 
-/**
- * memset_io	Set a range of I/O memory to a constant value
- * @addr:	The beginning of the I/O-memory range to set
- * @val:	The value to set the memory to
- * @count:	The number of bytes to set
- *
- * Set a range of I/O memory to a given value.
- */
-static inline void
-memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
-{
-	memset((void __force *)addr, val, count);
-}
-#define memset_io(dst,c,count) memset_io(dst,c,count)
-
-/**
- * memcpy_fromio	Copy a block of data from I/O memory
- * @dst:		The (RAM) destination for the copy
- * @src:		The (I/O memory) source for the data
- * @count:		The number of bytes to copy
- *
- * Copy a block of data from I/O memory.
- */
-static inline void
-memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
-{
-	memcpy(dst, (const void __force *)src, count);
-}
-#define memcpy_fromio(to,from,count) memcpy_fromio(to,from,count)
-
-/**
- * memcpy_toio		Copy a block of data into I/O memory
- * @dst:		The (I/O memory) destination for the copy
- * @src:		The (RAM) source for the data
- * @count:		The number of bytes to copy
- *
- * Copy a block of data to I/O memory.
- */
-static inline void
-memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
-{
-	memcpy((void __force *)dst, src, count);
-}
-#define memcpy_toio(to,from,count) memcpy_toio(to,from,count)
-
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
  * explicitly ioremap() it. The fact that the ISA IO space is mapped
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 7ef015eb3403..395afc829409 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -954,6 +954,14 @@ static inline void *bus_to_virt(unsigned long address)
 
 #ifndef memset_io
 #define memset_io memset_io
+/**
+ * memset_io	Set a range of I/O memory to a constant value
+ * @addr:	The beginning of the I/O-memory range to set
+ * @val:	The value to set the memory to
+ * @count:	The number of bytes to set
+ *
+ * Set a range of I/O memory to a given value.
+ */
 static inline void memset_io(volatile void __iomem *addr, int value,
 			     size_t size)
 {
@@ -963,6 +971,14 @@ static inline void memset_io(volatile void __iomem *addr, int value,
 
 #ifndef memcpy_fromio
 #define memcpy_fromio memcpy_fromio
+/**
+ * memcpy_fromio	Copy a block of data from I/O memory
+ * @dst:		The (RAM) destination for the copy
+ * @src:		The (I/O memory) source for the data
+ * @count:		The number of bytes to copy
+ *
+ * Copy a block of data from I/O memory.
+ */
 static inline void memcpy_fromio(void *buffer,
 				 const volatile void __iomem *addr,
 				 size_t size)
@@ -973,6 +989,14 @@ static inline void memcpy_fromio(void *buffer,
 
 #ifndef memcpy_toio
 #define memcpy_toio memcpy_toio
+/**
+ * memcpy_toio		Copy a block of data into I/O memory
+ * @dst:		The (I/O memory) destination for the copy
+ * @src:		The (RAM) source for the data
+ * @count:		The number of bytes to copy
+ *
+ * Copy a block of data to I/O memory.
+ */
 static inline void memcpy_toio(volatile void __iomem *addr, const void *buffer,
 			       size_t size)
 {
-- 
2.11.0

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

* [PATCH v2 3/5] x86/io: Remove mem*io() duplications
@ 2017-06-30 17:09   ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

Generic header defines memset_io, memcpy_fromio(). and memcpy_toio().

Reuse them from generic header and remove in x86 code.
Move the descriptions to the generic header as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 45 ---------------------------------------------
 include/asm-generic/io.h  | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 45 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 0558d81c177e..252434b00fdb 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -220,51 +220,6 @@ extern void set_iounmap_nonlazy(void);
  */
 #define xlate_dev_kmem_ptr(p)	p
 
-/**
- * memset_io	Set a range of I/O memory to a constant value
- * @addr:	The beginning of the I/O-memory range to set
- * @val:	The value to set the memory to
- * @count:	The number of bytes to set
- *
- * Set a range of I/O memory to a given value.
- */
-static inline void
-memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
-{
-	memset((void __force *)addr, val, count);
-}
-#define memset_io(dst,c,count) memset_io(dst,c,count)
-
-/**
- * memcpy_fromio	Copy a block of data from I/O memory
- * @dst:		The (RAM) destination for the copy
- * @src:		The (I/O memory) source for the data
- * @count:		The number of bytes to copy
- *
- * Copy a block of data from I/O memory.
- */
-static inline void
-memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
-{
-	memcpy(dst, (const void __force *)src, count);
-}
-#define memcpy_fromio(to,from,count) memcpy_fromio(to,from,count)
-
-/**
- * memcpy_toio		Copy a block of data into I/O memory
- * @dst:		The (I/O memory) destination for the copy
- * @src:		The (RAM) source for the data
- * @count:		The number of bytes to copy
- *
- * Copy a block of data to I/O memory.
- */
-static inline void
-memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
-{
-	memcpy((void __force *)dst, src, count);
-}
-#define memcpy_toio(to,from,count) memcpy_toio(to,from,count)
-
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
  * explicitly ioremap() it. The fact that the ISA IO space is mapped
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 7ef015eb3403..395afc829409 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -954,6 +954,14 @@ static inline void *bus_to_virt(unsigned long address)
 
 #ifndef memset_io
 #define memset_io memset_io
+/**
+ * memset_io	Set a range of I/O memory to a constant value
+ * @addr:	The beginning of the I/O-memory range to set
+ * @val:	The value to set the memory to
+ * @count:	The number of bytes to set
+ *
+ * Set a range of I/O memory to a given value.
+ */
 static inline void memset_io(volatile void __iomem *addr, int value,
 			     size_t size)
 {
@@ -963,6 +971,14 @@ static inline void memset_io(volatile void __iomem *addr, int value,
 
 #ifndef memcpy_fromio
 #define memcpy_fromio memcpy_fromio
+/**
+ * memcpy_fromio	Copy a block of data from I/O memory
+ * @dst:		The (RAM) destination for the copy
+ * @src:		The (I/O memory) source for the data
+ * @count:		The number of bytes to copy
+ *
+ * Copy a block of data from I/O memory.
+ */
 static inline void memcpy_fromio(void *buffer,
 				 const volatile void __iomem *addr,
 				 size_t size)
@@ -973,6 +989,14 @@ static inline void memcpy_fromio(void *buffer,
 
 #ifndef memcpy_toio
 #define memcpy_toio memcpy_toio
+/**
+ * memcpy_toio		Copy a block of data into I/O memory
+ * @dst:		The (I/O memory) destination for the copy
+ * @src:		The (RAM) source for the data
+ * @count:		The number of bytes to copy
+ *
+ * Copy a block of data to I/O memory.
+ */
 static inline void memcpy_toio(volatile void __iomem *addr, const void *buffer,
 			       size_t size)
 {
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH v2 4/5] x86/io: Remove xlate_dev_kmem_ptr() duplication
  2017-06-30 17:09 [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko
@ 2017-06-30 17:09   ` Andy Shevchenko
  2017-06-30 17:09   ` Andy Shevchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

Generic header defines xlate_dev_kmem_ptr().

Reuse it from generic header and remove in x86 code.
Move a description to the generic header as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 5 -----
 include/asm-generic/io.h  | 3 +++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 252434b00fdb..b3bba2f87e18 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -216,11 +216,6 @@ extern void set_iounmap_nonlazy(void);
 #include <asm-generic/iomap.h>
 
 /*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
-/*
  * ISA space is 'always mapped' on a typical x86 system, no need to
  * explicitly ioremap() it. The fact that the ISA IO space is mapped
  * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 395afc829409..b4531e3b2120 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -915,6 +915,9 @@ extern void ioport_unmap(void __iomem *p);
 #endif /* CONFIG_GENERIC_IOMAP */
 #endif /* CONFIG_HAS_IOPORT_MAP */
 
+/*
+ * Convert a virtual cached pointer to an uncached pointer
+ */
 #ifndef xlate_dev_kmem_ptr
 #define xlate_dev_kmem_ptr xlate_dev_kmem_ptr
 static inline void *xlate_dev_kmem_ptr(void *addr)
-- 
2.11.0

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

* [PATCH v2 4/5] x86/io: Remove xlate_dev_kmem_ptr() duplication
@ 2017-06-30 17:09   ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

Generic header defines xlate_dev_kmem_ptr().

Reuse it from generic header and remove in x86 code.
Move a description to the generic header as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 5 -----
 include/asm-generic/io.h  | 3 +++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 252434b00fdb..b3bba2f87e18 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -216,11 +216,6 @@ extern void set_iounmap_nonlazy(void);
 #include <asm-generic/iomap.h>
 
 /*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
-/*
  * ISA space is 'always mapped' on a typical x86 system, no need to
  * explicitly ioremap() it. The fact that the ISA IO space is mapped
  * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 395afc829409..b4531e3b2120 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -915,6 +915,9 @@ extern void ioport_unmap(void __iomem *p);
 #endif /* CONFIG_GENERIC_IOMAP */
 #endif /* CONFIG_HAS_IOPORT_MAP */
 
+/*
+ * Convert a virtual cached pointer to an uncached pointer
+ */
 #ifndef xlate_dev_kmem_ptr
 #define xlate_dev_kmem_ptr xlate_dev_kmem_ptr
 static inline void *xlate_dev_kmem_ptr(void *addr)
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH v2 5/5] x86/io: Make readq() / writeq() API consistent
  2017-06-30 17:09 [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko
@ 2017-06-30 17:09   ` Andy Shevchenko
  2017-06-30 17:09   ` Andy Shevchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

Despite the commit 93093d099e5d

	x86: provide readq()/writeq() on 32-bit too, complete

says
	...Also, map all the APIs to the strongest ordering variant. It's way
	too easy to mess such details up in drivers and the difference between
	"memory" and "" constrained asm() constructs is in the noise range.

we have for now only one user of this API (i.e. writeq_relaxed() in
drivers/hwtracing/intel_th/sth.c) on x86 and it does care about
"relaxed" part of it. Moreover 32-bit support has been removed from that
header, though appeared later in specific headers that emphasizes its
non-atomic context.

The rest should keep in mind consistent picture of __raw_IO() vs. IO()
vs. IO_relaxed() API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index b3bba2f87e18..9ada93f01524 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -94,13 +94,15 @@ build_mmio_write(__writel, "l", unsigned int, "r", )
 #ifdef CONFIG_X86_64
 
 build_mmio_read(readq, "q", unsigned long, "=r", :"memory")
+build_mmio_read(__readq, "q", unsigned long, "=r", )
 build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
+build_mmio_write(__writeq, "q", unsigned long, "r", )
 
-#define readq_relaxed(a)	readq(a)
-#define writeq_relaxed(v, a)	writeq(v, a)
+#define readq_relaxed(a)	__readq(a)
+#define writeq_relaxed(v, a)	__writeq(v, a)
 
-#define __raw_readq(a)		readq(a)
-#define __raw_writeq(val, addr)	writeq(val, addr)
+#define __raw_readq		__readq
+#define __raw_writeq		__writeq
 
 /* Let people know that we have them */
 #define readq			readq
-- 
2.11.0

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

* [PATCH v2 5/5] x86/io: Make readq() / writeq() API consistent
@ 2017-06-30 17:09   ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-06-30 17:09 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx
  Cc: Andy Shevchenko

Despite the commit 93093d099e5d

	x86: provide readq()/writeq() on 32-bit too, complete

says
	...Also, map all the APIs to the strongest ordering variant. It's way
	too easy to mess such details up in drivers and the difference between
	"memory" and "" constrained asm() constructs is in the noise range.

we have for now only one user of this API (i.e. writeq_relaxed() in
drivers/hwtracing/intel_th/sth.c) on x86 and it does care about
"relaxed" part of it. Moreover 32-bit support has been removed from that
header, though appeared later in specific headers that emphasizes its
non-atomic context.

The rest should keep in mind consistent picture of __raw_IO() vs. IO()
vs. IO_relaxed() API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/io.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index b3bba2f87e18..9ada93f01524 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -94,13 +94,15 @@ build_mmio_write(__writel, "l", unsigned int, "r", )
 #ifdef CONFIG_X86_64
 
 build_mmio_read(readq, "q", unsigned long, "=r", :"memory")
+build_mmio_read(__readq, "q", unsigned long, "=r", )
 build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
+build_mmio_write(__writeq, "q", unsigned long, "r", )
 
-#define readq_relaxed(a)	readq(a)
-#define writeq_relaxed(v, a)	writeq(v, a)
+#define readq_relaxed(a)	__readq(a)
+#define writeq_relaxed(v, a)	__writeq(v, a)
 
-#define __raw_readq(a)		readq(a)
-#define __raw_writeq(val, addr)	writeq(val, addr)
+#define __raw_readq		__readq
+#define __raw_writeq		__writeq
 
 /* Let people know that we have them */
 #define readq			readq
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✓ Fi.CI.BAT: success for x86/io: Rely on asm-generic/io.h
  2017-06-30 17:09 [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko
                   ` (4 preceding siblings ...)
  2017-06-30 17:09   ` Andy Shevchenko
@ 2017-06-30 17:29 ` Patchwork
  2017-07-18 15:52   ` Andy Shevchenko
  6 siblings, 0 replies; 19+ messages in thread
From: Patchwork @ 2017-06-30 17:29 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: intel-gfx

== Series Details ==

Series: x86/io: Rely on asm-generic/io.h
URL   : https://patchwork.freedesktop.org/series/26649/
State : success

== Summary ==

Series 26649v1 x86/io: Rely on asm-generic/io.h
https://patchwork.freedesktop.org/api/1.0/series/26649/revisions/1/mbox/

Test kms_pipe_crc_basic:
        Subgroup hang-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-pnv-d510) fdo#101597
        Subgroup suspend-read-crc-pipe-b:
                pass       -> DMESG-WARN (fi-byt-j1900) fdo#101516

fdo#101597 https://bugs.freedesktop.org/show_bug.cgi?id=101597
fdo#101516 https://bugs.freedesktop.org/show_bug.cgi?id=101516

fi-bdw-5557u     total:279  pass:264  dwarn:0   dfail:0   fail:3   skip:11  time:441s
fi-bdw-gvtdvm    total:279  pass:257  dwarn:8   dfail:0   fail:0   skip:14  time:426s
fi-blb-e6850     total:279  pass:224  dwarn:1   dfail:0   fail:0   skip:54  time:357s
fi-bsw-n3050     total:279  pass:239  dwarn:0   dfail:0   fail:3   skip:36  time:510s
fi-bxt-j4205     total:279  pass:256  dwarn:0   dfail:0   fail:3   skip:19  time:501s
fi-byt-j1900     total:279  pass:250  dwarn:1   dfail:0   fail:3   skip:24  time:484s
fi-byt-n2820     total:279  pass:246  dwarn:1   dfail:0   fail:3   skip:28  time:473s
fi-glk-2a        total:279  pass:256  dwarn:0   dfail:0   fail:3   skip:19  time:581s
fi-hsw-4770      total:279  pass:259  dwarn:0   dfail:0   fail:3   skip:16  time:432s
fi-hsw-4770r     total:279  pass:259  dwarn:0   dfail:0   fail:3   skip:16  time:414s
fi-ilk-650       total:279  pass:225  dwarn:0   dfail:0   fail:3   skip:50  time:417s
fi-ivb-3520m     total:279  pass:257  dwarn:0   dfail:0   fail:3   skip:18  time:486s
fi-ivb-3770      total:279  pass:257  dwarn:0   dfail:0   fail:3   skip:18  time:474s
fi-kbl-7500u     total:279  pass:257  dwarn:0   dfail:0   fail:3   skip:18  time:460s
fi-kbl-7560u     total:279  pass:264  dwarn:1   dfail:0   fail:3   skip:10  time:562s
fi-kbl-r         total:279  pass:256  dwarn:1   dfail:0   fail:3   skip:18  time:561s
fi-pnv-d510      total:279  pass:222  dwarn:2   dfail:0   fail:0   skip:55  time:559s
fi-skl-6260u     total:279  pass:265  dwarn:0   dfail:0   fail:3   skip:10  time:451s
fi-skl-6700hq    total:279  pass:219  dwarn:1   dfail:0   fail:33  skip:24  time:331s
fi-skl-6700k     total:279  pass:257  dwarn:0   dfail:0   fail:3   skip:18  time:467s
fi-skl-6770hq    total:279  pass:265  dwarn:0   dfail:0   fail:3   skip:10  time:472s
fi-skl-gvtdvm    total:279  pass:266  dwarn:0   dfail:0   fail:0   skip:13  time:435s
fi-snb-2520m     total:279  pass:247  dwarn:0   dfail:0   fail:3   skip:28  time:538s
fi-snb-2600      total:279  pass:246  dwarn:0   dfail:0   fail:3   skip:29  time:403s

6412bcb8e279d62b9d8ae2840712d6c85806369b drm-tip: 2017y-06m-30d-14h-56m-41s UTC integration manifest
5c9d6dc x86/io: Make readq() / writeq() API consistent
d47ceb1 x86/io: Remove xlate_dev_kmem_ptr() duplication
95a7ac2 x86/io: Remove mem*io() duplications
fb67a5d x86/io: Include asm-generic/io.h to architectural code
b34944e x86/io: Define IO accessors by preprocessor

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_5081/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h
  2017-06-30 17:09 [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko
@ 2017-07-18 15:52   ` Andy Shevchenko
  2017-06-30 17:09   ` Andy Shevchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-07-18 15:52 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx

On Fri, 2017-06-30 at 20:09 +0300, Andy Shevchenko wrote:
> The series brings a bit of order to arch/x86/include/asm/io.h by re-
> using
> definitions in the generic header.
> 
> The series has been tested on Intel Broxton hardware in 32- and 64-bit 
> modes.

Any comments?
Shall I resend this?

> 
> Since v2:
> - add cleanup patches in accordance to re-use what's defined in
> generic header
> - split to few patches
> - hopefully nail down an issue kbuild bot complained about
> - append tags (Wolfram)
> 
> Andy Shevchenko (5):
>   x86/io: Define IO accessors by preprocessor
>   x86/io: Include asm-generic/io.h to architectural code
>   x86/io: Remove mem*io() duplications
>   x86/io: Remove xlate_dev_kmem_ptr() duplication
>   x86/io: Make readq() / writeq() API consistent
> 
>  arch/x86/include/asm/io.h | 98 +++++++++++++++++++++++---------------
> ---------
>  include/asm-generic/io.h  | 27 +++++++++++++
>  2 files changed, 74 insertions(+), 51 deletions(-)
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h
@ 2017-07-18 15:52   ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-07-18 15:52 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Baolin Wang, wsa, linux-i2c, Mika Westerberg, intel-gfx

On Fri, 2017-06-30 at 20:09 +0300, Andy Shevchenko wrote:
> The series brings a bit of order to arch/x86/include/asm/io.h by re-
> using
> definitions in the generic header.
> 
> The series has been tested on Intel Broxton hardware in 32- and 64-bit 
> modes.

Any comments?
Shall I resend this?

> 
> Since v2:
> - add cleanup patches in accordance to re-use what's defined in
> generic header
> - split to few patches
> - hopefully nail down an issue kbuild bot complained about
> - append tags (Wolfram)
> 
> Andy Shevchenko (5):
>   x86/io: Define IO accessors by preprocessor
>   x86/io: Include asm-generic/io.h to architectural code
>   x86/io: Remove mem*io() duplications
>   x86/io: Remove xlate_dev_kmem_ptr() duplication
>   x86/io: Make readq() / writeq() API consistent
> 
>  arch/x86/include/asm/io.h | 98 +++++++++++++++++++++++---------------
> ---------
>  include/asm-generic/io.h  | 27 +++++++++++++
>  2 files changed, 74 insertions(+), 51 deletions(-)
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [tip:x86/asm] x86/io: Define IO accessors by preprocessor
  2017-06-30 17:09   ` Andy Shevchenko
  (?)
@ 2017-07-24 10:19   ` tip-bot for Andy Shevchenko
  -1 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Andy Shevchenko @ 2017-07-24 10:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, mingo, andriy.shevchenko, mika.westerberg,
	linux-kernel, peterz, wsa, baolin.wang, tglx, hpa

Commit-ID:  80b9ece1339374444f08da46fa2383019fcf4374
Gitweb:     http://git.kernel.org/tip/80b9ece1339374444f08da46fa2383019fcf4374
Author:     Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Fri, 30 Jun 2017 20:09:30 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 24 Jul 2017 11:18:20 +0200

x86/io: Define IO accessors by preprocessor

As a preparatory to use generic IO accessor helpers we need to define
architecture dependent functions via preprocessor to let world know we
have them.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Cc: Baolin Wang <baolin.wang@spreadtrum.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: intel-gfx@lists.freedesktop.org
Cc: linux-i2c@vger.kernel.org
Link: http://lkml.kernel.org/r/20170630170934.83028-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/io.h | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 7afb0e2..c1c0880 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -69,6 +69,9 @@ build_mmio_write(__writeb, "b", unsigned char, "q", )
 build_mmio_write(__writew, "w", unsigned short, "r", )
 build_mmio_write(__writel, "l", unsigned int, "r", )
 
+#define readb readb
+#define readw readw
+#define readl readl
 #define readb_relaxed(a) __readb(a)
 #define readw_relaxed(a) __readw(a)
 #define readl_relaxed(a) __readl(a)
@@ -76,6 +79,9 @@ build_mmio_write(__writel, "l", unsigned int, "r", )
 #define __raw_readw __readw
 #define __raw_readl __readl
 
+#define writeb writeb
+#define writew writew
+#define writel writel
 #define writeb_relaxed(v, a) __writeb(v, a)
 #define writew_relaxed(v, a) __writew(v, a)
 #define writel_relaxed(v, a) __writel(v, a)
@@ -119,6 +125,7 @@ static inline phys_addr_t virt_to_phys(volatile void *address)
 {
 	return __pa(address);
 }
+#define virt_to_phys virt_to_phys
 
 /**
  *	phys_to_virt	-	map physical address to virtual
@@ -137,6 +144,7 @@ static inline void *phys_to_virt(phys_addr_t address)
 {
 	return __va(address);
 }
+#define phys_to_virt phys_to_virt
 
 /*
  * Change "struct page" to physical address.
@@ -169,11 +177,14 @@ static inline unsigned int isa_virt_to_bus(volatile void *address)
  * else, you probably want one of the following.
  */
 extern void __iomem *ioremap_nocache(resource_size_t offset, unsigned long size);
+#define ioremap_nocache ioremap_nocache
 extern void __iomem *ioremap_uc(resource_size_t offset, unsigned long size);
 #define ioremap_uc ioremap_uc
 
 extern void __iomem *ioremap_cache(resource_size_t offset, unsigned long size);
+#define ioremap_cache ioremap_cache
 extern void __iomem *ioremap_prot(resource_size_t offset, unsigned long size, unsigned long prot_val);
+#define ioremap_prot ioremap_prot
 
 /**
  * ioremap     -   map bus memory into CPU space
@@ -193,8 +204,10 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
 {
 	return ioremap_nocache(offset, size);
 }
+#define ioremap ioremap
 
 extern void iounmap(volatile void __iomem *addr);
+#define iounmap iounmap
 
 extern void set_iounmap_nonlazy(void);
 
@@ -220,6 +233,7 @@ memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
 {
 	memset((void __force *)addr, val, count);
 }
+#define memset_io(dst,c,count) memset_io(dst,c,count)
 
 /**
  * memcpy_fromio	Copy a block of data from I/O memory
@@ -234,6 +248,7 @@ memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
 {
 	memcpy(dst, (const void __force *)src, count);
 }
+#define memcpy_fromio(to,from,count) memcpy_fromio(to,from,count)
 
 /**
  * memcpy_toio		Copy a block of data into I/O memory
@@ -248,6 +263,7 @@ memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
 {
 	memcpy((void __force *)dst, src, count);
 }
+#define memcpy_toio(to,from,count) memcpy_toio(to,from,count)
 
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
@@ -341,13 +357,38 @@ BUILDIO(b, b, char)
 BUILDIO(w, w, short)
 BUILDIO(l, , int)
 
+#define inb inb
+#define inw inw
+#define inl inl
+#define inb_p inb_p
+#define inw_p inw_p
+#define inl_p inl_p
+#define insb insb
+#define insw insw
+#define insl insl
+
+#define outb outb
+#define outw outw
+#define outl outl
+#define outb_p outb_p
+#define outw_p outw_p
+#define outl_p outl_p
+#define outsb outsb
+#define outsw outsw
+#define outsl outsl
+
 extern void *xlate_dev_mem_ptr(phys_addr_t phys);
 extern void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
 
+#define xlate_dev_mem_ptr xlate_dev_mem_ptr
+#define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
+
 extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
 				enum page_cache_mode pcm);
 extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size);
+#define ioremap_wc ioremap_wc
 extern void __iomem *ioremap_wt(resource_size_t offset, unsigned long size);
+#define ioremap_wt ioremap_wt
 
 extern bool is_early_ioremap_ptep(pte_t *ptep);
 

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

* [tip:x86/asm] x86/io: Include asm-generic/io.h to architectural code
  2017-06-30 17:09   ` Andy Shevchenko
  (?)
@ 2017-07-24 10:20   ` tip-bot for Andy Shevchenko
  -1 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Andy Shevchenko @ 2017-07-24 10:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, andriy.shevchenko, mika.westerberg, peterz, wsa,
	baolin.wang, mingo, torvalds, linux-kernel, tglx

Commit-ID:  3195201198aad06c151dcfcb09e2fff79b2fda0e
Gitweb:     http://git.kernel.org/tip/3195201198aad06c151dcfcb09e2fff79b2fda0e
Author:     Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Fri, 30 Jun 2017 20:09:31 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 24 Jul 2017 11:18:21 +0200

x86/io: Include asm-generic/io.h to architectural code

asm-generic/io.h defines few helpers which would be useful in the drivers,
such as writesb() and readsb().

Include it to the asm/io.h in architectural folder.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Cc: Baolin Wang <baolin.wang@spreadtrum.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: intel-gfx@lists.freedesktop.org
Cc: linux-i2c@vger.kernel.org
Link: http://lkml.kernel.org/r/20170630170934.83028-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/io.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index c1c0880..0558d81 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -406,6 +406,9 @@ extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 
 #define IO_SPACE_LIMIT 0xffff
 
+#include <asm-generic/io.h>
+#undef PCI_IOBASE
+
 #ifdef CONFIG_MTRR
 extern int __must_check arch_phys_wc_index(int handle);
 #define arch_phys_wc_index arch_phys_wc_index

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

* [tip:x86/asm] x86/io: Remove mem*io() duplications
  2017-06-30 17:09   ` Andy Shevchenko
  (?)
@ 2017-07-24 10:20   ` tip-bot for Andy Shevchenko
  -1 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Andy Shevchenko @ 2017-07-24 10:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, andriy.shevchenko, mingo, mika.westerberg, linux-kernel,
	baolin.wang, torvalds, peterz, tglx

Commit-ID:  c2327da06b33d8e1093ce2c28f395bc500d1b0d3
Gitweb:     http://git.kernel.org/tip/c2327da06b33d8e1093ce2c28f395bc500d1b0d3
Author:     Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Fri, 30 Jun 2017 20:09:32 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 24 Jul 2017 11:18:21 +0200

x86/io: Remove mem*io() duplications

Generic header defines memset_io, memcpy_fromio(). and memcpy_toio().

Reuse them from generic header and remove in x86 code.
Move the descriptions to the generic header as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Baolin Wang <baolin.wang@spreadtrum.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: intel-gfx@lists.freedesktop.org
Cc: linux-i2c@vger.kernel.org
Cc: wsa@the-dreams.de
Link: http://lkml.kernel.org/r/20170630170934.83028-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/io.h | 45 ---------------------------------------------
 include/asm-generic/io.h  | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 45 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 0558d81..252434b 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -220,51 +220,6 @@ extern void set_iounmap_nonlazy(void);
  */
 #define xlate_dev_kmem_ptr(p)	p
 
-/**
- * memset_io	Set a range of I/O memory to a constant value
- * @addr:	The beginning of the I/O-memory range to set
- * @val:	The value to set the memory to
- * @count:	The number of bytes to set
- *
- * Set a range of I/O memory to a given value.
- */
-static inline void
-memset_io(volatile void __iomem *addr, unsigned char val, size_t count)
-{
-	memset((void __force *)addr, val, count);
-}
-#define memset_io(dst,c,count) memset_io(dst,c,count)
-
-/**
- * memcpy_fromio	Copy a block of data from I/O memory
- * @dst:		The (RAM) destination for the copy
- * @src:		The (I/O memory) source for the data
- * @count:		The number of bytes to copy
- *
- * Copy a block of data from I/O memory.
- */
-static inline void
-memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
-{
-	memcpy(dst, (const void __force *)src, count);
-}
-#define memcpy_fromio(to,from,count) memcpy_fromio(to,from,count)
-
-/**
- * memcpy_toio		Copy a block of data into I/O memory
- * @dst:		The (I/O memory) destination for the copy
- * @src:		The (RAM) source for the data
- * @count:		The number of bytes to copy
- *
- * Copy a block of data to I/O memory.
- */
-static inline void
-memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
-{
-	memcpy((void __force *)dst, src, count);
-}
-#define memcpy_toio(to,from,count) memcpy_toio(to,from,count)
-
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
  * explicitly ioremap() it. The fact that the ISA IO space is mapped
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 7ef015e..395afc8 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -954,6 +954,14 @@ static inline void *bus_to_virt(unsigned long address)
 
 #ifndef memset_io
 #define memset_io memset_io
+/**
+ * memset_io	Set a range of I/O memory to a constant value
+ * @addr:	The beginning of the I/O-memory range to set
+ * @val:	The value to set the memory to
+ * @count:	The number of bytes to set
+ *
+ * Set a range of I/O memory to a given value.
+ */
 static inline void memset_io(volatile void __iomem *addr, int value,
 			     size_t size)
 {
@@ -963,6 +971,14 @@ static inline void memset_io(volatile void __iomem *addr, int value,
 
 #ifndef memcpy_fromio
 #define memcpy_fromio memcpy_fromio
+/**
+ * memcpy_fromio	Copy a block of data from I/O memory
+ * @dst:		The (RAM) destination for the copy
+ * @src:		The (I/O memory) source for the data
+ * @count:		The number of bytes to copy
+ *
+ * Copy a block of data from I/O memory.
+ */
 static inline void memcpy_fromio(void *buffer,
 				 const volatile void __iomem *addr,
 				 size_t size)
@@ -973,6 +989,14 @@ static inline void memcpy_fromio(void *buffer,
 
 #ifndef memcpy_toio
 #define memcpy_toio memcpy_toio
+/**
+ * memcpy_toio		Copy a block of data into I/O memory
+ * @dst:		The (I/O memory) destination for the copy
+ * @src:		The (RAM) source for the data
+ * @count:		The number of bytes to copy
+ *
+ * Copy a block of data to I/O memory.
+ */
 static inline void memcpy_toio(volatile void __iomem *addr, const void *buffer,
 			       size_t size)
 {

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

* [tip:x86/asm] x86/io: Remove xlate_dev_kmem_ptr() duplication
  2017-06-30 17:09   ` Andy Shevchenko
  (?)
@ 2017-07-24 10:20   ` tip-bot for Andy Shevchenko
  -1 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Andy Shevchenko @ 2017-07-24 10:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, linux-kernel, andriy.shevchenko, mingo, peterz,
	baolin.wang, torvalds, mika.westerberg, hpa

Commit-ID:  eabc2a7c49c01fc97ff8c764ef7d74276b904af6
Gitweb:     http://git.kernel.org/tip/eabc2a7c49c01fc97ff8c764ef7d74276b904af6
Author:     Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Fri, 30 Jun 2017 20:09:33 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 24 Jul 2017 11:18:21 +0200

x86/io: Remove xlate_dev_kmem_ptr() duplication

Generic header defines xlate_dev_kmem_ptr().

Reuse it from generic header and remove in x86 code.
Move a description to the generic header as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Baolin Wang <baolin.wang@spreadtrum.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: intel-gfx@lists.freedesktop.org
Cc: linux-i2c@vger.kernel.org
Cc: wsa@the-dreams.de
Link: http://lkml.kernel.org/r/20170630170934.83028-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/io.h | 5 -----
 include/asm-generic/io.h  | 3 +++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 252434b..b3bba2f 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -216,11 +216,6 @@ extern void set_iounmap_nonlazy(void);
 #include <asm-generic/iomap.h>
 
 /*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
-/*
  * ISA space is 'always mapped' on a typical x86 system, no need to
  * explicitly ioremap() it. The fact that the ISA IO space is mapped
  * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 395afc8..b4531e3 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -915,6 +915,9 @@ extern void ioport_unmap(void __iomem *p);
 #endif /* CONFIG_GENERIC_IOMAP */
 #endif /* CONFIG_HAS_IOPORT_MAP */
 
+/*
+ * Convert a virtual cached pointer to an uncached pointer
+ */
 #ifndef xlate_dev_kmem_ptr
 #define xlate_dev_kmem_ptr xlate_dev_kmem_ptr
 static inline void *xlate_dev_kmem_ptr(void *addr)

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

* [tip:x86/asm] x86/io: Make readq() / writeq() API consistent
  2017-06-30 17:09   ` Andy Shevchenko
  (?)
@ 2017-07-24 10:21   ` tip-bot for Andy Shevchenko
  -1 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Andy Shevchenko @ 2017-07-24 10:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, peterz, mingo, baolin.wang, mika.westerberg, torvalds, hpa,
	linux-kernel, andriy.shevchenko

Commit-ID:  9683a64fc3cb67e663859a6bb2e0db5dcee9ed32
Gitweb:     http://git.kernel.org/tip/9683a64fc3cb67e663859a6bb2e0db5dcee9ed32
Author:     Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Fri, 30 Jun 2017 20:09:34 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 24 Jul 2017 11:18:21 +0200

x86/io: Make readq() / writeq() API consistent

Despite the following commit:

  93093d099e5d ("x86: provide readq()/writeq() on 32-bit too, complete")

which says:

  ...Also, map all the APIs to the strongest ordering variant. It's way
  too easy to mess such details up in drivers and the difference between
  "memory" and "" constrained asm() constructs is in the noise range.

... we have for now only one user of this API (i.e. writeq_relaxed() in
drivers/hwtracing/intel_th/sth.c) on x86 and it does care about
"relaxed" part of it.

Moreover 32-bit support has been removed from that header, though appeared
later in specific headers that emphasizes its non-atomic context.

The rest should keep in mind a consistent picture of the __raw_IO() vs. IO()
vs. IO_relaxed() API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Baolin Wang <baolin.wang@spreadtrum.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: intel-gfx@lists.freedesktop.org
Cc: linux-i2c@vger.kernel.org
Cc: wsa@the-dreams.de
Link: http://lkml.kernel.org/r/20170630170934.83028-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/io.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index b3bba2f..9ada93f 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -94,13 +94,15 @@ build_mmio_write(__writel, "l", unsigned int, "r", )
 #ifdef CONFIG_X86_64
 
 build_mmio_read(readq, "q", unsigned long, "=r", :"memory")
+build_mmio_read(__readq, "q", unsigned long, "=r", )
 build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
+build_mmio_write(__writeq, "q", unsigned long, "r", )
 
-#define readq_relaxed(a)	readq(a)
-#define writeq_relaxed(v, a)	writeq(v, a)
+#define readq_relaxed(a)	__readq(a)
+#define writeq_relaxed(v, a)	__writeq(v, a)
 
-#define __raw_readq(a)		readq(a)
-#define __raw_writeq(val, addr)	writeq(val, addr)
+#define __raw_readq		__readq
+#define __raw_writeq		__writeq
 
 /* Let people know that we have them */
 #define readq			readq

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

end of thread, other threads:[~2017-07-24 10:25 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-30 17:09 [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko
2017-06-30 17:09 ` [PATCH v2 1/5] x86/io: Define IO accessors by preprocessor Andy Shevchenko
2017-06-30 17:09   ` Andy Shevchenko
2017-07-24 10:19   ` [tip:x86/asm] " tip-bot for Andy Shevchenko
2017-06-30 17:09 ` [PATCH v2 2/5] x86/io: Include asm-generic/io.h to architectural code Andy Shevchenko
2017-06-30 17:09   ` Andy Shevchenko
2017-07-24 10:20   ` [tip:x86/asm] " tip-bot for Andy Shevchenko
2017-06-30 17:09 ` [PATCH v2 3/5] x86/io: Remove mem*io() duplications Andy Shevchenko
2017-06-30 17:09   ` Andy Shevchenko
2017-07-24 10:20   ` [tip:x86/asm] " tip-bot for Andy Shevchenko
2017-06-30 17:09 ` [PATCH v2 4/5] x86/io: Remove xlate_dev_kmem_ptr() duplication Andy Shevchenko
2017-06-30 17:09   ` Andy Shevchenko
2017-07-24 10:20   ` [tip:x86/asm] " tip-bot for Andy Shevchenko
2017-06-30 17:09 ` [PATCH v2 5/5] x86/io: Make readq() / writeq() API consistent Andy Shevchenko
2017-06-30 17:09   ` Andy Shevchenko
2017-07-24 10:21   ` [tip:x86/asm] " tip-bot for Andy Shevchenko
2017-06-30 17:29 ` ✓ Fi.CI.BAT: success for x86/io: Rely on asm-generic/io.h Patchwork
2017-07-18 15:52 ` [PATCH v2 0/5] " Andy Shevchenko
2017-07-18 15:52   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.