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>
This commit is contained in:
Debarshi Dutta
2018-04-24 10:38:30 +05:30
committed by mobile promotions
parent 70e69e2686
commit 4f40637c58
8 changed files with 37 additions and 43 deletions

View File

@@ -52,6 +52,14 @@ void nvgpu_os_fence_android_drop_ref(struct nvgpu_os_fence *s)
nvgpu_os_fence_clear(s);
}
void nvgpu_os_fence_android_install_fd(struct nvgpu_os_fence *s, int fd)
{
struct sync_fence *fence = nvgpu_get_sync_fence(s);
sync_fence_get(fence);
sync_fence_install(fence, fd);
}
int nvgpu_os_fence_fdget(struct nvgpu_os_fence *fence_out,
struct channel_gk20a *c, int fd)
{

View File

@@ -69,6 +69,7 @@ int nvgpu_os_fence_sema_wait_gen_cmd(struct nvgpu_os_fence *s,
static const struct nvgpu_os_fence_ops sema_ops = {
.program_waits = nvgpu_os_fence_sema_wait_gen_cmd,
.drop_ref = nvgpu_os_fence_android_drop_ref,
.install_fence = nvgpu_os_fence_android_install_fd,
};
int nvgpu_os_fence_sema_create(

View File

@@ -88,6 +88,7 @@ int nvgpu_os_fence_syncpt_wait_gen_cmd(struct nvgpu_os_fence *s,
static const struct nvgpu_os_fence_ops syncpt_ops = {
.program_waits = nvgpu_os_fence_syncpt_wait_gen_cmd,
.drop_ref = nvgpu_os_fence_android_drop_ref,
.install_fence = nvgpu_os_fence_android_install_fd,
};
int nvgpu_os_fence_syncpt_create(

View File

@@ -37,10 +37,6 @@
#include "sync_gk20a.h"
#include "mm_gk20a.h"
#ifdef CONFIG_SYNC
#include "../drivers/staging/android/sync.h"
#endif
#ifdef CONFIG_TEGRA_GK20A_NVHOST
struct gk20a_channel_syncpt {
@@ -145,7 +141,6 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s,
struct gk20a_channel_syncpt *sp =
container_of(s, struct gk20a_channel_syncpt, ops);
struct channel_gk20a *c = sp->c;
struct sync_fence *sync_fence = NULL;
struct nvgpu_os_fence os_fence = {0};
err = gk20a_channel_alloc_priv_cmdbuf(c,
@@ -194,12 +189,10 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s,
if (err)
goto clean_up_priv_cmd;
sync_fence = (struct sync_fence *)os_fence.priv;
}
err = gk20a_fence_from_syncpt(fence, sp->nvhost_dev,
sp->id, thresh, sync_fence);
sp->id, thresh, os_fence);
if (err) {
if (nvgpu_os_fence_is_initialized(&os_fence))
@@ -494,7 +487,6 @@ static int __gk20a_channel_semaphore_incr(
struct channel_gk20a *c = sp->c;
struct nvgpu_semaphore *semaphore;
int err = 0;
struct sync_fence *sync_fence = NULL;
struct nvgpu_os_fence os_fence = {0};
semaphore = nvgpu_semaphore_alloc(c);
@@ -521,14 +513,12 @@ static int __gk20a_channel_semaphore_incr(
if (err)
goto clean_up_sema;
sync_fence = (struct sync_fence *)os_fence.priv;
}
err = gk20a_fence_from_semaphore(fence,
semaphore,
&c->semaphore_wq,
sync_fence);
os_fence);
if (err) {
if (nvgpu_os_fence_is_initialized(&os_fence))

View File

@@ -22,25 +22,17 @@
#include "fence_gk20a.h"
#ifdef CONFIG_SYNC
#include <linux/file.h>
#include <linux/fs.h>
#endif
#include <nvgpu/semaphore.h>
#include <nvgpu/kmem.h>
#include <nvgpu/soc.h>
#include <nvgpu/nvhost.h>
#include <nvgpu/barrier.h>
#include <nvgpu/os_fence.h>
#include "gk20a.h"
#include "channel_gk20a.h"
#include "sync_gk20a.h"
#ifdef CONFIG_SYNC
#include "../drivers/staging/android/sync.h"
#endif
struct gk20a_fence_ops {
int (*wait)(struct gk20a_fence *, long timeout);
bool (*is_expired)(struct gk20a_fence *);
@@ -53,10 +45,8 @@ static void gk20a_fence_free(struct nvgpu_ref *ref)
container_of(ref, struct gk20a_fence, ref);
struct gk20a *g = f->g;
#ifdef CONFIG_SYNC
if (f->os_fence)
sync_fence_put(f->os_fence);
#endif
if (nvgpu_os_fence_is_initialized(&f->os_fence))
f->os_fence.ops->drop_ref(&f->os_fence);
if (f->semaphore)
nvgpu_semaphore_put(f->semaphore);
@@ -91,17 +81,13 @@ inline bool gk20a_fence_is_valid(struct gk20a_fence *f)
int gk20a_fence_install_fd(struct gk20a_fence *f, int fd)
{
#ifdef CONFIG_SYNC
if (!f || !gk20a_fence_is_valid(f) || !f->os_fence)
return -EINVAL;
if (!f || !gk20a_fence_is_valid(f) ||
!nvgpu_os_fence_is_initialized(&f->os_fence))
return -EINVAL;
sync_fence_get(f->os_fence);
sync_fence_install(f->os_fence, fd);
f->os_fence.ops->install_fence(&f->os_fence, fd);
return 0;
#else
return -ENODEV;
#endif
}
int gk20a_fence_wait(struct gk20a *g, struct gk20a_fence *f,
@@ -191,7 +177,7 @@ struct gk20a_fence *gk20a_alloc_fence(struct channel_gk20a *c)
void gk20a_init_fence(struct gk20a_fence *f,
const struct gk20a_fence_ops *ops,
struct sync_fence *os_fence)
struct nvgpu_os_fence os_fence)
{
if (!f)
return;
@@ -229,7 +215,7 @@ int gk20a_fence_from_semaphore(
struct gk20a_fence *fence_out,
struct nvgpu_semaphore *semaphore,
struct nvgpu_cond *semaphore_wq,
struct sync_fence *os_fence)
struct nvgpu_os_fence os_fence)
{
struct gk20a_fence *f = fence_out;
@@ -290,7 +276,7 @@ static const struct gk20a_fence_ops gk20a_syncpt_fence_ops = {
int gk20a_fence_from_syncpt(
struct gk20a_fence *fence_out,
struct nvgpu_nvhost_dev *nvhost_dev,
u32 id, u32 value, struct sync_fence *os_fence)
u32 id, u32 value, struct nvgpu_os_fence os_fence)
{
struct gk20a_fence *f = fence_out;
@@ -312,7 +298,7 @@ int gk20a_fence_from_syncpt(
int gk20a_fence_from_syncpt(
struct gk20a_fence *fence_out,
struct nvgpu_nvhost_dev *nvhost_dev,
u32 id, u32 value, struct sync_fence *os_fence)
u32 id, u32 value, struct nvgpu_os_fence os_fence)
{
return -EINVAL;
}

View File

@@ -28,13 +28,13 @@
#include <nvgpu/types.h>
#include <nvgpu/kref.h>
#include <nvgpu/os_fence.h>
struct platform_device;
struct sync_timeline;
struct sync_fence;
struct nvgpu_semaphore;
struct channel_gk20a;
struct gk20a;
struct nvgpu_os_fence;
struct gk20a_fence_ops;
@@ -46,7 +46,7 @@ struct gk20a_fence {
struct nvgpu_ref ref;
const struct gk20a_fence_ops *ops;
struct sync_fence *os_fence;
struct nvgpu_os_fence os_fence;
/* Valid for fences created from semaphores: */
struct nvgpu_semaphore *semaphore;
@@ -66,13 +66,13 @@ int gk20a_fence_from_semaphore(
struct gk20a_fence *fence_out,
struct nvgpu_semaphore *semaphore,
struct nvgpu_cond *semaphore_wq,
struct sync_fence *os_fence);
struct nvgpu_os_fence os_fence);
int gk20a_fence_from_syncpt(
struct gk20a_fence *fence_out,
struct nvgpu_nvhost_dev *nvhost_dev,
u32 id, u32 value,
struct sync_fence *os_fence);
struct nvgpu_os_fence os_fence);
int gk20a_alloc_fence_pool(
struct channel_gk20a *c,
@@ -86,7 +86,7 @@ struct gk20a_fence *gk20a_alloc_fence(
void gk20a_init_fence(struct gk20a_fence *f,
const struct gk20a_fence_ops *ops,
struct sync_fence *os_fence);
struct nvgpu_os_fence os_fence);
/* Fence operations */
void gk20a_fence_put(struct gk20a_fence *f);

View File

@@ -39,6 +39,8 @@ void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out,
struct gk20a *g, const struct nvgpu_os_fence_ops *fops,
struct sync_fence *fence);
void nvgpu_os_fence_android_install_fd(struct nvgpu_os_fence *s, int fd);
int nvgpu_os_fence_syncpt_fdget(
struct nvgpu_os_fence *fence_out,
struct channel_gk20a *c, int fd);

View File

@@ -60,6 +60,12 @@ struct nvgpu_os_fence_ops {
* for the underlying sync_fence.
*/
void (*drop_ref)(struct nvgpu_os_fence *s);
/*
* Used to install the fd in the corresponding OS. The underlying
* implementation varies from OS to OS.
*/
void (*install_fence)(struct nvgpu_os_fence *s, int fd);
};
/*