drivers/gpu/drm/v3d/v3d_mmu.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/v3d/v3d_mmu.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/v3d/v3d_mmu.c
Extension
.c
Size
4459 bytes
Lines
164
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.

Dependency Surface

Detected Declarations

Annotated Snippet

while (len > 0) {
			u32 page_prot = V3D_PTE_WRITEABLE | V3D_PTE_VALID;
			u32 page_address = page_prot | pfn;
			unsigned int i, page_size;

			BUG_ON(pfn + V3D_PAGE_FACTOR >= BIT(24));

			if (len >= SZ_1M &&
			    v3d_mmu_is_aligned(page, page_address, SZ_1M)) {
				page_size = SZ_1M;
				page_address |= V3D_PTE_SUPERPAGE;
			} else if (len >= SZ_64K &&
				   v3d_mmu_is_aligned(page, page_address, SZ_64K)) {
				page_size = SZ_64K;
				page_address |= V3D_PTE_BIGPAGE;
			} else {
				page_size = SZ_4K;
			}

			for (i = 0; i < page_size >> V3D_MMU_PAGE_SHIFT; i++) {
				v3d->pt[page++] = page_address + i;
				pfn++;
			}

			len -= page_size;
		}
	}

	WARN_ON_ONCE(page - bo->node.start !=
		     shmem_obj->base.size >> V3D_MMU_PAGE_SHIFT);

	if (v3d_mmu_flush_all(v3d))
		drm_err(&v3d->drm, "MMU flush timeout\n");
}

void v3d_mmu_remove_ptes(struct v3d_bo *bo)
{
	struct v3d_dev *v3d = to_v3d_dev(bo->base.base.dev);
	u32 npages = bo->base.base.size >> V3D_MMU_PAGE_SHIFT;
	u32 page;

	for (page = bo->node.start; page < bo->node.start + npages; page++)
		v3d->pt[page] = 0;

	if (v3d_mmu_flush_all(v3d))
		drm_err(&v3d->drm, "MMU flush timeout\n");
}

Annotation

Implementation Notes