arch/sparc/mm/srmmu.c
Source file repositories/reference/linux-study-clean/arch/sparc/mm/srmmu.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/mm/srmmu.c- Extension
.c- Size
- 49101 bytes
- Lines
- 1803
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/seq_file.hlinux/spinlock.hlinux/memblock.hlinux/pagemap.hlinux/vmalloc.hlinux/kdebug.hlinux/export.hlinux/kernel.hlinux/init.hlinux/log2.hlinux/gfp.hlinux/fs.hlinux/mm.hasm/mmu_context.hasm/cacheflush.hasm/tlbflush.hasm/io-unit.hasm/pgalloc.hasm/pgtable.hasm/bitext.hasm/vaddrs.hasm/cache.hasm/traps.hasm/oplib.hasm/mbus.hasm/page.hasm/asi.hasm/smp.hasm/io.hasm/turbosparc.hasm/tsunami.hasm/viking.h
Detected Declarations
struct ctx_listfunction srmmu_pmd_nonefunction srmmu_ctxd_setfunction msi_set_syncfunction pmd_setfunction srmmu_free_nocachefunction probe_memoryfunction srmmu_nocache_calcsizefunction srmmu_nocache_initfunction pte_alloc_onefunction pte_freefunction remove_from_ctx_listfunction add_to_ctx_listfunction alloc_contextfunction free_contextfunction sparc_context_initfunction switch_mmfunction srmmu_mapioaddrfunction srmmu_mapiorangefunction srmmu_unmapioaddrfunction srmmu_unmapiorangefunction swift_flush_tlb_pagefunction early_pgtable_allocfailfunction srmmu_early_allocate_ptable_skeletonfunction srmmu_allocate_ptable_skeletonfunction srmmu_probefunction srmmu_inherit_prom_mappingsfunction do_large_mappingfunction map_spbankfunction map_kernelfunction arch_zone_limits_initfunction srmmu_paging_initfunction mmu_infofunction init_new_contextfunction destroy_contextfunction srmmu_is_badfunction init_vac_layoutfunction poke_hypersparcfunction init_hypersparcfunction poke_swiftfunction init_swiftfunction turbosparc_flush_cache_allfunction turbosparc_flush_cache_mmfunction turbosparc_flush_cache_rangefunction turbosparc_flush_cache_pagefunction turbosparc_flush_page_to_ramfunction turbosparc_flush_sig_insnsfunction turbosparc_flush_tlb_all
Annotated Snippet
struct ctx_list {
struct ctx_list *next;
struct ctx_list *prev;
unsigned int ctx_number;
struct mm_struct *ctx_mm;
};
static struct ctx_list *ctx_list_pool;
static struct ctx_list ctx_free;
static struct ctx_list ctx_used;
/* At boot time we determine the number of contexts */
static int num_contexts;
static inline void remove_from_ctx_list(struct ctx_list *entry)
{
entry->next->prev = entry->prev;
entry->prev->next = entry->next;
}
static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry)
{
entry->next = head;
(entry->prev = head->prev)->next = entry;
head->prev = entry;
}
#define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry)
#define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry)
static inline void alloc_context(struct mm_struct *old_mm, struct mm_struct *mm)
{
struct ctx_list *ctxp;
ctxp = ctx_free.next;
if (ctxp != &ctx_free) {
remove_from_ctx_list(ctxp);
add_to_used_ctxlist(ctxp);
mm->context = ctxp->ctx_number;
ctxp->ctx_mm = mm;
return;
}
ctxp = ctx_used.next;
if (ctxp->ctx_mm == old_mm)
ctxp = ctxp->next;
if (ctxp == &ctx_used)
panic("out of mmu contexts");
flush_cache_mm(ctxp->ctx_mm);
flush_tlb_mm(ctxp->ctx_mm);
remove_from_ctx_list(ctxp);
add_to_used_ctxlist(ctxp);
ctxp->ctx_mm->context = NO_CONTEXT;
ctxp->ctx_mm = mm;
mm->context = ctxp->ctx_number;
}
static inline void free_context(int context)
{
struct ctx_list *ctx_old;
ctx_old = ctx_list_pool + context;
remove_from_ctx_list(ctx_old);
add_to_free_ctxlist(ctx_old);
}
static void __init sparc_context_init(int numctx)
{
int ctx;
unsigned long size;
size = numctx * sizeof(struct ctx_list);
ctx_list_pool = memblock_alloc_or_panic(size, SMP_CACHE_BYTES);
for (ctx = 0; ctx < numctx; ctx++) {
struct ctx_list *clist;
clist = (ctx_list_pool + ctx);
clist->ctx_number = ctx;
clist->ctx_mm = NULL;
}
ctx_free.next = ctx_free.prev = &ctx_free;
ctx_used.next = ctx_used.prev = &ctx_used;
for (ctx = 0; ctx < numctx; ctx++)
add_to_free_ctxlist(ctx_list_pool + ctx);
}
void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm,
struct task_struct *tsk)
{
unsigned long flags;
Annotation
- Immediate include surface: `linux/seq_file.h`, `linux/spinlock.h`, `linux/memblock.h`, `linux/pagemap.h`, `linux/vmalloc.h`, `linux/kdebug.h`, `linux/export.h`, `linux/kernel.h`.
- Detected declarations: `struct ctx_list`, `function srmmu_pmd_none`, `function srmmu_ctxd_set`, `function msi_set_sync`, `function pmd_set`, `function srmmu_free_nocache`, `function probe_memory`, `function srmmu_nocache_calcsize`, `function srmmu_nocache_init`, `function pte_alloc_one`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.