Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1678999 > unrolled thread

[PATCH v2 0/5] x86/io: Rely on asm-generic/io.h

Started byAndy Shevchenko <andriy.shevchenko@linux.intel.com>
First post2017-06-30 19:10 +0200
Last post2017-06-30 19:20 +0200
Articles 6 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-06-30 19:10 +0200
    [PATCH v2 3/5] x86/io: Remove mem*io() duplications Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-06-30 19:10 +0200
    [PATCH v2 5/5] x86/io: Make readq() / writeq() API consistent Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-06-30 19:10 +0200
    [PATCH v2 1/5] x86/io: Define IO accessors by preprocessor Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-06-30 19:20 +0200
    [PATCH v2 2/5] x86/io: Include asm-generic/io.h to architectural code Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-06-30 19:20 +0200
    [PATCH v2 4/5] x86/io: Remove xlate_dev_kmem_ptr() duplication Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-06-30 19:20 +0200

#1678999 — [PATCH v2 0/5] x86/io: Rely on asm-generic/io.h

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-06-30 19:10 +0200
Subject[PATCH v2 0/5] x86/io: Rely on asm-generic/io.h
Message-ID<tY7AC-8dL-21@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1679004 — [PATCH v2 3/5] x86/io: Remove mem*io() duplications

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-06-30 19:10 +0200
Subject[PATCH v2 3/5] x86/io: Remove mem*io() duplications
Message-ID<tY7AC-8dL-29@gated-at.bofh.it>
In reply to#1678999
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

[toc] | [prev] | [next] | [standalone]


#1679005 — [PATCH v2 5/5] x86/io: Make readq() / writeq() API consistent

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-06-30 19:10 +0200
Subject[PATCH v2 5/5] x86/io: Make readq() / writeq() API consistent
Message-ID<tY7AC-8dL-33@gated-at.bofh.it>
In reply to#1678999
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

[toc] | [prev] | [next] | [standalone]


#1679007 — [PATCH v2 1/5] x86/io: Define IO accessors by preprocessor

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-06-30 19:20 +0200
Subject[PATCH v2 1/5] x86/io: Define IO accessors by preprocessor
Message-ID<tY7Kh-8gS-1@gated-at.bofh.it>
In reply to#1678999
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

[toc] | [prev] | [next] | [standalone]


#1679010 — [PATCH v2 2/5] x86/io: Include asm-generic/io.h to architectural code

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-06-30 19:20 +0200
Subject[PATCH v2 2/5] x86/io: Include asm-generic/io.h to architectural code
Message-ID<tY7Ki-8gS-9@gated-at.bofh.it>
In reply to#1678999
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

[toc] | [prev] | [next] | [standalone]


#1679012 — [PATCH v2 4/5] x86/io: Remove xlate_dev_kmem_ptr() duplication

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-06-30 19:20 +0200
Subject[PATCH v2 4/5] x86/io: Remove xlate_dev_kmem_ptr() duplication
Message-ID<tY7Ki-8gS-11@gated-at.bofh.it>
In reply to#1678999
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web