Skip to contentSkip to conversation

drm/amdgpu: Fix IP block NULL check during soft reset

PATCH Applied Timur Kristóf 2 participants 2 messages Jul 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix IP block NULL check during soft reset

We can't print the IP block name when the IP block is NULL.

Note that it should never be NULL, the only way that can happen is when amdgpu_ip_from_ring() is missing the given ring type. The check is just there to be sure.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c +7 -1
index 33a04113ed74..922f4b15619d 100644
@@ -489,7 +489,13 @@ int amdgpu_device_ip_soft_reset(struct amdgpu_ring *guilty_ring,
 	ip_type = amdgpu_ip_from_ring(guilty_ring->funcs->type);
 	ip_block = amdgpu_device_ip_get_ip_block(adev, ip_type);
 
-	if (!ip_block || !ip_block->version->funcs->soft_reset) {
+	if (unlikely(!ip_block)) {
+		dev_warn(adev->dev, "IP block not found for ring %s\n",
+			 guilty_ring->name);
+		return -EOPNOTSUPP;
+	}
+
+	if (!ip_block->version->funcs->soft_reset) {
 		dev_warn(adev->dev, "IP block soft reset not supported on %s\n",
 			 ip_block->version->funcs->name);
 		return -EOPNOTSUPP;
Signature · 1 line
2.54.0
Applied
#1 lore raw

Applied. Thanks!

Alex

Quoted 37 lines · Timur Kristóf

We can't print the IP block name when the IP block is NULL.

Note that it should never be NULL, the only way that can happen is when amdgpu_ip_from_ring() is missing the given ring type. The check is just there to be sure.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ip.c +7 -2
index 33a04113ed74..922f4b15619d 100644
@@ -489,7 +489,13 @@ int amdgpu_device_ip_soft_reset(struct amdgpu_ring *guilty_ring,
        ip_type = amdgpu_ip_from_ring(guilty_ring->funcs->type);
        ip_block = amdgpu_device_ip_get_ip_block(adev, ip_type);
 
-       if (!ip_block || !ip_block->version->funcs->soft_reset) {
+       if (unlikely(!ip_block)) {
+               dev_warn(adev->dev, "IP block not found for ring %s\n",
+                        guilty_ring->name);
+               return -EOPNOTSUPP;
+       }
+
+       if (!ip_block->version->funcs->soft_reset) {
                dev_warn(adev->dev, "IP block soft reset not supported on %s\n",
                         ip_block->version->funcs->name);
                return -EOPNOTSUPP;
--

2.54.0