Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright © 2026 Intel Corporation
4 */
5
6#ifndef __DRM_RAS_H__
7#define __DRM_RAS_H__
8
9#include <uapi/drm/drm_ras.h>
10
11/**
12 * struct drm_ras_node - A DRM RAS Node
13 */
14struct drm_ras_node {
15 /** @id: Unique identifier for the node. Dynamically assigned. */
16 u32 id;
17 /**
18 * @device_name: Human-readable name of the device. Given by the driver.
19 */
20 const char *device_name;
21 /** @node_name: Human-readable name of the node. Given by the driver. */
22 const char *node_name;
23 /** @type: Type of the node (enum drm_ras_node_type). */
24 enum drm_ras_node_type type;
25
26 /* Error-Counter Related Callback and Variables */
27
28 /** @error_counter_range: Range of valid Error IDs for this node. */
29 struct {
30 /** @first: First valid Error ID. */
31 u32 first;
32 /** @last: Last valid Error ID. Mandatory entry. */
33 u32 last;
34 } error_counter_range;
35
36 /**
37 * @query_error_counter:
38 *
39 * This callback is used by drm-ras to query a specific error counter.
40 * Used for input check and to iterate all error counters in a node.
41 *
42 * Driver should expect query_error_counter() to be called with
43 * error_id from `error_counter_range.first` to
44 * `error_counter_range.last`.
45 *
46 * The @query_error_counter is a mandatory callback for
47 * error_counter_node.
48 *
49 * Returns: 0 on success,
50 * -ENOENT when error_id is not supported as an indication that
51 * drm_ras should silently skip this entry. Used for
52 * supporting non-contiguous error ranges.
53 * Driver is responsible for maintaining the list of
54 * supported error IDs in the range of first to last.
55 * Other negative values on errors that should terminate the
56 * netlink query.
57 */
58 int (*query_error_counter)(struct drm_ras_node *node, u32 error_id,
59 const char **name, u32 *val);
60
61 /** @priv: Driver private data */
62 void *priv;
63};
64
65struct drm_device;
66
67#if IS_ENABLED(CONFIG_DRM_RAS)
68int drm_ras_node_register(struct drm_ras_node *node);
69void drm_ras_node_unregister(struct drm_ras_node *node);
70#else
71static inline int drm_ras_node_register(struct drm_ras_node *node) { return 0; }
72static inline void drm_ras_node_unregister(struct drm_ras_node *node) { }
73#endif
74
75#endif