summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorRaag Jadav <raag.jadav@intel.com>2026-06-02 10:18:43 +0530
committerMatthew Brost <matthew.brost@intel.com>2026-06-16 10:18:29 -0700
commit042f1d5f20d63fb9b0e2fbba97648d16fe1a845d (patch)
tree30cea5bc5867c58e8442a9de15b3699bfa13f993 /drivers/gpu
parent45fa032b68570a9ccd80328a857ac5872217be92 (diff)
drm/xe/drm_ras: Add per node cleanup action
cleanup_node_param() is not registered for previous node in case of counter allocation failure, which results in stale memory of previous node that isn't cleaned up on unwind. Add per node cleanup action which guarantees cleanup on unwind and also simplifies the cleanup logic. Fixes: b40db12b542f ("drm/xe/xe_drm_ras: Add support for XE DRM RAS") Signed-off-by: Raag Jadav <raag.jadav@intel.com> Reviewed-by: Riana Tauro <riana.tauro@intel.com> Link: https://patch.msgid.link/20260602044919.702209-4-raag.jadav@intel.com Signed-off-by: Matt Roper <matthew.d.roper@intel.com> (cherry picked from commit 67fc5543d8274b2fcbef87734fad0469358f4478) Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/xe/xe_drm_ras.c58
1 files changed, 23 insertions, 35 deletions
diff --git a/drivers/gpu/drm/xe/xe_drm_ras.c b/drivers/gpu/drm/xe/xe_drm_ras.c
index c1d5ac198a7c..cd236f53699e 100644
--- a/drivers/gpu/drm/xe/xe_drm_ras.c
+++ b/drivers/gpu/drm/xe/xe_drm_ras.c
@@ -131,53 +131,47 @@ static int assign_node_params(struct xe_device *xe, struct drm_ras_node *node,
return 0;
}
-static void cleanup_node_param(struct xe_drm_ras *ras, const enum drm_xe_ras_error_severity severity)
+static void cleanup_node_param(struct drm_ras_node *node)
{
- struct drm_ras_node *node = &ras->node[severity];
-
- ras->info[severity] = NULL;
-
kfree(node->device_name);
node->device_name = NULL;
}
+static void cleanup_node(struct drm_device *drm, void *node)
+{
+ drm_ras_node_unregister(node);
+ cleanup_node_param(node);
+}
+
static int register_nodes(struct xe_device *xe)
{
struct xe_drm_ras *ras = &xe->ras;
- int i;
+ struct drm_ras_node *node;
+ int i, ret;
for_each_error_severity(i) {
- struct drm_ras_node *node = &ras->node[i];
- int ret;
+ node = &ras->node[i];
ret = assign_node_params(xe, node, i);
- if (ret) {
- cleanup_node_param(ras, i);
- return ret;
- }
+ if (ret)
+ goto free_param;
ret = drm_ras_node_register(node);
- if (ret) {
- cleanup_node_param(ras, i);
- return ret;
- }
+ if (ret)
+ goto free_param;
+
+ ret = drmm_add_action_or_reset(&xe->drm, cleanup_node, node);
+ if (ret)
+ goto null_info;
}
return 0;
-}
-
-static void xe_drm_ras_unregister_nodes(struct drm_device *device, void *arg)
-{
- struct xe_device *xe = arg;
- struct xe_drm_ras *ras = &xe->ras;
- int i;
-
- for_each_error_severity(i) {
- struct drm_ras_node *node = &ras->node[i];
- drm_ras_node_unregister(node);
- cleanup_node_param(ras, i);
- }
+free_param:
+ cleanup_node_param(node);
+null_info:
+ ras->info[i] = NULL;
+ return ret;
}
/**
@@ -206,11 +200,5 @@ int xe_drm_ras_init(struct xe_device *xe)
return err;
}
- err = drmm_add_action_or_reset(&xe->drm, xe_drm_ras_unregister_nodes, xe);
- if (err) {
- drm_err(&xe->drm, "Failed to add action for Xe DRM RAS (%pe)\n", ERR_PTR(err));
- return err;
- }
-
return 0;
}