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

@@ -67,15 +67,15 @@ struct nvgpu_fence_ops {
#ifdef CONFIG_NVGPU_SW_SEMAPHORE
/* Fences can be created from semaphores or syncpoint (id, value) pairs */
int nvgpu_fence_from_semaphore(
struct nvgpu_fence_type *fence_out,
void nvgpu_fence_from_semaphore(
struct nvgpu_fence_type *f,
struct nvgpu_semaphore *semaphore,
struct nvgpu_cond *semaphore_wq,
struct nvgpu_os_fence os_fence);
#endif
int nvgpu_fence_from_syncpt(
struct nvgpu_fence_type *fence_out,
void nvgpu_fence_from_syncpt(
struct nvgpu_fence_type *f,
struct nvgpu_nvhost_dev *nvhost_dev,
u32 id, u32 value,
struct nvgpu_os_fence os_fence);