mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-09 11:30:02 +00:00
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() ...
565 lines
16 KiB
C
565 lines
16 KiB
C
/*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
* for more details.
|
|
*
|
|
* Copyright (C) 1994, 1995 Waldorf GmbH
|
|
* Copyright (C) 1994 - 2000, 06 Ralf Baechle
|
|
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
|
|
* Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved.
|
|
* Author: Maciej W. Rozycki <macro@mips.com>
|
|
*/
|
|
#ifndef _ASM_IO_H
|
|
#define _ASM_IO_H
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/types.h>
|
|
#include <linux/irqflags.h>
|
|
|
|
#include <asm/addrspace.h>
|
|
#include <asm/barrier.h>
|
|
#include <asm/bug.h>
|
|
#include <asm/byteorder.h>
|
|
#include <asm/cpu.h>
|
|
#include <asm/cpu-features.h>
|
|
#include <asm/page.h>
|
|
#include <asm/pgtable-bits.h>
|
|
#include <asm/string.h>
|
|
#include <mangle-port.h>
|
|
|
|
/*
|
|
* Raw operations are never swapped in software. OTOH values that raw
|
|
* operations are working on may or may not have been swapped by the bus
|
|
* hardware. An example use would be for flash memory that's used for
|
|
* execute in place.
|
|
*/
|
|
# define __raw_ioswabb(a, x) (x)
|
|
# define __raw_ioswabw(a, x) (x)
|
|
# define __raw_ioswabl(a, x) (x)
|
|
# define __raw_ioswabq(a, x) (x)
|
|
# define ____raw_ioswabq(a, x) (x)
|
|
|
|
# define _ioswabb ioswabb
|
|
# define _ioswabw ioswabw
|
|
# define _ioswabl ioswabl
|
|
# define _ioswabq ioswabq
|
|
|
|
# define __relaxed_ioswabb ioswabb
|
|
# define __relaxed_ioswabw ioswabw
|
|
# define __relaxed_ioswabl ioswabl
|
|
# define __relaxed_ioswabq ioswabq
|
|
|
|
/* ioswab[bwlq], __mem_ioswab[bwlq] are defined in mangle-port.h */
|
|
|
|
/*
|
|
* On MIPS I/O ports are memory mapped, so we access them using normal
|
|
* load/store instructions. mips_io_port_base is the virtual address to
|
|
* which all ports are being mapped. For sake of efficiency some code
|
|
* assumes that this is an address that can be loaded with a single lui
|
|
* instruction, so the lower 16 bits must be zero. Should be true on
|
|
* any sane architecture; generic code does not use this assumption.
|
|
*/
|
|
extern unsigned long mips_io_port_base;
|
|
|
|
static inline void set_io_port_base(unsigned long base)
|
|
{
|
|
mips_io_port_base = base;
|
|
}
|
|
|
|
/*
|
|
* Enforce in-order execution of data I/O. In the MIPS architecture
|
|
* these are equivalent to corresponding platform-specific memory
|
|
* barriers defined in <asm/barrier.h>. API pinched from PowerPC,
|
|
* with sync additionally defined.
|
|
*/
|
|
#define iobarrier_rw() mb()
|
|
#define iobarrier_r() rmb()
|
|
#define iobarrier_w() wmb()
|
|
#define iobarrier_sync() iob()
|
|
|
|
/*
|
|
* 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 unsigned long __virt_to_phys_nodebug(volatile const void *address)
|
|
{
|
|
return __pa(address);
|
|
}
|
|
|
|
#ifdef CONFIG_DEBUG_VIRTUAL
|
|
extern phys_addr_t __virt_to_phys(volatile const void *x);
|
|
#else
|
|
#define __virt_to_phys(x) __virt_to_phys_nodebug(x)
|
|
#endif
|
|
|
|
#define virt_to_phys virt_to_phys
|
|
static inline phys_addr_t virt_to_phys(const volatile void *x)
|
|
{
|
|
return __virt_to_phys(x);
|
|
}
|
|
|
|
/*
|
|
* ISA I/O bus memory addresses are 1:1 with the physical address.
|
|
*/
|
|
static inline unsigned long isa_virt_to_bus(volatile void *address)
|
|
{
|
|
return virt_to_phys(address);
|
|
}
|
|
|
|
void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
|
|
pgprot_t prot);
|
|
void iounmap(const volatile void __iomem *addr);
|
|
|
|
/*
|
|
* 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.
|
|
*/
|
|
#define ioremap(offset, size) \
|
|
ioremap_prot((offset), (size), __pgprot(_CACHE_UNCACHED))
|
|
|
|
/*
|
|
* ioremap_cache - map bus memory into CPU space
|
|
* @offset: bus address of the memory
|
|
* @size: size of the resource to map
|
|
*
|
|
* ioremap_cache 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.
|
|
*
|
|
* This version of ioremap ensures that the memory is marked cacheable by
|
|
* the CPU. Also enables full write-combining. Useful for some
|
|
* memory-like regions on I/O busses.
|
|
*/
|
|
#define ioremap_cache(offset, size) \
|
|
ioremap_prot((offset), (size), __pgprot(_page_cachable_default))
|
|
|
|
/*
|
|
* ioremap_wc - map bus memory into CPU space
|
|
* @offset: bus address of the memory
|
|
* @size: size of the resource to map
|
|
*
|
|
* ioremap_wc 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.
|
|
*
|
|
* This version of ioremap ensures that the memory is marked uncacheable
|
|
* but accelerated by means of write-combining feature. It is specifically
|
|
* useful for PCIe prefetchable windows, which may vastly improve a
|
|
* communications performance. If it was determined on boot stage, what
|
|
* CPU CCA doesn't support UCA, the method shall fall-back to the
|
|
* _CACHE_UNCACHED option (see cpu_probe() method).
|
|
*/
|
|
#define ioremap_wc(offset, size) \
|
|
ioremap_prot((offset), (size), __pgprot(boot_cpu_data.writecombine))
|
|
|
|
#if defined(CONFIG_CPU_CAVIUM_OCTEON)
|
|
#define war_io_reorder_wmb() wmb()
|
|
#else
|
|
#define war_io_reorder_wmb() barrier()
|
|
#endif
|
|
|
|
#define __BUILD_MEMORY_SINGLE(pfx, bwlq, type, barrier, relax, irq) \
|
|
\
|
|
static inline void pfx##write##bwlq(type val, \
|
|
volatile void __iomem *mem) \
|
|
{ \
|
|
volatile type *__mem; \
|
|
type __val; \
|
|
\
|
|
if (barrier) \
|
|
iobarrier_rw(); \
|
|
else \
|
|
war_io_reorder_wmb(); \
|
|
\
|
|
__mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
|
|
\
|
|
__val = pfx##ioswab##bwlq(__mem, val); \
|
|
\
|
|
if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
|
|
*__mem = __val; \
|
|
else if (cpu_has_64bits) { \
|
|
unsigned long __flags; \
|
|
type __tmp; \
|
|
\
|
|
if (irq) \
|
|
local_irq_save(__flags); \
|
|
__asm__ __volatile__( \
|
|
".set push" "\t\t# __writeq""\n\t" \
|
|
".set arch=r4000" "\n\t" \
|
|
"dsll32 %L0, %L0, 0" "\n\t" \
|
|
"dsrl32 %L0, %L0, 0" "\n\t" \
|
|
"dsll32 %M0, %M0, 0" "\n\t" \
|
|
"or %L0, %L0, %M0" "\n\t" \
|
|
"sd %L0, %2" "\n\t" \
|
|
".set pop" "\n" \
|
|
: "=r" (__tmp) \
|
|
: "0" (__val), "m" (*__mem)); \
|
|
if (irq) \
|
|
local_irq_restore(__flags); \
|
|
} else \
|
|
BUG(); \
|
|
} \
|
|
\
|
|
static inline type pfx##read##bwlq(const volatile void __iomem *mem) \
|
|
{ \
|
|
volatile type *__mem; \
|
|
type __val; \
|
|
\
|
|
__mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
|
|
\
|
|
if (barrier) \
|
|
iobarrier_rw(); \
|
|
\
|
|
if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
|
|
__val = *__mem; \
|
|
else if (cpu_has_64bits) { \
|
|
unsigned long __flags; \
|
|
\
|
|
if (irq) \
|
|
local_irq_save(__flags); \
|
|
__asm__ __volatile__( \
|
|
".set push" "\t\t# __readq" "\n\t" \
|
|
".set arch=r4000" "\n\t" \
|
|
"ld %L0, %1" "\n\t" \
|
|
"dsra32 %M0, %L0, 0" "\n\t" \
|
|
"sll %L0, %L0, 0" "\n\t" \
|
|
".set pop" "\n" \
|
|
: "=r" (__val) \
|
|
: "m" (*__mem)); \
|
|
if (irq) \
|
|
local_irq_restore(__flags); \
|
|
} else { \
|
|
__val = 0; \
|
|
BUG(); \
|
|
} \
|
|
\
|
|
/* prevent prefetching of coherent DMA data prematurely */ \
|
|
if (!relax) \
|
|
rmb(); \
|
|
return pfx##ioswab##bwlq(__mem, __val); \
|
|
}
|
|
|
|
#define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, barrier, relax) \
|
|
\
|
|
static inline void pfx##out##bwlq(type val, unsigned long port) \
|
|
{ \
|
|
volatile type *__addr; \
|
|
type __val; \
|
|
\
|
|
if (barrier) \
|
|
iobarrier_rw(); \
|
|
else \
|
|
war_io_reorder_wmb(); \
|
|
\
|
|
__addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
|
|
\
|
|
__val = pfx##ioswab##bwlq(__addr, val); \
|
|
\
|
|
/* Really, we want this to be atomic */ \
|
|
BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
|
|
\
|
|
*__addr = __val; \
|
|
} \
|
|
\
|
|
static inline type pfx##in##bwlq(unsigned long port) \
|
|
{ \
|
|
volatile type *__addr; \
|
|
type __val; \
|
|
\
|
|
__addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
|
|
\
|
|
BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
|
|
\
|
|
if (barrier) \
|
|
iobarrier_rw(); \
|
|
\
|
|
__val = *__addr; \
|
|
\
|
|
/* prevent prefetching of coherent DMA data prematurely */ \
|
|
if (!relax) \
|
|
rmb(); \
|
|
return pfx##ioswab##bwlq(__addr, __val); \
|
|
}
|
|
|
|
#define __BUILD_MEMORY_PFX(bus, bwlq, type, relax) \
|
|
\
|
|
__BUILD_MEMORY_SINGLE(bus, bwlq, type, 1, relax, 1)
|
|
|
|
#define BUILDIO_MEM(bwlq, type) \
|
|
\
|
|
__BUILD_MEMORY_PFX(__raw_, bwlq, type, 0) \
|
|
__BUILD_MEMORY_PFX(__relaxed_, bwlq, type, 1) \
|
|
__BUILD_MEMORY_PFX(__mem_, bwlq, type, 0) \
|
|
__BUILD_MEMORY_PFX(, bwlq, type, 0)
|
|
|
|
BUILDIO_MEM(b, u8)
|
|
BUILDIO_MEM(w, u16)
|
|
BUILDIO_MEM(l, u32)
|
|
#ifdef CONFIG_64BIT
|
|
BUILDIO_MEM(q, u64)
|
|
#else
|
|
__BUILD_MEMORY_PFX(__raw_, q, u64, 0)
|
|
__BUILD_MEMORY_PFX(__mem_, q, u64, 0)
|
|
#endif
|
|
|
|
#define __BUILD_IOPORT_PFX(bus, bwlq, type) \
|
|
__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0)
|
|
|
|
#define BUILDIO_IOPORT(bwlq, type) \
|
|
__BUILD_IOPORT_PFX(_, bwlq, type) \
|
|
__BUILD_IOPORT_PFX(__mem_, bwlq, type)
|
|
|
|
BUILDIO_IOPORT(b, u8)
|
|
BUILDIO_IOPORT(w, u16)
|
|
BUILDIO_IOPORT(l, u32)
|
|
#ifdef CONFIG_64BIT
|
|
BUILDIO_IOPORT(q, u64)
|
|
#endif
|
|
|
|
#define __BUILDIO(bwlq, type) \
|
|
\
|
|
__BUILD_MEMORY_SINGLE(____raw_, bwlq, type, 1, 0, 0)
|
|
|
|
__BUILDIO(q, u64)
|
|
|
|
#define readb_relaxed __relaxed_readb
|
|
#define readw_relaxed __relaxed_readw
|
|
#define readl_relaxed __relaxed_readl
|
|
#ifdef CONFIG_64BIT
|
|
#define readq_relaxed __relaxed_readq
|
|
#endif
|
|
|
|
#define writeb_relaxed __relaxed_writeb
|
|
#define writew_relaxed __relaxed_writew
|
|
#define writel_relaxed __relaxed_writel
|
|
#ifdef CONFIG_64BIT
|
|
#define writeq_relaxed __relaxed_writeq
|
|
#endif
|
|
|
|
#define readb_be(addr) \
|
|
__raw_readb((__force unsigned *)(addr))
|
|
#define readw_be(addr) \
|
|
be16_to_cpu(__raw_readw((__force unsigned *)(addr)))
|
|
#define readl_be(addr) \
|
|
be32_to_cpu(__raw_readl((__force unsigned *)(addr)))
|
|
#define readq_be(addr) \
|
|
be64_to_cpu(__raw_readq((__force unsigned *)(addr)))
|
|
|
|
#define writeb_be(val, addr) \
|
|
__raw_writeb((val), (__force unsigned *)(addr))
|
|
#define writew_be(val, addr) \
|
|
__raw_writew(cpu_to_be16((val)), (__force unsigned *)(addr))
|
|
#define writel_be(val, addr) \
|
|
__raw_writel(cpu_to_be32((val)), (__force unsigned *)(addr))
|
|
#define writeq_be(val, addr) \
|
|
__raw_writeq(cpu_to_be64((val)), (__force unsigned *)(addr))
|
|
|
|
#define __BUILD_MEMORY_STRING(bwlq, type) \
|
|
\
|
|
static inline void writes##bwlq(volatile void __iomem *mem, \
|
|
const void *addr, unsigned int count) \
|
|
{ \
|
|
const volatile type *__addr = addr; \
|
|
\
|
|
while (count--) { \
|
|
__mem_write##bwlq(*__addr, mem); \
|
|
__addr++; \
|
|
} \
|
|
} \
|
|
\
|
|
static inline void reads##bwlq(const volatile void __iomem *mem, \
|
|
void *addr, unsigned int count) \
|
|
{ \
|
|
volatile type *__addr = addr; \
|
|
\
|
|
while (count--) { \
|
|
*__addr = __mem_read##bwlq(mem); \
|
|
__addr++; \
|
|
} \
|
|
}
|
|
|
|
#define __BUILD_IOPORT_STRING(bwlq, type) \
|
|
\
|
|
static inline void outs##bwlq(unsigned long port, const void *addr, \
|
|
unsigned int count) \
|
|
{ \
|
|
const volatile type *__addr = addr; \
|
|
\
|
|
while (count--) { \
|
|
__mem_out##bwlq(*__addr, port); \
|
|
__addr++; \
|
|
} \
|
|
} \
|
|
\
|
|
static inline void ins##bwlq(unsigned long port, void *addr, \
|
|
unsigned int count) \
|
|
{ \
|
|
volatile type *__addr = addr; \
|
|
\
|
|
while (count--) { \
|
|
*__addr = __mem_in##bwlq(port); \
|
|
__addr++; \
|
|
} \
|
|
}
|
|
|
|
#define BUILDSTRING(bwlq, type) \
|
|
\
|
|
__BUILD_MEMORY_STRING(bwlq, type) \
|
|
__BUILD_IOPORT_STRING(bwlq, type)
|
|
|
|
BUILDSTRING(b, u8)
|
|
BUILDSTRING(w, u16)
|
|
BUILDSTRING(l, u32)
|
|
#ifdef CONFIG_64BIT
|
|
BUILDSTRING(q, u64)
|
|
#endif
|
|
|
|
|
|
/*
|
|
* The caches on some architectures aren't dma-coherent and have need to
|
|
* handle this in software. There are three types of operations that
|
|
* can be applied to dma buffers.
|
|
*
|
|
* - dma_cache_wback_inv(start, size) makes caches and coherent by
|
|
* writing the content of the caches back to memory, if necessary.
|
|
* The function also invalidates the affected part of the caches as
|
|
* necessary before DMA transfers from outside to memory.
|
|
* - dma_cache_wback(start, size) makes caches and coherent by
|
|
* writing the content of the caches back to memory, if necessary.
|
|
* The function also invalidates the affected part of the caches as
|
|
* necessary before DMA transfers from outside to memory.
|
|
* - dma_cache_inv(start, size) invalidates the affected parts of the
|
|
* caches. Dirty lines of the caches may be written back or simply
|
|
* be discarded. This operation is necessary before dma operations
|
|
* to the memory.
|
|
*
|
|
* This API used to be exported; it now is for arch code internal use only.
|
|
*/
|
|
#ifdef CONFIG_DMA_NONCOHERENT
|
|
|
|
extern void (*_dma_cache_wback_inv)(unsigned long start, unsigned long size);
|
|
extern void (*_dma_cache_wback)(unsigned long start, unsigned long size);
|
|
extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
|
|
|
|
#define dma_cache_wback_inv(start, size) _dma_cache_wback_inv(start, size)
|
|
#define dma_cache_wback(start, size) _dma_cache_wback(start, size)
|
|
#define dma_cache_inv(start, size) _dma_cache_inv(start, size)
|
|
|
|
#else /* Sane hardware */
|
|
|
|
#define dma_cache_wback_inv(start,size) \
|
|
do { (void) (start); (void) (size); } while (0)
|
|
#define dma_cache_wback(start,size) \
|
|
do { (void) (start); (void) (size); } while (0)
|
|
#define dma_cache_inv(start,size) \
|
|
do { (void) (start); (void) (size); } while (0)
|
|
|
|
#endif /* CONFIG_DMA_NONCOHERENT */
|
|
|
|
/*
|
|
* Read a 32-bit register that requires a 64-bit read cycle on the bus.
|
|
* Avoid interrupt mucking, just adjust the address for 4-byte access.
|
|
* Assume the addresses are 8-byte aligned.
|
|
*/
|
|
#ifdef __MIPSEB__
|
|
#define __CSR_32_ADJUST 4
|
|
#else
|
|
#define __CSR_32_ADJUST 0
|
|
#endif
|
|
|
|
#define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
|
|
#define csr_in32(a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
|
|
|
|
#define __raw_readb __raw_readb
|
|
#define __raw_readw __raw_readw
|
|
#define __raw_readl __raw_readl
|
|
#ifdef CONFIG_64BIT
|
|
#define __raw_readq __raw_readq
|
|
#endif
|
|
#define __raw_writeb __raw_writeb
|
|
#define __raw_writew __raw_writew
|
|
#define __raw_writel __raw_writel
|
|
#ifdef CONFIG_64BIT
|
|
#define __raw_writeq __raw_writeq
|
|
#endif
|
|
|
|
#define readb readb
|
|
#define readw readw
|
|
#define readl readl
|
|
#ifdef CONFIG_64BIT
|
|
#define readq readq
|
|
#endif
|
|
#define writeb writeb
|
|
#define writew writew
|
|
#define writel writel
|
|
#ifdef CONFIG_64BIT
|
|
#define writeq writeq
|
|
#endif
|
|
|
|
#define readsb readsb
|
|
#define readsw readsw
|
|
#define readsl readsl
|
|
#ifdef CONFIG_64BIT
|
|
#define readsq readsq
|
|
#endif
|
|
#define writesb writesb
|
|
#define writesw writesw
|
|
#define writesl writesl
|
|
#ifdef CONFIG_64BIT
|
|
#define writesq writesq
|
|
#endif
|
|
|
|
#define _inb _inb
|
|
#define _inw _inw
|
|
#define _inl _inl
|
|
#define insb insb
|
|
#define insw insw
|
|
#define insl insl
|
|
|
|
#define _outb _outb
|
|
#define _outw _outw
|
|
#define _outl _outl
|
|
#define outsb outsb
|
|
#define outsw outsw
|
|
#define outsl outsl
|
|
|
|
void __ioread64_copy(void *to, const void __iomem *from, size_t count);
|
|
|
|
#if defined(CONFIG_PCI) && defined(CONFIG_PCI_DRIVERS_LEGACY)
|
|
struct pci_dev;
|
|
void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
|
|
#define pci_iounmap pci_iounmap
|
|
#endif
|
|
|
|
#ifndef PCI_IOBASE
|
|
#define PCI_IOBASE ((void __iomem *)mips_io_port_base)
|
|
#endif
|
|
|
|
#include <asm-generic/io.h>
|
|
|
|
static inline void *isa_bus_to_virt(unsigned long address)
|
|
{
|
|
return phys_to_virt(address);
|
|
}
|
|
|
|
#endif /* _ASM_IO_H */
|