media: hantro: Trace hevc hw cycles performance register
Subsystems (4)
PATCH 1/1 media: hantro: Trace hevc hw cycles performance register
After each hevc decoded frame trace the hardware performance. It provides the number of hw cycles spend per decoded macroblock.
--- Documentation/admin-guide/media/hantro.rst | 14 +++++++ .../admin-guide/media/v4l-drivers.rst | 1 + drivers/staging/media/hantro/hantro_drv.c | 3 ++ .../staging/media/hantro/hantro_g2_hevc_dec.c | 16 ++++++++ drivers/staging/media/hantro/hantro_g2_regs.h | 1 + drivers/staging/media/hantro/hantro_hw.h | 1 + drivers/staging/media/hantro/hantro_trace.h | 41 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 1 + 8 files changed, 78 insertions(+) create mode 100644 Documentation/admin-guide/media/hantro.rst create mode 100644 drivers/staging/media/hantro/hantro_trace.h
Documentation/admin-guide/media/hantro.rst new file +14 -0
@@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================= +The hantro driver +================= + +Trace +~~~~~ + +You can trace the hardware decoding performances by using event tracing:: + + # echo hantro_hevc_perf >> /sys/kernel/debug/tracing/set_event + +That will keep a log of the number of hardware cycles spend per decoded macroblock
Documentation/admin-guide/media/v4l-drivers.rst +1 -0
@@ -15,6 +15,7 @@ Video4Linux (V4L) driver-specific documentation cx88 davinci-vpbe fimc + hantro imx imx7 ipu3
drivers/staging/media/hantro/hantro_drv.c +3 -0
@@ -28,6 +28,9 @@#include "hantro.h" #include "hantro_hw.h" +#define CREATE_TRACE_POINTS +#include "hantro_trace.h" +#define DRIVER_NAME "hantro-vpu"int hantro_debug;
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +16 -0
@@ -7,6 +7,7 @@#include "hantro_hw.h" #include "hantro_g2_regs.h" +#include "hantro_trace.h" #define HEVC_DEC_MODE 0xC
@@ -22,6 +23,21 @@ static inline void hantro_write_addr(struct hantro_dev *vpu,vdpu_write (vpu, addr &0xffffffff , offset); } +void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx) +{ +const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls; +const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps; +struct hantro_dev *vpu = ctx->dev; +u32 hw_cycles =0 ; +u32 mbs = (sps->pic_width_in_luma_samples * + sps->pic_height_in_luma_samples) >>8 ; + +if (mbs) + hw_cycles =vdpu_read (vpu,G2_HW_PERFORMANCE ) / mbs; + +trace_hantro_hevc_perf (ctx, hw_cycles); +} +static void prepare_tile_info_buffer (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;
drivers/staging/media/hantro/hantro_g2_regs.h +1 -0
@@ -177,6 +177,7 @@#define G2_REG_CONFIG_DEC_CLK_GATE_E BIT(16)#define G2_REG_CONFIG_DEC_CLK_GATE_IDLE_E BIT(17) +#define G2_HW_PERFORMANCE (G2_SWREG(63))#define G2_ADDR_DST (G2_SWREG(65))#define G2_REG_ADDR_REF (i) (G2_SWREG(67) + ((i) * 0x8))#define G2_ADDR_DST_CHR (G2_SWREG(99))
drivers/staging/media/hantro/hantro_hw.h +1 -0
@@ -250,6 +250,7 @@ void hantro_h264_dec_exit(struct hantro_ctx *ctx);int hantro_hevc_dec_init (struct hantro_ctx *ctx);void hantro_hevc_dec_exit (struct hantro_ctx *ctx);int hantro_g2_hevc_dec_run (struct hantro_ctx *ctx); +void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx);int hantro_hevc_dec_prepare_run (struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,int poc);void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx);
drivers/staging/media/hantro/hantro_trace.h new file +41 -0
41 lines not on this page · raw message
drivers/staging/media/hantro/imx8m_vpu_hw.c +1 -0
@@ -239,6 +239,7 @@ static const struct hantro_codec_ops imx8mq_vpu_g2_codec_ops[] = { .reset = imx8m_vpu_g2_reset, .init = hantro_hevc_dec_init, .exit = hantro_hevc_dec_exit, + .done = hantro_g2_hevc_dec_done, }, };
Signature · 1 line
2.25.1
Hi Benjamin,
I'm confused: this is also part of '[PATCH v4 0/9] Additional features for Hantro HEVC', so do you want to merge this independently from that series? Are there differences between v4 1/9 and this patch, or are they identical?
In any case, I'd like to have a Reviewed-by or Acked-by from Ezequiel before merging this.
Regards,
Hans
Quoted 181 lines · Benjamin Gaignard
After each hevc decoded frame trace the hardware performance. It provides the number of hw cycles spend per decoded macroblock.
Signed-off-by Benjamin Gaignard <[email protected]>--- Documentation/admin-guide/media/hantro.rst | 14 +++++++ .../admin-guide/media/v4l-drivers.rst | 1 + drivers/staging/media/hantro/hantro_drv.c | 3 ++ .../staging/media/hantro/hantro_g2_hevc_dec.c | 16 ++++++++ drivers/staging/media/hantro/hantro_g2_regs.h | 1 + drivers/staging/media/hantro/hantro_hw.h | 1 + drivers/staging/media/hantro/hantro_trace.h | 41 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 1 + 8 files changed, 78 insertions(+) create mode 100644 Documentation/admin-guide/media/hantro.rst create mode 100644 drivers/staging/media/hantro/hantro_trace.hDocumentation/admin-guide/media/hantro.rst new file +14
-0@@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================= +The hantro driver +================= + +Trace +~~~~~ + +You can trace the hardware decoding performances by using event tracing:: + + # echo hantro_hevc_perf >> /sys/kernel/debug/tracing/set_event + +That will keep a log of the number of hardware cycles spend per decoded macroblockDocumentation/admin-guide/media/v4l-drivers.rst +1
-0@@ -15,6 +15,7 @@ Video4Linux (V4L) driver-specific documentation cx88 davinci-vpbe fimc + hantro imx imx7 ipu3drivers/staging/media/hantro/hantro_drv.c +3
-0@@ -28,6 +28,9 @@#include "hantro.h" #include "hantro_hw.h" +#define CREATE_TRACE_POINTS +#include "hantro_trace.h" +#define DRIVER_NAME "hantro-vpu"int hantro_debug;drivers/staging/media/hantro/hantro_g2_hevc_dec.c +16
-0@@ -7,6 +7,7 @@#include "hantro_hw.h" #include "hantro_g2_regs.h" +#include "hantro_trace.h" #define HEVC_DEC_MODE 0xC@@ -22,6 +23,21 @@ static inline void hantro_write_addr(struct hantro_dev *vpu,vdpu_write (vpu, addr &0xffffffff , offset); } +void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx) +{ +const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls; +const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps; +struct hantro_dev *vpu = ctx->dev; +u32 hw_cycles =0 ; +u32 mbs = (sps->pic_width_in_luma_samples * + sps->pic_height_in_luma_samples) >>8 ; + +if (mbs) + hw_cycles =vdpu_read (vpu,G2_HW_PERFORMANCE ) / mbs; + +trace_hantro_hevc_perf (ctx, hw_cycles); +} +static void prepare_tile_info_buffer (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;drivers/staging/media/hantro/hantro_g2_regs.h +1
-0@@ -177,6 +177,7 @@#define G2_REG_CONFIG_DEC_CLK_GATE_E BIT(16)#define G2_REG_CONFIG_DEC_CLK_GATE_IDLE_E BIT(17) +#define G2_HW_PERFORMANCE (G2_SWREG(63))#define G2_ADDR_DST (G2_SWREG(65))#define G2_REG_ADDR_REF (i) (G2_SWREG(67) + ((i) * 0x8))#define G2_ADDR_DST_CHR (G2_SWREG(99))drivers/staging/media/hantro/hantro_hw.h +1
-0@@ -250,6 +250,7 @@ void hantro_h264_dec_exit(struct hantro_ctx *ctx);int hantro_hevc_dec_init (struct hantro_ctx *ctx);void hantro_hevc_dec_exit (struct hantro_ctx *ctx);int hantro_g2_hevc_dec_run (struct hantro_ctx *ctx); +void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx);int hantro_hevc_dec_prepare_run (struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,int poc);void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx);drivers/staging/media/hantro/hantro_trace.h new file +41
-0@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#if !defined(__HANTRO_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ ) +#define __HANTRO_TRACE_H__ + +#include <linux/tracepoint.h> +#include <media/videobuf2-v4l2.h> + +#include "hantro.h" + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM hantro +#define TRACE_INCLUDE_FILE hantro_trace + +TRACE_EVENT (hantro_hevc_perf, + TP_PROTO(struct hantro_ctx *ctx, u32 hw_cycles), + +TP_ARGS (ctx, hw_cycles), + +TP_STRUCT__entry ( + __field(int, minor) + __field(struct v4l2_fh *, fh) +__field (u32, hw_cycles) + ), + +TP_fast_assign ( + __entry->minor = ctx->fh.vdev->minor; + __entry->fh = &ctx->fh; + __entry->hw_cycles = hw_cycles; + ), + +TP_printk ("minor = %d, fh = %p, %8d cycles / mb" , + __entry->minor, __entry->fh, __entry->hw_cycles) +); + +#endif /* __HANTRO_TRACE_H__ */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH ../../drivers/staging/media/hantro + +/* This part must be outside protection */ +#include <trace/define_trace.h> drivers/staging/media/hantro/imx8m_vpu_hw.c +1
-0@@ -239,6 +239,7 @@ static const struct hantro_codec_ops imx8mq_vpu_g2_codec_ops[] = { .reset = imx8m_vpu_g2_reset, .init = hantro_hevc_dec_init, .exit = hantro_hevc_dec_exit, + .done = hantro_g2_hevc_dec_done, }, };
Le 01/09/2021 à 13:27, Hans Verkuil a écrit :
Quoted 5 lines
Hi Benjamin,
I'm confused: this is also part of '[PATCH v4 0/9] Additional features for Hantro HEVC', so do you want to merge this independently from that series? Are there differences between v4 1/9 and this patch, or are they identical?
Hi Hans,
I thought that the series was to big so I decide to split it on smallest independent pieces.
Quoted 2 lines
In any case, I'd like to have a Reviewed-by or Acked-by from Ezequiel before merging this.
Get Ezequiel feedback is definitively need :-)
Regards,
Benjamin
Quoted 187 lines
Regards,
Hans
Quoted 181 lines · Benjamin Gaignard
After each hevc decoded frame trace the hardware performance. It provides the number of hw cycles spend per decoded macroblock.
Signed-off-by Benjamin Gaignard <[email protected]>--- Documentation/admin-guide/media/hantro.rst | 14 +++++++ .../admin-guide/media/v4l-drivers.rst | 1 + drivers/staging/media/hantro/hantro_drv.c | 3 ++ .../staging/media/hantro/hantro_g2_hevc_dec.c | 16 ++++++++ drivers/staging/media/hantro/hantro_g2_regs.h | 1 + drivers/staging/media/hantro/hantro_hw.h | 1 + drivers/staging/media/hantro/hantro_trace.h | 41 +++++++++++++++++++ drivers/staging/media/hantro/imx8m_vpu_hw.c | 1 + 8 files changed, 78 insertions(+)create mode 100644
Documentation/admin-guide/media/hantro.rstcreate mode 100644drivers/staging/media/hantro/hantro_trace.hDocumentation/admin-guide/media/hantro.rst new file +14
-0@@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================= +The hantro driver +================= + +Trace +~~~~~ + +You can trace the hardware decoding performances by using event tracing:: + + # echo hantro_hevc_perf >> /sys/kernel/debug/tracing/set_event + +That will keep a log of the number of hardware cycles spend per decoded macroblockDocumentation/admin-guide/media/v4l-drivers.rst +1
-0@@ -15,6 +15,7 @@ Video4Linux (V4L) driver-specific documentation cx88 davinci-vpbe fimc + hantro imx imx7 ipu3drivers/staging/media/hantro/hantro_drv.c +3
-0@@ -28,6 +28,9 @@#include "hantro.h" #include "hantro_hw.h" +#define CREATE_TRACE_POINTS +#include "hantro_trace.h" +#define DRIVER_NAME "hantro-vpu"int hantro_debug;drivers/staging/media/hantro/hantro_g2_hevc_dec.c +16
-0@@ -7,6 +7,7 @@#include "hantro_hw.h" #include "hantro_g2_regs.h" +#include "hantro_trace.h" #define HEVC_DEC_MODE 0xC@@ -22,6 +23,21 @@ static inline void hantro_write_addr(struct hantro_dev *vpu,vdpu_write (vpu, addr &0xffffffff , offset); } +void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx) +{ +const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls; +const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps; +struct hantro_dev *vpu = ctx->dev; +u32 hw_cycles =0 ; +u32 mbs = (sps->pic_width_in_luma_samples * + sps->pic_height_in_luma_samples) >>8 ; + +if (mbs) + hw_cycles =vdpu_read (vpu,G2_HW_PERFORMANCE ) / mbs; + +trace_hantro_hevc_perf (ctx, hw_cycles); +} +static void prepare_tile_info_buffer (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;drivers/staging/media/hantro/hantro_g2_regs.h +1
-0@@ -177,6 +177,7 @@#define G2_REG_CONFIG_DEC_CLK_GATE_E BIT(16)#define G2_REG_CONFIG_DEC_CLK_GATE_IDLE_E BIT(17) +#define G2_HW_PERFORMANCE (G2_SWREG(63))#define G2_ADDR_DST (G2_SWREG(65))#define G2_REG_ADDR_REF (i) (G2_SWREG(67) + ((i) * 0x8))#define G2_ADDR_DST_CHR (G2_SWREG(99))drivers/staging/media/hantro/hantro_hw.h +1
-0@@ -250,6 +250,7 @@ void hantro_h264_dec_exit(struct hantro_ctx *ctx);int hantro_hevc_dec_init (struct hantro_ctx *ctx);void hantro_hevc_dec_exit (struct hantro_ctx *ctx);int hantro_g2_hevc_dec_run (struct hantro_ctx *ctx); +void hantro_g2_hevc_dec_done (struct hantro_ctx *ctx);int hantro_hevc_dec_prepare_run (struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,int poc);void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx);drivers/staging/media/hantro/hantro_trace.h new file +41
-0@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#if !defined(__HANTRO_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ ) +#define __HANTRO_TRACE_H__ + +#include <linux/tracepoint.h> +#include <media/videobuf2-v4l2.h> + +#include "hantro.h" + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM hantro +#define TRACE_INCLUDE_FILE hantro_trace + +TRACE_EVENT (hantro_hevc_perf, + TP_PROTO(struct hantro_ctx *ctx, u32 hw_cycles), + +TP_ARGS (ctx, hw_cycles), + +TP_STRUCT__entry ( + __field(int, minor) + __field(struct v4l2_fh *, fh) +__field (u32, hw_cycles) + ), + +TP_fast_assign ( + __entry->minor = ctx->fh.vdev->minor; + __entry->fh = &ctx->fh; + __entry->hw_cycles = hw_cycles; + ), + +TP_printk ("minor = %d, fh = %p, %8d cycles / mb" , + __entry->minor, __entry->fh, __entry->hw_cycles) +); + +#endif /* __HANTRO_TRACE_H__ */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH ../../drivers/staging/media/hantro + +/* This part must be outside protection */ +#include <trace/define_trace.h> drivers/staging/media/hantro/imx8m_vpu_hw.c +1
-0@@ -239,6 +239,7 @@ static const struct hantro_codec_ops imx8mq_vpu_g2_codec_ops[] = { .reset = imx8m_vpu_g2_reset, .init = hantro_hevc_dec_init, .exit = hantro_hevc_dec_exit, + .done = hantro_g2_hevc_dec_done, }, };