drm/amdkfd: Validate user queue svm memory residency
authorPhilip Yang <Philip.Yang@amd.com>
Thu, 20 Jun 2024 16:44:57 +0000 (12:44 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 24 Jul 2024 18:43:28 +0000 (14:43 -0400)
commitb049504e211e8f4dbcd40434f2dcab2215ea1039
treed3073239bf55d201e506f26dfa6f209ad999cd2e
parentbd4bea5ab2bda37ddb092a978218c4d9b46927e6
drm/amdkfd: Validate user queue svm memory residency

Queue CWSR area maybe registered to GPU as svm memory, create queue to
ensure svm mapped to GPU with KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED flag.

Add queue_refcount to struct svm_range, to track queue CWSR area usage.

Because unmap mmu notifier callback return value is ignored, if
application unmap the CWSR area while queue is active, pr_warn message
in dmesg log. To be safe, evict user queue.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_queue.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.h