svm ioctl should only be processed on the primary
kfd process because only the lifecycle of the
primary kfd process is tied to the  user space
applicaiton.

Another reason is in virtualization the hypervisor owns
the primary kfd process as a privileged one.

Signed-off-by: Zhu Lingshan <lingshan....@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehl...@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index e8c6273de99b..f56faf11ee43 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1719,6 +1719,12 @@ static int kfd_ioctl_svm(struct file *filep, struct 
kfd_process *p, void *data)
        struct kfd_ioctl_svm_args *args = data;
        int r = 0;
 
+       if (!p->primary) {
+               pr_debug("SVM ioctl not supported on non-primary kfd 
process\n");
+
+               return -EOPNOTSUPP;
+       }
+
        pr_debug("start 0x%llx size 0x%llx op 0x%x nattr 0x%x\n",
                 args->start_addr, args->size, args->op, args->nattr);
 
-- 
2.47.1

Reply via email to