drivers/gpu/drm/drm_ras.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_ras.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_ras.c- Extension
.c- Size
- 11513 bytes
- Lines
- 396
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/netdevice.hlinux/xarray.hnet/genetlink.hdrm/drm_ras.hdrm_ras_nl.h
Detected Declarations
struct drm_ras_ctxfunction drm_ras_nl_list_nodes_dumpitfunction xa_for_each_startfunction get_node_error_counterfunction msg_reply_valuefunction doit_reply_valuefunction drm_ras_nl_get_error_counter_dumpitfunction drm_ras_nl_get_error_counter_doitfunction drm_ras_nl_clear_error_counter_doitfunction drm_ras_node_registerfunction drm_ras_node_unregisterexport drm_ras_node_registerexport drm_ras_node_unregister
Annotated Snippet
struct drm_ras_ctx {
/* Which xarray id to restart the dump from */
unsigned long restart;
};
/**
* drm_ras_nl_list_nodes_dumpit() - Dump all registered RAS nodes
* @skb: Netlink message buffer
* @cb: Callback context for multi-part dumps
*
* Iterates over all registered RAS nodes in the global xarray and appends
* their attributes (ID, name, type) to the given netlink message buffer.
* Uses @cb->ctx to track progress in case the message buffer fills up, allowing
* multi-part dump support. On buffer overflow, updates the context to resume
* from the last node on the next invocation.
*
* Return: 0 if all nodes fit in @skb, number of bytes added to @skb if
* the buffer filled up (requires multi-part continuation), or
* a negative error code on failure.
*/
int drm_ras_nl_list_nodes_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
const struct genl_info *info = genl_info_dump(cb);
struct drm_ras_ctx *ctx = (void *)cb->ctx;
struct drm_ras_node *node;
struct nlattr *hdr;
unsigned long id;
int ret;
xa_for_each_start(&drm_ras_xa, id, node, ctx->restart) {
hdr = genlmsg_iput(skb, info);
if (!hdr) {
ret = -EMSGSIZE;
break;
}
ret = nla_put_u32(skb, DRM_RAS_A_NODE_ATTRS_NODE_ID, node->id);
if (ret) {
genlmsg_cancel(skb, hdr);
break;
}
ret = nla_put_string(skb, DRM_RAS_A_NODE_ATTRS_DEVICE_NAME,
node->device_name);
if (ret) {
genlmsg_cancel(skb, hdr);
break;
}
ret = nla_put_string(skb, DRM_RAS_A_NODE_ATTRS_NODE_NAME,
node->node_name);
if (ret) {
genlmsg_cancel(skb, hdr);
break;
}
ret = nla_put_u32(skb, DRM_RAS_A_NODE_ATTRS_NODE_TYPE,
node->type);
if (ret) {
genlmsg_cancel(skb, hdr);
break;
}
genlmsg_end(skb, hdr);
}
if (ret == -EMSGSIZE)
ctx->restart = id;
return ret;
}
static int get_node_error_counter(u32 node_id, u32 error_id,
const char **name, u32 *value)
{
struct drm_ras_node *node;
node = xa_load(&drm_ras_xa, node_id);
if (!node || !node->query_error_counter)
return -ENOENT;
if (error_id < node->error_counter_range.first ||
error_id > node->error_counter_range.last)
return -EINVAL;
return node->query_error_counter(node, error_id, name, value);
}
static int msg_reply_value(struct sk_buff *msg, u32 error_id,
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/xarray.h`, `net/genetlink.h`, `drm/drm_ras.h`, `drm_ras_nl.h`.
- Detected declarations: `struct drm_ras_ctx`, `function drm_ras_nl_list_nodes_dumpit`, `function xa_for_each_start`, `function get_node_error_counter`, `function msg_reply_value`, `function doit_reply_value`, `function drm_ras_nl_get_error_counter_dumpit`, `function drm_ras_nl_get_error_counter_doit`, `function drm_ras_nl_clear_error_counter_doit`, `function drm_ras_node_register`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.