From d20a501dcbf2e29d5d319670485f273afa3aefad Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Thu, 22 Mar 2018 15:47:43 +0200 Subject: gpu: nvgpu: simplify job semaphore release in abort Instead of looping all jobs and releasing their semaphores separately, do just one semaphore release. All the jobs are using the same sema index, and the final, maximum value of it is known. Move also this resetting into ch->sync->set_min_eq_max() to be consistent with syncpoints. Change-Id: I03601aae67db0a65750c8df6b43387c042d383bd Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/1680362 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/semaphore.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/semaphore.h b/drivers/gpu/nvgpu/include/nvgpu/semaphore.h index 373c5745..9ab6cc67 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/semaphore.h +++ b/drivers/gpu/nvgpu/include/nvgpu/semaphore.h @@ -276,28 +276,36 @@ static inline bool nvgpu_semaphore_is_acquired(struct nvgpu_semaphore *s) } /* - * Fast-forward the hw sema to the threshold represented by sema_thresh. + * Fast-forward the hw sema to its tracked max value. + * + * Return true if the sema wasn't at the max value and needed updating, false + * otherwise. */ -static inline void nvgpu_semaphore_reset(struct nvgpu_semaphore *sema_thresh, - struct nvgpu_semaphore_int *hw_sema) +static inline bool nvgpu_semaphore_reset(struct nvgpu_semaphore_int *hw_sema) { - u32 current_val; - u32 threshold = nvgpu_semaphore_get_value(sema_thresh); - - current_val = nvgpu_semaphore_read(sema_thresh); + u32 threshold = (u32)nvgpu_atomic_read(&hw_sema->next_value); + u32 current_val = __nvgpu_semaphore_read(hw_sema); /* * If the semaphore has already reached the value we would write then - * this is really just a NO-OP. + * this is really just a NO-OP. However, the sema value shouldn't be + * more than what we expect to be the max. */ - if (__nvgpu_semaphore_value_released(threshold, current_val)) - return; + + if (WARN_ON(__nvgpu_semaphore_value_released(threshold + 1, + current_val))) + return false; + + if (current_val == threshold) + return false; nvgpu_mem_wr(hw_sema->ch->g, &hw_sema->location.pool->rw_mem, hw_sema->location.offset, threshold); gpu_sema_verbose_dbg(hw_sema->ch->g, "(c=%d) RESET %u -> %u", hw_sema->ch->chid, current_val, threshold); + + return true; } /* -- cgit v1.2.2