accel/amdxdna: Support submit commands without arguments
authorLizhi Hou <lizhi.hou@amd.com>
Wed, 7 May 2025 16:15:00 +0000 (09:15 -0700)
committerLizhi Hou <lizhi.hou@amd.com>
Thu, 8 May 2025 16:58:21 +0000 (09:58 -0700)
The latest userspace runtime allows generating commands which do not
have any argument. Remove the corresponding check in driver IOCTL to
enable this use case.

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://lore.kernel.org/r/20250507161500.2339701-1-lizhi.hou@amd.com
Link: https://lore.kernel.org/r/20250507161500.2339701-1-lizhi.hou@amd.com
drivers/accel/amdxdna/amdxdna_ctx.c

index 43442b9e273b346335f06a8420435dbfd662486f..be073224bd69333be0a0f0f563389eb346d50d6f 100644 (file)
@@ -496,11 +496,11 @@ static int amdxdna_drm_submit_execbuf(struct amdxdna_client *client,
                                      struct amdxdna_drm_exec_cmd *args)
 {
        struct amdxdna_dev *xdna = client->xdna;
-       u32 *arg_bo_hdls;
+       u32 *arg_bo_hdls = NULL;
        u32 cmd_bo_hdl;
        int ret;
 
-       if (!args->arg_count || args->arg_count > MAX_ARG_COUNT) {
+       if (args->arg_count > MAX_ARG_COUNT) {
                XDNA_ERR(xdna, "Invalid arg bo count %d", args->arg_count);
                return -EINVAL;
        }
@@ -512,14 +512,16 @@ static int amdxdna_drm_submit_execbuf(struct amdxdna_client *client,
        }
 
        cmd_bo_hdl = (u32)args->cmd_handles;
-       arg_bo_hdls = kcalloc(args->arg_count, sizeof(u32), GFP_KERNEL);
-       if (!arg_bo_hdls)
-               return -ENOMEM;
-       ret = copy_from_user(arg_bo_hdls, u64_to_user_ptr(args->args),
-                            args->arg_count * sizeof(u32));
-       if (ret) {
-               ret = -EFAULT;
-               goto free_cmd_bo_hdls;
+       if (args->arg_count) {
+               arg_bo_hdls = kcalloc(args->arg_count, sizeof(u32), GFP_KERNEL);
+               if (!arg_bo_hdls)
+                       return -ENOMEM;
+               ret = copy_from_user(arg_bo_hdls, u64_to_user_ptr(args->args),
+                                    args->arg_count * sizeof(u32));
+               if (ret) {
+                       ret = -EFAULT;
+                       goto free_cmd_bo_hdls;
+               }
        }
 
        ret = amdxdna_cmd_submit(client, cmd_bo_hdl, arg_bo_hdls,