drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c- Extension
.c- Size
- 61986 bytes
- Lines
- 2215
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
rm/rpc.hpriv.hcore/pci.hsubdev/pci/priv.hsubdev/timer.hsubdev/vfn.hengine/fifo/chan.hengine/sec2.hnvif/log.hnvfw/fw.hnvrm/gsp.hnvrm/rpcfn.hnvrm/msgfn.hnvrm/event.hnvrm/fifo.hlinux/acpi.hlinux/ctype.hlinux/parser.h
Detected Declarations
struct registry_list_entrystruct nv_gsp_registry_entriesstruct rpc_ucode_libos_print_v1e_08struct r535_gsp_logenum registry_typefunction r535_gsp_msgq_workfunction r535_gsp_intrfunction r535_gsp_xlat_mc_engine_idxfunction r535_gsp_intr_get_tablefunction r535_gsp_get_static_info_fbfunction r535_gsp_get_static_infofunction nvkm_gsp_mem_dtorfunction nvkm_gsp_mem_ctorfunction r535_gsp_postinitfunction r535_gsp_rpc_unloading_guest_driverfunction add_registryfunction add_registry_numfunction add_registry_stringfunction PACKED_REGISTRY_TABLEfunction list_for_each_entry_safefunction add_registryfunction list_for_each_entry_safefunction stripfunction r535_gsp_rpc_set_registryfunction r535_gsp_acpi_capsfunction r535_gsp_acpi_jtfunction r535_gsp_acpi_mux_idfunction r535_gsp_acpi_muxfunction r535_gsp_acpi_dodfunction r535_gsp_acpi_infofunction r535_gsp_set_system_infofunction r535_gsp_msg_os_error_logfunction r535_gsp_msg_mmu_fault_queuedfunction r535_gsp_msg_post_eventfunction list_for_each_entryfunction r535_gsp_msg_run_cpu_sequencerfunction r535_gsp_shared_initfunction r535_gsp_set_rmargsfunction r535_gsp_rmargs_initfunction r535_gsp_msg_libos_printfunction r535_gsp_booter_loadfunction r535_gsp_libos_id8function create_pte_arrayfunction r535_gsp_libos_initfunction nvkm_gsp_sg_freefunction for_each_sgtable_sgfunction nvkm_gsp_sgfunction for_each_sgtable_sg
Annotated Snippet
struct registry_list_entry {
struct list_head head;
enum registry_type type;
size_t klen;
char key[REGISTRY_MAX_KEY_LENGTH];
size_t vlen;
u32 dword; /* TYPE_DWORD */
u8 binary[] __counted_by(vlen); /* TYPE_BINARY or TYPE_STRING */
};
/**
* add_registry -- adds a registry entry
* @gsp: gsp pointer
* @key: name of the registry key
* @type: type of data
* @data: pointer to value
* @length: size of data, in bytes
*
* Adds a registry key/value pair to the registry database.
*
* This function collects the registry information in a linked list. After
* all registry keys have been added, build_registry() is used to create the
* RPC data structure.
*
* registry_rpc_size is a running total of the size of all registry keys.
* It's used to avoid an O(n) calculation of the size when the RPC is built.
*
* Returns 0 on success, or negative error code on error.
*/
static int add_registry(struct nvkm_gsp *gsp, const char *key,
enum registry_type type, const void *data, size_t length)
{
struct registry_list_entry *reg;
const size_t nlen = strnlen(key, REGISTRY_MAX_KEY_LENGTH) + 1;
size_t alloc_size; /* extra bytes to alloc for binary or string value */
if (nlen > REGISTRY_MAX_KEY_LENGTH)
return -EINVAL;
alloc_size = (type == REGISTRY_TABLE_ENTRY_TYPE_DWORD) ? 0 : length;
reg = kmalloc(sizeof(*reg) + alloc_size, GFP_KERNEL);
if (!reg)
return -ENOMEM;
switch (type) {
case REGISTRY_TABLE_ENTRY_TYPE_DWORD:
reg->dword = *(const u32 *)(data);
break;
case REGISTRY_TABLE_ENTRY_TYPE_BINARY:
case REGISTRY_TABLE_ENTRY_TYPE_STRING:
memcpy(reg->binary, data, alloc_size);
break;
default:
nvkm_error(&gsp->subdev, "unrecognized registry type %u for '%s'\n",
type, key);
kfree(reg);
return -EINVAL;
}
memcpy(reg->key, key, nlen);
reg->klen = nlen;
reg->vlen = length;
reg->type = type;
list_add_tail(®->head, &gsp->registry_list);
gsp->registry_rpc_size += sizeof(PACKED_REGISTRY_ENTRY) + nlen + alloc_size;
return 0;
}
static int add_registry_num(struct nvkm_gsp *gsp, const char *key, u32 value)
{
return add_registry(gsp, key, REGISTRY_TABLE_ENTRY_TYPE_DWORD,
&value, sizeof(u32));
}
static int add_registry_string(struct nvkm_gsp *gsp, const char *key, const char *value)
{
return add_registry(gsp, key, REGISTRY_TABLE_ENTRY_TYPE_STRING,
value, strlen(value) + 1);
}
/**
* build_registry -- create the registry RPC data
* @gsp: gsp pointer
* @registry: pointer to the RPC payload to fill
*
* After all registry key/value pairs have been added, call this function to
* build the RPC.
Annotation
- Immediate include surface: `rm/rpc.h`, `priv.h`, `core/pci.h`, `subdev/pci/priv.h`, `subdev/timer.h`, `subdev/vfn.h`, `engine/fifo/chan.h`, `engine/sec2.h`.
- Detected declarations: `struct registry_list_entry`, `struct nv_gsp_registry_entries`, `struct rpc_ucode_libos_print_v1e_08`, `struct r535_gsp_log`, `enum registry_type`, `function r535_gsp_msgq_work`, `function r535_gsp_intr`, `function r535_gsp_xlat_mc_engine_idx`, `function r535_gsp_intr_get_table`, `function r535_gsp_get_static_info_fb`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.