drivers/gpu/drm/xe/xe_guc_klv_helpers.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_guc_klv_helpers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_guc_klv_helpers.c- Extension
.c- Size
- 4373 bytes
- Lines
- 158
- 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
linux/bitfield.hdrm/drm_print.habi/guc_klvs_abi.hxe_guc_klv_helpers.hxe_guc_klv_thresholds_set.h
Detected Declarations
function xe_guc_klv_printfunction xe_guc_klv_count
Annotated Snippet
if (num_dwords < len) {
drm_printf(p, "{ key %#06x : truncated %zu of %zu bytes %*ph } # %s\n",
key, num_dwords * sizeof(u32), len * sizeof(u32),
(int)(num_dwords * sizeof(u32)), klvs,
xe_guc_klv_key_to_string(key));
return;
}
switch (len) {
case 0:
drm_printf(p, "{ key %#06x : no value } # %s\n",
key, xe_guc_klv_key_to_string(key));
break;
case 1:
drm_printf(p, "{ key %#06x : 32b value %u } # %s\n",
key, klvs[0], xe_guc_klv_key_to_string(key));
break;
case 2:
drm_printf(p, "{ key %#06x : 64b value %#llx } # %s\n",
key, make_u64(klvs[1], klvs[0]),
xe_guc_klv_key_to_string(key));
break;
default:
drm_printf(p, "{ key %#06x : %zu bytes %*ph } # %s\n",
key, len * sizeof(u32), (int)(len * sizeof(u32)),
klvs, xe_guc_klv_key_to_string(key));
break;
}
klvs += len;
num_dwords -= len;
}
/* we don't expect any leftovers, fix if KLV header is ever changed */
BUILD_BUG_ON(GUC_KLV_LEN_MIN > 1);
}
/**
* xe_guc_klv_count - Count KLVs present in the buffer.
* @klvs: the buffer with KLVs
* @num_dwords: number of dwords (u32) in the buffer
*
* Return: number of recognized KLVs or
* a negative error code if KLV buffer is truncated.
*/
int xe_guc_klv_count(const u32 *klvs, u32 num_dwords)
{
int num_klvs = 0;
while (num_dwords >= GUC_KLV_LEN_MIN) {
u32 len = FIELD_GET(GUC_KLV_0_LEN, klvs[0]);
if (num_dwords < len + GUC_KLV_LEN_MIN)
break;
klvs += GUC_KLV_LEN_MIN + len;
num_dwords -= GUC_KLV_LEN_MIN + len;
num_klvs++;
}
return num_dwords ? -ENODATA : num_klvs;
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `drm/drm_print.h`, `abi/guc_klvs_abi.h`, `xe_guc_klv_helpers.h`, `xe_guc_klv_thresholds_set.h`.
- Detected declarations: `function xe_guc_klv_print`, `function xe_guc_klv_count`.
- 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.