From 793f7deb941072aa581de7ddd8dcfc93118f41a9 Mon Sep 17 00:00:00 2001 From: Ken Chang Date: Mon, 4 Dec 2017 10:08:54 +0800 Subject: [PATCH] gpu: nvgpu: error handling for gk20a_fence alloc In current design, the new increments are added to the threshold for fence allocation. So if it fails to get gk20a_fence, decrease the new increments before bailing out from __gk20a_channel_syncpt_incr() and propagating the error code. Bug 1867651 Change-Id: I8a21bf0afef1d9ebe660ebea59d877acad1b726a Signed-off-by: Ken Chang Reviewed-on: http://git-master/r/1300421 (cherry picked from commit a4a55f1851834042ab14e487f1ff0d497509ff24) Reviewed-on: https://git-master.nvidia.com/r/1609824 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta Reviewed-by: Deepak Nibade Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c index c2fb28a53..80433ae4c 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c @@ -235,6 +235,16 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s, thresh = nvhost_syncpt_incr_max_ext(sp->host1x_pdev, sp->id, 2); + err = gk20a_fence_from_syncpt(fence, sp->host1x_pdev, sp->id, thresh, + wfi_cmd, need_sync_fence); + if (err) { + thresh = nvhost_syncpt_decr_max_ext(sp->host1x_pdev, sp->id, 2); + gk20a_err(dev_from_gk20a(c->g), + "failed to get fence, fallback syncpt id %d to %d!", + sp->id, thresh); + goto clean_up_priv_cmd; + } + if (register_irq) { struct channel_gk20a *referenced = gk20a_channel_get(c); @@ -261,11 +271,6 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s, } } - err = gk20a_fence_from_syncpt(fence, sp->host1x_pdev, sp->id, thresh, - wfi_cmd, need_sync_fence); - if (err) - goto clean_up_priv_cmd; - return 0; clean_up_priv_cmd: