drivers/gpu/drm/xe/xe_guc_db_mgr.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_guc_db_mgr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_guc_db_mgr.c- Extension
.c- Size
- 7070 bytes
- Lines
- 268
- 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
linux/bitmap.hlinux/mutex.hdrm/drm_managed.hregs/xe_guc_regs.hxe_assert.hxe_gt_printk.hxe_guc.hxe_guc_db_mgr.hxe_guc_types.htests/xe_guc_db_mgr_test.c
Detected Declarations
function __fini_dbmfunction xe_guc_db_mgr_initfunction dbm_reserve_chunk_lockedfunction dbm_release_chunk_lockedfunction xe_guc_db_mgr_reserve_id_lockedfunction xe_guc_db_mgr_release_id_lockedfunction xe_guc_db_mgr_reserve_rangefunction xe_guc_db_mgr_release_rangefunction dbm_print_lockedfunction xe_guc_db_mgr_print
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023 Intel Corporation
*/
#include <linux/bitmap.h>
#include <linux/mutex.h>
#include <drm/drm_managed.h>
#include "regs/xe_guc_regs.h"
#include "xe_assert.h"
#include "xe_gt_printk.h"
#include "xe_guc.h"
#include "xe_guc_db_mgr.h"
#include "xe_guc_types.h"
/**
* DOC: GuC Doorbells
*
* The GFX doorbell solution provides a mechanism for submission of workload
* to the graphics hardware by a ring3 application without the penalty of
* ring transition for each workload submission.
*
* In SR-IOV mode, the doorbells are treated as shared resource and PF must
* be able to provision exclusive range of IDs across VFs, which may want to
* use this feature.
*/
static struct xe_guc *dbm_to_guc(struct xe_guc_db_mgr *dbm)
{
return container_of(dbm, struct xe_guc, dbm);
}
static struct xe_gt *dbm_to_gt(struct xe_guc_db_mgr *dbm)
{
return guc_to_gt(dbm_to_guc(dbm));
}
static struct xe_device *dbm_to_xe(struct xe_guc_db_mgr *dbm)
{
return gt_to_xe(dbm_to_gt(dbm));
}
#define dbm_assert(_dbm, _cond) xe_gt_assert(dbm_to_gt(_dbm), _cond)
#define dbm_mutex(_dbm) (&dbm_to_guc(_dbm)->submission_state.lock)
static void dbm_print_locked(struct xe_guc_db_mgr *dbm, struct drm_printer *p, int indent);
static void __fini_dbm(struct drm_device *drm, void *arg)
{
struct xe_guc_db_mgr *dbm = arg;
unsigned int weight;
mutex_lock(dbm_mutex(dbm));
weight = bitmap_weight(dbm->bitmap, dbm->count);
if (weight) {
struct drm_printer p = xe_gt_info_printer(dbm_to_gt(dbm));
xe_gt_err(dbm_to_gt(dbm), "GuC doorbells manager unclean (%u/%u)\n",
weight, dbm->count);
dbm_print_locked(dbm, &p, 1);
}
bitmap_free(dbm->bitmap);
dbm->bitmap = NULL;
dbm->count = 0;
mutex_unlock(dbm_mutex(dbm));
}
/**
* xe_guc_db_mgr_init() - Initialize GuC Doorbells Manager.
* @dbm: the &xe_guc_db_mgr to initialize
* @count: number of doorbells to manage
*
* The bare-metal or PF driver can pass ~0 as &count to indicate that all
* doorbells supported by the hardware are available for use.
*
* Only VF's drivers will have to provide explicit number of doorbells IDs
* that they can use.
*
* Return: 0 on success or a negative error code on failure.
*/
int xe_guc_db_mgr_init(struct xe_guc_db_mgr *dbm, unsigned int count)
{
int ret;
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/mutex.h`, `drm/drm_managed.h`, `regs/xe_guc_regs.h`, `xe_assert.h`, `xe_gt_printk.h`, `xe_guc.h`, `xe_guc_db_mgr.h`.
- Detected declarations: `function __fini_dbm`, `function xe_guc_db_mgr_init`, `function dbm_reserve_chunk_locked`, `function dbm_release_chunk_locked`, `function xe_guc_db_mgr_reserve_id_locked`, `function xe_guc_db_mgr_release_id_locked`, `function xe_guc_db_mgr_reserve_range`, `function xe_guc_db_mgr_release_range`, `function dbm_print_locked`, `function xe_guc_db_mgr_print`.
- 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.