From 1b2a3db0049b4512737abd98d11e4abcc9be079c Mon Sep 17 00:00:00 2001 From: Raag Jadav Date: Tue, 18 Aug 2026 19:22:08 +0530 Subject: [PATCH] drm/xe/drm_ras: Wire up error threshold callbacks 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 Reviewed-by: Riana Tauro Link: https://patch.msgid.link/20260818135304.497098-5-raag.jadav@intel.com Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_drm_ras.c | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_drm_ras.c b/drivers/gpu/drm/xe/xe_drm_ras.c index 78184b6ea7d4..7f3695707611 100644 --- a/drivers/gpu/drm/xe/xe_drm_ras.c +++ b/drivers/gpu/drm/xe/xe_drm_ras.c @@ -86,6 +86,38 @@ static int clear_correctable_error_counter(struct drm_ras_node *node, u32 error_ return clear_error_counter(xe, DRM_XE_RAS_ERR_SEV_CORRECTABLE, error_id); } +static int query_correctable_error_threshold(struct drm_ras_node *ep, u32 error_id, + const char **name, u32 *threshold) +{ + 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 (!info || !info[error_id].name) + return -ENOENT; + + if (!xe->info.has_sysctrl) + return -EOPNOTSUPP; + + *name = info[error_id].name; + return xe_ras_get_threshold(xe, DRM_XE_RAS_ERR_SEV_CORRECTABLE, error_id, threshold); +} + +static int set_correctable_error_threshold(struct drm_ras_node *ep, u32 error_id, u32 threshold) +{ + 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 (!info || !info[error_id].name) + return -ENOENT; + + if (!xe->info.has_sysctrl) + return -EOPNOTSUPP; + + return xe_ras_set_threshold(xe, DRM_XE_RAS_ERR_SEV_CORRECTABLE, error_id, threshold); +} + static struct xe_drm_ras_counter *allocate_and_copy_counters(struct xe_device *xe) { struct xe_drm_ras_counter *counter; @@ -134,6 +166,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;