x86: unify asm/io.h: IO_SPACE_LIMIT
PATCH 1/3 x86: unify asm/io.h: IO_SPACE_LIMIT
---
arch/x86/include/asm/io.h | 1 + arch/x86/include/asm/io_32.h | 2 -- arch/x86/include/asm/io_64.h | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-)
===================================================================
arch/x86/include/asm/io.h +0 -0
@@ -105,5 +105,6 @@
extern void early_iounmap(void __iomem *addr, unsigned long size); extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
+#define IO_SPACE_LIMIT 0xffff
#endif /* _ASM_X86_IO_H */
===================================================================
arch/x86/include/asm/io_32.h +0 -2
@@ -37,8 +37,6 @@* - Arnaldo Carvalho de Melo <[email protected]> */ -#define IO_SPACE_LIMIT 0xffff -
#define XQUAD_PORTIO_BASE 0xfe400000
#define XQUAD_PORTIO_QUAD 0x40000 /* 256k per quad. */
===================================================================
arch/x86/include/asm/io_64.h +0 -0
@@ -136,8 +136,6 @@
__OUTS(w)__OUTS(l)
-#define IO_SPACE_LIMIT 0xffff
-
#if defined(__KERNEL__) && defined(__x86_64__)
#include <linux/vmalloc.h>
H. Peter Anvin
reviewerHi Jeremy,
I applied patch #1 to tip:x86/cleanups, however, patch #2 and #3 are identical... did you mean to do something different here?
Furthermore, please provide an actual description (and preferrably an
Impact: line) with your patches. In particular, when unifying code that is identical between 32 and 64 bits, please specify this in the description (e.g. "unified functions X and Y which were already identical between 32 and 64 bits"), so we know why there isn't a preceeding patch to remove the remaining differences.
Thanks,
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Quoted 11 lines · H. Peter Anvin
Hi Jeremy,
I applied patch #1 to tip:x86/cleanups, however, patch #2 and #3 are identical... did you mean to do something different here?
Furthermore, please provide an actual description (and preferrably an
Impact: line) with your patches. In particular, when unifying code that is identical between 32 and 64 bits, please specify this in the description (e.g. "unified functions X and Y which were already identical between 32 and 64 bits"), so we know why there isn't a preceeding patch to remove the remaining differences.
Oops. Here they are. The order is:
x86-unify-io.h-virt-phys.patch
x86-unify-io.h-ioremap-proto.patch
J
Subject: x86: asm/io.h: unify virt_to_phys/phys_to_virt
Impact: unify identical code
asm/io_32.h and _64.h has functionally identical definitions for virt_to_phys, phys_to_virt, page_to_phys, and the isa_* variants, so just unify them.
The only slightly functional change is using phys_addr_t for the physical address argument and return val.
--- arch/x86/include/asm/io.h | 59 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/include/asm/io_32.h | 57 ---------------------------------------- arch/x86/include/asm/io_64.h | 37 -------------------------- 3 files changed, 59 insertions(+), 94 deletions(-)
===================================================================
arch/x86/include/asm/io.h +59 -0
@@ -5,6 +5,7 @@#include <linux/compiler.h> #include <asm-generic/int-ll64.h> +#include <asm/page.h> #define build_mmio_read (name, size, type, reg, barrier) \ static inline type name(const volatile void __iomem *addr) \
@@ -80,6 +81,64 @@#define readq readq#define writeq writeq +/** +* virt_to_phys - map virtual addresses to physical +* @address: address to remap +* +* The returned physical address is the physical (CPU) mapping for +* the memory address given. It is only valid to use this function on +* addresses directly mapped or allocated via kmalloc. +* +* This function does not give bus mappings for DMA transfers. In +* almost all conceivable cases a device driver should not be using +* this function +*/ + +static inline phys_addr_t virt_to_phys (volatile void *address) +{ +return __pa (address); +} + +/** +* phys_to_virt - map physical address to virtual +* @address: address to remap +* +* The returned virtual address is a current CPU mapping for +* the memory address given. It is only valid to use this function on +* addresses that have a kernel mapping +* +* This function does not handle bus mappings for DMA transfers. In +* almost all conceivable cases a device driver should not be using +* this function +*/ + +static inline void *phys_to_virt (phys_addr_t address) +{ +return __va (address); +} + +/* +* Change "struct page" to physical address. +*/ +#define page_to_phys (page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) + +/* +* ISA I/O bus memory addresses are 1:1 with the physical address. +*/ +#define isa_virt_to_bus virt_to_phys +#define isa_page_to_bus page_to_phys +#define isa_bus_to_virt phys_to_virt + +/* +* However PCI ones are not necessarily 1:1 and therefore these interfaces +* are forbidden in portable PCI drivers. +* +* Allow them on x86 for legacy drivers, though. +*/ +#define virt_to_bus virt_to_phys +#define bus_to_virt phys_to_virt + +#ifdef CONFIG_X86_32 # include "io_32.h" #else
===================================================================
arch/x86/include/asm/io_32.h +0 -57
69 lines not on this page · raw message
===================================================================
arch/x86/include/asm/io_64.h +0 -37
@@ -140,27 +140,6 @@#include <linux/vmalloc.h> -#ifndef __i386__ -/* -* Change virtual addresses to physical addresses and vv. -* These are pretty trivial -*/ -static inline unsigned long virt_to_phys (volatile void *address) -{ -return __pa (address); -} - -static inline void *phys_to_virt (unsigned long address) -{ -return __va (address); -} -#endif - -/* -* Change "struct page" to physical address. -*/ -#define page_to_phys (page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) -#include <asm-generic/iomap.h> /*
@@ -185,22 +164,6 @@extern void __iomem *fix_ioremap (unsigned idx,unsigned long phys); -/* -* ISA I/O bus memory addresses are 1:1 with the physical address. -*/ -#define isa_virt_to_bus virt_to_phys -#define isa_page_to_bus page_to_phys -#define isa_bus_to_virt phys_to_virt - -/* -* However PCI ones are not necessarily 1:1 and therefore these interfaces -* are forbidden in portable PCI drivers. -* -* Allow them on x86 for legacy drivers, though. -*/ -#define virt_to_bus virt_to_phys -#define bus_to_virt phys_to_virt -void __memcpy_fromio (void *,unsigned long ,unsigned );void __memcpy_toio (unsigned long ,const void *,unsigned );
Subject: x86: asm/io.h: unify ioremap prototypes
Impact: unify identical code
asm/io_32.h and _64.h have identical prototypes for the ioremap family of functions. The 32-bit header had a more descriptive comment.
--- arch/x86/include/asm/io.h | 31 +++++++++++++++++++++++++++++++ arch/x86/include/asm/io_32.h | 29 ----------------------------- arch/x86/include/asm/io_64.h | 22 ---------------------- 3 files changed, 31 insertions(+), 51 deletions(-)
===================================================================
arch/x86/include/asm/io.h +31 -0
@@ -118,6 +118,37 @@#define virt_to_bus virt_to_phys#define bus_to_virt phys_to_virt +/** +* ioremap - map bus memory into CPU space +* @offset: bus address of the memory +* @size: size of the resource to map +* +* ioremap performs a platform specific sequence of operations to +* make bus memory CPU accessible via the readb/readw/readl/writeb/ +* writew/writel functions and the other mmio helpers. The returned +* address is not guaranteed to be usable directly as a virtual +* address. +* +* If the area you are trying to map is a PCI BAR you should have a +* look at pci_iomap(). +*/ +extern void __iomem *ioremap_nocache (resource_size_t offset,unsigned long size); +extern void __iomem *ioremap_cache (resource_size_t offset,unsigned long size); +extern void __iomem *ioremap_prot (resource_size_t offset,unsigned long size, +unsigned long prot_val); + +/* +* The default ioremap() behavior is non-cached: +*/ +static inline void __iomem *ioremap (resource_size_t offset,unsigned long size) +{ +return ioremap_nocache (offset, size); +} + +extern void iounmap (volatile void __iomem *addr); + +extern void __iomem *fix_ioremap (unsigned idx,unsigned long phys); +#ifdef CONFIG_X86_32 # include "io_32.h"
===================================================================
arch/x86/include/asm/io_32.h +0 -29
@@ -52,35 +52,6 @@* Convert a virtual cached pointer to an uncached pointer */ #define xlate_dev_kmem_ptr (p) p - -/** -* ioremap - map bus memory into CPU space -* @offset: bus address of the memory -* @size: size of the resource to map -* -* ioremap performs a platform specific sequence of operations to -* make bus memory CPU accessible via the readb/readw/readl/writeb/ -* writew/writel functions and the other mmio helpers. The returned -* address is not guaranteed to be usable directly as a virtual -* address. -* -* If the area you are trying to map is a PCI BAR you should have a -* look at pci_iomap(). -*/ -extern void __iomem *ioremap_nocache (resource_size_t offset,unsigned long size); -extern void __iomem *ioremap_cache (resource_size_t offset,unsigned long size); -extern void __iomem *ioremap_prot (resource_size_t offset,unsigned long size, -unsigned long prot_val); - -/* -* The default ioremap() behavior is non-cached: -*/ -static inline void __iomem *ioremap (resource_size_t offset,unsigned long size) -{ -return ioremap_nocache (offset, size); -} - -extern void iounmap (volatile void __iomem *addr);static inline void memset_io (volatile void __iomem *addr,unsigned char val,int count)
===================================================================
arch/x86/include/asm/io_64.h +0 -22
@@ -144,28 +144,6 @@#include <asm-generic/iomap.h> -/* -* This one maps high address device memory and turns off caching for that area. -* it's useful if some control registers are in such an area and write combining -* or read caching is not desirable: -*/ -extern void __iomem *ioremap_nocache (resource_size_t offset,unsigned long size); -extern void __iomem *ioremap_cache (resource_size_t offset,unsigned long size); -extern void __iomem *ioremap_prot (resource_size_t offset,unsigned long size, -unsigned long prot_val); - -/* -* The default ioremap() behavior is non-cached: -*/ -static inline void __iomem *ioremap (resource_size_t offset,unsigned long size) -{ -return ioremap_nocache (offset, size); -} - -extern void iounmap (volatile void __iomem *addr); - -extern void __iomem *fix_ioremap (unsigned idx,unsigned long phys); -void __memcpy_fromio (void *,unsigned long ,unsigned );void __memcpy_toio (unsigned long ,const void *,unsigned );