projects/linux·blob master · refs

88 lines · 2.6 KiB

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 <linux/types.h>
10
11#include <uapi/drm/drm_ras.h>
12
13/**
14 * struct drm_ras_node - A DRM RAS Node
15 */
16struct drm_ras_node {
17 /** @id: Unique identifier for the node. Dynamically assigned. */
18 u32 id;
19 /**
20 * @device_name: Human-readable name of the device. Given by the driver.
21 */
22 const char *device_name;
23 /** @node_name: Human-readable name of the node. Given by the driver. */
24 const char *node_name;
25 /** @type: Type of the node (enum drm_ras_node_type). */
26 enum drm_ras_node_type type;
27
28 /* Error-Counter Related Callback and Variables */
29
30 /** @error_counter_range: Range of valid Error IDs for this node. */
31 struct {
32 /** @first: First valid Error ID. */
33 u32 first;
34 /** @last: Last valid Error ID. Mandatory entry. */
35 u32 last;
36 } error_counter_range;
37
38 /**
39 * @query_error_counter:
40 *
41 * This callback is used by drm-ras to query a specific error counter.
42 * Used for input check and to iterate all error counters in a node.
43 *
44 * Driver should expect query_error_counter() to be called with
45 * error_id from `error_counter_range.first` to
46 * `error_counter_range.last`.
47 *
48 * The @query_error_counter is a mandatory callback for
49 * error_counter_node.
50 *
51 * Returns: 0 on success,
52 * -ENOENT when error_id is not supported as an indication that
53 * drm_ras should silently skip this entry. Used for
54 * supporting non-contiguous error ranges.
55 * Driver is responsible for maintaining the list of
56 * supported error IDs in the range of first to last.
57 * Other negative values on errors that should terminate the
58 * netlink query.
59 */
60 int (*query_error_counter)(struct drm_ras_node *node, u32 error_id,
61 const char **name, u32 *val);
62
63 /**
64 * @clear_error_counter:
65 *
66 * This callback is used by drm_ras to clear a specific error counter.
67 * Driver should implement this callback to support clearing error counters
68 * of a node.
69 *
70 * Returns: 0 on success, negative error code on failure.
71 */
72 int (*clear_error_counter)(struct drm_ras_node *node, u32 error_id);
73
74 /** @priv: Driver private data */
75 void *priv;
76};
77
78struct drm_device;
79
80#if IS_ENABLED(CONFIG_DRM_RAS)
81int drm_ras_node_register(struct drm_ras_node *node);
82void drm_ras_node_unregister(struct drm_ras_node *node);
83#else
84static inline int drm_ras_node_register(struct drm_ras_node *node) { return 0; }
85static inline void drm_ras_node_unregister(struct drm_ras_node *node) { }
86#endif
87
88#endif