arch/arm/mm/cache-l2x0.c
Source file repositories/reference/linux-study-clean/arch/arm/mm/cache-l2x0.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/mm/cache-l2x0.c- Extension
.c- Size
- 50680 bytes
- Lines
- 1827
- Domain
- Architecture Layer
- Bucket
- arch/arm
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cpu.hlinux/err.hlinux/init.hlinux/smp.hlinux/spinlock.hlinux/log2.hlinux/io.hlinux/of.hlinux/of_address.hlinux/string_choices.hasm/cacheflush.hasm/cp15.hasm/cputype.hasm/hardware/cache-l2x0.hasm/hardware/cache-aurora-l2.hcache-tauros3.h
Detected Declarations
struct l2c_init_datafunction l2c_wait_maskfunction l2c_write_secfunction l2c_set_debugfunction __l2c_op_wayfunction l2c_unlockfunction l2c_configurefunction l2c_enablefunction l2c_disablefunction l2c_savefunction l2c_resumefunction ignoredfunction __l2c210_op_pa_rangefunction l2c210_inv_rangefunction l2c210_clean_rangefunction l2c210_flush_rangefunction l2c210_flush_allfunction l2c210_syncfunction errorfunction l2c220_op_wayfunction l2c220_op_pa_rangefunction l2c220_inv_rangefunction l2c220_clean_rangefunction l2c220_flush_rangefunction l2c220_flush_allfunction l2c220_syncfunction l2c220_enablefunction l2c220_unlockfunction __l2c210_cache_syncfunction l2c310_flush_range_erratumfunction l2c310_flush_all_erratumfunction l2c310_savefunction l2c310_configurefunction l2c310_starting_cpufunction l2c310_dying_cpufunction l2c310_enablefunction l2c310_fixupfunction l2c310_disablefunction l2c310_resumefunction l2c310_unlockfunction __l2c_initfunction l2x0_initfunction l2x0_cache_size_of_parsefunction l2x0_of_parsefunction l2c310_of_parsefunction aurora_range_endfunction aurora_pa_rangefunction aurora_inv_range
Annotated Snippet
struct l2c_init_data {
const char *type;
unsigned way_size_0;
unsigned num_lock;
void (*of_parse)(const struct device_node *, u32 *, u32 *);
void (*enable)(void __iomem *, unsigned);
void (*fixup)(void __iomem *, u32, struct outer_cache_fns *);
void (*save)(void __iomem *);
void (*configure)(void __iomem *);
void (*unlock)(void __iomem *, unsigned);
struct outer_cache_fns outer_cache;
};
#define CACHE_LINE_SIZE 32
static void __iomem *l2x0_base;
static const struct l2c_init_data *l2x0_data;
static DEFINE_RAW_SPINLOCK(l2x0_lock);
static u32 l2x0_way_mask; /* Bitmask of active ways */
static u32 l2x0_size;
static unsigned long sync_reg_offset = L2X0_CACHE_SYNC;
struct l2x0_regs l2x0_saved_regs;
static bool l2x0_bresp_disable;
static bool l2x0_flz_disable;
/*
* Common code for all cache controllers.
*/
static inline void l2c_wait_mask(void __iomem *reg, unsigned long mask)
{
/* wait for cache operation by line or way to complete */
while (readl_relaxed(reg) & mask)
cpu_relax();
}
/*
* By default, we write directly to secure registers. Platforms must
* override this if they are running non-secure.
*/
static void l2c_write_sec(unsigned long val, void __iomem *base, unsigned reg)
{
if (val == readl_relaxed(base + reg))
return;
if (outer_cache.write_sec)
outer_cache.write_sec(val, reg);
else
writel_relaxed(val, base + reg);
}
/*
* This should only be called when we have a requirement that the
* register be written due to a work-around, as platforms running
* in non-secure mode may not be able to access this register.
*/
static inline void l2c_set_debug(void __iomem *base, unsigned long val)
{
l2c_write_sec(val, base, L2X0_DEBUG_CTRL);
}
static void __l2c_op_way(void __iomem *reg)
{
writel_relaxed(l2x0_way_mask, reg);
l2c_wait_mask(reg, l2x0_way_mask);
}
static inline void l2c_unlock(void __iomem *base, unsigned num)
{
unsigned i;
for (i = 0; i < num; i++) {
writel_relaxed(0, base + L2X0_LOCKDOWN_WAY_D_BASE +
i * L2X0_LOCKDOWN_STRIDE);
writel_relaxed(0, base + L2X0_LOCKDOWN_WAY_I_BASE +
i * L2X0_LOCKDOWN_STRIDE);
}
}
static void l2c_configure(void __iomem *base)
{
l2c_write_sec(l2x0_saved_regs.aux_ctrl, base, L2X0_AUX_CTRL);
}
/*
* Enable the L2 cache controller. This function must only be
* called when the cache controller is known to be disabled.
*/
static void l2c_enable(void __iomem *base, unsigned num_lock)
{
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/err.h`, `linux/init.h`, `linux/smp.h`, `linux/spinlock.h`, `linux/log2.h`, `linux/io.h`, `linux/of.h`.
- Detected declarations: `struct l2c_init_data`, `function l2c_wait_mask`, `function l2c_write_sec`, `function l2c_set_debug`, `function __l2c_op_way`, `function l2c_unlock`, `function l2c_configure`, `function l2c_enable`, `function l2c_disable`, `function l2c_save`.
- Atlas domain: Architecture Layer / arch/arm.
- Implementation status: source 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.