[RFC v2 04/15] drm/amdgpu: introduce a flag to track refcount held for features
Jiang Liu
gerry at linux.alibaba.com
Mon Jan 13 01:42:09 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 | 1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 09b63a622728..24ef39b706e3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -380,6 +380,7 @@ int amdgpu_ip_block_resume(struct amdgpu_ip_block *ip_block);
enum amdgpu_marker {
// Markers for ras blocks.
AMDGPU_MARKER_RAS_DEBUGFS,
+ AMDGPU_MARKER_RAS_FEATURE,
// Markers for IRQs, used for both ip blocks and ras blocks.
AMDGPU_MARKER_IRQ0 = 32,
AMDGPU_MARKER_IRQ1,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 6b508a9b1abe..f0cd14ff78a7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -775,15 +775,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