drivers/gpu/drm/ast/ast_mm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ast/ast_mm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ast/ast_mm.c- Extension
.c- Size
- 2562 bytes
- Lines
- 98
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hdrm/drm_managed.hdrm/drm_print.hast_drv.h
Detected Declarations
function filesfunction ast_mm_init
Annotated Snippet
#include <linux/pci.h>
#include <drm/drm_managed.h>
#include <drm/drm_print.h>
#include "ast_drv.h"
static u32 ast_get_vram_size(struct ast_device *ast)
{
u32 vram_size;
u8 vgacr99, vgacraa;
vgacraa = ast_get_index_reg(ast, AST_IO_VGACRI, 0xaa);
switch (vgacraa & AST_IO_VGACRAA_VGAMEM_SIZE_MASK) {
case 0:
vram_size = SZ_8M;
break;
case 1:
vram_size = SZ_16M;
break;
case 2:
vram_size = SZ_32M;
break;
case 3:
vram_size = SZ_64M;
break;
}
vgacr99 = ast_get_index_reg(ast, AST_IO_VGACRI, 0x99);
switch (vgacr99 & AST_IO_VGACR99_VGAMEM_RSRV_MASK) {
case 1:
vram_size -= SZ_1M;
break;
case 2:
vram_size -= SZ_2M;
break;
case 3:
vram_size -= SZ_4M;
break;
}
return vram_size;
}
int ast_mm_init(struct ast_device *ast)
{
struct drm_device *dev = &ast->base;
struct pci_dev *pdev = to_pci_dev(dev->dev);
resource_size_t base, size;
u32 vram_size;
base = pci_resource_start(pdev, 0);
size = pci_resource_len(pdev, 0);
/* Don't fail on errors, but performance might be reduced. */
devm_arch_io_reserve_memtype_wc(dev->dev, base, size);
devm_arch_phys_wc_add(dev->dev, base, size);
vram_size = ast_get_vram_size(ast);
ast->vram = devm_ioremap_wc(dev->dev, base, vram_size);
if (!ast->vram)
return -ENOMEM;
ast->vram_base = base;
ast->vram_size = vram_size;
return 0;
}
Annotation
- Immediate include surface: `linux/pci.h`, `drm/drm_managed.h`, `drm/drm_print.h`, `ast_drv.h`.
- Detected declarations: `function files`, `function ast_mm_init`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.