[RFC PATCH 05/13] drm/amdgpu: introduce a flag to track refcount held for features
Jiang Liu
gerry at linux.alibaba.com
Wed Jan 8 13:59:57 UTC 2025
Currently we track the refcount on ras block object for features by
checking `if (obj && amdgpu_ras_is_feature_enabled(adev, head))`,
which is a little unreliable. So introduce a dedicated flag to track
the reference count.
Signed-off-by: Jiang Liu <gerry at linux.alibaba.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 9 +++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 2ef7d3102be3..fa19c5391d8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -378,6 +378,8 @@ enum amdgpu_marker {
AMDGPU_MARKER_IRQ6 = 6,
AMDGPU_MARKER_IRQ7 = 7,
AMDGPU_MARKER_IRQ_MAX = 47,
+ // used for ras blocks
+ AMDGPU_MARKER_RAS_FEATURE = 62,
AMDGPU_MARKER_RAS_DEBUGFS = 63,
};
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 5e8838ffccaa..41978116b92b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -774,15 +774,20 @@ static int __amdgpu_ras_feature_enable(struct amdgpu_device *adev,
obj = amdgpu_ras_create_obj(adev, head);
if (!obj)
return -EINVAL;
- } else {
+ amdgpu_ras_set_marker(adev, head, AMDGPU_MARKER_RAS_FEATURE);
+ } else if (!amdgpu_ras_test_marker(adev, head,
+ AMDGPU_MARKER_RAS_FEATURE)) {
/* In case we create obj somewhere else */
get_obj(obj);
+ amdgpu_ras_set_marker(adev, head, AMDGPU_MARKER_RAS_FEATURE);
}
con->features |= BIT(head->block);
} else {
if (obj && amdgpu_ras_is_feature_enabled(adev, head)) {
con->features &= ~BIT(head->block);
- put_obj(obj);
+ if (amdgpu_ras_test_and_clear_marker(adev, head,
+ AMDGPU_MARKER_RAS_FEATURE))
+ put_obj(obj);
}
}
--
2.43.5
More information about the amd-gfx
mailing list