Skip to contentSkip to conversation

drm/amdgpu: Handle NULL bo->tbo.resource (again) in amdgpu_vm_bo_update

PATCH Applied Michel Dänzer 4 participants 5 messages Dec 17, 2024 – Dec 19, 2024

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

PATCH 1/1 drm/amdgpu: Handle NULL bo->tbo.resource (again) in amdgpu_vm_bo_update

From: Michel Dänzer <[email protected]>

Third time's the charm, I hope?

Fixes d3116756a710 ("drm/ttm: rename bo->mem and make it a pointer")

Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/3837

---

Or should amdgpu_vm_bo_evicted be called in the !bo->tbo.resource case as well?

 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -4
index ddd7f05e4db9..c9c48b782ec1 100644
@@ -1266,10 +1266,9 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
 	 * next command submission.
 	 */
 	if (amdgpu_vm_is_bo_always_valid(vm, bo)) {
-		uint32_t mem_type = bo->tbo.resource->mem_type;
-
-		if (!(bo->preferred_domains &
-		      amdgpu_mem_type_to_domain(mem_type)))
+		if (bo->tbo.resource &&
+		    !(bo->preferred_domains &
+		      amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type)))
 			amdgpu_vm_bo_evicted(&bo_va->base);
 		else
 			amdgpu_vm_bo_idle(&bo_va->base);
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 17.12.24 um 18:22 schrieb Michel Dänzer:

Quoted 3 lines

From: Michel Dänzer <[email protected]>

Third time's the charm, I hope?

More like the twenties. It's astonishing how many use cases for BOs without a backing store we have.

Quoted 2 lines
Fixes d3116756a710 ("drm/ttm: rename bo->mem and make it a pointer")

Please double check if that code wasn't introduced later than this patch.

Quoted 2 lines

Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/3837

Quoted 26 lines

---

Or should amdgpu_vm_bo_evicted be called in the !bo->tbo.resource case as well?

  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -4
index ddd7f05e4db9..c9c48b782ec1 100644
@@ -1266,10 +1266,9 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
  	 * next command submission.
  	 */
  	if (amdgpu_vm_is_bo_always_valid(vm, bo)) {
-		uint32_t mem_type = bo->tbo.resource->mem_type;
-
-		if (!(bo->preferred_domains &
-		      amdgpu_mem_type_to_domain(mem_type)))
+		if (bo->tbo.resource &&
+		    !(bo->preferred_domains &
+		      amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type)))
  			amdgpu_vm_bo_evicted(&bo_va->base);
  		else
  			amdgpu_vm_bo_idle(&bo_va->base);
#2 lore raw
Quoted 6 lines · Christian König

Am 17.12.24 um 18:22 schrieb Michel Dänzer:

Quoted 3 lines

From: Michel Dänzer <[email protected]>

Third time's the charm, I hope?

More like the twenties.

The reference is to it being the third time in amdgpu_vm_bo_update.

Quoted 3 lines
Quoted 1 line
Fixes d3116756a710 ("drm/ttm: rename bo->mem and make it a pointer")

Please double check if that code wasn't introduced later than this patch.

Checked before adding this to the commit log and double-checked, d3116756a710 modified this code, no other commit has touched it since.

Quoted 4 lines
Quoted 2 lines

Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/3837

Thanks!

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
Applied
#3 lore raw

Applied. Thanks!

Quoted 30 lines · Michel Dänzer
Quoted 6 lines · Christian König

Am 17.12.24 um 18:22 schrieb Michel Dänzer:

Quoted 3 lines

From: Michel Dänzer <[email protected]>

Third time's the charm, I hope?

More like the twenties.

The reference is to it being the third time in amdgpu_vm_bo_update.

Quoted 3 lines
Quoted 1 line
Fixes d3116756a710 ("drm/ttm: rename bo->mem and make it a pointer")

Please double check if that code wasn't introduced later than this patch.

Checked before adding this to the commit log and double-checked, d3116756a710 modified this code, no other commit has touched it since.

Quoted 4 lines
Quoted 2 lines

Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/3837

Thanks!

--
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer
https://redhat.com \ Libre software enthusiast

#4 lore raw
In reply to Michel Dänzer
Quoted 32 lines

From: Michel Dänzer <[email protected]>

Third time's the charm, I hope?

Fixes d3116756a710 ("drm/ttm: rename bo->mem and make it a pointer")

Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/3837

---

Or should amdgpu_vm_bo_evicted be called in the !bo->tbo.resource case as well?

 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index ddd7f05e4db9..c9c48b782ec1 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
@@ -1266,10 +1266,9 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,

struct amdgpu_bo_va *bo_va, * next command submission.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -4
 	 */
 	if (amdgpu_vm_is_bo_always_valid(vm, bo)) {
-		uint32_t mem_type = bo->tbo.resource->mem_type;
-
-		if (!(bo->preferred_domains &
-		      amdgpu_mem_type_to_domain(mem_type)))
+		if (bo->tbo.resource &&
+		    !(bo->preferred_domains &
+		      amdgpu_mem_type_to_domain(bo->tbo.resource-

mem_type)))

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va, · line 1274

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
 			amdgpu_vm_bo_evicted(&bo_va->base);
 		else
 			amdgpu_vm_bo_idle(&bo_va->base);

Hi

I reported the issue and just replying to confirm the fix works for me. I applied the patch to the openSUSE kernel sources of the same kernel version that I got the original bug with and tested again with this patch and now all applications works fine.

Thanks!

Signature · 3 lines
         Jabber/XMPP: [email protected]
              Matrix: @jlp:matrix.org
Mastodon/ActivityPub: @[email protected]