gpu: nvgpu: make os_fence_android_syncpt common

The differences between sync_fence ("android sync") and dma_fence are
abstracted away by nvhost in the nvhost_fence interface. There is no
need to have separate android and dma os fences for syncpoints; unify
the general implementation so that it's always used when requested for
the build.

Jira NVGPU-5386

Change-Id: Ia829e93e18d03064ff46ab1271547de2d1fb1cae
Signed-off-by: Konsta Hölttä <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2356158
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Konsta Hölttä
2020-06-05 09:44:59 +03:00
committed by Alex Waterman
parent 4e241d5974
commit 98335c29b2
11 changed files with 57 additions and 123 deletions

View File

@@ -142,10 +142,10 @@ nvlink:
fence:
sources: [ os/linux/os_fence_android.c,
os/linux/os_fence_android_sema.c,
os/linux/os_fence_android_syncpt.c,
os/linux/os_fence_dma.c,
os/linux/os_fence_dma_sema.c,
os/linux/os_fence_dma_syncpt.c,
os/linux/os_fence_syncpt.c,
os/linux/os_fence_priv.h,
os/linux/sync_sema_android.c,
os/linux/sync_sema_android.h,
os/linux/sync_sema_dma.c,

View File

@@ -449,12 +449,11 @@ nvgpu-$(CONFIG_NVGPU_SYNCFD_STABLE) += \
os/linux/os_fence_dma.o \
os/linux/os_fence_dma_sema.o
ifeq ($(CONFIG_TEGRA_GK20A_NVHOST), y)
nvgpu-$(CONFIG_NVGPU_SYNCFD_ANDROID) += \
os/linux/os_fence_android_syncpt.o
nvgpu-$(CONFIG_NVGPU_SYNCFD_STABLE) += \
os/linux/os_fence_dma_syncpt.o
nvgpu-y += common/sync/channel_sync_syncpt.o
nvgpu-$(CONFIG_TEGRA_GK20A_NVHOST) += \
common/sync/channel_sync_syncpt.o
ifneq ($(CONFIG_NVGPU_SYNCFD_NONE),y)
nvgpu-$(CONFIG_TEGRA_GK20A_NVHOST) += \
os/linux/os_fence_syncpt.o
endif
nvgpu-$(CONFIG_TEGRA_GK20A_NVHOST) += \

View File

@@ -29,10 +29,6 @@ void nvgpu_os_fence_android_drop_ref(struct nvgpu_os_fence *s);
int nvgpu_os_fence_sema_fdget(struct nvgpu_os_fence *fence_out,
struct nvgpu_channel *c, int fd);
void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out,
struct gk20a *g, const struct nvgpu_os_fence_ops *fops,
void *fence);
int nvgpu_os_fence_android_install_fd(struct nvgpu_os_fence *s, int fd);
int nvgpu_os_fence_syncpt_fdget(

View File

@@ -29,10 +29,6 @@ void nvgpu_os_fence_dma_drop_ref(struct nvgpu_os_fence *s);
int nvgpu_os_fence_sema_fdget(struct nvgpu_os_fence *fence_out,
struct nvgpu_channel *c, int fd);
void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out,
struct gk20a *g, const struct nvgpu_os_fence_ops *fops,
void *fence);
int nvgpu_os_fence_dma_install_fd(struct nvgpu_os_fence *s, int fd);
int nvgpu_os_fence_syncpt_fdget(struct nvgpu_os_fence *fence_out,

View File

@@ -20,6 +20,8 @@
#include <nvgpu/channel.h>
#include <nvgpu/nvhost.h>
#include "os_fence_priv.h"
#include "../drivers/staging/android/sync.h"
inline struct sync_fence *nvgpu_get_sync_fence(struct nvgpu_os_fence *s)
@@ -28,22 +30,6 @@ inline struct sync_fence *nvgpu_get_sync_fence(struct nvgpu_os_fence *s)
return fence;
}
static void nvgpu_os_fence_clear(struct nvgpu_os_fence *fence_out)
{
fence_out->priv = NULL;
fence_out->g = NULL;
fence_out->ops = NULL;
}
void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out,
struct gk20a *g, const struct nvgpu_os_fence_ops *fops,
void *fence)
{
fence_out->g = g;
fence_out->ops = fops;
fence_out->priv = fence;
}
void nvgpu_os_fence_android_drop_ref(struct nvgpu_os_fence *s)
{
struct sync_fence *fence = nvgpu_get_sync_fence(s);

View File

@@ -26,6 +26,7 @@
#include <nvgpu/channel_sync.h>
#include "sync_sema_android.h"
#include "os_fence_priv.h"
#include "../drivers/staging/android/sync.h"

View File

@@ -23,28 +23,14 @@
#include <linux/sync_file.h>
#include <linux/file.h>
#include "os_fence_priv.h"
inline struct dma_fence *nvgpu_get_dma_fence(struct nvgpu_os_fence *s)
{
struct dma_fence *fence = (struct dma_fence *)s->priv;
return fence;
}
static void nvgpu_os_fence_clear(struct nvgpu_os_fence *fence_out)
{
fence_out->priv = NULL;
fence_out->g = NULL;
fence_out->ops = NULL;
}
void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out,
struct gk20a *g, const struct nvgpu_os_fence_ops *fops,
void *fence)
{
fence_out->g = g;
fence_out->ops = fops;
fence_out->priv = fence;
}
void nvgpu_os_fence_dma_drop_ref(struct nvgpu_os_fence *s)
{
struct dma_fence *fence = nvgpu_get_dma_fence(s);

View File

@@ -23,6 +23,7 @@
#include <nvgpu/gk20a.h>
#include <nvgpu/channel.h>
#include "os_fence_priv.h"
#include "sync_sema_dma.h"
static const struct nvgpu_os_fence_ops sema_ops = {

View File

@@ -1,70 +0,0 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <nvgpu/errno.h>
#include <nvgpu/types.h>
#include <nvgpu/os_fence.h>
#include <nvgpu/os_fence_syncpts.h>
#include <nvgpu/linux/os_fence_dma.h>
#include <nvgpu/nvhost.h>
#include <nvgpu/gk20a.h>
#include <nvgpu/channel.h>
static const struct nvgpu_os_fence_ops syncpt_ops = {
.drop_ref = nvgpu_os_fence_dma_drop_ref,
.install_fence = nvgpu_os_fence_dma_install_fd,
};
int nvgpu_os_fence_syncpt_create(struct nvgpu_os_fence *fence_out,
struct nvgpu_channel *c, struct nvgpu_nvhost_dev *nvhost_dev,
u32 id, u32 thresh)
{
return -ENOSYS;
}
int nvgpu_os_fence_syncpt_fdget(struct nvgpu_os_fence *fence_out,
struct nvgpu_channel *c, int fd)
{
return -ENOSYS;
}
int nvgpu_os_fence_get_syncpts(struct nvgpu_os_fence_syncpt *fence_syncpt_out,
struct nvgpu_os_fence *fence_in)
{
if (fence_in->ops != &syncpt_ops) {
return -EINVAL;
}
fence_syncpt_out->fence = fence_in;
return 0;
}
u32 nvgpu_os_fence_syncpt_get_num_syncpoints(
struct nvgpu_os_fence_syncpt *fence)
{
WARN(1, "can't get here until nvhost support exists");
return -EINVAL;
}
int nvgpu_os_fence_syncpt_foreach_pt(
struct nvgpu_os_fence_syncpt *fence,
int (*iter)(struct nvhost_ctrl_sync_fence_info, void *),
void *data)
{
WARN(1, "can't get here until nvhost support exists");
return -EINVAL;
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NVGPU_OS_FENCE_PRIV_H
#define NVGPU_OS_FENCE_PRIV_H
#include <nvgpu/os_fence.h>
static inline void nvgpu_os_fence_clear(struct nvgpu_os_fence *fence_out)
{
fence_out->priv = NULL;
fence_out->g = NULL;
fence_out->ops = NULL;
}
static inline void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out,
struct gk20a *g, const struct nvgpu_os_fence_ops *fops,
void *fence)
{
fence_out->g = g;
fence_out->ops = fops;
fence_out->priv = fence;
}
#endif /* NVGPU_OS_FENCE_PRIV_H */

View File

@@ -23,29 +23,30 @@
#include <nvgpu/types.h>
#include <nvgpu/os_fence.h>
#include <nvgpu/os_fence_syncpts.h>
#include <nvgpu/linux/os_fence_android.h>
#include <nvgpu/nvhost.h>
#include <nvgpu/atomic.h>
#include <nvgpu/gk20a.h>
#include <nvgpu/channel.h>
#include <nvgpu/channel_sync.h>
#include "os_fence_priv.h"
#include "nvhost_priv.h"
static int nvgpu_os_fence_android_syncpt_install_fd(struct nvgpu_os_fence *s,
static int nvgpu_os_fence_syncpt_install_fd(struct nvgpu_os_fence *s,
int fd)
{
return nvhost_fence_install(s->priv, fd);
}
static void nvgpu_os_fence_android_syncpt_drop_ref(struct nvgpu_os_fence *s)
static void nvgpu_os_fence_syncpt_drop_ref(struct nvgpu_os_fence *s)
{
nvhost_fence_put(s->priv);
nvgpu_os_fence_clear(s);
}
static const struct nvgpu_os_fence_ops syncpt_ops = {
.drop_ref = nvgpu_os_fence_android_syncpt_drop_ref,
.install_fence = nvgpu_os_fence_android_syncpt_install_fd,
.drop_ref = nvgpu_os_fence_syncpt_drop_ref,
.install_fence = nvgpu_os_fence_syncpt_install_fd,
};
int nvgpu_os_fence_syncpt_create(struct nvgpu_os_fence *fence_out,