gpu: nvgpu: clarify fence api assumptions

Adjust documentation and validity checks in the fence functions for
simplicity.

Now that the cde code is using user fences cleanly, the
do-nothing-on-null action can cause unintended behaviour in new code
using nvgpu_fence_get and nvgpu_fence_put. It does not make sense to
call these with a null fence, so delete the checks.

Extend the documentation in nvgpu_fence_extract_user() for the os fence
lifetime to give a reason for the dup call.

Make nvgpu_fence_from_semaphore() and nvgpu_fence_from_syncpt() return
void. These fill a previously allocated object; the only failure would
have been a null object, but that never happens and is not acceptable
behaviour for callers so delete these null checks and fix types.

Jira NVGPU-5248

Change-Id: I9f82365d50ab5600374c8f7dd513691eac14a2f1
Signed-off-by: Konsta Hölttä <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2359624
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>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Konsta Hölttä
2020-06-17 16:13:17 +03:00
committed by Alex Waterman
parent 39d1af0f65
commit 223d8522a1
4 changed files with 17 additions and 61 deletions

View File

@@ -216,15 +216,7 @@ static int channel_sync_syncpt_incr_common(struct nvgpu_channel_sync *s,
}
}
err = nvgpu_fence_from_syncpt(fence, sp->nvhost,
sp->id, thresh, os_fence);
if (err != 0) {
if (nvgpu_os_fence_is_initialized(&os_fence) != 0) {
os_fence.ops->drop_ref(&os_fence);
}
goto clean_up_priv_cmd;
}
nvgpu_fence_from_syncpt(fence, sp->nvhost, sp->id, thresh, os_fence);
return 0;