| 1 |
|
| 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 |
|
| 16 | struct drm_ras_node {
|
| 17 |
|
| 18 | u32 id;
|
| 19 | |
| 20 | * @device_name: Human-readable name of the device. Given by the driver.
|
| 21 |
|
| 22 | const char *device_name;
|
| 23 |
|
| 24 | const char *node_name;
|
| 25 |
|
| 26 | enum drm_ras_node_type type;
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 | struct {
|
| 32 |
|
| 33 | u32 first;
|
| 34 |
|
| 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 |
|
| 75 | void *priv;
|
| 76 | };
|
| 77 |
|
| 78 | struct drm_device;
|
| 79 |
|
| 80 | #if IS_ENABLED(CONFIG_DRM_RAS)
|
| 81 | int drm_ras_node_register(struct drm_ras_node *node);
|
| 82 | void drm_ras_node_unregister(struct drm_ras_node *node);
|
| 83 | #else
|
| 84 | static inline int drm_ras_node_register(struct drm_ras_node *node) { return 0; }
|
| 85 | static inline void drm_ras_node_unregister(struct drm_ras_node *node) { }
|
| 86 | #endif
|
| 87 |
|
| 88 | #endif
|