summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDebarshi Dutta <ddutta@nvidia.com>2018-04-24 01:08:30 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-05-10 11:40:36 -0400
commit4f40637c580c5f25f34f45c2c16b5332104897bc (patch)
tree997eb7390801e3159611d59e0b2f149e43d14470
parent70e69e2686527990865b221a60e0ec1e9a53d316 (diff)
gpu: nvgpu: remove sync_fence dependencies from fence_gk20a
Replaced all instances of sync_fence in gk20a_fence* code with nvgpu_os_fence. Added the API install_fence for the nvgpu_os_fence abstraction. sync_fence mechanism and its dependencies are completely removed from the fence_gk20a methods. Due to the recent os_fence changes and the changes to fence_gk20a, we can finally get rid of all the CONFIG_SYNCS present in the submit path. JIRA NVGPU-66 Change-Id: I3551dab04b93b1e94db83fc102a41872be89e9ed Signed-off-by: Debarshi Dutta <ddutta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1701245 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_fence_android.c8
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_fence_android_sema.c1
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_fence_android_syncpt.c1
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c14
-rw-r--r--drivers/gpu/nvgpu/gk20a/fence_gk20a.c36
-rw-r--r--drivers/gpu/nvgpu/gk20a/fence_gk20a.h12
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h2
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/os_fence.h6
8 files changed, 37 insertions, 43 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/os_fence_android.c b/drivers/gpu/nvgpu/common/linux/os_fence_android.c
index d8f70639..9be8c6c0 100644
--- a/drivers/gpu/nvgpu/common/linux/os_fence_android.c
+++ b/drivers/gpu/nvgpu/common/linux/os_fence_android.c
@@ -52,6 +52,14 @@ void nvgpu_os_fence_android_drop_ref(struct nvgpu_os_fence *s)
52 nvgpu_os_fence_clear(s); 52 nvgpu_os_fence_clear(s);
53} 53}
54 54
55void nvgpu_os_fence_android_install_fd(struct nvgpu_os_fence *s, int fd)
56{
57 struct sync_fence *fence = nvgpu_get_sync_fence(s);
58
59 sync_fence_get(fence);
60 sync_fence_install(fence, fd);
61}
62
55int nvgpu_os_fence_fdget(struct nvgpu_os_fence *fence_out, 63int nvgpu_os_fence_fdget(struct nvgpu_os_fence *fence_out,
56 struct channel_gk20a *c, int fd) 64 struct channel_gk20a *c, int fd)
57{ 65{
diff --git a/drivers/gpu/nvgpu/common/linux/os_fence_android_sema.c b/drivers/gpu/nvgpu/common/linux/os_fence_android_sema.c
index b61bd893..d4aeb6ed 100644
--- a/drivers/gpu/nvgpu/common/linux/os_fence_android_sema.c
+++ b/drivers/gpu/nvgpu/common/linux/os_fence_android_sema.c
@@ -69,6 +69,7 @@ int nvgpu_os_fence_sema_wait_gen_cmd(struct nvgpu_os_fence *s,
69static const struct nvgpu_os_fence_ops sema_ops = { 69static const struct nvgpu_os_fence_ops sema_ops = {
70 .program_waits = nvgpu_os_fence_sema_wait_gen_cmd, 70 .program_waits = nvgpu_os_fence_sema_wait_gen_cmd,
71 .drop_ref = nvgpu_os_fence_android_drop_ref, 71 .drop_ref = nvgpu_os_fence_android_drop_ref,
72 .install_fence = nvgpu_os_fence_android_install_fd,
72}; 73};
73 74
74int nvgpu_os_fence_sema_create( 75int nvgpu_os_fence_sema_create(
diff --git a/drivers/gpu/nvgpu/common/linux/os_fence_android_syncpt.c b/drivers/gpu/nvgpu/common/linux/os_fence_android_syncpt.c
index 76def831..b3712011 100644
--- a/drivers/gpu/nvgpu/common/linux/os_fence_android_syncpt.c
+++ b/drivers/gpu/nvgpu/common/linux/os_fence_android_syncpt.c
@@ -88,6 +88,7 @@ int nvgpu_os_fence_syncpt_wait_gen_cmd(struct nvgpu_os_fence *s,
88static const struct nvgpu_os_fence_ops syncpt_ops = { 88static const struct nvgpu_os_fence_ops syncpt_ops = {
89 .program_waits = nvgpu_os_fence_syncpt_wait_gen_cmd, 89 .program_waits = nvgpu_os_fence_syncpt_wait_gen_cmd,
90 .drop_ref = nvgpu_os_fence_android_drop_ref, 90 .drop_ref = nvgpu_os_fence_android_drop_ref,
91 .install_fence = nvgpu_os_fence_android_install_fd,
91}; 92};
92 93
93int nvgpu_os_fence_syncpt_create( 94int nvgpu_os_fence_syncpt_create(
diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c
index 16898593..a2047444 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c
@@ -37,10 +37,6 @@
37#include "sync_gk20a.h" 37#include "sync_gk20a.h"
38#include "mm_gk20a.h" 38#include "mm_gk20a.h"
39 39
40#ifdef CONFIG_SYNC
41#include "../drivers/staging/android/sync.h"
42#endif
43
44#ifdef CONFIG_TEGRA_GK20A_NVHOST 40#ifdef CONFIG_TEGRA_GK20A_NVHOST
45 41
46struct gk20a_channel_syncpt { 42struct gk20a_channel_syncpt {
@@ -145,7 +141,6 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s,
145 struct gk20a_channel_syncpt *sp = 141 struct gk20a_channel_syncpt *sp =
146 container_of(s, struct gk20a_channel_syncpt, ops); 142 container_of(s, struct gk20a_channel_syncpt, ops);
147 struct channel_gk20a *c = sp->c; 143 struct channel_gk20a *c = sp->c;
148 struct sync_fence *sync_fence = NULL;
149 struct nvgpu_os_fence os_fence = {0}; 144 struct nvgpu_os_fence os_fence = {0};
150 145
151 err = gk20a_channel_alloc_priv_cmdbuf(c, 146 err = gk20a_channel_alloc_priv_cmdbuf(c,
@@ -194,12 +189,10 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s,
194 189
195 if (err) 190 if (err)
196 goto clean_up_priv_cmd; 191 goto clean_up_priv_cmd;
197
198 sync_fence = (struct sync_fence *)os_fence.priv;
199 } 192 }
200 193
201 err = gk20a_fence_from_syncpt(fence, sp->nvhost_dev, 194 err = gk20a_fence_from_syncpt(fence, sp->nvhost_dev,
202 sp->id, thresh, sync_fence); 195 sp->id, thresh, os_fence);
203 196
204 if (err) { 197 if (err) {
205 if (nvgpu_os_fence_is_initialized(&os_fence)) 198 if (nvgpu_os_fence_is_initialized(&os_fence))
@@ -494,7 +487,6 @@ static int __gk20a_channel_semaphore_incr(
494 struct channel_gk20a *c = sp->c; 487 struct channel_gk20a *c = sp->c;
495 struct nvgpu_semaphore *semaphore; 488 struct nvgpu_semaphore *semaphore;
496 int err = 0; 489 int err = 0;
497 struct sync_fence *sync_fence = NULL;
498 struct nvgpu_os_fence os_fence = {0}; 490 struct nvgpu_os_fence os_fence = {0};
499 491
500 semaphore = nvgpu_semaphore_alloc(c); 492 semaphore = nvgpu_semaphore_alloc(c);
@@ -521,14 +513,12 @@ static int __gk20a_channel_semaphore_incr(
521 513
522 if (err) 514 if (err)
523 goto clean_up_sema; 515 goto clean_up_sema;
524
525 sync_fence = (struct sync_fence *)os_fence.priv;
526 } 516 }
527 517
528 err = gk20a_fence_from_semaphore(fence, 518 err = gk20a_fence_from_semaphore(fence,
529 semaphore, 519 semaphore,
530 &c->semaphore_wq, 520 &c->semaphore_wq,
531 sync_fence); 521 os_fence);
532 522
533 if (err) { 523 if (err) {
534 if (nvgpu_os_fence_is_initialized(&os_fence)) 524 if (nvgpu_os_fence_is_initialized(&os_fence))
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
index f0ad773f..0f7f3ea1 100644
--- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c
@@ -22,25 +22,17 @@
22 22
23#include "fence_gk20a.h" 23#include "fence_gk20a.h"
24 24
25#ifdef CONFIG_SYNC
26#include <linux/file.h>
27#include <linux/fs.h>
28#endif
29
30#include <nvgpu/semaphore.h> 25#include <nvgpu/semaphore.h>
31#include <nvgpu/kmem.h> 26#include <nvgpu/kmem.h>
32#include <nvgpu/soc.h> 27#include <nvgpu/soc.h>
33#include <nvgpu/nvhost.h> 28#include <nvgpu/nvhost.h>
34#include <nvgpu/barrier.h> 29#include <nvgpu/barrier.h>
30#include <nvgpu/os_fence.h>
35 31
36#include "gk20a.h" 32#include "gk20a.h"
37#include "channel_gk20a.h" 33#include "channel_gk20a.h"
38#include "sync_gk20a.h" 34#include "sync_gk20a.h"
39 35
40#ifdef CONFIG_SYNC
41#include "../drivers/staging/android/sync.h"
42#endif
43
44struct gk20a_fence_ops { 36struct gk20a_fence_ops {
45 int (*wait)(struct gk20a_fence *, long timeout); 37 int (*wait)(struct gk20a_fence *, long timeout);
46 bool (*is_expired)(struct gk20a_fence *); 38 bool (*is_expired)(struct gk20a_fence *);
@@ -53,10 +45,8 @@ static void gk20a_fence_free(struct nvgpu_ref *ref)
53 container_of(ref, struct gk20a_fence, ref); 45 container_of(ref, struct gk20a_fence, ref);
54 struct gk20a *g = f->g; 46 struct gk20a *g = f->g;
55 47
56#ifdef CONFIG_SYNC 48 if (nvgpu_os_fence_is_initialized(&f->os_fence))
57 if (f->os_fence) 49 f->os_fence.ops->drop_ref(&f->os_fence);
58 sync_fence_put(f->os_fence);
59#endif
60 50
61 if (f->semaphore) 51 if (f->semaphore)
62 nvgpu_semaphore_put(f->semaphore); 52 nvgpu_semaphore_put(f->semaphore);
@@ -91,17 +81,13 @@ inline bool gk20a_fence_is_valid(struct gk20a_fence *f)
91 81
92int gk20a_fence_install_fd(struct gk20a_fence *f, int fd) 82int gk20a_fence_install_fd(struct gk20a_fence *f, int fd)
93{ 83{
94#ifdef CONFIG_SYNC 84 if (!f || !gk20a_fence_is_valid(f) ||
95 if (!f || !gk20a_fence_is_valid(f) || !f->os_fence) 85 !nvgpu_os_fence_is_initialized(&f->os_fence))
96 return -EINVAL; 86 return -EINVAL;
97 87
98 sync_fence_get(f->os_fence); 88 f->os_fence.ops->install_fence(&f->os_fence, fd);
99 sync_fence_install(f->os_fence, fd);
100 89
101 return 0; 90 return 0;
102#else
103 return -ENODEV;
104#endif
105} 91}
106 92
107int gk20a_fence_wait(struct gk20a *g, struct gk20a_fence *f, 93int gk20a_fence_wait(struct gk20a *g, struct gk20a_fence *f,
@@ -191,7 +177,7 @@ struct gk20a_fence *gk20a_alloc_fence(struct channel_gk20a *c)
191 177
192void gk20a_init_fence(struct gk20a_fence *f, 178void gk20a_init_fence(struct gk20a_fence *f,
193 const struct gk20a_fence_ops *ops, 179 const struct gk20a_fence_ops *ops,
194 struct sync_fence *os_fence) 180 struct nvgpu_os_fence os_fence)
195{ 181{
196 if (!f) 182 if (!f)
197 return; 183 return;
@@ -229,7 +215,7 @@ int gk20a_fence_from_semaphore(
229 struct gk20a_fence *fence_out, 215 struct gk20a_fence *fence_out,
230 struct nvgpu_semaphore *semaphore, 216 struct nvgpu_semaphore *semaphore,
231 struct nvgpu_cond *semaphore_wq, 217 struct nvgpu_cond *semaphore_wq,
232 struct sync_fence *os_fence) 218 struct nvgpu_os_fence os_fence)
233{ 219{
234 struct gk20a_fence *f = fence_out; 220 struct gk20a_fence *f = fence_out;
235 221
@@ -290,7 +276,7 @@ static const struct gk20a_fence_ops gk20a_syncpt_fence_ops = {
290int gk20a_fence_from_syncpt( 276int gk20a_fence_from_syncpt(
291 struct gk20a_fence *fence_out, 277 struct gk20a_fence *fence_out,
292 struct nvgpu_nvhost_dev *nvhost_dev, 278 struct nvgpu_nvhost_dev *nvhost_dev,
293 u32 id, u32 value, struct sync_fence *os_fence) 279 u32 id, u32 value, struct nvgpu_os_fence os_fence)
294{ 280{
295 struct gk20a_fence *f = fence_out; 281 struct gk20a_fence *f = fence_out;
296 282
@@ -312,7 +298,7 @@ int gk20a_fence_from_syncpt(
312int gk20a_fence_from_syncpt( 298int gk20a_fence_from_syncpt(
313 struct gk20a_fence *fence_out, 299 struct gk20a_fence *fence_out,
314 struct nvgpu_nvhost_dev *nvhost_dev, 300 struct nvgpu_nvhost_dev *nvhost_dev,
315 u32 id, u32 value, struct sync_fence *os_fence) 301 u32 id, u32 value, struct nvgpu_os_fence os_fence)
316{ 302{
317 return -EINVAL; 303 return -EINVAL;
318} 304}
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
index 6a28e657..271b2a18 100644
--- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
@@ -28,13 +28,13 @@
28 28
29#include <nvgpu/types.h> 29#include <nvgpu/types.h>
30#include <nvgpu/kref.h> 30#include <nvgpu/kref.h>
31#include <nvgpu/os_fence.h>
31 32
32struct platform_device; 33struct platform_device;
33struct sync_timeline;
34struct sync_fence;
35struct nvgpu_semaphore; 34struct nvgpu_semaphore;
36struct channel_gk20a; 35struct channel_gk20a;
37struct gk20a; 36struct gk20a;
37struct nvgpu_os_fence;
38 38
39struct gk20a_fence_ops; 39struct gk20a_fence_ops;
40 40
@@ -46,7 +46,7 @@ struct gk20a_fence {
46 struct nvgpu_ref ref; 46 struct nvgpu_ref ref;
47 const struct gk20a_fence_ops *ops; 47 const struct gk20a_fence_ops *ops;
48 48
49 struct sync_fence *os_fence; 49 struct nvgpu_os_fence os_fence;
50 50
51 /* Valid for fences created from semaphores: */ 51 /* Valid for fences created from semaphores: */
52 struct nvgpu_semaphore *semaphore; 52 struct nvgpu_semaphore *semaphore;
@@ -66,13 +66,13 @@ int gk20a_fence_from_semaphore(
66 struct gk20a_fence *fence_out, 66 struct gk20a_fence *fence_out,
67 struct nvgpu_semaphore *semaphore, 67 struct nvgpu_semaphore *semaphore,
68 struct nvgpu_cond *semaphore_wq, 68 struct nvgpu_cond *semaphore_wq,
69 struct sync_fence *os_fence); 69 struct nvgpu_os_fence os_fence);
70 70
71int gk20a_fence_from_syncpt( 71int gk20a_fence_from_syncpt(
72 struct gk20a_fence *fence_out, 72 struct gk20a_fence *fence_out,
73 struct nvgpu_nvhost_dev *nvhost_dev, 73 struct nvgpu_nvhost_dev *nvhost_dev,
74 u32 id, u32 value, 74 u32 id, u32 value,
75 struct sync_fence *os_fence); 75 struct nvgpu_os_fence os_fence);
76 76
77int gk20a_alloc_fence_pool( 77int gk20a_alloc_fence_pool(
78 struct channel_gk20a *c, 78 struct channel_gk20a *c,
@@ -86,7 +86,7 @@ struct gk20a_fence *gk20a_alloc_fence(
86 86
87void gk20a_init_fence(struct gk20a_fence *f, 87void gk20a_init_fence(struct gk20a_fence *f,
88 const struct gk20a_fence_ops *ops, 88 const struct gk20a_fence_ops *ops,
89 struct sync_fence *os_fence); 89 struct nvgpu_os_fence os_fence);
90 90
91/* Fence operations */ 91/* Fence operations */
92void gk20a_fence_put(struct gk20a_fence *f); 92void gk20a_fence_put(struct gk20a_fence *f);
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h b/drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h
index 39d08339..201b5306 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h
@@ -39,6 +39,8 @@ void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out,
39 struct gk20a *g, const struct nvgpu_os_fence_ops *fops, 39 struct gk20a *g, const struct nvgpu_os_fence_ops *fops,
40 struct sync_fence *fence); 40 struct sync_fence *fence);
41 41
42void nvgpu_os_fence_android_install_fd(struct nvgpu_os_fence *s, int fd);
43
42int nvgpu_os_fence_syncpt_fdget( 44int nvgpu_os_fence_syncpt_fdget(
43 struct nvgpu_os_fence *fence_out, 45 struct nvgpu_os_fence *fence_out,
44 struct channel_gk20a *c, int fd); 46 struct channel_gk20a *c, int fd);
diff --git a/drivers/gpu/nvgpu/include/nvgpu/os_fence.h b/drivers/gpu/nvgpu/include/nvgpu/os_fence.h
index a22140da..4713ed3e 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/os_fence.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/os_fence.h
@@ -60,6 +60,12 @@ struct nvgpu_os_fence_ops {
60 * for the underlying sync_fence. 60 * for the underlying sync_fence.
61 */ 61 */
62 void (*drop_ref)(struct nvgpu_os_fence *s); 62 void (*drop_ref)(struct nvgpu_os_fence *s);
63
64 /*
65 * Used to install the fd in the corresponding OS. The underlying
66 * implementation varies from OS to OS.
67 */
68 void (*install_fence)(struct nvgpu_os_fence *s, int fd);
63}; 69};
64 70
65/* 71/*