gpu: nvgpu: add user fence type

Decouple the fence information needed for providing submit postfences to
userspace by adding a separate type for that and using it to pass fence
data to ioctls.

The data in struct nvgpu_fence_type is used in various places:

- job tracking needs to know when a post fence is expired
- job submitters within the driver (vidmem clears) need to be able to
  wait for these fences
- userspace needs the fence as an id, value pair or as a file descriptor
  created from an os fence

To keep object lifetimes strict, start decoupling the os fence data out
of struct nvgpu_fence_type: delete nvgpu_fence_install_fd() and add
nvgpu_fence_extract_user() to return a struct nvgpu_user_fence that
contains only the necessary information. Storing the os fence in job
tracking metadata is legacy code and not useful. Passing the os fence
from where it's created through the whole submit path inside this
combined fence type has been convenient, though.

The internally stored cde job fence in dmabuf compression metadata is
still nvgpu_fence_type to keep this patch simple.

Jira NVGPU-5248

Change-Id: I75b7da676fb6aa083828f888c55571bbf7645ef3
Signed-off-by: Konsta Hölttä <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2359064
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Konsta Hölttä
2020-06-10 21:01:20 +03:00
committed by Alex Waterman
parent 8c224adb91
commit ca1f93bdd7
10 changed files with 118 additions and 43 deletions

View File

@@ -48,6 +48,7 @@
#include <nvgpu/preempt.h>
#include <nvgpu/swprofile.h>
#include <nvgpu/nvgpu_init.h>
#include <nvgpu/user_fence.h>
#include <nvgpu/fifo/swprofile.h>
@@ -793,13 +794,13 @@ static int gk20a_ioctl_channel_submit_gpfifo(
struct nvgpu_submit_gpfifo_args *args)
{
struct nvgpu_channel_fence fence;
struct nvgpu_fence_type *fence_out;
struct nvgpu_user_fence fence_out = nvgpu_user_fence_init();
u32 submit_flags = 0;
int fd = -1;
struct gk20a *g = ch->g;
struct nvgpu_fifo *f = &g->fifo;
struct nvgpu_swprofiler *kickoff_profiler = &f->kickoff_profiler;
struct nvgpu_gpfifo_userdata userdata;
struct nvgpu_gpfifo_userdata userdata = { NULL, NULL };
bool flag_fence_wait = (args->flags &
NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_WAIT) != 0U;
bool flag_fence_get = (args->flags &
@@ -860,17 +861,18 @@ static int gk20a_ioctl_channel_submit_gpfifo(
/* Convert fence_out to something we can pass back to user space. */
if (flag_fence_get) {
if (flag_sync_fence) {
ret = nvgpu_fence_install_fd(fence_out, fd);
ret = fence_out.os_fence.ops->install_fence(
&fence_out.os_fence, fd);
if (ret)
put_unused_fd(fd);
else
args->fence.id = fd;
} else {
args->fence.id = fence_out->syncpt_id;
args->fence.value = fence_out->syncpt_value;
args->fence.id = fence_out.syncpt_id;
args->fence.value = fence_out.syncpt_value;
}
nvgpu_user_fence_release(&fence_out);
}
nvgpu_fence_put(fence_out);
nvgpu_swprofile_snapshot(kickoff_profiler, PROF_KICKOFF_IOCTL_EXIT);