From aa1322f9757731f275e3ed2804147e4d6ed34c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konsta=20H=C3=B6ltt=C3=A4?= Date: Mon, 6 Apr 2020 13:23:41 +0300 Subject: [PATCH] gpu: nvgpu: move syncpt priv cmd allocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit channel_sync_syncpt_gen_wait_cmd() is rather simple now and is called from two places where one has the buf preallocated and the other doesn't. Remove the preallocated flag from the function, moving the allocation to the single place where it is needed. Jira NVGPU-4548 Change-Id: I48083f4f6f1093d64b67c63582291392a3481932 Signed-off-by: Konsta Hölttä Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2325101 (cherry picked from commit afb566721e2b4c15349ff79d51f5eddc49b66014) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2331338 Reviewed-by: automaticguardword Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Alex Waterman Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- .../nvgpu/common/sync/channel_sync_syncpt.c | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c b/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c index e91e94187..463b8218f 100644 --- a/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c +++ b/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c @@ -56,27 +56,14 @@ nvgpu_channel_sync_syncpt_from_base(struct nvgpu_channel_sync *base) offsetof(struct nvgpu_channel_sync_syncpt, base)); } -static int channel_sync_syncpt_gen_wait_cmd(struct nvgpu_channel *c, +static void channel_sync_syncpt_gen_wait_cmd(struct nvgpu_channel *c, u32 id, u32 thresh, struct priv_cmd_entry *wait_cmd, - u32 wait_cmd_size, bool preallocated) + u32 wait_cmd_size) { - int err = 0; - - if (!preallocated) { - err = nvgpu_channel_alloc_priv_cmdbuf(c, - c->g->ops.sync.syncpt.get_wait_cmd_size(), - wait_cmd); - if (err != 0) { - nvgpu_err(c->g, "not enough priv cmd buffer space"); - return err; - } - } nvgpu_log(c->g, gpu_dbg_info, "sp->id %d gpu va %llx", id, c->vm->syncpt_ro_map_gpu_va); c->g->ops.sync.syncpt.add_wait_cmd(c->g, wait_cmd, id, thresh, c->vm->syncpt_ro_map_gpu_va); - - return 0; } static int channel_sync_syncpt_wait_raw(struct nvgpu_channel_sync_syncpt *s, @@ -90,10 +77,18 @@ static int channel_sync_syncpt_wait_raw(struct nvgpu_channel_sync_syncpt *s, return -EINVAL; } - err = channel_sync_syncpt_gen_wait_cmd(c, id, thresh, - wait_cmd, wait_cmd_size, false); + err = nvgpu_channel_alloc_priv_cmdbuf(c, + c->g->ops.sync.syncpt.get_wait_cmd_size(), + wait_cmd); + if (err != 0) { + nvgpu_err(c->g, "not enough priv cmd buffer space"); + return err; + } - return err; + channel_sync_syncpt_gen_wait_cmd(c, id, thresh, + wait_cmd, wait_cmd_size); + + return 0; } static int channel_sync_syncpt_wait_fd(struct nvgpu_channel_sync *s, int fd, @@ -152,8 +147,8 @@ static int channel_sync_syncpt_wait_fd(struct nvgpu_channel_sync *s, int fd, for (i = 0; i < num_fences; i++) { nvgpu_os_fence_syncpt_extract_nth_syncpt( &os_fence_syncpt, i, &syncpt_id, &syncpt_thresh); - err = channel_sync_syncpt_gen_wait_cmd(c, syncpt_id, - syncpt_thresh, wait_cmd, wait_cmd_size, true); + channel_sync_syncpt_gen_wait_cmd(c, syncpt_id, + syncpt_thresh, wait_cmd, wait_cmd_size); } cleanup: