Skip to contentSkip to conversation

drm:amd:amdgpu: Fix missing bo unlock in failure path

PATCH Applied Sukrut Bellary 3 participants 3 messages Apr 24, 2023

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

PATCH 1/1 drm:amd:amdgpu: Fix missing bo unlock in failure path

smatch warning - inconsistent handling of buffer object reserve and unreserve.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -1
index 278416acf060..5de44d7e92de 100644
@@ -4686,8 +4686,10 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev)
 		return r;
 
 	r = amdgpu_bo_kmap(ring->mqd_obj, &ring->mqd_ptr);
-	if (unlikely(r != 0))
+	if (unlikely(r != 0)) {
+		amdgpu_bo_unreserve(ring->mqd_obj);
 		return r;
+	}
 
 	gfx_v8_0_kiq_init_queue(ring);
 	amdgpu_bo_kunmap(ring->mqd_obj);
Signature · 1 line
2.34.1
maintainer
#1 lore raw

Am 24.04.23 um 07:59 schrieb Sukrut Bellary:

Quoted 4 lines

smatch warning - inconsistent handling of buffer object reserve and unreserve.

For now that patch is Reviewed-by: Christian König <[email protected]>.

But for the record mapping/unmapping the MQD like this is a very bad idea in the first place.

We could need to shuffle memory around for that during resume and that is not something we really want to do.

Christian.

Quoted 20 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -1
index 278416acf060..5de44d7e92de 100644
@@ -4686,8 +4686,10 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev)
  		return r;
 
  	r = amdgpu_bo_kmap(ring->mqd_obj, &ring->mqd_ptr);
-	if (unlikely(r != 0))
+	if (unlikely(r != 0)) {
+		amdgpu_bo_unreserve(ring->mqd_obj);
  		return r;
+	}
 
  	gfx_v8_0_kiq_init_queue(ring);
  	amdgpu_bo_kunmap(ring->mqd_obj);
Applied
#2 lore raw
Quoted 9 lines · Christian König

Am 24.04.23 um 07:59 schrieb Sukrut Bellary:

Quoted 4 lines

smatch warning - inconsistent handling of buffer object reserve and unreserve.

For now that patch is Reviewed-by: Christian König <[email protected]>.

Applied. Thanks.

Quoted 6 lines

But for the record mapping/unmapping the MQD like this is a very bad idea in the first place.

We could need to shuffle memory around for that during resume and that is not something we really want to do.

We should probably just keep the MQDs mapped. On suspend we need to save out the MQD state so it can be restored on resume when the MQDs are in vram.

Alex

Quoted 24 lines

Christian.

Quoted 20 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -1
index 278416acf060..5de44d7e92de 100644
@@ -4686,8 +4686,10 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev)
              return r;
 
      r = amdgpu_bo_kmap(ring->mqd_obj, &ring->mqd_ptr);
-     if (unlikely(r != 0))
+     if (unlikely(r != 0)) {
+             amdgpu_bo_unreserve(ring->mqd_obj);
              return r;
+     }
 
      gfx_v8_0_kiq_init_queue(ring);
      amdgpu_bo_kunmap(ring->mqd_obj);