summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhu Lingshan <lingshan.zhu@amd.com>2026-07-22 18:13:44 +0800
committerAlex Deucher <alexander.deucher@amd.com>2026-08-19 10:03:04 -0400
commitffdb7a8104f51d552dea4b319c8ce5169f63e724 (patch)
tree7463a6d1dddb8992ea2b133a76b7f6ecbcb2ebba
parentef5fcf2a6c320676bf8be2dadac93d9023b468b7 (diff)
downloadlinux-ffdb7a8104f51d552dea4b319c8ce5169f63e724.tar.gz
linux-ffdb7a8104f51d552dea4b319c8ce5169f63e724.zip
drm/amdgpu: ensure all userq VAs mapped before restore
amdgpu_userq_buffer_vas_mapped() checks whether all VAs of a queue are mapped before restoring it. So that HW won't access any invalid addresses. Currently, this function assumes all VAs are mapped if any VA of a queue has been mapped, which is wrong. This commit fixes this problem by examining all VAs of a queue and reporting false if any of them is not mapped. Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com> Reviewed-by: Sunil Khatri <sunil.khatri@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index bcfbd7213dd6..04639f894903 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -287,22 +287,24 @@ static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)
static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue *queue)
{
- int i, r = 0;
+ int i;
+ bool mapped;
for (i = 0; i < ARRAY_SIZE(queue->userq_vas.va_array); i++) {
if (!queue->userq_vas.va_array[i])
continue;
- r += amdgpu_userq_buffer_va_mapped(queue->vm,
+
+ mapped = amdgpu_userq_buffer_va_mapped(queue->vm,
queue->userq_vas.va_array[i]);
dev_dbg(queue->userq_mgr->adev->dev,
"validate the userq mapping:%p va:%llx r:%d\n",
- queue, queue->userq_vas.va_array[i], r);
- }
+ queue, queue->userq_vas.va_array[i], mapped);
- if (r != 0)
- return true;
+ if (!mapped)
+ return false;
+ }
- return false;
+ return true;
}