Public

Ping...

Best Regards,
Yifan

-----Original Message-----
From: Zhang, Yifan <[email protected]>
Sent: Wednesday, August 12, 2026 3:14 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian 
<[email protected]>; Yuan, Perry <[email protected]>; Ghosh, Prerona 
<[email protected]>; Zhang, Yifan <[email protected]>
Subject: [PATCH v3] drm/amdgpu: bind imported BOs when they are opened

From: Prerona Ghosh <[email protected]>

DMA-buf imports are created unbound and land on the VM idle list, so neither 
amdgpu_vm_validate() nor amdgpu_userq_bo_validate() ever binds them. Only the 
BO list of a command submission does, and a VM using user queues never runs 
amdgpu_cs. AMDGPU_GEM_VA then programs PTEs from a TTM_PL_SYSTEM resource, i.e. 
without AMDGPU_PTE_VALID, and the first GPU access faults.

Validate imports in amdgpu_gem_object_open() instead, while the BO is already 
reserved by the drm_exec context. Graphics and compute VMs now follow the same 
rule, and a BO that cannot be bound fails the ioctl rather than handing out a 
handle that only maps to faulting PTEs.

v3: validate inside amdgpu_gem_object_open (Christian)

Signed-off-by: Prerona Ghosh <[email protected]>
Signed-off-by: Yifan Zhang <[email protected]>
Assisted-by: Claude:claude-opus-5.0
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index f754a4a3a1c2..261218cb57a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -271,6 +271,20 @@ static int amdgpu_gem_object_open(struct drm_gem_object 
*obj,
                ++bo_va->ref_count;
        }

+       /* Imports are created unbound and land on the VM idle list, so neither
+        * amdgpu_vm_validate() nor an amdgpu_cs BO list ever binds them for a
+        * VM that submits through user queues. AMDGPU_GEM_VA would then program
+        * PTEs from a TTM_PL_SYSTEM resource, i.e. without AMDGPU_PTE_VALID.
+        */
+       if (drm_gem_is_imported(obj)) {
+               struct ttm_operation_ctx ctx = { false, false };
+
+               amdgpu_bo_placement_from_domain(abo, abo->allowed_domains);
+               r = ttm_bo_validate(&abo->tbo, &abo->placement, &ctx);
+               if (r)
+                       goto out_unlock;
+       }
+
        drm_exec_fini(&exec);

        /* Validate and add eviction fence to DMABuf imports with dynamic
--
2.43.0

Reply via email to