From b1585130481bac5351578d39aae8cefb78fc3ea7 Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Tue, 8 Mar 2022 14:38:20 +0800 Subject: [PATCH] video: rockchip: mpp: Add partition timing function On encoder slice output mode the timing of each slice can be recorded. Signed-off-by: Herman Chen Change-Id: Iceac5b8488dbfa85068e1460709f278cc2d3ebe4 --- drivers/video/rockchip/mpp/mpp_common.c | 31 ++++++++++++++++++------- drivers/video/rockchip/mpp/mpp_common.h | 4 +++- drivers/video/rockchip/mpp/mpp_debug.h | 3 +++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/video/rockchip/mpp/mpp_common.c b/drivers/video/rockchip/mpp/mpp_common.c index fc5816a84573..1bfe0b3f9614 100644 --- a/drivers/video/rockchip/mpp/mpp_common.c +++ b/drivers/video/rockchip/mpp/mpp_common.c @@ -2213,22 +2213,37 @@ int mpp_set_grf(struct mpp_grf_info *grf_info) int mpp_time_record(struct mpp_task *task) { - if (mpp_debug_unlikely(DEBUG_TIMING) && task) - ktime_get_real_ts64(&task->start); + if (mpp_debug_unlikely(DEBUG_TIMING) && task) { + task->start = ktime_get(); + task->part = task->start; + } + + return 0; +} + +int mpp_time_part_diff(struct mpp_task *task) +{ + ktime_t end; + struct mpp_dev *mpp = mpp_get_task_used_device(task, task->session); + + end = ktime_get(); + mpp_debug(DEBUG_PART_TIMING, "%s: session %d:%d part time: %lld us\n", + dev_name(mpp->dev), task->session->pid, task->session->index, + ktime_us_delta(end, task->part)); + task->part = end; return 0; } int mpp_time_diff(struct mpp_task *task) { - struct timespec64 end; + ktime_t end; struct mpp_dev *mpp = mpp_get_task_used_device(task, task->session); - ktime_get_real_ts64(&end); - mpp_debug(DEBUG_TIMING, "%s: pid: %d, session: %p, time: %lld us\n", - dev_name(mpp->dev), task->session->pid, task->session, - (end.tv_sec - task->start.tv_sec) * 1000000 + - (end.tv_nsec - task->start.tv_nsec)/1000); + end = ktime_get(); + mpp_debug(DEBUG_TIMING, "%s: session %d:%d task time: %lld us\n", + dev_name(mpp->dev), task->session->pid, task->session->index, + ktime_us_delta(end, task->start)); return 0; } diff --git a/drivers/video/rockchip/mpp/mpp_common.h b/drivers/video/rockchip/mpp/mpp_common.h index 09ffe954ba4a..0440e55bacb2 100644 --- a/drivers/video/rockchip/mpp/mpp_common.h +++ b/drivers/video/rockchip/mpp/mpp_common.h @@ -442,7 +442,8 @@ struct mpp_task { struct kref ref; /* record context running start time */ - struct timespec64 start; + ktime_t start; + ktime_t part; /* hardware info for current task */ struct mpp_hw_info *hw_info; u32 task_index; @@ -655,6 +656,7 @@ int mpp_set_grf(struct mpp_grf_info *grf_info); int mpp_time_record(struct mpp_task *task); int mpp_time_diff(struct mpp_task *task); +int mpp_time_part_diff(struct mpp_task *task); int mpp_write_req(struct mpp_dev *mpp, u32 *regs, u32 start_idx, u32 end_idx, u32 en_idx); diff --git a/drivers/video/rockchip/mpp/mpp_debug.h b/drivers/video/rockchip/mpp/mpp_debug.h index 5fe843a479ee..439f7ab4c4d5 100644 --- a/drivers/video/rockchip/mpp/mpp_debug.h +++ b/drivers/video/rockchip/mpp/mpp_debug.h @@ -56,6 +56,9 @@ #define PRINT_FUNCTION 0x80000000 #define PRINT_LINE 0x40000000 +/* reuse old debug bit flag */ +#define DEBUG_PART_TIMING 0x00000080 + extern unsigned int mpp_dev_debug; #define mpp_debug_unlikely(type) \