drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c- Extension
.c- Size
- 10097 bytes
- Lines
- 320
- 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
kunit/static_stub.hkunit/test.hkunit/test-bug.hxe_kunit_helpers.hxe_pci_test.h
Detected Declarations
function xe_device_is_admin_only_stub_enablefunction xe_device_is_admin_only_stub_disablefunction pf_set_admin_modefunction pf_set_usable_vramfunction pf_gt_config_test_initfunction fair_contexts_1vffunction fair_contextsfunction fair_doorbells_1vffunction fair_doorbellsfunction fair_ggtt_1vffunction fair_ggttfunction u64_param_get_descfunction fair_vram_1vffunction fair_vram_1vf_admin_onlyfunction fair_vram
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 AND MIT
/*
* Copyright © 2025 Intel Corporation
*/
#include <kunit/static_stub.h>
#include <kunit/test.h>
#include <kunit/test-bug.h>
#include "xe_kunit_helpers.h"
#include "xe_pci_test.h"
#define TEST_MAX_VFS 63
#define TEST_VRAM 0x7a800000ull /* random size that works on 32-bit */
static bool xe_device_is_admin_only_stub_enable(const struct xe_device *xe)
{
return true;
}
static bool xe_device_is_admin_only_stub_disable(const struct xe_device *xe)
{
return false;
}
static void pf_set_admin_mode(struct xe_device *xe, bool enable)
{
typeof(xe_device_is_admin_only) *stub = enable ?
xe_device_is_admin_only_stub_enable :
xe_device_is_admin_only_stub_disable;
kunit_activate_static_stub(kunit_get_current_test(),
xe_device_is_admin_only,
*stub);
KUNIT_EXPECT_EQ(kunit_get_current_test(), enable, xe_sriov_pf_admin_only(xe));
KUNIT_EXPECT_EQ(kunit_get_current_test(), enable, xe_device_is_admin_only(xe));
}
static void pf_set_usable_vram(struct xe_device *xe, u64 usable)
{
struct xe_tile *tile = xe_device_get_root_tile(xe);
struct kunit *test = kunit_get_current_test();
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, tile);
xe->mem.vram->usable_size = usable;
tile->mem.vram->usable_size = usable;
KUNIT_ASSERT_EQ(test, usable, xe_vram_region_usable_size(tile->mem.vram));
}
static const void *num_vfs_gen_param(struct kunit *test, const void *prev, char *desc)
{
unsigned long next = 1 + (unsigned long)prev;
if (next > TEST_MAX_VFS)
return NULL;
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%lu VF%s",
next, str_plural(next));
return (void *)next;
}
static int pf_gt_config_test_init(struct kunit *test)
{
struct xe_pci_fake_data fake = {
.sriov_mode = XE_SRIOV_MODE_PF,
.platform = XE_BATTLEMAGE, /* any random DGFX platform with SR-IOV */
.subplatform = XE_SUBPLATFORM_NONE,
.graphics_verx100 = 2001,
};
struct xe_vram_region *vram;
struct xe_device *xe;
struct xe_gt *gt;
test->priv = &fake;
xe_kunit_helper_xe_device_test_init(test);
xe = test->priv;
KUNIT_ASSERT_TRUE(test, IS_SRIOV_PF(xe));
gt = xe_root_mmio_gt(xe);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, gt);
test->priv = gt;
/* pretend it has some VRAM */
KUNIT_ASSERT_TRUE(test, IS_DGFX(xe));
vram = kunit_kzalloc(test, sizeof(*vram), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vram);
vram->usable_size = TEST_VRAM;
xe->mem.vram = vram;
xe->tiles[0].mem.vram = vram;
Annotation
- Immediate include surface: `kunit/static_stub.h`, `kunit/test.h`, `kunit/test-bug.h`, `xe_kunit_helpers.h`, `xe_pci_test.h`.
- Detected declarations: `function xe_device_is_admin_only_stub_enable`, `function xe_device_is_admin_only_stub_disable`, `function pf_set_admin_mode`, `function pf_set_usable_vram`, `function pf_gt_config_test_init`, `function fair_contexts_1vf`, `function fair_contexts`, `function fair_doorbells_1vf`, `function fair_doorbells`, `function fair_ggtt_1vf`.
- 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.