From a04525ece8b32e39339ff50836ca8d1415c923bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konsta=20H=C3=B6ltt=C3=A4?= Date: Wed, 12 Aug 2020 18:10:35 +0300 Subject: [PATCH] gpu: nvgpu: require deterministic for usermode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deterministic mode has always been a requirement for usermode submit; enforce it in the setup_bind path. Adjust tests to use the flag. QNX uses NVGPU_SETUP_BIND_FLAGS_SUPPORT_DETERMINISTIC only if CONFIG_NVGPU_IOCTL_NON_FUSA is set, so guard the check with that for now. Jira NVGPU-5582 Change-Id: Idedd01a3a24420b45195a472e8ca5c9f32f4ef46 Signed-off-by: Konsta Hölttä Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2369818 Reviewed-by: automaticguardword Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/channel.c | 16 ++++++++++++++++ userspace/units/fifo/channel/nvgpu-channel.c | 3 +++ 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/nvgpu/common/fifo/channel.c b/drivers/gpu/nvgpu/common/fifo/channel.c index 797d7074f..09425c040 100644 --- a/drivers/gpu/nvgpu/common/fifo/channel.c +++ b/drivers/gpu/nvgpu/common/fifo/channel.c @@ -1640,6 +1640,22 @@ static int channel_setup_bind_prechecks(struct nvgpu_channel *c, err = -EINVAL; goto fail; } + + /* FUSA build for now assumes that the deterministic flag is not useful */ +#ifdef CONFIG_NVGPU_IOCTL_NON_FUSA + if ((args->flags & NVGPU_SETUP_BIND_FLAGS_USERMODE_SUPPORT) != 0U && + (args->flags & NVGPU_SETUP_BIND_FLAGS_SUPPORT_DETERMINISTIC) == 0U) { + /* + * Usermode submit shares various preconditions with + * deterministic mode. Require that it's explicitly set to + * avoid surprises. + */ + nvgpu_err(g, "need deterministic for usermode submit"); + err = -EINVAL; + goto fail; + } +#endif + fail: return err; } diff --git a/userspace/units/fifo/channel/nvgpu-channel.c b/userspace/units/fifo/channel/nvgpu-channel.c index 6f3c3c7cd..fef3b55e9 100644 --- a/userspace/units/fifo/channel/nvgpu-channel.c +++ b/userspace/units/fifo/channel/nvgpu-channel.c @@ -821,6 +821,8 @@ int test_channel_setup_bind(struct unit_module *m, struct gk20a *g, void *vargs) bind_args.flags &= ~NVGPU_SETUP_BIND_FLAGS_USERMODE_SUPPORT; } else { + bind_args.flags |= + NVGPU_SETUP_BIND_FLAGS_SUPPORT_DETERMINISTIC; bind_args.flags |= NVGPU_SETUP_BIND_FLAGS_USERMODE_SUPPORT; } @@ -1705,6 +1707,7 @@ int test_channel_semaphore_wakeup(struct unit_module *m, memset(&bind_args, 0, sizeof(bind_args)); bind_args.num_gpfifo_entries = 32; + bind_args.flags |= NVGPU_SETUP_BIND_FLAGS_SUPPORT_DETERMINISTIC; bind_args.flags |= NVGPU_SETUP_BIND_FLAGS_USERMODE_SUPPORT; err = nvgpu_channel_setup_bind(ch, &bind_args);