drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c- Extension
.c- Size
- 7106 bytes
- Lines
- 305
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/export.hdrm/ttm/ttm_tt.httm_kunit_helpers.h
Detected Declarations
function ttm_tt_simple_destroyfunction mock_movefunction mock_evict_flagsfunction bad_evict_flagsfunction ttm_device_kunit_init_with_funcsfunction ttm_device_kunit_initfunction ttm_device_kunit_init_bad_evictfunction dummy_ttm_bo_destroyfunction ttm_test_devices_putfunction ttm_test_devices_initfunction ttm_test_devices_all_initfunction ttm_test_devices_finiexport ttm_dev_funcsexport ttm_device_kunit_initexport ttm_dev_funcs_bad_evictexport ttm_device_kunit_init_bad_evictexport ttm_bo_kunit_initexport ttm_place_kunit_initexport dummy_ttm_bo_destroyexport ttm_test_devices_basicexport ttm_test_devices_allexport ttm_test_devices_putexport ttm_test_devices_initexport ttm_test_devices_all_initexport ttm_test_devices_fini
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 AND MIT
/*
* Copyright © 2023 Intel Corporation
*/
#include <linux/export.h>
#include <drm/ttm/ttm_tt.h>
#include "ttm_kunit_helpers.h"
static const struct ttm_place sys_place = {
.fpfn = 0,
.lpfn = 0,
.mem_type = TTM_PL_SYSTEM,
.flags = TTM_PL_FLAG_FALLBACK,
};
static const struct ttm_place mock1_place = {
.fpfn = 0,
.lpfn = 0,
.mem_type = TTM_PL_MOCK1,
.flags = TTM_PL_FLAG_FALLBACK,
};
static const struct ttm_place mock2_place = {
.fpfn = 0,
.lpfn = 0,
.mem_type = TTM_PL_MOCK2,
.flags = TTM_PL_FLAG_FALLBACK,
};
static struct ttm_placement sys_placement = {
.num_placement = 1,
.placement = &sys_place,
};
static struct ttm_placement bad_placement = {
.num_placement = 1,
.placement = &mock1_place,
};
static struct ttm_placement mock_placement = {
.num_placement = 1,
.placement = &mock2_place,
};
static struct ttm_tt *ttm_tt_simple_create(struct ttm_buffer_object *bo, u32 page_flags)
{
struct ttm_tt *tt;
tt = kzalloc_obj(*tt);
ttm_tt_init(tt, bo, page_flags, ttm_cached, 0);
return tt;
}
static void ttm_tt_simple_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
{
kfree(ttm);
}
static int mock_move(struct ttm_buffer_object *bo, bool evict,
struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem,
struct ttm_place *hop)
{
struct ttm_resource *old_mem = bo->resource;
if (!old_mem || (old_mem->mem_type == TTM_PL_SYSTEM && !bo->ttm)) {
ttm_bo_move_null(bo, new_mem);
return 0;
}
if (bo->resource->mem_type == TTM_PL_VRAM &&
new_mem->mem_type == TTM_PL_SYSTEM) {
hop->mem_type = TTM_PL_TT;
hop->flags = TTM_PL_FLAG_TEMPORARY;
hop->fpfn = 0;
hop->lpfn = 0;
return -EMULTIHOP;
}
if ((old_mem->mem_type == TTM_PL_SYSTEM &&
new_mem->mem_type == TTM_PL_TT) ||
(old_mem->mem_type == TTM_PL_TT &&
new_mem->mem_type == TTM_PL_SYSTEM)) {
ttm_bo_move_null(bo, new_mem);
return 0;
}
Annotation
- Immediate include surface: `linux/export.h`, `drm/ttm/ttm_tt.h`, `ttm_kunit_helpers.h`.
- Detected declarations: `function ttm_tt_simple_destroy`, `function mock_move`, `function mock_evict_flags`, `function bad_evict_flags`, `function ttm_device_kunit_init_with_funcs`, `function ttm_device_kunit_init`, `function ttm_device_kunit_init_bad_evict`, `function dummy_ttm_bo_destroy`, `function ttm_test_devices_put`, `function ttm_test_devices_init`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.