summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/os_fence_android.c
diff options
context:
space:
mode:
authorDebarshi Dutta <ddutta@nvidia.com>2018-04-18 01:33:02 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-05-10 11:40:02 -0400
commit4dfd6e43cfe303c8b23421ef32738db2ee52e291 (patch)
tree510ce3c59745ea98e44b355d9c4c4cf101bab9c2 /drivers/gpu/nvgpu/common/linux/os_fence_android.c
parent90b2f780d414d993571dceccafbc01b371068782 (diff)
gpu: nvgpu: create a wrapper over sync_fences
This patch constructs an abstraction to hide the sync_fence functionality from the common code. struct nvgpu_os_fence acts as an abstraction for struct sync_fence. struct nvgpu_os_fence consists of an ops structure named nvgpu_os_fence_ops which contains an API to do pushbuffer programming to generate wait commands for the fence. The current implementation of nvgpu only allows for wait method on a sync_fence which was generated using a similar backend(i.e. either Nvhost Syncpoints or Semaphores). In this patch, a generic API is introduced which will decide the type of the underlying implementation of the struct nvgpu_os_fence at runtime and run the corresponding wait implementation on it. This patch changes the channel_sync_gk20a's semaphore specific implementation to use the abstract API. A subsequent patch will make the changes for the nvhost_syncpoint based implementations as well. JIRA NVGPU-66 Change-Id: If6675bfde5885c3d15d2ca380bb6c7c0e240e734 Signed-off-by: Debarshi Dutta <ddutta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1667218 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/os_fence_android.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_fence_android.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/os_fence_android.c b/drivers/gpu/nvgpu/common/linux/os_fence_android.c
new file mode 100644
index 00000000..d689a2a8
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/os_fence_android.c
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include <nvgpu/types.h>
17#include <nvgpu/os_fence.h>
18#include <nvgpu/linux/os_fence_android.h>
19
20#include "gk20a/gk20a.h"
21
22#include "../drivers/staging/android/sync.h"
23
24inline struct sync_fence *nvgpu_get_sync_fence(struct nvgpu_os_fence *s)
25{
26 struct sync_fence *fence = (struct sync_fence *)s->priv;
27 return fence;
28}
29
30static void nvgpu_os_fence_clear(struct nvgpu_os_fence *fence_out)
31{
32 fence_out->priv = NULL;
33 fence_out->g = NULL;
34 fence_out->ops = NULL;
35}
36
37void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out,
38 struct gk20a *g, const struct nvgpu_os_fence_ops *fops,
39 struct sync_fence *fence)
40{
41 fence_out->g = g;
42 fence_out->ops = fops;
43 fence_out->priv = (void *)fence;
44}
45
46void nvgpu_os_fence_android_drop_ref(struct nvgpu_os_fence *s)
47{
48 struct sync_fence *fence = nvgpu_get_sync_fence(s);
49
50 sync_fence_put(fence);
51
52 nvgpu_os_fence_clear(s);
53}
54
55int nvgpu_os_fence_fdget(struct nvgpu_os_fence *fence_out,
56 struct channel_gk20a *c, int fd)
57{
58 int err;
59
60 err = nvgpu_os_fence_sema_fdget(fence_out, c, fd);
61
62 /* TO-DO
63 * check if fence is empty and if CONFIG_TEGRA_GK20A_NVHOST
64 * is enabled, try to get a sync_fence using
65 * corresponding nvhost method.
66 */
67 if (err)
68 nvgpu_err(c->g, "error obtaining fence from fd %d", fd);
69
70 return err;
71}