drivers/gpu/drm/gma500/mmu.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/gma500/mmu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/gma500/mmu.c- Extension
.c- Size
- 16711 bytes
- Lines
- 735
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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/highmem.hlinux/vmalloc.hasm/cpuid/api.hmmu.hpsb_drv.hpsb_reg.h
Detected Declarations
function Copyrightfunction psb_mmu_pd_indexfunction psb_clflushfunction psb_mmu_clflushfunction psb_mmu_flush_pd_lockedfunction psb_mmu_flush_pdfunction psb_mmu_flushfunction psb_mmu_set_pd_contextfunction psb_pd_addr_endfunction psb_mmu_mask_ptefunction psb_mmu_free_ptfunction psb_mmu_free_pagedirfunction psb_mmu_pt_unmap_unlockfunction psb_mmu_set_ptefunction psb_mmu_invalidate_ptefunction psb_mmu_driver_takedownfunction psb_mmu_flush_ptesfunction psb_mmu_remove_pfn_sequencefunction psb_mmu_remove_pagesfunction psb_mmu_insert_pfn_sequencefunction psb_mmu_insert_pages
Annotated Snippet
if (pd->tables[index]) {
spin_unlock(lock);
psb_mmu_free_pt(pt);
spin_lock(lock);
pt = pd->tables[index];
continue;
}
v = kmap_atomic(pd->p);
pd->tables[index] = pt;
v[index] = (page_to_pfn(pt->p) << 12) | pd->pd_mask;
pt->index = index;
kunmap_atomic((void *) v);
if (pd->hw_context != -1) {
psb_mmu_clflush(pd->driver, (void *)&v[index]);
atomic_set(&pd->driver->needs_tlbflush, 1);
}
}
pt->v = kmap_atomic(pt->p);
return pt;
}
static struct psb_mmu_pt *psb_mmu_pt_map_lock(struct psb_mmu_pd *pd,
unsigned long addr)
{
uint32_t index = psb_mmu_pd_index(addr);
struct psb_mmu_pt *pt;
spinlock_t *lock = &pd->driver->lock;
spin_lock(lock);
pt = pd->tables[index];
if (!pt) {
spin_unlock(lock);
return NULL;
}
pt->v = kmap_atomic(pt->p);
return pt;
}
static void psb_mmu_pt_unmap_unlock(struct psb_mmu_pt *pt)
{
struct psb_mmu_pd *pd = pt->pd;
uint32_t *v;
kunmap_atomic(pt->v);
if (pt->count == 0) {
v = kmap_atomic(pd->p);
v[pt->index] = pd->invalid_pde;
pd->tables[pt->index] = NULL;
if (pd->hw_context != -1) {
psb_mmu_clflush(pd->driver, (void *)&v[pt->index]);
atomic_set(&pd->driver->needs_tlbflush, 1);
}
kunmap_atomic(v);
spin_unlock(&pd->driver->lock);
psb_mmu_free_pt(pt);
return;
}
spin_unlock(&pd->driver->lock);
}
static inline void psb_mmu_set_pte(struct psb_mmu_pt *pt, unsigned long addr,
uint32_t pte)
{
pt->v[psb_mmu_pt_index(addr)] = pte;
}
static inline void psb_mmu_invalidate_pte(struct psb_mmu_pt *pt,
unsigned long addr)
{
pt->v[psb_mmu_pt_index(addr)] = pt->pd->invalid_pte;
}
struct psb_mmu_pd *psb_mmu_get_default_pd(struct psb_mmu_driver *driver)
{
struct psb_mmu_pd *pd;
down_read(&driver->sem);
pd = driver->default_pd;
up_read(&driver->sem);
return pd;
}
void psb_mmu_driver_takedown(struct psb_mmu_driver *driver)
{
struct drm_device *dev = driver->dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
Annotation
- Immediate include surface: `linux/highmem.h`, `linux/vmalloc.h`, `asm/cpuid/api.h`, `mmu.h`, `psb_drv.h`, `psb_reg.h`.
- Detected declarations: `function Copyright`, `function psb_mmu_pd_index`, `function psb_clflush`, `function psb_mmu_clflush`, `function psb_mmu_flush_pd_locked`, `function psb_mmu_flush_pd`, `function psb_mmu_flush`, `function psb_mmu_set_pd_context`, `function psb_pd_addr_end`, `function psb_mmu_mask_pte`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.