drivers/gpu/drm/i915/intel_region_ttm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/intel_region_ttm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/intel_region_ttm.c- Extension
.c- Size
- 7641 bytes
- Lines
- 267
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/ttm/ttm_device.hdrm/ttm/ttm_range_manager.hi915_drv.hi915_scatterlist.hi915_ttm_buddy_manager.hintel_region_ttm.hgem/i915_gem_region.hgem/i915_gem_ttm.h
Detected Declarations
function intel_region_ttm_device_initfunction intel_region_ttm_device_finifunction intel_region_to_ttm_typefunction intel_region_ttm_initfunction intel_region_ttm_finifunction intel_region_ttm_resource_to_rsgtfunction intel_region_ttm_resource_to_stfunction intel_region_ttm_resource_free
Annotated Snippet
if (WARN_ON(overflows_type(offset >> PAGE_SHIFT, place.fpfn))) {
ret = -E2BIG;
goto out;
}
place.fpfn = offset >> PAGE_SHIFT;
if (WARN_ON(overflows_type(place.fpfn + (size >> PAGE_SHIFT), place.lpfn))) {
ret = -E2BIG;
goto out;
}
place.lpfn = place.fpfn + (size >> PAGE_SHIFT);
} else if (resource_size(&mem->io) && resource_size(&mem->io) < mem->total) {
if (flags & I915_BO_ALLOC_GPU_ONLY) {
place.flags |= TTM_PL_FLAG_TOPDOWN;
} else {
place.fpfn = 0;
if (WARN_ON(overflows_type(resource_size(&mem->io) >> PAGE_SHIFT, place.lpfn))) {
ret = -E2BIG;
goto out;
}
place.lpfn = resource_size(&mem->io) >> PAGE_SHIFT;
}
}
mock_bo.base.size = size;
mock_bo.bdev = &mem->i915->bdev;
ret = man->func->alloc(man, &mock_bo, &place, &res);
out:
if (ret == -ENOSPC)
ret = -ENXIO;
if (!ret)
res->bo = NULL; /* Rather blow up, then some uaf */
return ret ? ERR_PTR(ret) : res;
}
#endif
/**
* intel_region_ttm_resource_free - Free a resource allocated from a resource manager
* @mem: The region the resource was allocated from.
* @res: The opaque resource representing an allocation.
*/
void intel_region_ttm_resource_free(struct intel_memory_region *mem,
struct ttm_resource *res)
{
struct ttm_resource_manager *man = mem->region_private;
struct ttm_buffer_object mock_bo = {};
mock_bo.base.size = res->size;
mock_bo.bdev = &mem->i915->bdev;
res->bo = &mock_bo;
man->func->free(man, res);
}
Annotation
- Immediate include surface: `drm/ttm/ttm_device.h`, `drm/ttm/ttm_range_manager.h`, `i915_drv.h`, `i915_scatterlist.h`, `i915_ttm_buddy_manager.h`, `intel_region_ttm.h`, `gem/i915_gem_region.h`, `gem/i915_gem_ttm.h`.
- Detected declarations: `function intel_region_ttm_device_init`, `function intel_region_ttm_device_fini`, `function intel_region_to_ttm_type`, `function intel_region_ttm_init`, `function intel_region_ttm_fini`, `function intel_region_ttm_resource_to_rsgt`, `function intel_region_ttm_resource_to_st`, `function intel_region_ttm_resource_free`.
- 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.