DRM RAS over Generic Netlink¶
The DRM RAS (Reliability, Availability, Serviceability) interface provides a standardized way for GPU/accelerator drivers to expose error counters and other reliability nodes to user space via Generic Netlink. This allows diagnostic tools, monitoring daemons, or test infrastructure to query hardware health in a uniform way across different DRM drivers.
Key Goals:
Provide a standardized RAS solution for GPU and accelerator drivers, enabling data center monitoring and reliability operations.
Implement a single drm-ras Generic Netlink family to meet modern Netlink YAML specifications and centralize all RAS-related communication in one namespace.
Support a basic error counter interface, addressing the immediate, essential monitoring needs.
Offer a flexible, future-proof interface that can be extended to support additional types of RAS data in the future.
Allow multiple nodes per driver, enabling drivers to register separate nodes for different IP blocks, sub-blocks, or other logical subdivisions as applicable.
Nodes¶
Nodes are logical abstractions representing an error type or error source within the device. Currently, only error counter nodes is supported.
Drivers are responsible for registering and unregistering nodes via the
drm_ras_node_register() and drm_ras_node_unregister() APIs.
Node Management¶
This module provides the infrastructure to manage RAS (Reliability, Availability, and Serviceability) nodes for DRM drivers. Each DRM driver may register one or more RAS nodes, which represent logical components capable of reporting error counters and other reliability metrics.
The nodes are stored in a global xarray drm_ras_xa to allow efficient lookup by ID. Nodes can be registered or unregistered dynamically at runtime.
A Generic Netlink family drm_ras exposes the below operations to userspace:
LIST_NODES: Dump all currently registered RAS nodes. The user receives an array of node IDs, names, and types.
GET_ERROR_COUNTER: Get error counters of a given node. Userspace must provide Node ID, Error ID (Optional for specific counter). Returns all counters of a node if only Node ID is provided or specific error counters.
CLEAR_ERROR_COUNTER: Clear error counter of a given node. Userspace must provide Node ID, Error ID. Clears specific error counter of a node if supported.
ERROR_REPORT: Subscribe to this multicast group to receive error events
ERROR_EVENT: Report an error event to userspace. The event contains device, node and error information that triggered the event.
GET_ERROR_THRESHOLD: Query error threshold of a given counter. Userspace must provide Node ID and Error ID. Returns the error threshold of a specific counter.
SET_ERROR_THRESHOLD: Set error threshold of a given counter. Userspace must provide Node ID, Error ID and threshold to be set.
TELEMETRY_GET: Read a telemetry value. Userspace must provide Node ID and telemetry field to be read. Returns the status of the read and the value read (if valid).
TELEMETRY_SET: Write a telemetry value. Userspace must provide Node ID, the telemetry field to write, and the value to be written. Returns the status of the write.
TELEMETRY_LIST_FIELDS: List the telemetry fields provided by the device. Each field contains the uAPI defined
enum string, its numerical value, and its mode bitmask, which encodes read/write capabilities.
Node registration:
drm_ras_node_register(): Registers a new node and assigns it a unique ID in the xarray.drm_ras_node_unregister(): Removes a previously registered node from the xarray.
Node lifetime:
The drm_ras_nl_family uses genl_family.parallel_ops, so netlink
handlers may run concurrently with each other and with
drm_ras_node_unregister(). Node memory is owned by the driver, which
typically frees it right after drm_ras_node_unregister() returns. To make
this safe, every handler looks a node up with drm_ras_node_get(), which
takes a reference under the xarray lock, and drops it with
drm_ras_node_put() once it is done touching the node. A node holds one
reference for being registered; drm_ras_node_unregister() removes the node
from the xarray (so no new lookups can find it), drops that registration
reference, and then waits for any in-flight handlers to drop theirs before
returning. The driver may therefore free the node as soon as
drm_ras_node_unregister() returns.
Node type:
- ERROR_COUNTER:
The driver must implement the
query_error_counter()callback to provide the name and the value of the error counter.The driver must provide a error_counter_range.last value informing the last valid error ID.
The driver can provide a error_counter_range.first value informing the first valid error ID.
The error counters in the driver doesn’t need to be contiguous, but the driver must return -ENOENT to the query_error_counter as an indication that the ID should be skipped and not listed in the netlink API.
The driver can optionally implement
query_error_threshold()andset_error_threshold()callbacks to facilitate getting/setting error threshold of the counter. Threshold in RAS context means the number of errors the hardware is expected to accumulate before it raises them to software. This is to have a fine grained control over error notifications that are raised by the hardware.The driver is responsible for error threshold bounds checking.
- TELEMETRY:
The driver must implement the
telemetry_get()callbacks,telemetry_set()is optional.The driver must provide a list of telemetry fields corresponding to their uAPI definitions and values, with each field’s supported access modes (read/write) encoded in its mode bitmask. Fields writable via
telemetry_set()must have the write mode bit set.The driver can optionally provide a pre_doit callback,
telemetry_pre(), to enforce permissions checks on telemetry operations.
Netlink handlers:
drm_ras_nl_list_nodes_dumpit(): Implements the LIST_NODES operation, iterating over the xarray.drm_ras_nl_get_error_counter_dumpit(): Implements the GET_ERROR_COUNTER dumpit operation, fetching all counters from a specific node.drm_ras_nl_get_error_counter_doit(): Implements the GET_ERROR_COUNTER doit operation, fetching a counter value from a specific node.drm_ras_nl_clear_error_counter_doit(): Implements the CLEAR_ERROR_COUNTER doit operation, clearing a counter value from a specific node.drm_ras_nl_get_error_threshold_doit(): Implements the GET_ERROR_THRESHOLD doit operation, fetching the error threshold of a specific counter.drm_ras_nl_set_error_threshold_doit(): Implements the SET_ERROR_THRESHOLD doit operation, setting the error threshold of a specific counter.drm_ras_nl_pre_telemetry(): TELEMETRY_GET and TELEMETRY_SET pre_doit operation. Looks the node up, takes a reference on it and stashes it in info->ctx, and enforces the node’s optional permission check.drm_ras_nl_post_telemetry(): TELEMETRY_GET and TELEMETRY_SET post_doit operation, dropping the reference taken bydrm_ras_nl_pre_telemetry().drm_ras_nl_telemetry_get_doit(): Implements the TELEMETRY_GET doit operation, invoking the driver’s telemetry_get callback and returning the results.drm_ras_nl_telemetry_set_doit(): Implements the TELEMETRY_SET doit operation, invoking the driver’s telemetry_set callback and returning the results.drm_ras_nl_telemetry_list_fields_dumpit(): Implements the TELEMETRY_LIST_FIELDS dumpit operation, enumerating all telemetry fields and their supported access modes for a telemetry node.
-
struct drm_ras_node *drm_ras_node_get(u32 node_id)¶
Look up a RAS node by ID and take a reference
Parameters
u32 node_idID of the node to look up
Description
Looks the node up in the global xarray and, if found, takes a reference to
it so that it cannot be freed while the caller is using it. The lookup and
the reference bump happen under the xarray lock, which serialises them
against the xa_erase() in drm_ras_node_unregister(): a node that is still
present in the xarray is guaranteed to still hold its registration
reference, so the bump can never operate on freed memory.
The caller must drop the returned reference with drm_ras_node_put().
Return
the referenced node, or NULL if no node with node_id is registered.
-
struct drm_ras_node *drm_ras_node_get_next(unsigned long *next)¶
Take a reference on the next registered RAS node
Parameters
unsigned long *nextin/out cursor; on entry the first ID to consider, on return the ID of the node whose reference was taken
Description
Iterator counterpart of drm_ras_node_get() used by the LIST_NODES dump.
Finds the first node with an ID at or above *next, takes a reference to it
under the xarray lock and reports its ID back in *next.
The caller must drop the returned reference with drm_ras_node_put().
Return
the referenced node, or NULL if no further node is registered.
-
void drm_ras_node_put(struct drm_ras_node *node)¶
Drop a reference taken on a RAS node
Parameters
struct drm_ras_node *nodenode to drop a reference on, may be NULL
Description
Drops a reference previously taken by drm_ras_node_get() or
drm_ras_node_get_next(). When the last reference (including the registration
reference dropped by drm_ras_node_unregister()) goes away, the waiter in
drm_ras_node_unregister() is woken so the driver can free the node.
-
int drm_ras_nl_list_nodes_dumpit(struct sk_buff *skb, struct netlink_callback *cb)¶
Dump all registered RAS nodes
Parameters
struct sk_buff *skbNetlink message buffer
struct netlink_callback *cbCallback context for multi-part dumps
Description
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_get_error_counter_dumpit(struct sk_buff *skb, struct netlink_callback *cb)¶
Dump all Error Counters
Parameters
struct sk_buff *skbNetlink message buffer
struct netlink_callback *cbCallback context for multi-part dumps
Description
Iterates over all error counters in a given Node and appends their attributes (ID, name, value) 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 errors 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_get_error_counter_doit(struct sk_buff *skb, struct genl_info *info)¶
Query an error counter of an node
Parameters
struct sk_buff *skbNetlink message buffer
struct genl_info *infoGeneric Netlink info containing attributes of the request
Description
Extracts the node ID and error ID from the netlink attributes and retrieves the current value of the corresponding error counter. Sends the result back to the requesting user via the standard Genl reply.
Return
0 on success, or negative errno on failure.
-
int drm_ras_nl_clear_error_counter_doit(struct sk_buff *skb, struct genl_info *info)¶
Clear an error counter of a node
Parameters
struct sk_buff *skbNetlink message buffer
struct genl_info *infoGeneric Netlink info containing attributes of the request
Description
Extracts the node ID and error ID from the netlink attributes and clears the current value.
Return
0 on success, or negative errno on failure.
-
int drm_ras_nl_get_error_threshold_doit(struct sk_buff *skb, struct genl_info *info)¶
Query error threshold of a counter
Parameters
struct sk_buff *skbNetlink message buffer
struct genl_info *infoGeneric Netlink info containing attributes of the request
Description
Extracts the Node ID and Error ID from the netlink attributes and retrieves the error threshold of the corresponding counter. Sends the result back to the requesting user via the standard Genl reply.
Return
0 on success, or negative errno on failure.
-
int drm_ras_nl_set_error_threshold_doit(struct sk_buff *skb, struct genl_info *info)¶
Set error threshold of a counter
Parameters
struct sk_buff *skbNetlink message buffer
struct genl_info *infoGeneric Netlink info containing attributes of the request
Description
Extracts the Node ID, Error ID and threshold from the netlink attributes and sets the error threshold of the corresponding counter.
Return
0 on success, or negative errno on failure.
-
int drm_ras_nl_pre_telemetry(const struct genl_split_ops *ops, struct sk_buff *skb, struct genl_info *info)¶
Look up the telemetry node and enforce permissions
Parameters
const struct genl_split_ops *opsGeneric netlink operations
struct sk_buff *skbNetlink message buffer
struct genl_info *infoGeneric Netlink info containing attributes of the request
Description
Looks up the telemetry node, takes a reference on it with drm_ras_node_get()
and stashes it in info->ctx so the doit handler can use it without a second
lookup. The reference is dropped by drm_ras_nl_post_telemetry(), which
genetlink only calls when this pre_doit succeeds; every error path here must
therefore drop the reference itself. Also enforces the node’s optional
permission check via the telemetry_pre() callback.
Return
0 on success, or negative errno on failure.
-
void drm_ras_nl_post_telemetry(const struct genl_split_ops *ops, struct sk_buff *skb, struct genl_info *info)¶
Release the telemetry node after a doit handler
Parameters
const struct genl_split_ops *opsGeneric netlink operations
struct sk_buff *skbNetlink message buffer
struct genl_info *infoGeneric Netlink info containing attributes of the request
Description
Drops the reference that drm_ras_nl_pre_telemetry() took and stashed in
info->ctx. genetlink only invokes this post_doit when the matching pre_doit
succeeded, so ctx->node is always the referenced node here.
-
int drm_ras_nl_telemetry_list_fields_dumpit(struct sk_buff *skb, struct netlink_callback *cb)¶
Dump a node’s telemetry fields.
Parameters
struct sk_buff *skbNetlink message buffer
struct netlink_callback *cbCallback context for multi-part dumps
Description
Displays every telemetry field exposed by the given node, along with each field’s supported access modes (read/write).
The node reference is taken and dropped within each dumpit() call rather
than held across the whole dump, so a userspace dump that is never
completed cannot block drm_ras_node_unregister().
Return
0 on success, or negative errno on failure.
-
int drm_ras_nl_telemetry_get_doit(struct sk_buff *skb, struct genl_info *info)¶
Query a telemetry value
Parameters
struct sk_buff *skbNetlink message buffer
struct genl_info *infoGeneric Netlink info containing attributes of the request
Description
Extracts the telemetry field from the netlink attributes and reads that value from the device.
Return
0 on success, or negative errno on failure.
-
int drm_ras_nl_telemetry_set_doit(struct sk_buff *skb, struct genl_info *info)¶
Write a telemetry value
Parameters
struct sk_buff *skbNetlink message buffer
struct genl_info *infoGeneric Netlink info containing attributes of the request
Description
Extracts the telemetry field and value to be written from the netlink attributes and writes that value to the specified field on the device.
Return
0 on success, or negative errno on failure.
Generic Netlink Usage¶
The interface is implemented as a Generic Netlink family named drm-ras.
User space tools can:
List registered nodes with the
list-nodescommand.List all error counters in an node with the
get-error-countercommand withnode-idas a parameter.Query specific error counter values with the
get-error-countercommand, using bothnode-idanderror-idas parameters.Clear specific error counters with the
clear-error-countercommand, using bothnode-idanderror-idas parameters.Subscribe to the
error-reportmulticast group to receiveerror-event.Query specific error counter threshold with the
get-error-thresholdcommand, using bothnode-idanderror-idas parameters.Set specific error counter threshold with the
set-error-thresholdcommand, usingnode-id,error-idanderror-thresholdas parameters.
YAML-based Interface¶
The interface is described in a YAML specification Documentation/netlink/specs/drm_ras.yaml
This YAML is used to auto-generate user space bindings via
tools/net/ynl/pyynl/ynl_gen_c.py, and drives the structure of netlink
attributes and operations.
Usage Notes¶
User space must first enumerate nodes to obtain their IDs.
Node IDs or Node names can be used for all further queries, such as error counters.
Error counters can be queried by either the Error ID or Error name.
Query Parameters should be defined as part of the uAPI to ensure user interface stability.
The interface supports future extension by adding new node types and additional attributes.
Example: List nodes using ynl
sudo ynl --family drm_ras --dump list-nodes
[{'device-name': '0000:03:00.0',
'node-id': 0,
'node-name': 'correctable-errors',
'node-type': 'error-counter'},
{'device-name': '0000:03:00.0',
'node-id': 1,
'node-name': 'uncorrectable-errors',
'node-type': 'error-counter'}]
Example: List all error counters using ynl
sudo ynl --family drm_ras --dump get-error-counter --json '{"node-id":0}'
[{'error-id': 1, 'error-name': 'error_name1', 'error-value': 0},
{'error-id': 2, 'error-name': 'error_name2', 'error-value': 0}]
Example: Query an error counter for a given node
sudo ynl --family drm_ras --do get-error-counter --json '{"node-id":0, "error-id":1}'
{'error-id': 1, 'error-name': 'error_name1', 'error-value': 0}
Example: Clear an error counter for a given node
sudo ynl --family drm_ras --do clear-error-counter --json '{"node-id":0, "error-id":1}'
None
Example: Subscribe to error-report multicast group
sudo ynl --family drm_ras --output-json --subscribe error-report
{
"name": "error-event",
"msg": {
"device-name": "0000:03:00.0",
"node-id": 1,
"node-name": "uncorrectable-errors",
"error-id": 1,
"error-name": "error_name1",
"error-value": 1
}
}
Example: Query error threshold of a given counter
sudo ynl --family drm_ras --do get-error-threshold --json '{"node-id":0, "error-id":1}'
{'error-id': 1, 'error-name': 'error_name1', 'error-threshold': 16}
Example: Set error threshold of a given counter
sudo ynl --family drm_ras --do set-error-threshold --json '{"node-id":0, "error-id":1, "error-threshold":8}'
None