Skip to content

Commit c065e46

Browse files
committed
accel/amdxdna: Support submit commands without arguments
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 <[email protected]> Signed-off-by: Lizhi Hou <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 4fca684 commit c065e46

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

drivers/accel/amdxdna/amdxdna_ctx.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,11 @@ static int amdxdna_drm_submit_execbuf(struct amdxdna_client *client,
496496
struct amdxdna_drm_exec_cmd *args)
497497
{
498498
struct amdxdna_dev *xdna = client->xdna;
499-
u32 *arg_bo_hdls;
499+
u32 *arg_bo_hdls = NULL;
500500
u32 cmd_bo_hdl;
501501
int ret;
502502

503-
if (!args->arg_count || args->arg_count > MAX_ARG_COUNT) {
503+
if (args->arg_count > MAX_ARG_COUNT) {
504504
XDNA_ERR(xdna, "Invalid arg bo count %d", args->arg_count);
505505
return -EINVAL;
506506
}
@@ -512,14 +512,16 @@ static int amdxdna_drm_submit_execbuf(struct amdxdna_client *client,
512512
}
513513

514514
cmd_bo_hdl = (u32)args->cmd_handles;
515-
arg_bo_hdls = kcalloc(args->arg_count, sizeof(u32), GFP_KERNEL);
516-
if (!arg_bo_hdls)
517-
return -ENOMEM;
518-
ret = copy_from_user(arg_bo_hdls, u64_to_user_ptr(args->args),
519-
args->arg_count * sizeof(u32));
520-
if (ret) {
521-
ret = -EFAULT;
522-
goto free_cmd_bo_hdls;
515+
if (args->arg_count) {
516+
arg_bo_hdls = kcalloc(args->arg_count, sizeof(u32), GFP_KERNEL);
517+
if (!arg_bo_hdls)
518+
return -ENOMEM;
519+
ret = copy_from_user(arg_bo_hdls, u64_to_user_ptr(args->args),
520+
args->arg_count * sizeof(u32));
521+
if (ret) {
522+
ret = -EFAULT;
523+
goto free_cmd_bo_hdls;
524+
}
523525
}
524526

525527
ret = amdxdna_cmd_submit(client, cmd_bo_hdl, arg_bo_hdls,

0 commit comments

Comments
 (0)