mirror of
https://github.com/torvalds/linux.git
synced 2025-04-09 14:45:27 +00:00

Uros Bizjak uses x86 named address space qualifiers to provide compile-time checking of percpu area accesses. This has caused a small amount of fallout - two or three issues were reported. In all cases the calling code was founf to be incorrect. - The 4 patch series "Some cleanup for memcg" from Chen Ridong implements some relatively monir cleanups for the memcontrol code. - The 17 patch series "mm: fixes for device-exclusive entries (hmm)" from David Hildenbrand fixes a boatload of issues which David found then using device-exclusive PTE entries when THP is enabled. More work is needed, but this makes thins better - our own HMM selftests now succeed. - The 2 patch series "mm: zswap: remove z3fold and zbud" from Yosry Ahmed remove the z3fold and zbud implementations. They have been deprecated for half a year and nobody has complained. - The 5 patch series "mm: further simplify VMA merge operation" from Lorenzo Stoakes implements numerous simplifications in this area. No runtime effects are anticipated. - The 4 patch series "mm/madvise: remove redundant mmap_lock operations from process_madvise()" from SeongJae Park rationalizes the locking in the madvise() implementation. Performance gains of 20-25% were observed in one MADV_DONTNEED microbenchmark. - The 12 patch series "Tiny cleanup and improvements about SWAP code" from Baoquan He contains a number of touchups to issues which Baoquan noticed when working on the swap code. - The 2 patch series "mm: kmemleak: Usability improvements" from Catalin Marinas implements a couple of improvements to the kmemleak user-visible output. - The 2 patch series "mm/damon/paddr: fix large folios access and schemes handling" from Usama Arif provides a couple of fixes for DAMON's handling of large folios. - The 3 patch series "mm/damon/core: fix wrong and/or useless damos_walk() behaviors" from SeongJae Park fixes a few issues with the accuracy of kdamond's walking of DAMON regions. - The 3 patch series "expose mapping wrprotect, fix fb_defio use" from Lorenzo Stoakes changes the interaction between framebuffer deferred-io and core MM. No functional changes are anticipated - this is preparatory work for the future removal of page structure fields. - The 4 patch series "mm/damon: add support for hugepage_size DAMOS filter" from Usama Arif adds a DAMOS filter which permits the filtering by huge page sizes. - The 4 patch series "mm: permit guard regions for file-backed/shmem mappings" from Lorenzo Stoakes extends the guard region feature from its present "anon mappings only" state. The feature now covers shmem and file-backed mappings. - The 4 patch series "mm: batched unmap lazyfree large folios during reclamation" from Barry Song cleans up and speeds up the unmapping for pte-mapped large folios. - The 18 patch series "reimplement per-vma lock as a refcount" from Suren Baghdasaryan puts the vm_lock back into the vma. Our reasons for pulling it out were largely bogus and that change made the code more messy. This patchset provides small (0-10%) improvements on one microbenchmark. - The 5 patch series "Docs/mm/damon: misc DAMOS filters documentation fixes and improves" from SeongJae Park does some maintenance work on the DAMON docs. - The 27 patch series "hugetlb/CMA improvements for large systems" from Frank van der Linden addresses a pile of issues which have been observed when using CMA on large machines. - The 2 patch series "mm/damon: introduce DAMOS filter type for unmapped pages" from SeongJae Park enables users of DMAON/DAMOS to filter my the page's mapped/unmapped status. - The 19 patch series "zsmalloc/zram: there be preemption" from Sergey Senozhatsky teaches zram to run its compression and decompression operations preemptibly. - The 12 patch series "selftests/mm: Some cleanups from trying to run them" from Brendan Jackman fixes a pile of unrelated issues which Brendan encountered while runnimg our selftests. - The 2 patch series "fs/proc/task_mmu: add guard region bit to pagemap" from Lorenzo Stoakes permits userspace to use /proc/pid/pagemap to determine whether a particular page is a guard page. - The 7 patch series "mm, swap: remove swap slot cache" from Kairui Song removes the swap slot cache from the allocation path - it simply wasn't being effective. - The 5 patch series "mm: cleanups for device-exclusive entries (hmm)" from David Hildenbrand implements a number of unrelated cleanups in this code. - The 5 patch series "mm: Rework generic PTDUMP configs" from Anshuman Khandual implements a number of preparatoty cleanups to the GENERIC_PTDUMP Kconfig logic. - The 8 patch series "mm/damon: auto-tune aggregation interval" from SeongJae Park implements a feedback-driven automatic tuning feature for DAMON's aggregation interval tuning. - The 5 patch series "Fix lazy mmu mode" from Ryan Roberts fixes some issues in powerpc, sparc and x86 lazy MMU implementations. Ryan did this in preparation for implementing lazy mmu mode for arm64 to optimize vmalloc. - The 2 patch series "mm/page_alloc: Some clarifications for migratetype fallback" from Brendan Jackman reworks some commentary to make the code easier to follow. - The 3 patch series "page_counter cleanup and size reduction" from Shakeel Butt cleans up the page_counter code and fixes a size increase which we accidentally added late last year. - The 3 patch series "Add a command line option that enables control of how many threads should be used to allocate huge pages" from Thomas Prescher does that. It allows the careful operator to significantly reduce boot time by tuning the parallalization of huge page initialization. - The 3 patch series "Fix calculations in trace_balance_dirty_pages() for cgwb" from Tang Yizhou fixes the tracing output from the dirty page balancing code. - The 9 patch series "mm/damon: make allow filters after reject filters useful and intuitive" from SeongJae Park improves the handling of allow and reject filters. Behaviour is made more consistent and the documention is updated accordingly. - The 5 patch series "Switch zswap to object read/write APIs" from Yosry Ahmed updates zswap to the new object read/write APIs and thus permits the removal of some legacy code from zpool and zsmalloc. - The 6 patch series "Some trivial cleanups for shmem" from Baolin Wang does as it claims. - The 20 patch series "fs/dax: Fix ZONE_DEVICE page reference counts" from Alistair Popple regularizes the weird ZONE_DEVICE page refcount handling in DAX, permittig the removal of a number of special-case checks. - The 4 patch series "refactor mremap and fix bug" from Lorenzo Stoakes is a preparatoty refactoring and cleanup of the mremap() code. - The 20 patch series "mm: MM owner tracking for large folios (!hugetlb) + CONFIG_NO_PAGE_MAPCOUNT" from David Hildenbrand reworks the manner in which we determine whether a large folio is known to be mapped exclusively into a single MM. - The 8 patch series "mm/damon: add sysfs dirs for managing DAMOS filters based on handling layers" from SeongJae Park adds a couple of new sysfs directories to ease the management of DAMON/DAMOS filters. - The 13 patch series "arch, mm: reduce code duplication in mem_init()" from Mike Rapoport consolidates many per-arch implementations of mem_init() into code generic code, where that is practical. - The 13 patch series "mm/damon/sysfs: commit parameters online via damon_call()" from SeongJae Park continues the cleaning up of sysfs access to DAMON internal data. - The 3 patch series "mm: page_ext: Introduce new iteration API" from Luiz Capitulino reworks the page_ext initialization to fix a boot-time crash which was observed with an unusual combination of compile and cmdline options. - The 8 patch series "Buddy allocator like (or non-uniform) folio split" from Zi Yan reworks the code to split a folio into smaller folios. The main benefit is lessened memory consumption: fewer post-split folios are generated. - The 2 patch series "Minimize xa_node allocation during xarry split" from Zi Yan reduces the number of xarray xa_nodes which are generated during an xarray split. - The 2 patch series "drivers/base/memory: Two cleanups" from Gavin Shan performs some maintenance work on the drivers/base/memory code. - The 3 patch series "Add tracepoints for lowmem reserves, watermarks and totalreserve_pages" from Martin Liu adds some more tracepoints to the page allocator code. - The 4 patch series "mm/madvise: cleanup requests validations and classifications" from SeongJae Park cleans up some warts which SeongJae observed during his earlier madvise work. - The 3 patch series "mm/hwpoison: Fix regressions in memory failure handling" from Shuai Xue addresses two quite serious regressions which Shuai has observed in the memory-failure implementation. - The 5 patch series "mm: reliable huge page allocator" from Johannes Weiner makes huge page allocations cheaper and more reliable by reducing fragmentation. - The 5 patch series "Minor memcg cleanups & prep for memdescs" from Matthew Wilcox is preparatory work for the future implementation of memdescs. - The 4 patch series "track memory used by balloon drivers" from Nico Pache introduces a way to track memory used by our various balloon drivers. - The 2 patch series "mm/damon: introduce DAMOS filter type for active pages" from Nhat Pham permits users to filter for active/inactive pages, separately for file and anon pages. - The 2 patch series "Adding Proactive Memory Reclaim Statistics" from Hao Jia separates the proactive reclaim statistics from the direct reclaim statistics. - The 2 patch series "mm/vmscan: don't try to reclaim hwpoison folio" from Jinjiang Tu fixes our handling of hwpoisoned pages within the reclaim code. -----BEGIN PGP SIGNATURE----- iHQEABYKAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCZ+nZaAAKCRDdBJ7gKXxA jsOWAPiP4r7CJHMZRK4eyJOkvS1a1r+TsIarrFZtjwvf/GIfAQCEG+JDxVfUaUSF Ee93qSSLR1BkNdDw+931Pu0mXfbnBw== =Pn2K -----END PGP SIGNATURE----- Merge tag 'mm-stable-2025-03-30-16-52' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull MM updates from Andrew Morton: - The series "Enable strict percpu address space checks" from Uros Bizjak uses x86 named address space qualifiers to provide compile-time checking of percpu area accesses. This has caused a small amount of fallout - two or three issues were reported. In all cases the calling code was found to be incorrect. - The series "Some cleanup for memcg" from Chen Ridong implements some relatively monir cleanups for the memcontrol code. - The series "mm: fixes for device-exclusive entries (hmm)" from David Hildenbrand fixes a boatload of issues which David found then using device-exclusive PTE entries when THP is enabled. More work is needed, but this makes thins better - our own HMM selftests now succeed. - The series "mm: zswap: remove z3fold and zbud" from Yosry Ahmed remove the z3fold and zbud implementations. They have been deprecated for half a year and nobody has complained. - The series "mm: further simplify VMA merge operation" from Lorenzo Stoakes implements numerous simplifications in this area. No runtime effects are anticipated. - The series "mm/madvise: remove redundant mmap_lock operations from process_madvise()" from SeongJae Park rationalizes the locking in the madvise() implementation. Performance gains of 20-25% were observed in one MADV_DONTNEED microbenchmark. - The series "Tiny cleanup and improvements about SWAP code" from Baoquan He contains a number of touchups to issues which Baoquan noticed when working on the swap code. - The series "mm: kmemleak: Usability improvements" from Catalin Marinas implements a couple of improvements to the kmemleak user-visible output. - The series "mm/damon/paddr: fix large folios access and schemes handling" from Usama Arif provides a couple of fixes for DAMON's handling of large folios. - The series "mm/damon/core: fix wrong and/or useless damos_walk() behaviors" from SeongJae Park fixes a few issues with the accuracy of kdamond's walking of DAMON regions. - The series "expose mapping wrprotect, fix fb_defio use" from Lorenzo Stoakes changes the interaction between framebuffer deferred-io and core MM. No functional changes are anticipated - this is preparatory work for the future removal of page structure fields. - The series "mm/damon: add support for hugepage_size DAMOS filter" from Usama Arif adds a DAMOS filter which permits the filtering by huge page sizes. - The series "mm: permit guard regions for file-backed/shmem mappings" from Lorenzo Stoakes extends the guard region feature from its present "anon mappings only" state. The feature now covers shmem and file-backed mappings. - The series "mm: batched unmap lazyfree large folios during reclamation" from Barry Song cleans up and speeds up the unmapping for pte-mapped large folios. - The series "reimplement per-vma lock as a refcount" from Suren Baghdasaryan puts the vm_lock back into the vma. Our reasons for pulling it out were largely bogus and that change made the code more messy. This patchset provides small (0-10%) improvements on one microbenchmark. - The series "Docs/mm/damon: misc DAMOS filters documentation fixes and improves" from SeongJae Park does some maintenance work on the DAMON docs. - The series "hugetlb/CMA improvements for large systems" from Frank van der Linden addresses a pile of issues which have been observed when using CMA on large machines. - The series "mm/damon: introduce DAMOS filter type for unmapped pages" from SeongJae Park enables users of DMAON/DAMOS to filter my the page's mapped/unmapped status. - The series "zsmalloc/zram: there be preemption" from Sergey Senozhatsky teaches zram to run its compression and decompression operations preemptibly. - The series "selftests/mm: Some cleanups from trying to run them" from Brendan Jackman fixes a pile of unrelated issues which Brendan encountered while runnimg our selftests. - The series "fs/proc/task_mmu: add guard region bit to pagemap" from Lorenzo Stoakes permits userspace to use /proc/pid/pagemap to determine whether a particular page is a guard page. - The series "mm, swap: remove swap slot cache" from Kairui Song removes the swap slot cache from the allocation path - it simply wasn't being effective. - The series "mm: cleanups for device-exclusive entries (hmm)" from David Hildenbrand implements a number of unrelated cleanups in this code. - The series "mm: Rework generic PTDUMP configs" from Anshuman Khandual implements a number of preparatoty cleanups to the GENERIC_PTDUMP Kconfig logic. - The series "mm/damon: auto-tune aggregation interval" from SeongJae Park implements a feedback-driven automatic tuning feature for DAMON's aggregation interval tuning. - The series "Fix lazy mmu mode" from Ryan Roberts fixes some issues in powerpc, sparc and x86 lazy MMU implementations. Ryan did this in preparation for implementing lazy mmu mode for arm64 to optimize vmalloc. - The series "mm/page_alloc: Some clarifications for migratetype fallback" from Brendan Jackman reworks some commentary to make the code easier to follow. - The series "page_counter cleanup and size reduction" from Shakeel Butt cleans up the page_counter code and fixes a size increase which we accidentally added late last year. - The series "Add a command line option that enables control of how many threads should be used to allocate huge pages" from Thomas Prescher does that. It allows the careful operator to significantly reduce boot time by tuning the parallalization of huge page initialization. - The series "Fix calculations in trace_balance_dirty_pages() for cgwb" from Tang Yizhou fixes the tracing output from the dirty page balancing code. - The series "mm/damon: make allow filters after reject filters useful and intuitive" from SeongJae Park improves the handling of allow and reject filters. Behaviour is made more consistent and the documention is updated accordingly. - The series "Switch zswap to object read/write APIs" from Yosry Ahmed updates zswap to the new object read/write APIs and thus permits the removal of some legacy code from zpool and zsmalloc. - The series "Some trivial cleanups for shmem" from Baolin Wang does as it claims. - The series "fs/dax: Fix ZONE_DEVICE page reference counts" from Alistair Popple regularizes the weird ZONE_DEVICE page refcount handling in DAX, permittig the removal of a number of special-case checks. - The series "refactor mremap and fix bug" from Lorenzo Stoakes is a preparatoty refactoring and cleanup of the mremap() code. - The series "mm: MM owner tracking for large folios (!hugetlb) + CONFIG_NO_PAGE_MAPCOUNT" from David Hildenbrand reworks the manner in which we determine whether a large folio is known to be mapped exclusively into a single MM. - The series "mm/damon: add sysfs dirs for managing DAMOS filters based on handling layers" from SeongJae Park adds a couple of new sysfs directories to ease the management of DAMON/DAMOS filters. - The series "arch, mm: reduce code duplication in mem_init()" from Mike Rapoport consolidates many per-arch implementations of mem_init() into code generic code, where that is practical. - The series "mm/damon/sysfs: commit parameters online via damon_call()" from SeongJae Park continues the cleaning up of sysfs access to DAMON internal data. - The series "mm: page_ext: Introduce new iteration API" from Luiz Capitulino reworks the page_ext initialization to fix a boot-time crash which was observed with an unusual combination of compile and cmdline options. - The series "Buddy allocator like (or non-uniform) folio split" from Zi Yan reworks the code to split a folio into smaller folios. The main benefit is lessened memory consumption: fewer post-split folios are generated. - The series "Minimize xa_node allocation during xarry split" from Zi Yan reduces the number of xarray xa_nodes which are generated during an xarray split. - The series "drivers/base/memory: Two cleanups" from Gavin Shan performs some maintenance work on the drivers/base/memory code. - The series "Add tracepoints for lowmem reserves, watermarks and totalreserve_pages" from Martin Liu adds some more tracepoints to the page allocator code. - The series "mm/madvise: cleanup requests validations and classifications" from SeongJae Park cleans up some warts which SeongJae observed during his earlier madvise work. - The series "mm/hwpoison: Fix regressions in memory failure handling" from Shuai Xue addresses two quite serious regressions which Shuai has observed in the memory-failure implementation. - The series "mm: reliable huge page allocator" from Johannes Weiner makes huge page allocations cheaper and more reliable by reducing fragmentation. - The series "Minor memcg cleanups & prep for memdescs" from Matthew Wilcox is preparatory work for the future implementation of memdescs. - The series "track memory used by balloon drivers" from Nico Pache introduces a way to track memory used by our various balloon drivers. - The series "mm/damon: introduce DAMOS filter type for active pages" from Nhat Pham permits users to filter for active/inactive pages, separately for file and anon pages. - The series "Adding Proactive Memory Reclaim Statistics" from Hao Jia separates the proactive reclaim statistics from the direct reclaim statistics. - The series "mm/vmscan: don't try to reclaim hwpoison folio" from Jinjiang Tu fixes our handling of hwpoisoned pages within the reclaim code. * tag 'mm-stable-2025-03-30-16-52' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (431 commits) mm/page_alloc: remove unnecessary __maybe_unused in order_to_pindex() x86/mm: restore early initialization of high_memory for 32-bits mm/vmscan: don't try to reclaim hwpoison folio mm/hwpoison: introduce folio_contain_hwpoisoned_page() helper cgroup: docs: add pswpin and pswpout items in cgroup v2 doc mm: vmscan: split proactive reclaim statistics from direct reclaim statistics selftests/mm: speed up split_huge_page_test selftests/mm: uffd-unit-tests support for hugepages > 2M docs/mm/damon/design: document active DAMOS filter type mm/damon: implement a new DAMOS filter type for active pages fs/dax: don't disassociate zero page entries MM documentation: add "Unaccepted" meminfo entry selftests/mm: add commentary about 9pfs bugs fork: use __vmalloc_node() for stack allocation docs/mm: Physical Memory: Populate the "Zones" section xen: balloon: update the NR_BALLOON_PAGES state hv_balloon: update the NR_BALLOON_PAGES state balloon_compaction: update the NR_BALLOON_PAGES state meminfo: add a per node counter for balloon drivers mm: remove references to folio in __memcg_kmem_uncharge_page() ...
1254 lines
28 KiB
C
1254 lines
28 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/* Generic I/O port emulation.
|
|
*
|
|
* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
*/
|
|
#ifndef __ASM_GENERIC_IO_H
|
|
#define __ASM_GENERIC_IO_H
|
|
|
|
#include <asm/page.h> /* I/O is all done through memory accesses */
|
|
#include <linux/string.h> /* for memset() and memcpy() */
|
|
#include <linux/sizes.h>
|
|
#include <linux/types.h>
|
|
#include <linux/instruction_pointer.h>
|
|
|
|
#ifdef CONFIG_GENERIC_IOMAP
|
|
#include <asm-generic/iomap.h>
|
|
#endif
|
|
|
|
#include <asm/mmiowb.h>
|
|
#include <asm-generic/pci_iomap.h>
|
|
|
|
#ifndef __io_br
|
|
#define __io_br() barrier()
|
|
#endif
|
|
|
|
/* prevent prefetching of coherent DMA data ahead of a dma-complete */
|
|
#ifndef __io_ar
|
|
#ifdef rmb
|
|
#define __io_ar(v) rmb()
|
|
#else
|
|
#define __io_ar(v) barrier()
|
|
#endif
|
|
#endif
|
|
|
|
/* flush writes to coherent DMA data before possibly triggering a DMA read */
|
|
#ifndef __io_bw
|
|
#ifdef wmb
|
|
#define __io_bw() wmb()
|
|
#else
|
|
#define __io_bw() barrier()
|
|
#endif
|
|
#endif
|
|
|
|
/* serialize device access against a spin_unlock, usually handled there. */
|
|
#ifndef __io_aw
|
|
#define __io_aw() mmiowb_set_pending()
|
|
#endif
|
|
|
|
#ifndef __io_pbw
|
|
#define __io_pbw() __io_bw()
|
|
#endif
|
|
|
|
#ifndef __io_paw
|
|
#define __io_paw() __io_aw()
|
|
#endif
|
|
|
|
#ifndef __io_pbr
|
|
#define __io_pbr() __io_br()
|
|
#endif
|
|
|
|
#ifndef __io_par
|
|
#define __io_par(v) __io_ar(v)
|
|
#endif
|
|
|
|
/*
|
|
* "__DISABLE_TRACE_MMIO__" flag can be used to disable MMIO tracing for
|
|
* specific kernel drivers in case of excessive/unwanted logging.
|
|
*
|
|
* Usage: Add a #define flag at the beginning of the driver file.
|
|
* Ex: #define __DISABLE_TRACE_MMIO__
|
|
* #include <...>
|
|
* ...
|
|
*/
|
|
#if IS_ENABLED(CONFIG_TRACE_MMIO_ACCESS) && !(defined(__DISABLE_TRACE_MMIO__))
|
|
#include <linux/tracepoint-defs.h>
|
|
|
|
DECLARE_TRACEPOINT(rwmmio_write);
|
|
DECLARE_TRACEPOINT(rwmmio_post_write);
|
|
DECLARE_TRACEPOINT(rwmmio_read);
|
|
DECLARE_TRACEPOINT(rwmmio_post_read);
|
|
|
|
void log_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
|
|
unsigned long caller_addr, unsigned long caller_addr0);
|
|
void log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
|
|
unsigned long caller_addr, unsigned long caller_addr0);
|
|
void log_read_mmio(u8 width, const volatile void __iomem *addr,
|
|
unsigned long caller_addr, unsigned long caller_addr0);
|
|
void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr,
|
|
unsigned long caller_addr, unsigned long caller_addr0);
|
|
|
|
#else
|
|
|
|
static inline void log_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
|
|
unsigned long caller_addr, unsigned long caller_addr0) {}
|
|
static inline void log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
|
|
unsigned long caller_addr, unsigned long caller_addr0) {}
|
|
static inline void log_read_mmio(u8 width, const volatile void __iomem *addr,
|
|
unsigned long caller_addr, unsigned long caller_addr0) {}
|
|
static inline void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr,
|
|
unsigned long caller_addr, unsigned long caller_addr0) {}
|
|
|
|
#endif /* CONFIG_TRACE_MMIO_ACCESS */
|
|
|
|
/*
|
|
* __raw_{read,write}{b,w,l,q}() access memory in native endianness.
|
|
*
|
|
* On some architectures memory mapped IO needs to be accessed differently.
|
|
* On the simple architectures, we just read/write the memory location
|
|
* directly.
|
|
*/
|
|
|
|
#ifndef __raw_readb
|
|
#define __raw_readb __raw_readb
|
|
static inline u8 __raw_readb(const volatile void __iomem *addr)
|
|
{
|
|
return *(const volatile u8 __force *)addr;
|
|
}
|
|
#endif
|
|
|
|
#ifndef __raw_readw
|
|
#define __raw_readw __raw_readw
|
|
static inline u16 __raw_readw(const volatile void __iomem *addr)
|
|
{
|
|
return *(const volatile u16 __force *)addr;
|
|
}
|
|
#endif
|
|
|
|
#ifndef __raw_readl
|
|
#define __raw_readl __raw_readl
|
|
static inline u32 __raw_readl(const volatile void __iomem *addr)
|
|
{
|
|
return *(const volatile u32 __force *)addr;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef __raw_readq
|
|
#define __raw_readq __raw_readq
|
|
static inline u64 __raw_readq(const volatile void __iomem *addr)
|
|
{
|
|
return *(const volatile u64 __force *)addr;
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef __raw_writeb
|
|
#define __raw_writeb __raw_writeb
|
|
static inline void __raw_writeb(u8 value, volatile void __iomem *addr)
|
|
{
|
|
*(volatile u8 __force *)addr = value;
|
|
}
|
|
#endif
|
|
|
|
#ifndef __raw_writew
|
|
#define __raw_writew __raw_writew
|
|
static inline void __raw_writew(u16 value, volatile void __iomem *addr)
|
|
{
|
|
*(volatile u16 __force *)addr = value;
|
|
}
|
|
#endif
|
|
|
|
#ifndef __raw_writel
|
|
#define __raw_writel __raw_writel
|
|
static inline void __raw_writel(u32 value, volatile void __iomem *addr)
|
|
{
|
|
*(volatile u32 __force *)addr = value;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef __raw_writeq
|
|
#define __raw_writeq __raw_writeq
|
|
static inline void __raw_writeq(u64 value, volatile void __iomem *addr)
|
|
{
|
|
*(volatile u64 __force *)addr = value;
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
/*
|
|
* {read,write}{b,w,l,q}() access little endian memory and return result in
|
|
* native endianness.
|
|
*/
|
|
|
|
#ifndef readb
|
|
#define readb readb
|
|
static inline u8 readb(const volatile void __iomem *addr)
|
|
{
|
|
u8 val;
|
|
|
|
log_read_mmio(8, addr, _THIS_IP_, _RET_IP_);
|
|
__io_br();
|
|
val = __raw_readb(addr);
|
|
__io_ar(val);
|
|
log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_);
|
|
return val;
|
|
}
|
|
#endif
|
|
|
|
#ifndef readw
|
|
#define readw readw
|
|
static inline u16 readw(const volatile void __iomem *addr)
|
|
{
|
|
u16 val;
|
|
|
|
log_read_mmio(16, addr, _THIS_IP_, _RET_IP_);
|
|
__io_br();
|
|
val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
|
|
__io_ar(val);
|
|
log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
|
|
return val;
|
|
}
|
|
#endif
|
|
|
|
#ifndef readl
|
|
#define readl readl
|
|
static inline u32 readl(const volatile void __iomem *addr)
|
|
{
|
|
u32 val;
|
|
|
|
log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
|
|
__io_br();
|
|
val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
|
|
__io_ar(val);
|
|
log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
|
|
return val;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef readq
|
|
#define readq readq
|
|
static inline u64 readq(const volatile void __iomem *addr)
|
|
{
|
|
u64 val;
|
|
|
|
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
|
|
__io_br();
|
|
val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
|
|
__io_ar(val);
|
|
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
|
|
return val;
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef writeb
|
|
#define writeb writeb
|
|
static inline void writeb(u8 value, volatile void __iomem *addr)
|
|
{
|
|
log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
|
|
__io_bw();
|
|
__raw_writeb(value, addr);
|
|
__io_aw();
|
|
log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
|
|
}
|
|
#endif
|
|
|
|
#ifndef writew
|
|
#define writew writew
|
|
static inline void writew(u16 value, volatile void __iomem *addr)
|
|
{
|
|
log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
|
|
__io_bw();
|
|
__raw_writew((u16 __force)cpu_to_le16(value), addr);
|
|
__io_aw();
|
|
log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
|
|
}
|
|
#endif
|
|
|
|
#ifndef writel
|
|
#define writel writel
|
|
static inline void writel(u32 value, volatile void __iomem *addr)
|
|
{
|
|
log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
|
|
__io_bw();
|
|
__raw_writel((u32 __force)__cpu_to_le32(value), addr);
|
|
__io_aw();
|
|
log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef writeq
|
|
#define writeq writeq
|
|
static inline void writeq(u64 value, volatile void __iomem *addr)
|
|
{
|
|
log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
|
|
__io_bw();
|
|
__raw_writeq((u64 __force)__cpu_to_le64(value), addr);
|
|
__io_aw();
|
|
log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
/*
|
|
* {read,write}{b,w,l,q}_relaxed() are like the regular version, but
|
|
* are not guaranteed to provide ordering against spinlocks or memory
|
|
* accesses.
|
|
*/
|
|
#ifndef readb_relaxed
|
|
#define readb_relaxed readb_relaxed
|
|
static inline u8 readb_relaxed(const volatile void __iomem *addr)
|
|
{
|
|
u8 val;
|
|
|
|
log_read_mmio(8, addr, _THIS_IP_, _RET_IP_);
|
|
val = __raw_readb(addr);
|
|
log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_);
|
|
return val;
|
|
}
|
|
#endif
|
|
|
|
#ifndef readw_relaxed
|
|
#define readw_relaxed readw_relaxed
|
|
static inline u16 readw_relaxed(const volatile void __iomem *addr)
|
|
{
|
|
u16 val;
|
|
|
|
log_read_mmio(16, addr, _THIS_IP_, _RET_IP_);
|
|
val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
|
|
log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
|
|
return val;
|
|
}
|
|
#endif
|
|
|
|
#ifndef readl_relaxed
|
|
#define readl_relaxed readl_relaxed
|
|
static inline u32 readl_relaxed(const volatile void __iomem *addr)
|
|
{
|
|
u32 val;
|
|
|
|
log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
|
|
val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
|
|
log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
|
|
return val;
|
|
}
|
|
#endif
|
|
|
|
#if defined(readq) && !defined(readq_relaxed)
|
|
#define readq_relaxed readq_relaxed
|
|
static inline u64 readq_relaxed(const volatile void __iomem *addr)
|
|
{
|
|
u64 val;
|
|
|
|
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
|
|
val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
|
|
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
|
|
return val;
|
|
}
|
|
#endif
|
|
|
|
#ifndef writeb_relaxed
|
|
#define writeb_relaxed writeb_relaxed
|
|
static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)
|
|
{
|
|
log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
|
|
__raw_writeb(value, addr);
|
|
log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
|
|
}
|
|
#endif
|
|
|
|
#ifndef writew_relaxed
|
|
#define writew_relaxed writew_relaxed
|
|
static inline void writew_relaxed(u16 value, volatile void __iomem *addr)
|
|
{
|
|
log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
|
|
__raw_writew((u16 __force)cpu_to_le16(value), addr);
|
|
log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
|
|
}
|
|
#endif
|
|
|
|
#ifndef writel_relaxed
|
|
#define writel_relaxed writel_relaxed
|
|
static inline void writel_relaxed(u32 value, volatile void __iomem *addr)
|
|
{
|
|
log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
|
|
__raw_writel((u32 __force)__cpu_to_le32(value), addr);
|
|
log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
|
|
}
|
|
#endif
|
|
|
|
#if defined(writeq) && !defined(writeq_relaxed)
|
|
#define writeq_relaxed writeq_relaxed
|
|
static inline void writeq_relaxed(u64 value, volatile void __iomem *addr)
|
|
{
|
|
log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
|
|
__raw_writeq((u64 __force)__cpu_to_le64(value), addr);
|
|
log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* {read,write}s{b,w,l,q}() repeatedly access the same memory address in
|
|
* native endianness in 8-, 16-, 32- or 64-bit chunks (@count times).
|
|
*/
|
|
#ifndef readsb
|
|
#define readsb readsb
|
|
static inline void readsb(const volatile void __iomem *addr, void *buffer,
|
|
unsigned int count)
|
|
{
|
|
if (count) {
|
|
u8 *buf = buffer;
|
|
|
|
do {
|
|
u8 x = __raw_readb(addr);
|
|
*buf++ = x;
|
|
} while (--count);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifndef readsw
|
|
#define readsw readsw
|
|
static inline void readsw(const volatile void __iomem *addr, void *buffer,
|
|
unsigned int count)
|
|
{
|
|
if (count) {
|
|
u16 *buf = buffer;
|
|
|
|
do {
|
|
u16 x = __raw_readw(addr);
|
|
*buf++ = x;
|
|
} while (--count);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifndef readsl
|
|
#define readsl readsl
|
|
static inline void readsl(const volatile void __iomem *addr, void *buffer,
|
|
unsigned int count)
|
|
{
|
|
if (count) {
|
|
u32 *buf = buffer;
|
|
|
|
do {
|
|
u32 x = __raw_readl(addr);
|
|
*buf++ = x;
|
|
} while (--count);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef readsq
|
|
#define readsq readsq
|
|
static inline void readsq(const volatile void __iomem *addr, void *buffer,
|
|
unsigned int count)
|
|
{
|
|
if (count) {
|
|
u64 *buf = buffer;
|
|
|
|
do {
|
|
u64 x = __raw_readq(addr);
|
|
*buf++ = x;
|
|
} while (--count);
|
|
}
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef writesb
|
|
#define writesb writesb
|
|
static inline void writesb(volatile void __iomem *addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
if (count) {
|
|
const u8 *buf = buffer;
|
|
|
|
do {
|
|
__raw_writeb(*buf++, addr);
|
|
} while (--count);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifndef writesw
|
|
#define writesw writesw
|
|
static inline void writesw(volatile void __iomem *addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
if (count) {
|
|
const u16 *buf = buffer;
|
|
|
|
do {
|
|
__raw_writew(*buf++, addr);
|
|
} while (--count);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifndef writesl
|
|
#define writesl writesl
|
|
static inline void writesl(volatile void __iomem *addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
if (count) {
|
|
const u32 *buf = buffer;
|
|
|
|
do {
|
|
__raw_writel(*buf++, addr);
|
|
} while (--count);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef writesq
|
|
#define writesq writesq
|
|
static inline void writesq(volatile void __iomem *addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
if (count) {
|
|
const u64 *buf = buffer;
|
|
|
|
do {
|
|
__raw_writeq(*buf++, addr);
|
|
} while (--count);
|
|
}
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef PCI_IOBASE
|
|
#define PCI_IOBASE ((void __iomem *)0)
|
|
#endif
|
|
|
|
#ifndef IO_SPACE_LIMIT
|
|
#define IO_SPACE_LIMIT 0xffff
|
|
#endif
|
|
|
|
/*
|
|
* {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be
|
|
* implemented on hardware that needs an additional delay for I/O accesses to
|
|
* take effect.
|
|
*/
|
|
|
|
#if !defined(inb) && !defined(_inb)
|
|
#define _inb _inb
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline u8 _inb(unsigned long addr)
|
|
{
|
|
u8 val;
|
|
|
|
__io_pbr();
|
|
val = __raw_readb(PCI_IOBASE + addr);
|
|
__io_par(val);
|
|
return val;
|
|
}
|
|
#else
|
|
u8 _inb(unsigned long addr)
|
|
__compiletime_error("inb()) requires CONFIG_HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#if !defined(inw) && !defined(_inw)
|
|
#define _inw _inw
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline u16 _inw(unsigned long addr)
|
|
{
|
|
u16 val;
|
|
|
|
__io_pbr();
|
|
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
|
|
__io_par(val);
|
|
return val;
|
|
}
|
|
#else
|
|
u16 _inw(unsigned long addr)
|
|
__compiletime_error("inw() requires CONFIG_HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#if !defined(inl) && !defined(_inl)
|
|
#define _inl _inl
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline u32 _inl(unsigned long addr)
|
|
{
|
|
u32 val;
|
|
|
|
__io_pbr();
|
|
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
|
|
__io_par(val);
|
|
return val;
|
|
}
|
|
#else
|
|
u32 _inl(unsigned long addr)
|
|
__compiletime_error("inl() requires CONFIG_HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#if !defined(outb) && !defined(_outb)
|
|
#define _outb _outb
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void _outb(u8 value, unsigned long addr)
|
|
{
|
|
__io_pbw();
|
|
__raw_writeb(value, PCI_IOBASE + addr);
|
|
__io_paw();
|
|
}
|
|
#else
|
|
void _outb(u8 value, unsigned long addr)
|
|
__compiletime_error("outb() requires CONFIG_HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#if !defined(outw) && !defined(_outw)
|
|
#define _outw _outw
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void _outw(u16 value, unsigned long addr)
|
|
{
|
|
__io_pbw();
|
|
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
|
|
__io_paw();
|
|
}
|
|
#else
|
|
void _outw(u16 value, unsigned long addr)
|
|
__compiletime_error("outw() requires CONFIG_HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#if !defined(outl) && !defined(_outl)
|
|
#define _outl _outl
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void _outl(u32 value, unsigned long addr)
|
|
{
|
|
__io_pbw();
|
|
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
|
|
__io_paw();
|
|
}
|
|
#else
|
|
void _outl(u32 value, unsigned long addr)
|
|
__compiletime_error("outl() requires CONFIG_HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#include <linux/logic_pio.h>
|
|
|
|
#ifndef inb
|
|
#define inb _inb
|
|
#endif
|
|
|
|
#ifndef inw
|
|
#define inw _inw
|
|
#endif
|
|
|
|
#ifndef inl
|
|
#define inl _inl
|
|
#endif
|
|
|
|
#ifndef outb
|
|
#define outb _outb
|
|
#endif
|
|
|
|
#ifndef outw
|
|
#define outw _outw
|
|
#endif
|
|
|
|
#ifndef outl
|
|
#define outl _outl
|
|
#endif
|
|
|
|
#ifndef inb_p
|
|
#define inb_p inb_p
|
|
static inline u8 inb_p(unsigned long addr)
|
|
{
|
|
return inb(addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef inw_p
|
|
#define inw_p inw_p
|
|
static inline u16 inw_p(unsigned long addr)
|
|
{
|
|
return inw(addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef inl_p
|
|
#define inl_p inl_p
|
|
static inline u32 inl_p(unsigned long addr)
|
|
{
|
|
return inl(addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef outb_p
|
|
#define outb_p outb_p
|
|
static inline void outb_p(u8 value, unsigned long addr)
|
|
{
|
|
outb(value, addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef outw_p
|
|
#define outw_p outw_p
|
|
static inline void outw_p(u16 value, unsigned long addr)
|
|
{
|
|
outw(value, addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef outl_p
|
|
#define outl_p outl_p
|
|
static inline void outl_p(u32 value, unsigned long addr)
|
|
{
|
|
outl(value, addr);
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* {in,out}s{b,w,l}{,_p}() are variants of the above that repeatedly access a
|
|
* single I/O port multiple times.
|
|
*/
|
|
|
|
#ifndef insb
|
|
#define insb insb
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void insb(unsigned long addr, void *buffer, unsigned int count)
|
|
{
|
|
readsb(PCI_IOBASE + addr, buffer, count);
|
|
}
|
|
#else
|
|
void insb(unsigned long addr, void *buffer, unsigned int count)
|
|
__compiletime_error("insb() requires HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef insw
|
|
#define insw insw
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void insw(unsigned long addr, void *buffer, unsigned int count)
|
|
{
|
|
readsw(PCI_IOBASE + addr, buffer, count);
|
|
}
|
|
#else
|
|
void insw(unsigned long addr, void *buffer, unsigned int count)
|
|
__compiletime_error("insw() requires HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef insl
|
|
#define insl insl
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void insl(unsigned long addr, void *buffer, unsigned int count)
|
|
{
|
|
readsl(PCI_IOBASE + addr, buffer, count);
|
|
}
|
|
#else
|
|
void insl(unsigned long addr, void *buffer, unsigned int count)
|
|
__compiletime_error("insl() requires HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef outsb
|
|
#define outsb outsb
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void outsb(unsigned long addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
writesb(PCI_IOBASE + addr, buffer, count);
|
|
}
|
|
#else
|
|
void outsb(unsigned long addr, const void *buffer, unsigned int count)
|
|
__compiletime_error("outsb() requires HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef outsw
|
|
#define outsw outsw
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void outsw(unsigned long addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
writesw(PCI_IOBASE + addr, buffer, count);
|
|
}
|
|
#else
|
|
void outsw(unsigned long addr, const void *buffer, unsigned int count)
|
|
__compiletime_error("outsw() requires HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef outsl
|
|
#define outsl outsl
|
|
#ifdef CONFIG_HAS_IOPORT
|
|
static inline void outsl(unsigned long addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
writesl(PCI_IOBASE + addr, buffer, count);
|
|
}
|
|
#else
|
|
void outsl(unsigned long addr, const void *buffer, unsigned int count)
|
|
__compiletime_error("outsl() requires HAS_IOPORT");
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef insb_p
|
|
#define insb_p insb_p
|
|
static inline void insb_p(unsigned long addr, void *buffer, unsigned int count)
|
|
{
|
|
insb(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef insw_p
|
|
#define insw_p insw_p
|
|
static inline void insw_p(unsigned long addr, void *buffer, unsigned int count)
|
|
{
|
|
insw(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef insl_p
|
|
#define insl_p insl_p
|
|
static inline void insl_p(unsigned long addr, void *buffer, unsigned int count)
|
|
{
|
|
insl(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef outsb_p
|
|
#define outsb_p outsb_p
|
|
static inline void outsb_p(unsigned long addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
outsb(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef outsw_p
|
|
#define outsw_p outsw_p
|
|
static inline void outsw_p(unsigned long addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
outsw(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef outsl_p
|
|
#define outsl_p outsl_p
|
|
static inline void outsl_p(unsigned long addr, const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
outsl(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef CONFIG_GENERIC_IOMAP
|
|
#ifndef ioread8
|
|
#define ioread8 ioread8
|
|
static inline u8 ioread8(const volatile void __iomem *addr)
|
|
{
|
|
return readb(addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef ioread16
|
|
#define ioread16 ioread16
|
|
static inline u16 ioread16(const volatile void __iomem *addr)
|
|
{
|
|
return readw(addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef ioread32
|
|
#define ioread32 ioread32
|
|
static inline u32 ioread32(const volatile void __iomem *addr)
|
|
{
|
|
return readl(addr);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef ioread64
|
|
#define ioread64 ioread64
|
|
static inline u64 ioread64(const volatile void __iomem *addr)
|
|
{
|
|
return readq(addr);
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef iowrite8
|
|
#define iowrite8 iowrite8
|
|
static inline void iowrite8(u8 value, volatile void __iomem *addr)
|
|
{
|
|
writeb(value, addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef iowrite16
|
|
#define iowrite16 iowrite16
|
|
static inline void iowrite16(u16 value, volatile void __iomem *addr)
|
|
{
|
|
writew(value, addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef iowrite32
|
|
#define iowrite32 iowrite32
|
|
static inline void iowrite32(u32 value, volatile void __iomem *addr)
|
|
{
|
|
writel(value, addr);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef iowrite64
|
|
#define iowrite64 iowrite64
|
|
static inline void iowrite64(u64 value, volatile void __iomem *addr)
|
|
{
|
|
writeq(value, addr);
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef ioread16be
|
|
#define ioread16be ioread16be
|
|
static inline u16 ioread16be(const volatile void __iomem *addr)
|
|
{
|
|
return swab16(readw(addr));
|
|
}
|
|
#endif
|
|
|
|
#ifndef ioread32be
|
|
#define ioread32be ioread32be
|
|
static inline u32 ioread32be(const volatile void __iomem *addr)
|
|
{
|
|
return swab32(readl(addr));
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef ioread64be
|
|
#define ioread64be ioread64be
|
|
static inline u64 ioread64be(const volatile void __iomem *addr)
|
|
{
|
|
return swab64(readq(addr));
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef iowrite16be
|
|
#define iowrite16be iowrite16be
|
|
static inline void iowrite16be(u16 value, void volatile __iomem *addr)
|
|
{
|
|
writew(swab16(value), addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef iowrite32be
|
|
#define iowrite32be iowrite32be
|
|
static inline void iowrite32be(u32 value, volatile void __iomem *addr)
|
|
{
|
|
writel(swab32(value), addr);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef iowrite64be
|
|
#define iowrite64be iowrite64be
|
|
static inline void iowrite64be(u64 value, volatile void __iomem *addr)
|
|
{
|
|
writeq(swab64(value), addr);
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef ioread8_rep
|
|
#define ioread8_rep ioread8_rep
|
|
static inline void ioread8_rep(const volatile void __iomem *addr, void *buffer,
|
|
unsigned int count)
|
|
{
|
|
readsb(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef ioread16_rep
|
|
#define ioread16_rep ioread16_rep
|
|
static inline void ioread16_rep(const volatile void __iomem *addr,
|
|
void *buffer, unsigned int count)
|
|
{
|
|
readsw(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef ioread32_rep
|
|
#define ioread32_rep ioread32_rep
|
|
static inline void ioread32_rep(const volatile void __iomem *addr,
|
|
void *buffer, unsigned int count)
|
|
{
|
|
readsl(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef ioread64_rep
|
|
#define ioread64_rep ioread64_rep
|
|
static inline void ioread64_rep(const volatile void __iomem *addr,
|
|
void *buffer, unsigned int count)
|
|
{
|
|
readsq(addr, buffer, count);
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
#ifndef iowrite8_rep
|
|
#define iowrite8_rep iowrite8_rep
|
|
static inline void iowrite8_rep(volatile void __iomem *addr,
|
|
const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
writesb(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef iowrite16_rep
|
|
#define iowrite16_rep iowrite16_rep
|
|
static inline void iowrite16_rep(volatile void __iomem *addr,
|
|
const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
writesw(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifndef iowrite32_rep
|
|
#define iowrite32_rep iowrite32_rep
|
|
static inline void iowrite32_rep(volatile void __iomem *addr,
|
|
const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
writesl(addr, buffer, count);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#ifndef iowrite64_rep
|
|
#define iowrite64_rep iowrite64_rep
|
|
static inline void iowrite64_rep(volatile void __iomem *addr,
|
|
const void *buffer,
|
|
unsigned int count)
|
|
{
|
|
writesq(addr, buffer, count);
|
|
}
|
|
#endif
|
|
#endif /* CONFIG_64BIT */
|
|
#endif /* CONFIG_GENERIC_IOMAP */
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
#define __io_virt(x) ((void __force *)(x))
|
|
|
|
/*
|
|
* Change virtual addresses to physical addresses and vv.
|
|
* These are pretty trivial
|
|
*/
|
|
#ifndef virt_to_phys
|
|
#define virt_to_phys virt_to_phys
|
|
static inline unsigned long virt_to_phys(volatile void *address)
|
|
{
|
|
return __pa((unsigned long)address);
|
|
}
|
|
#endif
|
|
|
|
#ifndef phys_to_virt
|
|
#define phys_to_virt phys_to_virt
|
|
static inline void *phys_to_virt(unsigned long address)
|
|
{
|
|
return __va(address);
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* DOC: ioremap() and ioremap_*() variants
|
|
*
|
|
* Architectures with an MMU are expected to provide ioremap() and iounmap()
|
|
* themselves or rely on GENERIC_IOREMAP. For NOMMU architectures we provide
|
|
* a default nop-op implementation that expect that the physical address used
|
|
* for MMIO are already marked as uncached, and can be used as kernel virtual
|
|
* addresses.
|
|
*
|
|
* ioremap_wc() and ioremap_wt() can provide more relaxed caching attributes
|
|
* for specific drivers if the architecture choses to implement them. If they
|
|
* are not implemented we fall back to plain ioremap. Conversely, ioremap_np()
|
|
* can provide stricter non-posted write semantics if the architecture
|
|
* implements them.
|
|
*/
|
|
#ifndef CONFIG_MMU
|
|
#ifndef ioremap
|
|
#define ioremap ioremap
|
|
static inline void __iomem *ioremap(phys_addr_t offset, size_t size)
|
|
{
|
|
return (void __iomem *)(unsigned long)offset;
|
|
}
|
|
#endif
|
|
|
|
#ifndef iounmap
|
|
#define iounmap iounmap
|
|
static inline void iounmap(volatile void __iomem *addr)
|
|
{
|
|
}
|
|
#endif
|
|
#elif defined(CONFIG_GENERIC_IOREMAP)
|
|
#include <linux/pgtable.h>
|
|
|
|
void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size,
|
|
pgprot_t prot);
|
|
|
|
void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
|
|
pgprot_t prot);
|
|
void iounmap(volatile void __iomem *addr);
|
|
void generic_iounmap(volatile void __iomem *addr);
|
|
|
|
#ifndef ioremap
|
|
#define ioremap ioremap
|
|
static inline void __iomem *ioremap(phys_addr_t addr, size_t size)
|
|
{
|
|
/* _PAGE_IOREMAP needs to be supplied by the architecture */
|
|
return ioremap_prot(addr, size, __pgprot(_PAGE_IOREMAP));
|
|
}
|
|
#endif
|
|
#endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */
|
|
|
|
#ifndef ioremap_wc
|
|
#define ioremap_wc ioremap
|
|
#endif
|
|
|
|
#ifndef ioremap_wt
|
|
#define ioremap_wt ioremap
|
|
#endif
|
|
|
|
/*
|
|
* ioremap_uc is special in that we do require an explicit architecture
|
|
* implementation. In general you do not want to use this function in a
|
|
* driver and use plain ioremap, which is uncached by default. Similarly
|
|
* architectures should not implement it unless they have a very good
|
|
* reason.
|
|
*/
|
|
#ifndef ioremap_uc
|
|
#define ioremap_uc ioremap_uc
|
|
static inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size)
|
|
{
|
|
return NULL;
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* ioremap_np needs an explicit architecture implementation, as it
|
|
* requests stronger semantics than regular ioremap(). Portable drivers
|
|
* should instead use one of the higher-level abstractions, like
|
|
* devm_ioremap_resource(), to choose the correct variant for any given
|
|
* device and bus. Portable drivers with a good reason to want non-posted
|
|
* write semantics should always provide an ioremap() fallback in case
|
|
* ioremap_np() is not available.
|
|
*/
|
|
#ifndef ioremap_np
|
|
#define ioremap_np ioremap_np
|
|
static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size)
|
|
{
|
|
return NULL;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_HAS_IOPORT_MAP
|
|
#ifndef CONFIG_GENERIC_IOMAP
|
|
#ifndef ioport_map
|
|
#define ioport_map ioport_map
|
|
static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
|
|
{
|
|
port &= IO_SPACE_LIMIT;
|
|
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
|
|
}
|
|
#define ARCH_HAS_GENERIC_IOPORT_MAP
|
|
#endif
|
|
|
|
#ifndef ioport_unmap
|
|
#define ioport_unmap ioport_unmap
|
|
static inline void ioport_unmap(void __iomem *p)
|
|
{
|
|
}
|
|
#endif
|
|
#else /* CONFIG_GENERIC_IOMAP */
|
|
extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
|
|
extern void ioport_unmap(void __iomem *p);
|
|
#endif /* CONFIG_GENERIC_IOMAP */
|
|
#endif /* CONFIG_HAS_IOPORT_MAP */
|
|
|
|
#ifndef CONFIG_GENERIC_IOMAP
|
|
#ifndef pci_iounmap
|
|
#define ARCH_WANTS_GENERIC_PCI_IOUNMAP
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef xlate_dev_mem_ptr
|
|
#define xlate_dev_mem_ptr xlate_dev_mem_ptr
|
|
static inline void *xlate_dev_mem_ptr(phys_addr_t addr)
|
|
{
|
|
return __va(addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef unxlate_dev_mem_ptr
|
|
#define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
|
|
static inline void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#ifndef 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.
|
|
*/
|
|
void memset_io(volatile void __iomem *addr, int val, size_t count);
|
|
#endif
|
|
|
|
#ifndef 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.
|
|
*/
|
|
void memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count);
|
|
#endif
|
|
|
|
#ifndef 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.
|
|
*/
|
|
void memcpy_toio(volatile void __iomem *dst, const void *src, size_t count);
|
|
#endif
|
|
|
|
extern int devmem_is_allowed(unsigned long pfn);
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* __ASM_GENERIC_IO_H */
|