drivers/gpu/drm/ttm/tests/ttm_device_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ttm/tests/ttm_device_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ttm/tests/ttm_device_test.c- Extension
.c- Size
- 5875 bytes
- Lines
- 207
- 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
drm/ttm/ttm_resource.hdrm/ttm/ttm_device.hdrm/ttm/ttm_placement.httm_kunit_helpers.h../ttm_pool_internal.h
Detected Declarations
struct ttm_device_test_casefunction ttm_device_init_basicfunction ttm_device_init_multiplefunction ttm_device_fini_basicfunction ttm_device_init_no_vma_manfunction ttm_device_case_descfunction ttm_device_init_pools
Annotated Snippet
struct ttm_device_test_case {
const char *description;
unsigned int alloc_flags;
bool pools_init_expected;
};
static void ttm_device_init_basic(struct kunit *test)
{
struct ttm_test_devices *priv = test->priv;
struct ttm_device *ttm_dev;
struct ttm_resource_manager *ttm_sys_man;
int err;
ttm_dev = kunit_kzalloc(test, sizeof(*ttm_dev), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, ttm_dev);
err = ttm_device_kunit_init(priv, ttm_dev, 0);
KUNIT_ASSERT_EQ(test, err, 0);
KUNIT_EXPECT_PTR_EQ(test, ttm_dev->funcs, &ttm_dev_funcs);
KUNIT_ASSERT_NOT_NULL(test, ttm_dev->wq);
KUNIT_ASSERT_NOT_NULL(test, ttm_dev->man_drv[TTM_PL_SYSTEM]);
ttm_sys_man = &ttm_dev->sysman;
KUNIT_ASSERT_NOT_NULL(test, ttm_sys_man);
KUNIT_EXPECT_TRUE(test, ttm_sys_man->use_tt);
KUNIT_EXPECT_TRUE(test, ttm_sys_man->use_type);
KUNIT_ASSERT_NOT_NULL(test, ttm_sys_man->func);
KUNIT_EXPECT_PTR_EQ(test, ttm_dev->dev_mapping,
priv->drm->anon_inode->i_mapping);
ttm_device_fini(ttm_dev);
}
static void ttm_device_init_multiple(struct kunit *test)
{
struct ttm_test_devices *priv = test->priv;
struct ttm_device *ttm_devs;
unsigned int i, num_dev = 3;
int err;
ttm_devs = kunit_kcalloc(test, num_dev, sizeof(*ttm_devs), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, ttm_devs);
for (i = 0; i < num_dev; i++) {
err = ttm_device_kunit_init(priv, &ttm_devs[i], 0);
KUNIT_ASSERT_EQ(test, err, 0);
KUNIT_EXPECT_PTR_EQ(test, ttm_devs[i].dev_mapping,
priv->drm->anon_inode->i_mapping);
KUNIT_ASSERT_NOT_NULL(test, ttm_devs[i].wq);
KUNIT_EXPECT_PTR_EQ(test, ttm_devs[i].funcs, &ttm_dev_funcs);
KUNIT_ASSERT_NOT_NULL(test, ttm_devs[i].man_drv[TTM_PL_SYSTEM]);
}
KUNIT_ASSERT_EQ(test, list_count_nodes(&ttm_devs[0].device_list), num_dev);
for (i = 0; i < num_dev; i++)
ttm_device_fini(&ttm_devs[i]);
}
static void ttm_device_fini_basic(struct kunit *test)
{
struct ttm_test_devices *priv = test->priv;
struct ttm_device *ttm_dev;
struct ttm_resource_manager *man;
int err;
ttm_dev = kunit_kzalloc(test, sizeof(*ttm_dev), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, ttm_dev);
err = ttm_device_kunit_init(priv, ttm_dev, 0);
KUNIT_ASSERT_EQ(test, err, 0);
man = ttm_manager_type(ttm_dev, TTM_PL_SYSTEM);
KUNIT_ASSERT_NOT_NULL(test, man);
ttm_device_fini(ttm_dev);
KUNIT_ASSERT_FALSE(test, man->use_type);
KUNIT_ASSERT_TRUE(test, list_empty(&man->lru[0]));
KUNIT_ASSERT_NULL(test, ttm_dev->man_drv[TTM_PL_SYSTEM]);
}
static void ttm_device_init_no_vma_man(struct kunit *test)
{
struct ttm_test_devices *priv = test->priv;
struct drm_device *drm = priv->drm;
struct ttm_device *ttm_dev;
Annotation
- Immediate include surface: `drm/ttm/ttm_resource.h`, `drm/ttm/ttm_device.h`, `drm/ttm/ttm_placement.h`, `ttm_kunit_helpers.h`, `../ttm_pool_internal.h`.
- Detected declarations: `struct ttm_device_test_case`, `function ttm_device_init_basic`, `function ttm_device_init_multiple`, `function ttm_device_fini_basic`, `function ttm_device_init_no_vma_man`, `function ttm_device_case_desc`, `function ttm_device_init_pools`.
- 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.