drivers/gpu/drm/ttm/tests/ttm_pool_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ttm/tests/ttm_pool_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ttm/tests/ttm_pool_test.c- Extension
.c- Size
- 11441 bytes
- Lines
- 432
- 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.
- 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/mm.hdrm/ttm/ttm_tt.hdrm/ttm/ttm_pool.httm_kunit_helpers.h../ttm_pool_internal.h
Detected Declarations
struct ttm_pool_test_casestruct ttm_pool_test_privfunction ttm_pool_test_initfunction ttm_pool_test_finifunction ttm_pool_alloc_case_descfunction ttm_pool_alloc_basicfunction ttm_pool_alloc_basic_dma_addrfunction ttm_pool_alloc_order_caching_matchfunction ttm_pool_alloc_caching_mismatchfunction ttm_pool_alloc_order_mismatchfunction ttm_pool_free_dma_allocfunction ttm_pool_free_no_dma_allocfunction ttm_pool_fini_basic
Annotated Snippet
struct ttm_pool_test_case {
const char *description;
unsigned int order;
unsigned int alloc_flags;
};
struct ttm_pool_test_priv {
struct ttm_test_devices *devs;
/* Used to create mock ttm_tts */
struct ttm_buffer_object *mock_bo;
};
static struct ttm_operation_ctx simple_ctx = {
.interruptible = true,
.no_wait_gpu = false,
};
static int ttm_pool_test_init(struct kunit *test)
{
struct ttm_pool_test_priv *priv;
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, priv);
priv->devs = ttm_test_devices_basic(test);
test->priv = priv;
return 0;
}
static void ttm_pool_test_fini(struct kunit *test)
{
struct ttm_pool_test_priv *priv = test->priv;
ttm_test_devices_put(test, priv->devs);
}
static struct ttm_tt *ttm_tt_kunit_init(struct kunit *test,
u32 page_flags,
enum ttm_caching caching,
size_t size)
{
struct ttm_pool_test_priv *priv = test->priv;
struct ttm_buffer_object *bo;
struct ttm_tt *tt;
int err;
bo = ttm_bo_kunit_init(test, priv->devs, size, NULL);
KUNIT_ASSERT_NOT_NULL(test, bo);
priv->mock_bo = bo;
tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, tt);
err = ttm_tt_init(tt, priv->mock_bo, page_flags, caching, 0);
KUNIT_ASSERT_EQ(test, err, 0);
return tt;
}
static struct ttm_pool *ttm_pool_pre_populated(struct kunit *test,
size_t size,
enum ttm_caching caching)
{
struct ttm_pool_test_priv *priv = test->priv;
struct ttm_test_devices *devs = priv->devs;
struct ttm_pool *pool;
struct ttm_tt *tt;
int err;
tt = ttm_tt_kunit_init(test, 0, caching, size);
KUNIT_ASSERT_NOT_NULL(test, tt);
pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, pool);
ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, TTM_ALLOCATION_POOL_USE_DMA_ALLOC);
err = ttm_pool_alloc(pool, tt, &simple_ctx);
KUNIT_ASSERT_EQ(test, err, 0);
ttm_pool_free(pool, tt);
ttm_tt_fini(tt);
return pool;
}
static const struct ttm_pool_test_case ttm_pool_basic_cases[] = {
{
Annotation
- Immediate include surface: `linux/mm.h`, `drm/ttm/ttm_tt.h`, `drm/ttm/ttm_pool.h`, `ttm_kunit_helpers.h`, `../ttm_pool_internal.h`.
- Detected declarations: `struct ttm_pool_test_case`, `struct ttm_pool_test_priv`, `function ttm_pool_test_init`, `function ttm_pool_test_fini`, `function ttm_pool_alloc_case_desc`, `function ttm_pool_alloc_basic`, `function ttm_pool_alloc_basic_dma_addr`, `function ttm_pool_alloc_order_caching_match`, `function ttm_pool_alloc_caching_mismatch`, `function ttm_pool_alloc_order_mismatch`.
- 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.