drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c- Extension
.c- Size
- 38599 bytes
- Lines
- 1218
- 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/delay.hlinux/kthread.hdrm/ttm/ttm_resource.hdrm/ttm/ttm_placement.hdrm/ttm/ttm_tt.httm_kunit_helpers.httm_mock_manager.h
Detected Declarations
struct ttm_bo_validate_test_casefunction dma_resv_kunit_active_fence_initfunction ttm_bo_validate_case_descfunction ttm_bo_init_reserved_sys_manfunction ttm_bo_init_reserved_mock_manfunction ttm_bo_init_reserved_resvfunction ttm_bo_validate_basicfunction ttm_bo_validate_invalid_placementfunction ttm_bo_validate_failed_allocfunction ttm_bo_validate_pinnedfunction ttm_bo_validate_same_placementfunction ttm_bo_validate_busy_placementfunction ttm_bo_validate_multihopfunction ttm_bo_validate_no_placement_signaledfunction threaded_dma_resv_signalfunction ttm_bo_validate_no_placement_not_signaledfunction ttm_bo_validate_move_fence_signaledfunction threaded_fence_signalfunction ttm_bo_validate_move_fence_not_signaledfunction ttm_bo_validate_swapoutfunction ttm_bo_validate_happy_evictfunction ttm_bo_validate_all_pinned_evictfunction ttm_bo_validate_allowed_only_evictfunction ttm_bo_validate_deleted_evictfunction ttm_bo_validate_busy_domain_evictfunction ttm_bo_validate_evict_guttingfunction ttm_bo_validate_recrusive_evict
Annotated Snippet
struct ttm_bo_validate_test_case {
const char *description;
enum ttm_bo_type bo_type;
u32 mem_type;
bool with_ttm;
bool no_gpu_wait;
};
static struct ttm_placement *ttm_placement_kunit_init(struct kunit *test,
struct ttm_place *places,
unsigned int num_places)
{
struct ttm_placement *placement;
placement = kunit_kzalloc(test, sizeof(*placement), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, placement);
placement->num_placement = num_places;
placement->placement = places;
return placement;
}
static const char *fence_name(struct dma_fence *f)
{
return "ttm-bo-validate-fence";
}
static const struct dma_fence_ops fence_ops = {
.get_driver_name = fence_name,
.get_timeline_name = fence_name,
};
static struct dma_fence *alloc_mock_fence(struct kunit *test)
{
struct dma_fence *fence;
fence = kunit_kzalloc(test, sizeof(*fence), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, fence);
dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0);
return fence;
}
static void dma_resv_kunit_active_fence_init(struct kunit *test,
struct dma_resv *resv,
enum dma_resv_usage usage)
{
struct dma_fence *fence;
fence = alloc_mock_fence(test);
dma_fence_enable_sw_signaling(fence);
dma_resv_lock(resv, NULL);
dma_resv_reserve_fences(resv, 1);
dma_resv_add_fence(resv, fence, usage);
dma_resv_unlock(resv);
}
static void ttm_bo_validate_case_desc(const struct ttm_bo_validate_test_case *t,
char *desc)
{
strscpy(desc, t->description, KUNIT_PARAM_DESC_SIZE);
}
static const struct ttm_bo_validate_test_case ttm_bo_type_cases[] = {
{
.description = "Buffer object for userspace",
.bo_type = ttm_bo_type_device,
},
{
.description = "Kernel buffer object",
.bo_type = ttm_bo_type_kernel,
},
{
.description = "Shared buffer object",
.bo_type = ttm_bo_type_sg,
},
};
KUNIT_ARRAY_PARAM(ttm_bo_types, ttm_bo_type_cases,
ttm_bo_validate_case_desc);
static void ttm_bo_init_reserved_sys_man(struct kunit *test)
{
const struct ttm_bo_validate_test_case *params = test->param_value;
struct ttm_test_devices *priv = test->priv;
enum ttm_bo_type bo_type = params->bo_type;
u32 size = ALIGN(BO_SIZE, PAGE_SIZE);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/kthread.h`, `drm/ttm/ttm_resource.h`, `drm/ttm/ttm_placement.h`, `drm/ttm/ttm_tt.h`, `ttm_kunit_helpers.h`, `ttm_mock_manager.h`.
- Detected declarations: `struct ttm_bo_validate_test_case`, `function dma_resv_kunit_active_fence_init`, `function ttm_bo_validate_case_desc`, `function ttm_bo_init_reserved_sys_man`, `function ttm_bo_init_reserved_mock_man`, `function ttm_bo_init_reserved_resv`, `function ttm_bo_validate_basic`, `function ttm_bo_validate_invalid_placement`, `function ttm_bo_validate_failed_alloc`, `function ttm_bo_validate_pinned`.
- 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.