From 1bf753648bcb56595489800959b7ae10429cb69d Mon Sep 17 00:00:00 2001 From: Li Huang Date: Mon, 23 May 2022 14:46:19 +0800 Subject: [PATCH] video: rockchip: rve: update to 1.0.4 The internal context is automatically canceled after calling commit by default. Signed-off-by: Li Huang Change-Id: I40f14fa0bddb95475a5cc76911a30df2ea1e122c --- drivers/video/rockchip/rve/include/rve.h | 3 ++- drivers/video/rockchip/rve/include/rve_drv.h | 5 +++- drivers/video/rockchip/rve/rve_drv.c | 7 +---- drivers/video/rockchip/rve/rve_job.c | 27 +++++++++++++------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/video/rockchip/rve/include/rve.h b/drivers/video/rockchip/rve/include/rve.h index 0667801264e4..922e9e3bfb47 100644 --- a/drivers/video/rockchip/rve/include/rve.h +++ b/drivers/video/rockchip/rve/include/rve.h @@ -64,8 +64,9 @@ struct rve_user_ctx_t { uint32_t id; uint8_t priority; uint32_t sync_mode; + uint32_t disable_auto_cancel; - uint32_t reserve[32]; + uint32_t reserve[31]; }; #endif /*_RVE_DRIVER_H_*/ diff --git a/drivers/video/rockchip/rve/include/rve_drv.h b/drivers/video/rockchip/rve/include/rve_drv.h index 0d070bc3e928..4fff93ff19eb 100644 --- a/drivers/video/rockchip/rve/include/rve_drv.h +++ b/drivers/video/rockchip/rve/include/rve_drv.h @@ -72,7 +72,7 @@ #define DRIVER_MAJOR_VERSION 1 #define DRIVER_MINOR_VERSION 0 -#define DRIVER_REVISION_VERSION 2 +#define DRIVER_REVISION_VERSION 4 #define DRIVER_VERSION (STR(DRIVER_MAJOR_VERSION) "." STR(DRIVER_MINOR_VERSION) \ "." STR(DRIVER_REVISION_VERSION)) @@ -239,6 +239,9 @@ struct rve_internal_ctx_t { uint32_t running_job_count; uint32_t finished_job_count; bool is_running; + + uint32_t disable_auto_cancel; + int priority; int32_t out_fence_fd; int32_t in_fence_fd; diff --git a/drivers/video/rockchip/rve/rve_drv.c b/drivers/video/rockchip/rve/rve_drv.c index 6167d4530839..2c6742609af8 100644 --- a/drivers/video/rockchip/rve/rve_drv.c +++ b/drivers/video/rockchip/rve/rve_drv.c @@ -251,14 +251,11 @@ static struct rve_session *rve_session_init(void) static int rve_session_deinit(struct rve_session *session) { - pid_t pid; int ctx_id; struct rve_pending_ctx_manager *ctx_manager; struct rve_internal_ctx_t *ctx; unsigned long flags; - pid = current->pid; - ctx_manager = rve_drvdata->pend_ctx_manager; spin_lock_irqsave(&ctx_manager->lock, flags); @@ -267,10 +264,8 @@ static int rve_session_deinit(struct rve_session *session) spin_unlock_irqrestore(&ctx_manager->lock, flags); - if (session == ctx->session) { - pr_err("[pid:%d] destroy ctx[%d] when the user exits", pid, ctx->id); + if (session == ctx->session) kref_put(&ctx->refcount, rve_internal_ctx_kref_release); - } spin_lock_irqsave(&ctx_manager->lock, flags); } diff --git a/drivers/video/rockchip/rve/rve_job.c b/drivers/video/rockchip/rve/rve_job.c index 6ed2c9cbaefe..35a29a39c180 100644 --- a/drivers/video/rockchip/rve/rve_job.c +++ b/drivers/video/rockchip/rve/rve_job.c @@ -452,7 +452,8 @@ static inline int rve_job_wait(struct rve_job *job) scheduler = rve_job_get_scheduler(job); left_time = wait_event_timeout(scheduler->job_done_wq, - job->flags & RVE_JOB_DONE, RVE_SYNC_TIMEOUT_DELAY); + job->ctx->finished_job_count == job->ctx->cmd_num, + RVE_SYNC_TIMEOUT_DELAY * job->ctx->cmd_num); switch (left_time) { case 0: @@ -588,6 +589,7 @@ int rve_job_commit_by_user_ctx(struct rve_user_ctx_t *user_ctx) ctx->finished_job_count = 0; ctx->running_job_count = 0; ctx->is_running = true; + ctx->disable_auto_cancel = user_ctx->disable_auto_cancel; ctx->sync_mode = user_ctx->sync_mode; if (ctx->sync_mode == 0) @@ -614,6 +616,9 @@ int rve_job_commit_by_user_ctx(struct rve_user_ctx_t *user_ctx) return -EFAULT; } + if (!ctx->disable_auto_cancel && ctx->sync_mode == RVE_SYNC) + kref_put(&ctx->refcount, rve_internal_ctx_kref_release); + return ret; } @@ -655,20 +660,21 @@ int rve_job_commit(struct rve_internal_ctx_t *ctx) #ifdef CONFIG_SYNC_FILE job->flags |= RVE_ASYNC; - if (ctx->out_fence) { - job->out_fence = ctx->out_fence; - } else { + if (!ctx->out_fence) { ret = rve_out_fence_alloc(job); if (ret) { rve_job_free(job); return ret; } - - ctx->out_fence = job->out_fence; } + ctx->out_fence = job->out_fence; + ctx->out_fence_fd = rve_out_fence_get_fd(job); + if (ctx->out_fence_fd < 0) + pr_err("out fence get fd failed"); + if (DEBUGGER_EN(MSG)) pr_info("in_fence_fd = %d", ctx->in_fence_fd); @@ -847,9 +853,6 @@ int rve_internal_ctx_signal(struct rve_job *job) job->flags |= RVE_JOB_DONE; - if (job->flags & RVE_ASYNC) - rve_job_cleanup(job); - wake_up(&scheduler->job_done_wq); spin_lock_irqsave(&ctx->lock, flags); @@ -858,6 +861,12 @@ int rve_internal_ctx_signal(struct rve_job *job) ctx->out_fence = NULL; spin_unlock_irqrestore(&ctx->lock, flags); + + if (job->flags & RVE_ASYNC) { + rve_job_cleanup(job); + if (!ctx->disable_auto_cancel) + kref_put(&ctx->refcount, rve_internal_ctx_kref_release); + } } return 0;