arch/arc/mm/cache.c
Source file repositories/reference/linux-study-clean/arch/arc/mm/cache.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arc/mm/cache.c- Extension
.c- Size
- 29641 bytes
- Lines
- 1095
- Domain
- Architecture Layer
- Bucket
- arch/arc
- Inferred role
- Architecture Layer: syscall or user/kernel boundary
- Status
- core implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/mm.hlinux/sched.hlinux/cache.hlinux/mmu_context.hlinux/syscalls.hlinux/uaccess.hlinux/pagemap.hasm/cacheflush.hasm/cachectl.hasm/setup.h
Detected Declarations
syscall cacheflushstruct ic_inv_argsfunction read_decode_cache_bcr_arcv2function arc_cache_mumbojumbofunction HS38xfunction __cache_line_loop_v4function __cache_line_loop_v4function regimefunction __before_dc_opfunction __after_dc_opfunction __dc_entire_opfunction __dc_disablefunction __dc_enablefunction __dc_line_opfunction __ic_entire_invfunction __ic_line_inv_vaddr_localfunction __ic_line_inv_vaddr_helperfunction __ic_line_inv_vaddrfunction slc_op_rgnfunction slc_op_linefunction slc_entire_opfunction arc_slc_disablefunction arc_slc_enablefunction flush_dcache_foliofunction flush_dcache_pagefunction __dma_cache_wback_inv_l1function __dma_cache_inv_l1function __dma_cache_wback_l1function __dma_cache_wback_inv_slcfunction __dma_cache_inv_slcfunction __dma_cache_wback_slcfunction dma_cache_wback_invfunction dma_cache_invfunction dma_cache_wbackfunction codefunction cachefunction __inv_icache_pagesfunction __flush_dcache_pagesfunction flush_cache_allfunction copy_user_highpagefunction clear_user_pagefunction arc_ioc_setupfunction arc_cache_init_masterfunction IOCexport flush_dcache_folioexport flush_dcache_pageexport dma_cache_wback_invexport dma_cache_inv
Annotated Snippet
SYSCALL_DEFINE3(cacheflush, uint32_t, start, uint32_t, sz, uint32_t, flags)
{
/* TBD: optimize this */
flush_cache_all();
return 0;
}
/*
* IO-Coherency (IOC) setup rules:
*
* 1. Needs to be at system level, so only once by Master core
* Non-Masters need not be accessing caches at that time
* - They are either HALT_ON_RESET and kick started much later or
* - if run on reset, need to ensure that arc_platform_smp_wait_to_boot()
* doesn't perturb caches or coherency unit
*
* 2. caches (L1 and SLC) need to be purged (flush+inv) before setting up IOC,
* otherwise any straggler data might behave strangely post IOC enabling
*
* 3. All Caches need to be disabled when setting up IOC to elide any in-flight
* Coherency transactions
*/
static noinline void __init arc_ioc_setup(void)
{
unsigned int ioc_base, mem_sz;
/*
* If IOC was already enabled (due to bootloader) it technically needs to
* be reconfigured with aperture base,size corresponding to Linux memory map
* which will certainly be different than uboot's. But disabling and
* reenabling IOC when DMA might be potentially active is tricky business.
* To avoid random memory issues later, just panic here and ask user to
* upgrade bootloader to one which doesn't enable IOC
*/
if (read_aux_reg(ARC_REG_IO_COH_ENABLE) & ARC_IO_COH_ENABLE_BIT)
panic("IOC already enabled, please upgrade bootloader!\n");
if (!ioc_enable)
return;
/* Flush + invalidate + disable L1 dcache */
__dc_disable();
/* Flush + invalidate SLC */
if (read_aux_reg(ARC_REG_SLC_BCR))
slc_entire_op(OP_FLUSH_N_INV);
/*
* currently IOC Aperture covers entire DDR
* TBD: fix for PGU + 1GB of low mem
* TBD: fix for PAE
*/
mem_sz = arc_get_mem_sz();
if (!is_power_of_2(mem_sz) || mem_sz < 4096)
panic("IOC Aperture size must be power of 2 larger than 4KB");
/*
* IOC Aperture size decoded as 2 ^ (SIZE + 2) KB,
* so setting 0x11 implies 512MB, 0x12 implies 1GB...
*/
write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, order_base_2(mem_sz >> 10) - 2);
/* for now assume kernel base is start of IOC aperture */
ioc_base = CONFIG_LINUX_RAM_BASE;
if (ioc_base % mem_sz != 0)
panic("IOC Aperture start must be aligned to the size of the aperture");
write_aux_reg(ARC_REG_IO_COH_AP0_BASE, ioc_base >> 12);
write_aux_reg(ARC_REG_IO_COH_PARTIAL, ARC_IO_COH_PARTIAL_BIT);
write_aux_reg(ARC_REG_IO_COH_ENABLE, ARC_IO_COH_ENABLE_BIT);
/* Re-enable L1 dcache */
__dc_enable();
}
/*
* Cache related boot time checks/setups only needed on master CPU:
* - Geometry checks (kernel build and hardware agree: e.g. L1_CACHE_BYTES)
* Assume SMP only, so all cores will have same cache config. A check on
* one core suffices for all
* - IOC setup / dma callbacks only need to be done once
*/
static noinline void __init arc_cache_init_master(void)
{
if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) {
struct cpuinfo_arc_cache *ic = &ic_info;
if (!ic->line_len)
Annotation
- Immediate include surface: `linux/module.h`, `linux/mm.h`, `linux/sched.h`, `linux/cache.h`, `linux/mmu_context.h`, `linux/syscalls.h`, `linux/uaccess.h`, `linux/pagemap.h`.
- Detected declarations: `syscall cacheflush`, `struct ic_inv_args`, `function read_decode_cache_bcr_arcv2`, `function arc_cache_mumbojumbo`, `function HS38x`, `function __cache_line_loop_v4`, `function __cache_line_loop_v4`, `function regime`, `function __before_dc_op`, `function __after_dc_op`.
- Atlas domain: Architecture Layer / arch/arc.
- Implementation status: core implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.