drivers/gpu/drm/xe/tests/xe_guc_id_mgr_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/tests/xe_guc_id_mgr_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/tests/xe_guc_id_mgr_test.c- Extension
.c- Size
- 3509 bytes
- Lines
- 137
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hxe_device.hxe_kunit_helpers.h
Detected Declarations
function guc_id_mgr_test_initfunction bad_initfunction no_initfunction init_finifunction check_usedfunction check_quotafunction check_all
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 AND MIT
/*
* Copyright © 2024 Intel Corporation
*/
#include <kunit/test.h>
#include "xe_device.h"
#include "xe_kunit_helpers.h"
static int guc_id_mgr_test_init(struct kunit *test)
{
struct xe_guc_id_mgr *idm;
xe_kunit_helper_xe_device_test_init(test);
idm = &xe_device_get_gt(test->priv, 0)->uc.guc.submission_state.idm;
mutex_init(idm_mutex(idm));
test->priv = idm;
return 0;
}
static void bad_init(struct kunit *test)
{
struct xe_guc_id_mgr *idm = test->priv;
KUNIT_EXPECT_EQ(test, -EINVAL, xe_guc_id_mgr_init(idm, 0));
KUNIT_EXPECT_EQ(test, -ERANGE, xe_guc_id_mgr_init(idm, GUC_ID_MAX + 1));
}
static void no_init(struct kunit *test)
{
struct xe_guc_id_mgr *idm = test->priv;
mutex_lock(idm_mutex(idm));
KUNIT_EXPECT_EQ(test, -ENODATA, xe_guc_id_mgr_reserve_locked(idm, 0));
mutex_unlock(idm_mutex(idm));
KUNIT_EXPECT_EQ(test, -ENODATA, xe_guc_id_mgr_reserve(idm, 1, 1));
}
static void init_fini(struct kunit *test)
{
struct xe_guc_id_mgr *idm = test->priv;
KUNIT_ASSERT_EQ(test, 0, xe_guc_id_mgr_init(idm, -1));
KUNIT_EXPECT_NOT_NULL(test, idm->bitmap);
KUNIT_EXPECT_EQ(test, idm->total, GUC_ID_MAX);
__fini_idm(NULL, idm);
KUNIT_EXPECT_NULL(test, idm->bitmap);
KUNIT_EXPECT_EQ(test, idm->total, 0);
}
static void check_used(struct kunit *test)
{
struct xe_guc_id_mgr *idm = test->priv;
unsigned int n;
KUNIT_ASSERT_EQ(test, 0, xe_guc_id_mgr_init(idm, 2));
mutex_lock(idm_mutex(idm));
for (n = 0; n < idm->total; n++) {
kunit_info(test, "n=%u", n);
KUNIT_EXPECT_EQ(test, idm->used, n);
KUNIT_EXPECT_GE(test, idm_reserve_chunk_locked(idm, 1, 0), 0);
KUNIT_EXPECT_EQ(test, idm->used, n + 1);
}
KUNIT_EXPECT_EQ(test, idm->used, idm->total);
idm_release_chunk_locked(idm, 0, idm->used);
KUNIT_EXPECT_EQ(test, idm->used, 0);
mutex_unlock(idm_mutex(idm));
}
static void check_quota(struct kunit *test)
{
struct xe_guc_id_mgr *idm = test->priv;
unsigned int n;
KUNIT_ASSERT_EQ(test, 0, xe_guc_id_mgr_init(idm, 2));
mutex_lock(idm_mutex(idm));
for (n = 0; n < idm->total - 1; n++) {
kunit_info(test, "n=%u", n);
KUNIT_EXPECT_EQ(test, idm_reserve_chunk_locked(idm, 1, idm->total), -EDQUOT);
KUNIT_EXPECT_EQ(test, idm_reserve_chunk_locked(idm, 1, idm->total - n), -EDQUOT);
KUNIT_EXPECT_EQ(test, idm_reserve_chunk_locked(idm, idm->total - n, 1), -EDQUOT);
KUNIT_EXPECT_GE(test, idm_reserve_chunk_locked(idm, 1, 1), 0);
Annotation
- Immediate include surface: `kunit/test.h`, `xe_device.h`, `xe_kunit_helpers.h`.
- Detected declarations: `function guc_id_mgr_test_init`, `function bad_init`, `function no_init`, `function init_fini`, `function check_used`, `function check_quota`, `function check_all`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.