From eea79aaa60087174adf7e6876ac089cb4734ebaf Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Sun, 20 Apr 2014 15:40:52 +0530 Subject: gpu: nvgpu: gk20a: free syncpt when channel becomes idle All of the channel's submit jobs are added to the list channel->jobs In channel_update(), we iterate over this list and check if any job has completed. If any job is complete then we remove it from the list. If this list is empty then it means channel is idle and we can free its syncpt. Hence after iterating this list, check if it is empty or not. If it is empty AND if we are aggressive to free the syncpt (syncpt_aggressive_destroy flag is set) then free the syncpt at this point. Keep the syncpt free code inside submit_lock to avoid race conditions. Also, do not free the syncpt if we have already scheduled WFI on some other path. In that case, syncpt is still needed to check for channel idle. Once WFI completes, we free the syncpt anyway. Bug 1305024 Change-Id: I1654e1db3b76b7ad14644dbb900b03f195ca3b2c Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/398617 Reviewed-by: Shridhar Rasal Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/gpu/nvgpu/gk20a/channel_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index b7bd55ea..d52e3f7e 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -1419,6 +1419,19 @@ void gk20a_channel_update(struct channel_gk20a *c, int nr_completed) kfree(job); gk20a_idle(g->dev); } + + /* + * If job list is empty then channel is idle and we can free + * the syncpt here (given aggressive_destroy flag is set) + * Note: if WFI is already scheduled on some other path + * then syncpt is still required to check for idle + */ + if (list_empty(&c->jobs) && !c->last_submit_fence.wfi) { + if (c->sync && c->sync->syncpt_aggressive_destroy) { + c->sync->destroy(c->sync); + c->sync = NULL; + } + } mutex_unlock(&c->jobs_lock); mutex_unlock(&c->submit_lock); -- cgit v1.2.2