drivers/gpu/drm/xe/xe_bb.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_bb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_bb.c- Extension
.c- Size
- 4043 bytes
- Lines
- 175
- 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
xe_bb.hinstructions/xe_mi_commands.hxe_assert.hxe_device_types.hxe_exec_queue_types.hxe_gt.hxe_sa.hxe_sched_job.hxe_vm_types.h
Detected Declarations
function bb_prefetchfunction xe_bb_allocfunction xe_bb_initfunction __xe_bb_create_jobfunction xe_bb_free
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2022 Intel Corporation
*/
#include "xe_bb.h"
#include "instructions/xe_mi_commands.h"
#include "xe_assert.h"
#include "xe_device_types.h"
#include "xe_exec_queue_types.h"
#include "xe_gt.h"
#include "xe_sa.h"
#include "xe_sched_job.h"
#include "xe_vm_types.h"
static int bb_prefetch(struct xe_gt *gt)
{
struct xe_device *xe = gt_to_xe(gt);
if (GRAPHICS_VERx100(xe) >= 1250 && xe_gt_is_main_type(gt))
/*
* RCS and CCS require 1K, although other engines would be
* okay with 512.
*/
return SZ_1K;
else
return SZ_512;
}
struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
{
struct xe_tile *tile = gt_to_tile(gt);
struct xe_bb *bb = kmalloc_obj(*bb);
int err;
if (!bb)
return ERR_PTR(-ENOMEM);
/*
* We need to allocate space for the requested number of dwords,
* one additional MI_BATCH_BUFFER_END dword, and additional buffer
* space to accommodate the platform-specific hardware prefetch
* requirements.
*/
bb->bo = xe_sa_bo_new(!usm ? tile->mem.kernel_bb_pool : gt->usm.bb_pool,
4 * (dwords + 1) + bb_prefetch(gt));
if (IS_ERR(bb->bo)) {
err = PTR_ERR(bb->bo);
goto err;
}
bb->cs = xe_sa_bo_cpu_addr(bb->bo);
bb->len = 0;
return bb;
err:
kfree(bb);
return ERR_PTR(err);
}
/**
* xe_bb_alloc() - Allocate a new batch buffer structure
* @gt: the &xe_gt
*
* Allocates and initializes a new xe_bb structure with an associated
* uninitialized suballoc object.
*
* Returns: Batch buffer structure or an ERR_PTR(-ENOMEM).
*/
struct xe_bb *xe_bb_alloc(struct xe_gt *gt)
{
struct xe_bb *bb = kmalloc_obj(*bb);
int err;
if (!bb)
return ERR_PTR(-ENOMEM);
bb->bo = xe_sa_bo_alloc(GFP_KERNEL);
if (IS_ERR(bb->bo)) {
err = PTR_ERR(bb->bo);
goto err;
}
return bb;
err:
kfree(bb);
return ERR_PTR(err);
}
Annotation
- Immediate include surface: `xe_bb.h`, `instructions/xe_mi_commands.h`, `xe_assert.h`, `xe_device_types.h`, `xe_exec_queue_types.h`, `xe_gt.h`, `xe_sa.h`, `xe_sched_job.h`.
- Detected declarations: `function bb_prefetch`, `function xe_bb_alloc`, `function xe_bb_init`, `function __xe_bb_create_job`, `function xe_bb_free`.
- 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.