x86/io: Rely on asm-generic/io.h
Subsystems (3)
v2 cover x86/io: Rely on asm-generic/io.h
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(-)
Signature · 1 line
2.11.0
PATCH v2 1/5 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.
--- arch/x86/include/asm/io.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
arch/x86/include/asm/io.h +41 -0
@@ -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_nocacheextern void __iomem *ioremap_uc (resource_size_t offset,unsigned long size);#define ioremap_uc ioremap_ucextern void __iomem *ioremap_cache (resource_size_t offset,unsigned long size); +#define ioremap_cache ioremap_cacheextern 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 ioremapextern void iounmap (volatile void __iomem *addr); +#define iounmap iounmapextern 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_wcextern void __iomem *ioremap_wt (resource_size_t offset,unsigned long size); +#define ioremap_wt ioremap_wtextern bool is_early_ioremap_ptep (pte_t *ptep);
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/5 x86/io: Include asm-generic/io.h to architectural code
In reply to Andy Shevchenkoasm-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.
--- arch/x86/include/asm/io.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/io.h +3 -0
@@ -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
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/5 x86/io: Remove mem*io() duplications
In reply to Andy ShevchenkoGeneric 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.
--- arch/x86/include/asm/io.h | 45 --------------------------------------------- include/asm-generic/io.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 45 deletions(-)
arch/x86/include/asm/io.h +0 -45
@@ -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
include/asm-generic/io.h +24 -0
@@ -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) {
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 4/5 x86/io: Remove xlate_dev_kmem_ptr() duplication
In reply to Andy ShevchenkoGeneric 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.
--- arch/x86/include/asm/io.h | 5 ----- include/asm-generic/io.h | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-)
arch/x86/include/asm/io.h +0 -5
@@ -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
include/asm-generic/io.h +3 -0
@@ -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_ptrstatic inline void *xlate_dev_kmem_ptr (void *addr)
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 5/5 x86/io: Make readq() / writeq() API consistent
In reply to Andy ShevchenkoDespite 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.
--- arch/x86/include/asm/io.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/io.h +6 -4
@@ -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
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for x86/io: Rely on asm-generic/io.h
In reply to Andy Shevchenko== Series Details ==
== 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#101516fdo#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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 6 lines · Andy Shevchenko
The series brings a bit of order to
arch/x86/include/asm/io.hby 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?
Quoted 20 lines
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: Includeasm-generic/io.hto architectural code x86/io: Remove mem*io() duplications
x86/io: Removexlate_dev_kmem_ptr()duplication x86/io: Makereadq()/writeq()API consistentarch/x86/include/asm/io.h | 98 +++++++++++++++++++++++---------------
---------
include/asm-generic/io.h | 27 +++++++++++++2 files changed, 74 insertions(+), 51 deletions(-)
Signature · 6 lines
Andy Shevchenko <[email protected]> Intel Finland Oy _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
tip-bot for Andy Shevchenko
merge bot[tip:x86/asm] x86/io: Define IO accessors by preprocessor
In reply to Andy Shevchenkox86/io: Define IO accessors by preprocessor
Commit-ID: 80b9ece1339374444f08da46fa2383019fcf4374 Gitweb: http://git.kernel.org/tip/80b9ece1339374444f08da46fa2383019fcf4374 Author: Andy Shevchenko <[email protected]> AuthorDate: Fri, 30 Jun 2017 20:09:30 +0300 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/include/asm/io.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
arch/x86/include/asm/io.h +41 -0
@@ -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_nocacheextern void __iomem *ioremap_uc (resource_size_t offset,unsigned long size);#define ioremap_uc ioremap_ucextern void __iomem *ioremap_cache (resource_size_t offset,unsigned long size); +#define ioremap_cache ioremap_cacheextern 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 ioremapextern void iounmap (volatile void __iomem *addr); +#define iounmap iounmapextern 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_wcextern void __iomem *ioremap_wt (resource_size_t offset,unsigned long size); +#define ioremap_wt ioremap_wtextern bool is_early_ioremap_ptep (pte_t *ptep);
tip-bot for Andy Shevchenko
merge bot[tip:x86/asm] x86/io: Include asm-generic/io.h to architectural code
In reply to Andy Shevchenkox86/io: Include asm-generic/io.h to architectural code
Commit-ID: 3195201198aad06c151dcfcb09e2fff79b2fda0e Gitweb: http://git.kernel.org/tip/3195201198aad06c151dcfcb09e2fff79b2fda0e Author: Andy Shevchenko <[email protected]> AuthorDate: Fri, 30 Jun 2017 20:09:31 +0300 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/include/asm/io.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/io.h +3 -0
@@ -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
tip-bot for Andy Shevchenko
merge bot[tip:x86/asm] x86/io: Remove mem*io() duplications
In reply to Andy Shevchenkox86/io: Remove mem*io() duplications
Commit-ID: c2327da06b33d8e1093ce2c28f395bc500d1b0d3 Gitweb: http://git.kernel.org/tip/c2327da06b33d8e1093ce2c28f395bc500d1b0d3 Author: Andy Shevchenko <[email protected]> AuthorDate: Fri, 30 Jun 2017 20:09:32 +0300 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/include/asm/io.h | 45 --------------------------------------------- include/asm-generic/io.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 45 deletions(-)
arch/x86/include/asm/io.h +0 -45
@@ -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
include/asm-generic/io.h +24 -0
@@ -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) {
tip-bot for Andy Shevchenko
merge bot[tip:x86/asm] x86/io: Remove xlate_dev_kmem_ptr() duplication
In reply to Andy Shevchenkox86/io: Remove xlate_dev_kmem_ptr() duplication
Commit-ID: eabc2a7c49c01fc97ff8c764ef7d74276b904af6 Gitweb: http://git.kernel.org/tip/eabc2a7c49c01fc97ff8c764ef7d74276b904af6 Author: Andy Shevchenko <[email protected]> AuthorDate: Fri, 30 Jun 2017 20:09:33 +0300 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/include/asm/io.h | 5 ----- include/asm-generic/io.h | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-)
arch/x86/include/asm/io.h +0 -5
@@ -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
include/asm-generic/io.h +3 -0
@@ -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_ptrstatic inline void *xlate_dev_kmem_ptr (void *addr)
tip-bot for Andy Shevchenko
merge bot[tip:x86/asm] x86/io: Make readq() / writeq() API consistent
In reply to Andy Shevchenkox86/io: Make readq() / writeq() API consistent
Commit-ID: 9683a64fc3cb67e663859a6bb2e0db5dcee9ed32 Gitweb: http://git.kernel.org/tip/9683a64fc3cb67e663859a6bb2e0db5dcee9ed32 Author: Andy Shevchenko <[email protected]> AuthorDate: Fri, 30 Jun 2017 20:09:34 +0300 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/include/asm/io.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/io.h +6 -4
@@ -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