On 5/13/2026 12:46 AM, Raag Jadav wrote:
Now that we have get/set error threshold support in xe driver, wire them
up to drm_ras so that userspace can make use of the functionality.

$ sudo ynl --family drm_ras --do get-error-threshold \
--json '{"node-id":0, "error-id":2}'
{'error-id': 2, 'error-name': 'soc-internal', 'error-threshold': 16}

$ sudo ynl --family drm_ras --do set-error-threshold \
--json '{"node-id":0, "error-id":2, "error-threshold":8}'
None

Signed-off-by: Raag Jadav <[email protected]>
Reviewed-by: Riana Tauro <[email protected]>
---
  drivers/gpu/drm/xe/xe_drm_ras.c | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_drm_ras.c b/drivers/gpu/drm/xe/xe_drm_ras.c
index c21c8b428de6..31780d8af7e9 100644
--- a/drivers/gpu/drm/xe/xe_drm_ras.c
+++ b/drivers/gpu/drm/xe/xe_drm_ras.c
@@ -11,6 +11,7 @@
#include "xe_device_types.h"
  #include "xe_drm_ras.h"
+#include "xe_ras.h"
static const char * const error_components[] = DRM_XE_RAS_ERROR_COMPONENT_NAMES;
  static const char * const error_severity[] = DRM_XE_RAS_ERROR_SEVERITY_NAMES;
@@ -75,6 +76,30 @@ static int clear_correctable_error_counter(struct 
drm_ras_node *node, u32 error_
        return hw_clear_error_counter(info, error_id);
  }
+static int query_correctable_error_threshold(struct drm_ras_node *ep, u32 error_id,
+                                            const char **name, u32 *val)
+{
+       struct xe_device *xe = ep->priv;
+       struct xe_drm_ras *ras = &xe->ras;
+       struct xe_drm_ras_counter *info = 
ras->info[DRM_XE_RAS_ERR_SEV_CORRECTABLE];
+
+       if (!xe->info.has_sysctrl)
+               return -EOPNOTSUPP;
+
+       *name = info[error_id].name;

Please check if name is null and return -ENOENT.

Thanks
Riana

+       return xe_ras_get_threshold(xe, DRM_XE_RAS_ERR_SEV_CORRECTABLE, 
error_id, val);
+}
+
+static int set_correctable_error_threshold(struct drm_ras_node *ep, u32 
error_id, u32 val)
+{
+       struct xe_device *xe = ep->priv;
+
+       if (!xe->info.has_sysctrl)
+               return -EOPNOTSUPP;
+
+       return xe_ras_set_threshold(xe, DRM_XE_RAS_ERR_SEV_CORRECTABLE, 
error_id, val);
+}
+
  static struct xe_drm_ras_counter *allocate_and_copy_counters(struct xe_device 
*xe)
  {
        struct xe_drm_ras_counter *counter;
@@ -123,6 +148,8 @@ static int assign_node_params(struct xe_device *xe, struct 
drm_ras_node *node,
        if (severity == DRM_XE_RAS_ERR_SEV_CORRECTABLE) {
                node->query_error_counter = query_correctable_error_counter;
                node->clear_error_counter = clear_correctable_error_counter;
+               node->query_error_threshold = query_correctable_error_threshold;
+               node->set_error_threshold = set_correctable_error_threshold;
        } else {
                node->query_error_counter = query_uncorrectable_error_counter;
                node->clear_error_counter = clear_uncorrectable_error_counter;

Reply via email to