Hello,
I apologize for the repeated mistakes in my previous messages and patch
submissions. Thank you for your patience. This version includes the corrected
Fixes tag and an unwrapped patch diff.
Unpinning a buffer object does not change its placement. Avoid calling
ttm_bo_validate() on the unpin path, where a placement validation failure
currently triggers BUG_ON() and crashes the kernel during PRIME cleanup.
Keep validation on the pin path, where it is needed to establish the
requested placement before pinning.
During PRIME/GEM cleanup, vmw_gem_object_unpin() calls
vmw_bo_pin_reserved(vbo, false). The latter currently calls
ttm_bo_validate() for both pin and unpin operations. In the observed Linux
7.3 QEMU run, ttm_bo_validate() returned -EINVAL on the unpin path; the
following BUG_ON() caused a kernel BUG during process teardown.
The path is:
exit_group()
-> GEM/PRIME object cleanup
-> vmw_gem_object_unpin()
-> vmw_bo_pin_reserved(vbo, false)
-> ttm_bo_validate() returns -EINVAL
-> BUG_ON(ret != 0 || bo->resource->mem_type != old_mem_type)
Observed report excerpt:
[BO_PIN_TRACE] before-validate pin=0 old_mem_type=0 target_mem_type=0
flags=0x10
[BO_PIN_TRACE] after-validate ret=-22 old_mem_type=0 new_mem_type=0 ...
kernel BUG at drivers/gpu/drm/vmwgfx/vmwgfx_bo.c:342!
RIP: vmw_bo_pin_reserved+0x36d/0x380
The change skips placement validation when unpinning and retains it on the
pin path.
Fixes: fbe86ca56791 ("drm/vmwgfx: switch over to the new pin interface v2")
Cc: [email protected]
Signed-off-by: Yuhang Pan <[email protected]>
---
Sorry, the previous submission was damaged by Thunderbird's line wrapping.
This v2 keeps the diff header on one physical line. I verified patch
applicability to the clean Linux 7.3 index after normalizing email CRLF line
endings; runtime verification of this exact patch is still pending.
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
index 9c7a73c..14d28e2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
@@ -308,6 +308,11 @@ void vmw_bo_pin_reserved(struct vmw_bo *vbo, bool pin)
if (pin == !!bo->pin_count)
return;
+ if (!pin) {
+ ttm_bo_unpin(bo);
+ return;
+ }
+
pl.fpfn = 0;
pl.lpfn = 0;
pl.mem_type = bo->resource->mem_type;
@@ -321,10 +326,7 @@ void vmw_bo_pin_reserved(struct vmw_bo *vbo, bool pin)
BUG_ON(ret != 0 || bo->resource->mem_type != old_mem_type);
- if (pin)
- ttm_bo_pin(bo);
- else
- ttm_bo_unpin(bo);
+ ttm_bo_pin(bo);
}
/**
--
2.43.0
Regards,
Yuhang Pan
[email protected]