From 1c1da3d6b4950ff12d5e8e9ca0e9bd45c0d13c6c Mon Sep 17 00:00:00 2001
From: Dinesh
Date: Mon, 6 Apr 2020 16:23:24 +0530
Subject: [PATCH] gpu: nvgpu: Syncpoint invalid value to ~0.
As qnx syncpoint's invalid value is ~0, change the code
to handle this.
Bug 200603716
Change-Id: I5ec79688cd9e60066725781f1effe57692ec0c27
Signed-off-by: Dinesh
(cherry picked from commit 705260565a75bc90683841c4c08e4c857bda39f0)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2331208
Tested-by: mobile promotions
Reviewed-by: mobile promotions
---
drivers/gpu/nvgpu/common/fifo/channel.c | 1 +
drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c | 8 +++++++-
drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c | 8 +++++++-
drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h | 5 ++---
drivers/gpu/nvgpu/include/nvgpu/nvhost.h | 1 +
drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 1 +
6 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/nvgpu/common/fifo/channel.c b/drivers/gpu/nvgpu/common/fifo/channel.c
index ccc57942c..da8dade64 100644
--- a/drivers/gpu/nvgpu/common/fifo/channel.c
+++ b/drivers/gpu/nvgpu/common/fifo/channel.c
@@ -54,6 +54,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c b/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c
index 807e43457..87e8bb702 100644
--- a/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c
+++ b/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c
@@ -354,7 +354,13 @@ nvgpu_channel_sync_syncpt_create(struct nvgpu_channel *c)
sp->id = nvgpu_nvhost_get_syncpt_host_managed(sp->nvhost,
c->chid, syncpt_name);
- if (sp->id == 0U) {
+ /**
+ * This is a WAR to handle invalid value of a syncpt.
+ * Once nvhost update the return value as NVGPU_INVALID_SYNCPT_ID,
+ * we can remove the zero check.
+ */
+ if ((sp->id == 0U) ||
+ (sp->id == NVGPU_INVALID_SYNCPT_ID)) {
nvgpu_kfree(c->g, sp);
nvgpu_err(c->g, "failed to get free syncpt");
return NULL;
diff --git a/drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c b/drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c
index 518d33fbd..5c0d79e30 100644
--- a/drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c
+++ b/drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c
@@ -88,7 +88,13 @@ nvgpu_channel_user_syncpt_create(struct nvgpu_channel *ch)
s->syncpt_id = nvgpu_nvhost_get_syncpt_client_managed(s->nvhost,
syncpt_name);
- if (s->syncpt_id == 0U) {
+ /**
+ * This is a WAR to handle invalid value of a syncpt.
+ * Once nvhost update the return value as NVGPU_INVALID_SYNCPT_ID,
+ * we can remove the zero check.
+ */
+ if ((s->syncpt_id == 0U) ||
+ (s->syncpt_id == NVGPU_INVALID_SYNCPT_ID)) {
nvgpu_err(g, "failed to get free syncpt");
goto err_free;
}
diff --git a/drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h b/drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h
index df2bcb9af..9d3bd904c 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h
@@ -2,7 +2,7 @@
*
* Nvgpu Channel Synchronization Abstraction (Syncpoints)
*
- * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -29,10 +29,9 @@
#include
#include
#include
+#include
#include
-#define NVGPU_INVALID_SYNCPT_ID (~U32(0U))
-
struct nvgpu_channel;
struct nvgpu_channel_sync_syncpt;
struct priv_cmd_entry;
diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h
index 12a507ed3..811f1c559 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h
@@ -26,6 +26,7 @@
#include
struct gk20a;
+#define NVGPU_INVALID_SYNCPT_ID (~U32(0U))
#ifdef CONFIG_TEGRA_GK20A_NVHOST
diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c
index 26bb8af80..00405753d 100644
--- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c
+++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c
@@ -24,6 +24,7 @@
#include
#include
+#include
#include
#include
#include