drivers/gpu/drm/xe/xe_guc_hwconfig.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_guc_hwconfig.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_guc_hwconfig.c- Extension
.c- Size
- 4378 bytes
- Lines
- 203
- 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_guc_hwconfig.hdrm/drm_managed.hdrm/drm_print.habi/guc_actions_abi.hxe_bo.hxe_device_types.hxe_gt_types.hxe_guc.hxe_map.h
Detected Declarations
function send_get_hwconfigfunction guc_hwconfig_sizefunction guc_hwconfig_copyfunction xe_guc_hwconfig_initfunction xe_guc_hwconfig_sizefunction xe_guc_hwconfig_copyfunction xe_guc_hwconfig_dumpfunction xe_guc_hwconfig_lookup_u32
Annotated Snippet
if (i + len_dw > num_dw) {
drm_printf(p, "Error: Attribute %u is %u dwords, but only %llu remain\n",
attribute, len_dw, num_dw - i);
len_dw = num_dw - i;
}
/*
* If it's a single dword (as most hwconfig attributes are),
* then it's probably a number that makes sense to display
* in decimal form. In the rare cases where it's more than
* one dword, just print it in hex form and let the user
* figure out how to interpret it.
*/
if (len_dw == 1)
drm_printf(p, "[%2u] = %u\n", attribute, hwconfig[i]);
else
drm_printf(p, "[%2u] = { %*ph }\n", attribute,
(int)(len_dw * sizeof(u32)), &hwconfig[i]);
i += len_dw;
}
if (i < num_dw || extra_bytes)
drm_printf(p, "Error: %llu extra bytes at end of hwconfig\n",
(num_dw - i) * sizeof(u32) + extra_bytes);
kfree(hwconfig);
}
/*
* Lookup a specific 32-bit attribute value in the GuC's hwconfig table.
*/
int xe_guc_hwconfig_lookup_u32(struct xe_guc *guc, u32 attribute, u32 *val)
{
size_t size = xe_guc_hwconfig_size(guc);
u64 num_dw = div_u64(size, sizeof(u32));
u32 *hwconfig;
bool found = false;
int i = 0;
if (num_dw == 0)
return -EINVAL;
hwconfig = kzalloc(size, GFP_KERNEL);
if (!hwconfig)
return -ENOMEM;
xe_guc_hwconfig_copy(guc, hwconfig);
/* An entry requires at least three dwords for key, length, value */
while (i + 3 <= num_dw) {
u32 key = hwconfig[i++];
u32 len_dw = hwconfig[i++];
if (key != attribute) {
i += len_dw;
continue;
}
*val = hwconfig[i];
found = true;
break;
}
kfree(hwconfig);
return found ? 0 : -ENOENT;
}
Annotation
- Immediate include surface: `xe_guc_hwconfig.h`, `drm/drm_managed.h`, `drm/drm_print.h`, `abi/guc_actions_abi.h`, `xe_bo.h`, `xe_device_types.h`, `xe_gt_types.h`, `xe_guc.h`.
- Detected declarations: `function send_get_hwconfig`, `function guc_hwconfig_size`, `function guc_hwconfig_copy`, `function xe_guc_hwconfig_init`, `function xe_guc_hwconfig_size`, `function xe_guc_hwconfig_copy`, `function xe_guc_hwconfig_dump`, `function xe_guc_hwconfig_lookup_u32`.
- 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.