From: Zhu Lingshan Date: Mon, 4 Aug 2025 07:33:51 +0000 (+0800) Subject: amdkfd: find kfd_process by filep->private_data in kfd_mmap X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4eb38fc0f1da9707b8866b4a91a4dd7c2becfda9;p=thirdparty%2Fkernel%2Flinux.git amdkfd: find kfd_process by filep->private_data in kfd_mmap This commit finds the proper kfd_process by filep->private_data in kfd_mmap, because the function kfd_get_process() can not locate a specific kfd process among multiple contexts. Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index ff1a6a903463..14bee49f0bf9 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -3414,16 +3414,19 @@ static int kfd_mmio_mmap(struct kfd_node *dev, struct kfd_process *process, } -static int kfd_mmap(struct file *filp, struct vm_area_struct *vma) +static int kfd_mmap(struct file *filep, struct vm_area_struct *vma) { struct kfd_process *process; struct kfd_node *dev = NULL; unsigned long mmap_offset; unsigned int gpu_id; - process = kfd_get_process(current); - if (IS_ERR(process)) - return PTR_ERR(process); + process = filep->private_data; + if (!process) + return -ESRCH; + + if (process->lead_thread != current->group_leader) + return -EBADF; mmap_offset = vma->vm_pgoff << PAGE_SHIFT; gpu_id = KFD_MMAP_GET_GPU_ID(mmap_offset);