From 0119aedbe5a2ad01c37a729f274a76d6dae72e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konsta=20H=C3=B6ltt=C3=A4?= Date: Wed, 8 Apr 2020 10:43:34 +0300 Subject: [PATCH] gpu: nvgpu: try syncpt fdget only if supported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guard nvgpu_os_fence_syncpt_fdget() with an nvgpu_has_syncpoints() check. Even when CONFIG_TEGRA_GK20A_NVHOST is set, the platform data bit can be disabled independently; on Linux we have a runtime flag to disable them, too. If nvgpu doesn't have syncpt support, don't try reading syncpt-based sync files. If a sema-only-backed channel sync is given a syncpoint-based prefence fd, we can't wait for it with the current design that couples waits and increments in one interface. This should eventually be fixed, but for now the extra check at least guards another interesting case. A sync file with a zero fence count can be trivially accepted as either a valid syncpoint fence or a sema fence. If only semas are supported, and the syncpt check that happens first would turn the empty fd into a syncpt-based sync fence, the sema wait layer would wrongly reject it. Jira NVGPU-4548 Change-Id: Ib40c2d9a6a25812c5e24eef52c1d1a4f81eeed83 Signed-off-by: Konsta Hölttä Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2325733 (cherry picked from commit 877f99d7c9977dfea14480a1b0488c990b813d1d) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2326044 Reviewed-by: automaticguardword Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/os_fence_android.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/os/linux/os_fence_android.c b/drivers/gpu/nvgpu/os/linux/os_fence_android.c index 290e8d056..1c07ac605 100644 --- a/drivers/gpu/nvgpu/os/linux/os_fence_android.c +++ b/drivers/gpu/nvgpu/os/linux/os_fence_android.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "../drivers/staging/android/sync.h" @@ -66,7 +67,9 @@ int nvgpu_os_fence_fdget(struct nvgpu_os_fence *fence_out, int err = -ENOSYS; #ifdef CONFIG_TEGRA_GK20A_NVHOST - err = nvgpu_os_fence_syncpt_fdget(fence_out, c, fd); + if (nvgpu_has_syncpoints(c->g)) { + err = nvgpu_os_fence_syncpt_fdget(fence_out, c, fd); + } #endif if (err)