drivers/gpu/drm/xe/tests/xe_lmtt_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/tests/xe_lmtt_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/tests/xe_lmtt_test.c- Extension
.c- Size
- 2180 bytes
- Lines
- 74
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.h
Detected Declarations
function lmtt_ops_param_get_descfunction test_ops
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 AND MIT
/*
* Copyright © 2023 Intel Corporation
*/
#include <kunit/test.h>
static const struct lmtt_ops_param {
const char *desc;
const struct xe_lmtt_ops *ops;
} lmtt_ops_params[] = {
{ "2-level", &lmtt_2l_ops, },
{ "multi-level", &lmtt_ml_ops, },
};
static void lmtt_ops_param_get_desc(const struct lmtt_ops_param *p, char *desc)
{
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", p->desc);
}
KUNIT_ARRAY_PARAM(lmtt_ops, lmtt_ops_params, lmtt_ops_param_get_desc);
static void test_ops(struct kunit *test)
{
const struct lmtt_ops_param *p = test->param_value;
const struct xe_lmtt_ops *ops = p->ops;
unsigned int n;
KUNIT_ASSERT_NOT_NULL(test, ops->lmtt_root_pd_level);
KUNIT_ASSERT_NOT_NULL(test, ops->lmtt_pte_num);
KUNIT_ASSERT_NOT_NULL(test, ops->lmtt_pte_size);
KUNIT_ASSERT_NOT_NULL(test, ops->lmtt_pte_shift);
KUNIT_ASSERT_NOT_NULL(test, ops->lmtt_pte_index);
KUNIT_ASSERT_NOT_NULL(test, ops->lmtt_pte_encode);
KUNIT_EXPECT_NE(test, ops->lmtt_root_pd_level(), 0);
for (n = 0; n <= ops->lmtt_root_pd_level(); n++) {
KUNIT_EXPECT_NE_MSG(test, ops->lmtt_pte_num(n), 0,
"level=%u", n);
KUNIT_EXPECT_NE_MSG(test, ops->lmtt_pte_size(n), 0,
"level=%u", n);
KUNIT_EXPECT_NE_MSG(test, ops->lmtt_pte_encode(0, n), LMTT_PTE_INVALID,
"level=%u", n);
}
for (n = 0; n < ops->lmtt_root_pd_level(); n++) {
u64 addr = BIT_ULL(ops->lmtt_pte_shift(n));
KUNIT_EXPECT_NE_MSG(test, ops->lmtt_pte_shift(n), 0,
"level=%u", n);
KUNIT_EXPECT_EQ_MSG(test, ops->lmtt_pte_index(addr - 1, n), 0,
"addr=%#llx level=%u", addr, n);
KUNIT_EXPECT_EQ_MSG(test, ops->lmtt_pte_index(addr + 1, n), 1,
"addr=%#llx level=%u", addr, n);
KUNIT_EXPECT_EQ_MSG(test, ops->lmtt_pte_index(addr * 2 - 1, n), 1,
"addr=%#llx level=%u", addr, n);
KUNIT_EXPECT_EQ_MSG(test, ops->lmtt_pte_index(addr * 2, n), 2,
"addr=%#llx level=%u", addr, n);
}
}
static struct kunit_case lmtt_test_cases[] = {
KUNIT_CASE_PARAM(test_ops, lmtt_ops_gen_params),
{}
};
static struct kunit_suite lmtt_suite = {
.name = "lmtt",
.test_cases = lmtt_test_cases,
};
kunit_test_suites(&lmtt_suite);
Annotation
- Immediate include surface: `kunit/test.h`.
- Detected declarations: `function lmtt_ops_param_get_desc`, `function test_ops`.
- 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.