drivers/gpu/drm/xe/tests/xe_sriov_pf_service_kunit.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/tests/xe_sriov_pf_service_kunit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/tests/xe_sriov_pf_service_kunit.c- Extension
.c- Size
- 7140 bytes
- Lines
- 228
- 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.hxe_device.hxe_kunit_helpers.hxe_pci_test.h
Detected Declarations
function pf_service_test_initfunction pf_negotiate_anyfunction pf_negotiate_base_matchfunction pf_negotiate_base_newerfunction pf_negotiate_base_nextfunction pf_negotiate_base_olderfunction pf_negotiate_base_prevfunction pf_negotiate_latest_matchfunction pf_negotiate_latest_newerfunction pf_negotiate_latest_nextfunction pf_negotiate_latest_olderfunction pf_negotiate_latest_prev
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 AND MIT
/*
* Copyright © 2024-2025 Intel Corporation
*/
#include <kunit/test.h>
#include "xe_device.h"
#include "xe_kunit_helpers.h"
#include "xe_pci_test.h"
static int pf_service_test_init(struct kunit *test)
{
struct xe_pci_fake_data fake = {
.sriov_mode = XE_SRIOV_MODE_PF,
.platform = XE_TIGERLAKE, /* some random platform */
.subplatform = XE_SUBPLATFORM_NONE,
};
struct xe_device *xe;
test->priv = &fake;
xe_kunit_helper_xe_device_test_init(test);
xe = test->priv;
KUNIT_ASSERT_EQ(test, xe_sriov_init(xe), 0);
xe_sriov_pf_service_init(xe);
/*
* sanity check:
* - all supported platforms VF/PF ABI versions must be defined
* - base version can't be newer than latest
*/
KUNIT_ASSERT_NE(test, 0, xe->sriov.pf.service.version.base.major);
KUNIT_ASSERT_NE(test, 0, xe->sriov.pf.service.version.latest.major);
KUNIT_ASSERT_LE(test, xe->sriov.pf.service.version.base.major,
xe->sriov.pf.service.version.latest.major);
if (xe->sriov.pf.service.version.base.major == xe->sriov.pf.service.version.latest.major)
KUNIT_ASSERT_LE(test, xe->sriov.pf.service.version.base.minor,
xe->sriov.pf.service.version.latest.minor);
return 0;
}
static void pf_negotiate_any(struct kunit *test)
{
struct xe_device *xe = test->priv;
u32 major, minor;
KUNIT_ASSERT_EQ(test, 0,
pf_negotiate_version(xe, VF2PF_HANDSHAKE_MAJOR_ANY,
VF2PF_HANDSHAKE_MINOR_ANY,
&major, &minor));
KUNIT_ASSERT_EQ(test, major, xe->sriov.pf.service.version.latest.major);
KUNIT_ASSERT_EQ(test, minor, xe->sriov.pf.service.version.latest.minor);
}
static void pf_negotiate_base_match(struct kunit *test)
{
struct xe_device *xe = test->priv;
u32 major, minor;
KUNIT_ASSERT_EQ(test, 0,
pf_negotiate_version(xe,
xe->sriov.pf.service.version.base.major,
xe->sriov.pf.service.version.base.minor,
&major, &minor));
KUNIT_ASSERT_EQ(test, major, xe->sriov.pf.service.version.base.major);
KUNIT_ASSERT_EQ(test, minor, xe->sriov.pf.service.version.base.minor);
}
static void pf_negotiate_base_newer(struct kunit *test)
{
struct xe_device *xe = test->priv;
u32 major, minor;
KUNIT_ASSERT_EQ(test, 0,
pf_negotiate_version(xe,
xe->sriov.pf.service.version.base.major,
xe->sriov.pf.service.version.base.minor + 1,
&major, &minor));
KUNIT_ASSERT_EQ(test, major, xe->sriov.pf.service.version.base.major);
KUNIT_ASSERT_GE(test, minor, xe->sriov.pf.service.version.base.minor);
if (xe->sriov.pf.service.version.base.major == xe->sriov.pf.service.version.latest.major)
KUNIT_ASSERT_LE(test, minor, xe->sriov.pf.service.version.latest.minor);
else
KUNIT_FAIL(test, "FIXME: don't know how to test multi-version yet!\n");
}
static void pf_negotiate_base_next(struct kunit *test)
{
struct xe_device *xe = test->priv;
Annotation
- Immediate include surface: `kunit/test.h`, `xe_device.h`, `xe_kunit_helpers.h`, `xe_pci_test.h`.
- Detected declarations: `function pf_service_test_init`, `function pf_negotiate_any`, `function pf_negotiate_base_match`, `function pf_negotiate_base_newer`, `function pf_negotiate_base_next`, `function pf_negotiate_base_older`, `function pf_negotiate_base_prev`, `function pf_negotiate_latest_match`, `function pf_negotiate_latest_newer`, `function pf_negotiate_latest_next`.
- 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.