drivers/gpu/drm/xe/xe_gt_ccs_mode.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gt_ccs_mode.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_gt_ccs_mode.c- Extension
.c- Size
- 5668 bytes
- Lines
- 219
- 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
drm/drm_managed.hregs/xe_gt_regs.hxe_assert.hxe_gt.hxe_gt_ccs_mode.hxe_gt_printk.hxe_gt_sysfs.hxe_mmio.hxe_pm.hxe_sriov.hxe_sriov_pf.h
Detected Declarations
function __xe_gt_apply_ccs_modefunction for_each_hw_enginefunction xe_gt_apply_ccs_modefunction gt_ccs_mode_defaultfunction num_cslices_showfunction ccs_mode_showfunction ccs_mode_storefunction xe_gt_ccs_mode_sysfs_finifunction xe_gt_ccs_mode_sysfs_init
Annotated Snippet
for_each_hw_engine(hwe, gt, id) {
if (hwe->class != XE_ENGINE_CLASS_COMPUTE)
continue;
if (hwe->logical_instance >= num_engines)
break;
config |= BIT(hwe->instance) << XE_HW_ENGINE_CCS0;
/* If a slice is fused off, leave disabled */
while ((CCS_INSTANCES(gt) & BIT(cslice)) == 0)
cslice++;
mode &= ~CCS_MODE_CSLICE(cslice, CCS_MODE_CSLICE_MASK);
mode |= CCS_MODE_CSLICE(cslice, hwe->instance);
cslice++;
}
}
/*
* Mask bits need to be set for the register. Though only Xe2+
* platforms require setting of mask bits, it won't harm for older
* platforms as these bits are unused there.
*/
mode |= CCS_MODE_CSLICE_0_3_MASK << 16;
xe_mmio_write32(>->mmio, CCS_MODE, mode);
xe_gt_dbg(gt, "CCS_MODE=%x config:%08x, num_engines:%d, num_slices:%d\n",
mode, config, num_engines, num_slices);
}
void xe_gt_apply_ccs_mode(struct xe_gt *gt)
{
if (!gt->ccs_mode || IS_SRIOV_VF(gt_to_xe(gt)))
return;
__xe_gt_apply_ccs_mode(gt, gt->ccs_mode);
}
static bool gt_ccs_mode_default(struct xe_gt *gt)
{
return gt->ccs_mode == 1;
}
static ssize_t
num_cslices_show(struct device *kdev,
struct device_attribute *attr, char *buf)
{
struct xe_gt *gt = kobj_to_gt(&kdev->kobj);
return sysfs_emit(buf, "%u\n", hweight32(CCS_INSTANCES(gt)));
}
static DEVICE_ATTR_RO(num_cslices);
static ssize_t
ccs_mode_show(struct device *kdev,
struct device_attribute *attr, char *buf)
{
struct xe_gt *gt = kobj_to_gt(&kdev->kobj);
return sysfs_emit(buf, "%u\n", gt->ccs_mode);
}
static ssize_t
ccs_mode_store(struct device *kdev, struct device_attribute *attr,
const char *buff, size_t count)
{
struct xe_gt *gt = kobj_to_gt(&kdev->kobj);
struct xe_device *xe = gt_to_xe(gt);
u32 num_engines, num_slices;
int ret;
ret = kstrtou32(buff, 0, &num_engines);
if (ret)
return ret;
/*
* Ensure number of engines specified is valid and there is an
* exact multiple of engines for slices.
*/
num_slices = hweight32(CCS_INSTANCES(gt));
if (!num_engines || num_engines > num_slices || num_slices % num_engines) {
xe_gt_dbg(gt, "Invalid compute config, %d engines %d slices\n",
num_engines, num_slices);
return -EINVAL;
}
/* CCS mode can only be updated when there are no drm clients */
guard(mutex)(&xe->drm.filelist_mutex);
Annotation
- Immediate include surface: `drm/drm_managed.h`, `regs/xe_gt_regs.h`, `xe_assert.h`, `xe_gt.h`, `xe_gt_ccs_mode.h`, `xe_gt_printk.h`, `xe_gt_sysfs.h`, `xe_mmio.h`.
- Detected declarations: `function __xe_gt_apply_ccs_mode`, `function for_each_hw_engine`, `function xe_gt_apply_ccs_mode`, `function gt_ccs_mode_default`, `function num_cslices_show`, `function ccs_mode_show`, `function ccs_mode_store`, `function xe_gt_ccs_mode_sysfs_fini`, `function xe_gt_ccs_mode_sysfs_init`.
- 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.