drm/amdgpu/userq: enable support for secure queues
authorAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Feb 2025 02:33:01 +0000 (21:33 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 22 Apr 2025 12:51:44 +0000 (08:51 -0400)
Enable users to create secure GFX/compute queues.

Reviewed-by: Sunil Khatri <sunil.khatri@amd.com>
Tested-by: Jesse.Zhang <Jesse.zhang@amd.com>
Reviewed-by: Jesse.Zhang <Jesse.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c

index 5f87cc8b5bf4f817a681fd6965861afcfd29026e..4e02d6cc66b537b13d3d315aaab89e3c879ce49d 100644 (file)
@@ -311,6 +311,14 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
        if (r)
                return r;
 
+       if ((args->in.flags & AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE) &&
+           (args->in.ip_type != AMDGPU_HW_IP_GFX) &&
+           (args->in.ip_type != AMDGPU_HW_IP_COMPUTE) &&
+           !amdgpu_is_tmz(adev)) {
+               drm_err(adev_to_drm(adev), "Secure only supported on GFX/Compute queues\n");
+               return -EINVAL;
+       }
+
        r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
        if (r < 0) {
                dev_err(adev->dev, "pm_runtime_get_sync() failed for userqueue create\n");
@@ -424,7 +432,8 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,
 
        switch (args->in.op) {
        case AMDGPU_USERQ_OP_CREATE:
-               if (args->in.flags & ~AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_MASK)
+               if (args->in.flags & ~(AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_MASK |
+                                      AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE))
                        return -EINVAL;
                r = amdgpu_userqueue_create(filp, args);
                if (r)