drivers/iommu/generic_pt/kunit_generic_pt.h
Source file repositories/reference/linux-study-clean/drivers/iommu/generic_pt/kunit_generic_pt.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/generic_pt/kunit_generic_pt.h- Extension
.h- Size
- 23680 bytes
- Lines
- 840
- Domain
- Driver Families
- Bucket
- drivers/iommu
- 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
kunit_iommu.hpt_iter.h
Detected Declarations
struct check_levels_argstruct lvl_radix_argfunction Copyrightfunction __check_all_levelsfunction check_all_levelsfunction test_initfunction test_bitopsfunction ref_best_pgsizefunction test_best_pgsizefunction test_pgsz_countfunction pt_install_tablefunction test_table_ptrfunction pt_table_oa_lg2szfunction test_max_vafunction test_table_radixfunction safe_pt_num_items_lg2function test_lvl_possible_sizesfunction test_entry_possible_sizesfunction sweep_all_pgsizesfunction pt_install_leaf_entryfunction test_entry_oafunction test_lvl_attr_from_entryfunction test_attr_from_entryfunction test_lvl_dirtyfunction test_dirtyfunction test_lvl_sw_bit_leaffunction test_sw_bit_leaffunction test_lvl_sw_bit_tablefunction test_sw_bit_tablefunction pt_kunit_generic_pt_initfunction pt_kunit_generic_pt_exit
Annotated Snippet
struct check_levels_arg {
struct kunit *test;
void *fn_arg;
void (*fn)(struct kunit *test, struct pt_state *pts, void *arg);
};
static int __check_all_levels(struct pt_range *range, void *arg,
unsigned int level, struct pt_table_p *table)
{
struct pt_state pts = pt_init(range, level, table);
struct check_levels_arg *chk = arg;
struct kunit *test = chk->test;
int ret;
_pt_iter_first(&pts);
/*
* If we were able to use the full VA space this should always be the
* last index in each table.
*/
if (!(IS_32BIT && range->max_vasz_lg2 > 32)) {
if (pt_feature(range->common, PT_FEAT_SIGN_EXTEND) &&
pts.level == pts.range->top_level)
KUNIT_ASSERT_EQ(test, pts.index,
log2_to_int(range->max_vasz_lg2 - 1 -
pt_table_item_lg2sz(&pts)) -
1);
else
KUNIT_ASSERT_EQ(test, pts.index,
log2_to_int(pt_table_oa_lg2sz(&pts) -
pt_table_item_lg2sz(&pts)) -
1);
}
if (pt_can_have_table(&pts)) {
pt_load_single_entry(&pts);
KUNIT_ASSERT_EQ(test, pts.type, PT_ENTRY_TABLE);
ret = pt_descend(&pts, arg, __check_all_levels);
KUNIT_ASSERT_EQ(test, ret, 0);
/* Index 0 is used by the test */
if (IS_32BIT && !pts.index)
return 0;
KUNIT_ASSERT_NE(chk->test, pts.index, 0);
}
/*
* A format should not create a table with only one entry, at least this
* test approach won't work.
*/
KUNIT_ASSERT_GT(chk->test, pts.end_index, 1);
/*
* For increase top we end up using index 0 for the original top's tree,
* so use index 1 for testing instead.
*/
pts.index = 0;
pt_index_to_va(&pts);
pt_load_single_entry(&pts);
if (pts.type == PT_ENTRY_TABLE && pts.end_index > 2) {
pts.index = 1;
pt_index_to_va(&pts);
}
(*chk->fn)(chk->test, &pts, chk->fn_arg);
return 0;
}
/*
* Call fn for each level in the table with a pts setup to index 0 in a table
* for that level. This allows writing tests that run on every level.
* The test can use every index in the table except the last one.
*/
static void check_all_levels(struct kunit *test,
void (*fn)(struct kunit *test,
struct pt_state *pts, void *arg),
void *fn_arg)
{
struct kunit_iommu_priv *priv = test->priv;
struct pt_range range = pt_top_range(priv->common);
struct check_levels_arg chk = {
.test = test,
.fn = fn,
.fn_arg = fn_arg,
};
int ret;
if (pt_feature(priv->common, PT_FEAT_DYNAMIC_TOP) &&
priv->common->max_vasz_lg2 > range.max_vasz_lg2)
range.last_va = fvalog2_set_mod_max(range.va,
Annotation
- Immediate include surface: `kunit_iommu.h`, `pt_iter.h`.
- Detected declarations: `struct check_levels_arg`, `struct lvl_radix_arg`, `function Copyright`, `function __check_all_levels`, `function check_all_levels`, `function test_init`, `function test_bitops`, `function ref_best_pgsize`, `function test_best_pgsize`, `function test_pgsz_count`.
- Atlas domain: Driver Families / drivers/iommu.
- 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.