support mt8195 decoder
Subsystems (4)
Yunfei Dong
maintainerv7 cover support mt8195 decoder
Firstly, add mt8195 soc lat hardware and compatible, then add documents. For vp8 only support MM21 mode, H264/vp9 support MT21C, need to separate them. Lastly, enable H264 inner racing mode to reduce hardware latency.
Patch 1~4 add mt8195 soc lat hardware and compatible, then add documents. Patch 5 using different format for different codecs.
Patch 6 prevent kernel crash when scp reboot.
Patch 7 enable H264 inner racing mode to reduce hardware latency.
---
This patch depends on "add h264 decoder driver for mt8186"[1]
[1] https://patchwork.kernel.org/project/linux-mediatek/cover/[email protected]/
---
changed with v6:
- add detail error message in patch 6.
changed with v5:
- fix __iomem not reasonable, align share memory to dram.
changed with v4:
- fix sparse and smatch check fail for patch 7.
changed with v3:
- rebase driver to the latest media_stage.
changed with v2:
- add detail explanation for lat soc hardware for patch 1.
changed with v1:
- separate "Init VP9 stateless decode params" patch and remove it to another one.
- add reviewed-by in patch v3/v4/v6
---
Yunfei Dong (7):
dt-bindings: media: mediatek: vcodec: Adds decoder dt-bindings for lat
soc
media: mediatek: vcodec: Add to support lat soc hardware
dt-bindings: media: mediatek: vcodec: Adds decoder dt-bindings for
mt8195
media: mediatek: vcodec: Adds compatible for mt8195
media: mediatek: vcodec: Different codec using different capture
format
media: mediatek: vcodec: prevent kernel crash when scp ipi timeout
media: mediatek: vcodec: Add to support H264 inner racing mode
.../media/mediatek,vcodec-subdev-decoder.yaml | 52 +++++++++++++------ .../platform/mediatek/vcodec/mtk_vcodec_dec.c | 41 +++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dec_drv.c | 8 +++ .../mediatek/vcodec/mtk_vcodec_dec_hw.c | 12 +++-- .../mediatek/vcodec/mtk_vcodec_dec_hw.h | 2 + .../mediatek/vcodec/mtk_vcodec_dec_pm.c | 50 ++++++++++++++++++ .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 12 +++++ .../vcodec/vdec/vdec_h264_req_multi_if.c | 25 +++++++-- .../platform/mediatek/vcodec/vdec_vpu_if.c | 5 ++ 9 files changed, 183 insertions(+), 24 deletions(-)
Signature · 1 line
2.18.0
Yunfei Dong
maintainerPATCH v7 1/7 dt-bindings: media: mediatek: vcodec: Adds decoder dt-bindings for lat soc
Adds decoder dt-bindings for compatible "mediatek,mtk-vcodec-lat-soc".
--- .../media/mediatek,vcodec-subdev-decoder.yaml | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-)
Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml +35 -16
@@ -17,20 +17,20 @@ description: | About the Decoder Hardware Block Diagram, please check below: - +---------------------------------+------------------------------------+ - | | | - | input -> lat HW -> lat buffer --|--> lat buffer -> core HW -> output | - | || | || | - +------------||-------------------+---------------------||-------------+ - lat workqueue | core workqueue <parent> - -------------||-----------------------------------------||------------------ - || || <child> - \/ <----------------HW index-------------->\/ - +------------------------------------------------------+ - | enable/disable | - | clk power irq iommu | - | (lat/lat soc/core0/core1) | - +------------------------------------------------------+ + +------------------------------------------------+-------------------------------------+ + | | | + | input -> lat soc HW -> lat HW -> lat buffer --|--> lat buffer -> core HW -> output | + | || || | || | + +------------||-------------||-------------------+---------------------||--------------+ + || lat || | core workqueue <parent> + -------------||-------------||-------------------|---------------------||--------------- + ||<------------||----------------HW index---------------->|| <child> + \/ \/ \/ + +-------------------------------------------------------------+ + | enable/disable | + | clk power irq iommu | + | (lat/lat soc/core0/core1) | + +-------------------------------------------------------------+ As above, there are parent and child devices, child mean each hardware. The child device controls the information of each hardware independent which include clk/power/irq.
@@ -45,6 +45,13 @@ description: | For the smi common may not the same for each hardware, can't combine all hardware in one node, or leading to iommu fault when access dram data. + Lat soc is a hardware which is related with some larb(local arbiter) ports. For mt8195 + platform, there are some ports like RDMA, UFO in lat soc larb, need to enable its power and + clock when lat start to work, don't have interrupt. + + mt8195: lat soc HW + lat HW + core HW + mt8192: lat HW + core HW + properties: compatible: enum:
@@ -88,7 +95,9 @@ patternProperties: properties: compatible: - const: mediatek,mtk-vcodec-lat + enum: + - mediatek,mtk-vcodec-lat + - mediatek,mtk-vcodec-lat-soc reg: maxItems: 1
@@ -126,7 +135,6 @@ patternProperties: required: - compatible - reg - - interrupts - iommus - clocks - clock-names
@@ -197,6 +205,17 @@ required: - dma-ranges - ranges +if: + properties: + compatible: + contains: + enum: + - mediatek,mtk-vcodec-lat + +then: + required: + - interrupts + additionalProperties: false examples:
Signature · 1 line
2.18.0
Yunfei Dong
maintainerPATCH v7 2/7 media: mediatek: vcodec: Add to support lat soc hardware
In reply to Yunfei DongAdd lat soc compatible and to support lat soc power/clk helper.
--- .../platform/mediatek/vcodec/mtk_vcodec_dec_hw.c | 12 +++++++++--- .../platform/mediatek/vcodec/mtk_vcodec_dec_hw.h | 2 ++ .../platform/mediatek/vcodec/mtk_vcodec_dec_pm.c | 16 ++++++++++++++++ .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 1 + 4 files changed, 28 insertions(+), 3 deletions(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c +9 -3
@@ -28,6 +28,10 @@ static const struct of_device_id mtk_vdec_hw_match[] = { .compatible = "mediatek,mtk-vcodec-core", .data = (void *)MTK_VDEC_CORE, }, + { + .compatible = "mediatek,mtk-vcodec-lat-soc", + .data = (void *)MTK_VDEC_LAT_SOC, + }, {}, };MODULE_DEVICE_TABLE (of, mtk_vdec_hw_match);
@@ -166,9 +170,11 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev) subdev_dev->reg_base[VDEC_HW_SYS ] = main_dev->reg_base[VDEC_HW_SYS ];set_bit (subdev_dev->hw_idx, main_dev->subdev_bitmap); - ret =mtk_vdec_hw_init_irq (subdev_dev); -if (ret) - goto err; +if (IS_SUPPORT_VDEC_HW_IRQ (hw_idx)) { + ret =mtk_vdec_hw_init_irq (subdev_dev); +if (ret) + goto err; + } subdev_dev->reg_base[VDEC_HW_MISC ] =devm_platform_ioremap_resource (pdev,0 );
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h +2 -0
@@ -17,6 +17,8 @@#define VDEC_IRQ_CLR 0x10#define VDEC_IRQ_CFG_REG 0xa4 +#define IS_SUPPORT_VDEC_HW_IRQ (hw_idx) ((hw_idx) != MTK_VDEC_LAT_SOC) +/** * enum mtk_vdec_hw_reg_idx - subdev hardware register base index * @VDEC_HW_SYS : vdec soc register index
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c +16 -0
@@ -174,6 +174,14 @@ static void mtk_vcodec_dec_child_dev_on(struct mtk_vcodec_dev *vdec_dev,mtk_vcodec_dec_pw_on (pm);mtk_vcodec_dec_clock_on (pm); } + +if (hw_idx ==MTK_VDEC_LAT0 ) { + pm =mtk_vcodec_dec_get_pm (vdec_dev,MTK_VDEC_LAT_SOC ); +if (pm) { +mtk_vcodec_dec_pw_on (pm); +mtk_vcodec_dec_clock_on (pm); + } + } } static void mtk_vcodec_dec_child_dev_off(struct mtk_vcodec_dev *vdec_dev,
@@ -186,6 +194,14 @@ static void mtk_vcodec_dec_child_dev_off(struct mtk_vcodec_dev *vdec_dev,mtk_vcodec_dec_clock_off (pm);mtk_vcodec_dec_pw_off (pm); } + +if (hw_idx ==MTK_VDEC_LAT0 ) { + pm =mtk_vcodec_dec_get_pm (vdec_dev,MTK_VDEC_LAT_SOC ); +if (pm) { +mtk_vcodec_dec_clock_off (pm); +mtk_vcodec_dec_pw_off (pm); + } + } }void mtk_vcodec_dec_enable_hardware (struct mtk_vcodec_ctx *ctx,int hw_idx)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +1 -0
@@ -104,6 +104,7 @@ enum mtk_vdec_hw_id {MTK_VDEC_CORE ,MTK_VDEC_LAT0 ,MTK_VDEC_LAT1 , +MTK_VDEC_LAT_SOC , MTK_VDEC_HW_MAX, };
Signature · 1 line
2.18.0
Yunfei Dong
maintainerPATCH v7 3/7 dt-bindings: media: mediatek: vcodec: Adds decoder dt-bindings for mt8195
In reply to Yunfei DongAdds decoder dt-bindings for mt8195.
--- .../bindings/media/mediatek,vcodec-subdev-decoder.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml +1 -0
@@ -57,6 +57,7 @@ properties: enum: - mediatek,mt8192-vcodec-dec - mediatek,mt8186-vcodec-dec + - mediatek,mt8195-vcodec-dec reg: maxItems: 1
Signature · 1 line
2.18.0
Yunfei Dong
maintainerPATCH v7 4/7 media: mediatek: vcodec: Adds compatible for mt8195
In reply to Yunfei DongAdds compatible for mt8195 platform.
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +4 -0
@@ -465,6 +465,10 @@ static const struct of_device_id mtk_vcodec_match[] = { .compatible = "mediatek,mt8186-vcodec-dec", .data = &mtk_vdec_single_core_pdata, }, + { + .compatible = "mediatek,mt8195-vcodec-dec", + .data = &mtk_lat_sig_core_pdata, + }, {}, };
Signature · 1 line
2.18.0
Yunfei Dong
maintainerPATCH v7 5/7 media: mediatek: vcodec: Different codec using different capture format
In reply to Yunfei DongVp8 need to use MM21, but vp9 and h264 need to use HyFbc mode for mt8195. Vp8/vp9/h264 use the same MM21 format for mt8192.
--- .../platform/mediatek/vcodec/mtk_vcodec_dec.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +41 -0
@@ -35,6 +35,44 @@ mtk_vdec_find_format(struct v4l2_format *f,return NULL ; } +static bool mtk_vdec_get_cap_fmt (struct mtk_vcodec_ctx *ctx,int format_index) +{ +const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata; +const struct mtk_video_fmt *fmt; +struct mtk_q_data *q_data; +int num_frame_count =0 , i; +bool ret = true; + +for (i =0 ; i < *dec_pdata->num_formats; i++) { +if (dec_pdata->vdec_formats[i].type !=MTK_FMT_FRAME ) +continue ; + + num_frame_count++; + } + +if (num_frame_count ==1 ) +return true; + + fmt = &dec_pdata->vdec_formats[format_index]; + q_data = &ctx->q_data[MTK_Q_DATA_SRC ]; +switch (q_data->fmt->fourcc) { +case V4L2_PIX_FMT_VP8_FRAME : +if (fmt->fourcc ==V4L2_PIX_FMT_MM21 ) + ret = true; +break ; +case V4L2_PIX_FMT_H264_SLICE : +case V4L2_PIX_FMT_VP9_FRAME : +if (fmt->fourcc ==V4L2_PIX_FMT_MM21 ) + ret = false; +break ; +default : + ret = true; +break ; + }; + +return ret; +} +static struct mtk_q_data *mtk_vdec_get_q_data (struct mtk_vcodec_ctx *ctx,enum v4l2_buf_type type) {
@@ -566,6 +604,9 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void *priv, dec_pdata->vdec_formats[i].type != MTK_FMT_FRAME)continue ; +if (!output_queue && !mtk_vdec_get_cap_fmt (ctx, i)) +continue ; +if (j == f->index)break ; ++j;
Signature · 1 line
2.18.0
Re: [PATCH v7, 5/7] media: mediatek: vcodec: Different codec using different capture format
Quoted 2 lines · Yunfei Dong
Vp8 need to use MM21, but vp9 and h264 need to use HyFbc mode for mt8195. Vp8/vp9/h264 use the same MM21 format for mt8192.
Hi Yunfei,
why do VP9 and H264 need to use HyFbc (is this the same as MT21C?) mode on MT8195? The SCP firmware on linux-firmware for MT8195 [1] only has MM21 available and based on my testing it works just fine. And contrary to what the commit message states this logic is also being applied to MT8192, preventing it to use MM21 when there are more than one format available.
Thanks,
Nícolas
Quoted 69 lines
Signed-off-by Yunfei Dong <[email protected]>--- .../platform/mediatek/vcodec/mtk_vcodec_dec.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+)drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +41
-0@@ -35,6 +35,44 @@ mtk_vdec_find_format(struct v4l2_format *f,return NULL ; } +static bool mtk_vdec_get_cap_fmt (struct mtk_vcodec_ctx *ctx,int format_index) +{ +const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata; +const struct mtk_video_fmt *fmt; +struct mtk_q_data *q_data; +int num_frame_count =0 , i; +bool ret = true; + +for (i =0 ; i < *dec_pdata->num_formats; i++) { +if (dec_pdata->vdec_formats[i].type !=MTK_FMT_FRAME ) +continue ; + + num_frame_count++; + } + +if (num_frame_count ==1 ) +return true; + + fmt = &dec_pdata->vdec_formats[format_index]; + q_data = &ctx->q_data[MTK_Q_DATA_SRC ]; +switch (q_data->fmt->fourcc) { +case V4L2_PIX_FMT_VP8_FRAME : +if (fmt->fourcc ==V4L2_PIX_FMT_MM21 ) + ret = true; +break ; +case V4L2_PIX_FMT_H264_SLICE : +case V4L2_PIX_FMT_VP9_FRAME : +if (fmt->fourcc ==V4L2_PIX_FMT_MM21 ) + ret = false; +break ; +default : + ret = true; +break ; + }; + +return ret; +} +static struct mtk_q_data *mtk_vdec_get_q_data (struct mtk_vcodec_ctx *ctx,enum v4l2_buf_type type) {@@ -566,6 +604,9 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void *priv, dec_pdata->vdec_formats[i].type != MTK_FMT_FRAME)continue ; +if (!output_queue && !mtk_vdec_get_cap_fmt (ctx, i)) +continue ; +if (j == f->index)break ; ++j;Signature · 1 line
2.18.0
Yunfei Dong (董云飞)
maintainerRe: [PATCH v7, 5/7] media: mediatek: vcodec: Different codec using different capture format
Hi Nicolas,
Thanks for your information.
Quoted 6 lines · Nícolas F. R. A. Prado
Quoted 2 lines · Yunfei Dong
Vp8 need to use MM21, but vp9 and h264 need to use HyFbc mode for mt8195. Vp8/vp9/h264 use the same MM21 format for mt8192.
Hi Yunfei,
Quoted 10 lines
why do VP9 and H264 need to use HyFbc (is this the same as MT21C?) mode on
MT8195? The SCP firmware on linux-firmware for MT8195 [1] only has MM21
available and based on my testing it works just fine. And contrary to what the
commit message states this logic is also being applied to MT8192, preventing it
to use MM21 when there are more than one format available.
The kernel driver not support dynamic switch mt21c and mm21. The driver flow as below:
1: If there are mt21c and mm21: h264/vp9/av1 will use mt21c(vp8 use mm21 always);
2: If there are only mt21c or mm21 will use this format only.
But the scp.img is changed to support mt21c and mm21, the kernel driver will use mt21c. Or force the kernel driver only support mm21(small effort).
But the best solution is changed the driver to dynamic switch mt21c and mm21, need to discuss the enum and set format flow(middle effort).
Best Regards,
Yunfei Dong
Quoted 85 lines
Thanks,
NícolasQuoted 76 lines
Signed-off-by Yunfei Dong <[email protected]>--- .../platform/mediatek/vcodec/mtk_vcodec_dec.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+)diff --git
a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.cb/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.cindex52e5d36aa912..254649240b34100644drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +38
-0@@ -35,6 +35,44 @@ mtk_vdec_find_format(struct v4l2_format *f,return NULL ; } +static bool mtk_vdec_get_cap_fmt (struct mtk_vcodec_ctx *ctx,int format_index) +{ +const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev- >vdec_pdata; +const struct mtk_video_fmt *fmt; +struct mtk_q_data *q_data; +int num_frame_count =0 , i; +bool ret = true; + +for (i =0 ; i < *dec_pdata->num_formats; i++) { +if (dec_pdata->vdec_formats[i].type !=MTK_FMT_FRAME ) +continue ; + + num_frame_count++; + } + +if (num_frame_count ==1 ) +return true; + + fmt = &dec_pdata->vdec_formats[format_index]; + q_data = &ctx->q_data[MTK_Q_DATA_SRC ]; +switch (q_data->fmt->fourcc) { +case V4L2_PIX_FMT_VP8_FRAME : +if (fmt->fourcc ==V4L2_PIX_FMT_MM21 ) + ret = true; +break ; +case V4L2_PIX_FMT_H264_SLICE : +case V4L2_PIX_FMT_VP9_FRAME : +if (fmt->fourcc ==V4L2_PIX_FMT_MM21 ) + ret = false; +break ; +default : + ret = true; +break ; + }; + +return ret; +} + static struct mtk_q_data *mtk_vdec_get_q_data(struct
mtk_vcodec_ctx*ctx,drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +3
-0enum v4l2_buf_type type) {@@ -566,6 +604,9 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void *priv, dec_pdata->vdec_formats[i].type != MTK_FMT_FRAME) continue; +if (!output_queue && !mtk_vdec_get_cap_fmt (ctx, i)) +continue ; +if (j == f->index)break ;++j;
Signature · 1 line
2.18.0
Re: [PATCH v7, 5/7] media: mediatek: vcodec: Different codec using different capture format
Quoted 26 lines · Yunfei Dong (董云飞)
Hi Nicolas,
Thanks for your information.
Quoted 6 lines · Nícolas F. R. A. Prado
Quoted 2 lines · Yunfei Dong
Vp8 need to use MM21, but vp9 and h264 need to use HyFbc mode for mt8195. Vp8/vp9/h264 use the same MM21 format for mt8192.
Hi Yunfei,
Quoted 10 lines
why do VP9 and H264 need to use HyFbc (is this the same as MT21C?) mode on
MT8195? The SCP firmware on linux-firmware for MT8195 [1] only has MM21
available and based on my testing it works just fine. And contrary to what the
commit message states this logic is also being applied to MT8192, preventing it
to use MM21 when there are more than one format available.The kernel driver not support dynamic switch mt21c and mm21. The driver flow as below:
1: If there are mt21c and mm21: h264/vp9/av1 will use mt21c(vp8 use mm21 always);
2: If there are only mt21c or mm21 will use this format only.
Quoted 6 lines
But the scp.img is changed to support mt21c and mm21, the kernel driver will use mt21c. Or force the kernel driver only support mm21(small effort).
But the best solution is changed the driver to dynamic switch mt21c and mm21, need to discuss the enum and set format flow(middle effort).
Agreed. The aim should be to get this dynamic format switching implemented in the driver so that the firmware can expose both formats and userspace can select any of them to use.
However, as you said that solution will take more effort, so in the meantime, given that currently only mm21 is supported by gstreamer, I think forcing the kernel driver to always select mm21 makes the most sense right now. That way it doesn't matter whether the firmware has mm21 or mm21+mt21c, decoding will keep working with gstreamer using mm21.
Thanks,
Nícolas
Yunfei Dong
maintainerPATCH v7 6/7 media: mediatek: vcodec: prevent kernel crash when scp ipi timeout
In reply to Yunfei DongWhen SCP timeout during playing video, kernel crashes with following message. It's caused by accessing NULL pointer in vpu_dec_ipi_handler. This patch doesn't solve the root cause of NULL pointer, but merely prevent kernel crashed when encounter the NULL pointer.
After applied this patch, kernel keeps alive, only the video player turns to green screen.
[67242.065474] pc : vpu_dec_ipi_handler+0xa0/0xb20 [mtk_vcodec_dec] [67242.065485] [MTK_V4L2] level=0 fops_vcodec_open(),334: 18000000.vcodec_dec decoder [135] [67242.065523] lr : scp_ipi_handler+0x11c/0x244 [mtk_scp] [67242.065540] sp : ffffffbb4207fb10 [67242.065557] x29: ffffffbb4207fb30 x28: ffffffd00a1d5000 [67242.065592] x27: 1ffffffa0143aa24 x26: 0000000000000000 [67242.065625] x25: dfffffd000000000 x24: ffffffd0168bfdb0 [67242.065659] x23: 1ffffff76840ff74 x22: ffffffbb41fa8a88 [67242.065692] x21: ffffffbb4207fb9c x20: ffffffbb4207fba0 [67242.065725] x19: ffffffbb4207fb98 x18: 0000000000000000 [67242.065758] x17: 0000000000000000 x16: ffffffd042022094 [67242.065791] x15: 1ffffff77ed4b71a x14: 1ffffff77ed4b719 [67242.065824] x13: 0000000000000000 x12: 0000000000000000 [67242.065857] x11: 0000000000000000 x10: dfffffd000000001 [67242.065890] x9 : 0000000000000000 x8 : 0000000000000002 [67242.065923] x7 : 0000000000000000 x6 : 000000000000003f [67242.065956] x5 : 0000000000000040 x4 : ffffffffffffffe0 [67242.065989] x3 : ffffffd043b841b8 x2 : 0000000000000000 [67242.066021] x1 : 0000000000000010 x0 : 0000000000000010 [67242.066055] Call trace: [67242.066092] vpu_dec_ipi_handler+0xa0/0xb20 [mtk_vcodec_dec 12220d230d83a7426fc38c56b3e7bc6066955bae] [67242.066119] scp_ipi_handler+0x11c/0x244 [mtk_scp 8fb69c2ef141dd3192518b952b65aba35627b8bf] [67242.066145] mt8192_scp_irq_handler+0x70/0x128 [mtk_scp 8fb69c2ef141dd3192518b952b65aba35627b8bf] [67242.066172] scp_irq_handler+0xa0/0x114 [mtk_scp 8fb69c2ef141dd3192518b952b65aba35627b8bf] [67242.066200] irq_thread_fn+0x84/0xf8 [67242.066220] irq_thread+0x170/0x1ec [67242.066242] kthread+0x2f8/0x3b8 [67242.066264] ret_from_fork+0x10/0x30 [67242.066292] Code: 38f96908 35003628 91004340 d343fc08 (38f96908)
--- drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c +5 -0
@@ -91,6 +91,11 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *) (unsigned long )msg->ap_inst_addr; +if (!vpu) { +mtk_v4l2_err ("ap_inst_addr is NULL, did the SCP hang or crash?" ); +return ; + } +mtk_vcodec_debug (vpu,"+ id=%X" , msg->msg_id); vpu->failure = msg->status;
Signature · 1 line
2.18.0
Yunfei Dong
maintainerPATCH v7 7/7 media: mediatek: vcodec: Add to support H264 inner racing mode
In reply to Yunfei DongIn order to reduce decoder latency, enable H264 inner racing mode.
Send lat trans buffer information to core when trigger lat to work, need not to wait until lat decode done.
--- .../mediatek/vcodec/mtk_vcodec_dec_drv.c | 4 +++ .../mediatek/vcodec/mtk_vcodec_dec_pm.c | 34 +++++++++++++++++++ .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 11 ++++++ .../vcodec/vdec/vdec_h264_req_multi_if.c | 25 +++++++++++--- 4 files changed, 69 insertions(+), 5 deletions(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +4 -0
@@ -388,6 +388,10 @@ static int mtk_vcodec_probe(struct platform_device *pdev) } } +atomic_set (&dev->dec_active_cnt,0 ); +memset (dev->vdec_racing_info,0 ,sizeof (dev->vdec_racing_info)); +mutex_init (&dev->dec_racing_info_mutex); + ret =video_register_device (vfd_dec,VFL_TYPE_VIDEO ,-1 );if (ret) {mtk_v4l2_err ("Failed to register video device" );
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c +34 -0
@@ -144,6 +144,34 @@ static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_i } } +static void mtk_vcodec_load_racing_info (struct mtk_vcodec_ctx *ctx) +{ +void __iomem *vdec_racing_addr; +int j; + +mutex_lock (&ctx->dev->dec_racing_info_mutex); +if (atomic_inc_return (&ctx->dev->dec_active_cnt) ==1 ) { + vdec_racing_addr = ctx->dev->reg_base[VDEC_MISC ] +0x100 ; +for (j =0 ; j <132 ; j++) +writel (ctx->dev->vdec_racing_info[j], vdec_racing_addr + j *4 ); + } +mutex_unlock (&ctx->dev->dec_racing_info_mutex); +} + +static void mtk_vcodec_record_racing_info (struct mtk_vcodec_ctx *ctx) +{ +void __iomem *vdec_racing_addr; +int j; + +mutex_lock (&ctx->dev->dec_racing_info_mutex); +if (atomic_dec_and_test (&ctx->dev->dec_active_cnt)) { + vdec_racing_addr = ctx->dev->reg_base[VDEC_MISC ] +0x100 ; +for (j =0 ; j <132 ; j++) + ctx->dev->vdec_racing_info[j] =readl (vdec_racing_addr + j *4 ); + } +mutex_unlock (&ctx->dev->dec_racing_info_mutex); +} +static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm (struct mtk_vcodec_dev *vdec_dev,int hw_idx) {
@@ -214,11 +242,17 @@ void mtk_vcodec_dec_enable_hardware(struct mtk_vcodec_ctx *ctx, int hw_idx)mtk_vcodec_dec_child_dev_on (ctx->dev, hw_idx);mtk_vcodec_dec_enable_irq (ctx->dev, hw_idx); + +if (IS_VDEC_INNER_RACING (ctx->dev->dec_capability)) +mtk_vcodec_load_racing_info (ctx); }EXPORT_SYMBOL_GPL (mtk_vcodec_dec_enable_hardware);void mtk_vcodec_dec_disable_hardware (struct mtk_vcodec_ctx *ctx,int hw_idx) { +if (IS_VDEC_INNER_RACING (ctx->dev->dec_capability)) +mtk_vcodec_record_racing_info (ctx); +mtk_vcodec_dec_disable_irq (ctx->dev, hw_idx);mtk_vcodec_dec_child_dev_off (ctx->dev, hw_idx);
drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +11 -0
@@ -28,6 +28,7 @@#define MTK_V4L2_BENCHMARK 0#define WAIT_INTR_TIMEOUT_MS 1000#define IS_VDEC_LAT_ARCH (hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE) +#define IS_VDEC_INNER_RACING (capability) ((capability) & MTK_VCODEC_INNER_RACING)/* * enum mtk_hw_reg_idx - MTK hw register base index
@@ -357,6 +358,7 @@ enum mtk_vdec_format_types {MTK_VDEC_FORMAT_H264_SLICE =0x100 ,MTK_VDEC_FORMAT_VP8_FRAME =0x200 ,MTK_VDEC_FORMAT_VP9_FRAME =0x400 , + MTK_VCODEC_INNER_RACING = 0x20000, };/**
@@ -478,6 +480,10 @@ struct mtk_vcodec_enc_pdata {* @subdev_dev: subdev hardware device * @subdev_prob_done: check whether all used hw device is prob done * @subdev_bitmap: used to record hardware is ready or not +* +* @dec_active_cnt: used to mark whether need to record register value +* @vdec_racing_info: record register value +* @dec_racing_info_mutex: mutex lock used for inner racing mode */ struct mtk_vcodec_dev {struct v4l2_device v4l2_dev;
@@ -523,6 +529,11 @@ struct mtk_vcodec_dev {void *subdev_dev[MTK_VDEC_HW_MAX ];int (*subdev_prob_done)(struct mtk_vcodec_dev *vdec_dev);DECLARE_BITMAP (subdev_bitmap,MTK_VDEC_HW_MAX ); + +atomic_t dec_active_cnt; +u32 vdec_racing_info[132 ]; +/* Protects access to vdec_racing_info data */ +struct mutex dec_racing_info_mutex; };static inline struct mtk_vcodec_ctx *fh_to_ctx (struct v4l2_fh *fh)
drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c +20 -5
@@ -626,6 +626,17 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, goto err_scp_decode; } + share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr + + inst->vsi->wdma_end_addr_offset; + share_info->trans_start = inst->ctx->msg_queue.wdma_wptr_addr; + share_info->nal_info = inst->vsi->dec.nal_info; + +if (IS_VDEC_INNER_RACING (inst->ctx->dev->dec_capability)) { +memcpy (&share_info->h264_slice_params, &inst->vsi->h264_slice_params, +sizeof (share_info->h264_slice_params)); +vdec_msg_queue_qbuf (&inst->ctx->dev->msg_queue_core_ctx, lat_buf); + } +/* wait decoder done interrupt */ timeout =mtk_vcodec_wait_for_done_ctx (inst->ctx,MTK_INST_IRQ_RECEIVED ,WAIT_INTR_TIMEOUT_MS ,MTK_VDEC_LAT0 );
@@ -639,18 +650,22 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, share_info->trans_end = inst->ctx->msg_queue.wdma_addr.dma_addr + inst->vsi->wdma_end_addr_offset; - share_info->trans_start = inst->ctx->msg_queue.wdma_wptr_addr; - share_info->nal_info = inst->vsi->dec.nal_info;vdec_msg_queue_update_ube_wptr (&lat_buf->ctx->msg_queue, share_info->trans_end); -memcpy (&share_info->h264_slice_params, &inst->vsi->h264_slice_params, -sizeof (share_info->h264_slice_params)); -vdec_msg_queue_qbuf (&inst->ctx->dev->msg_queue_core_ctx, lat_buf); +if (!IS_VDEC_INNER_RACING (inst->ctx->dev->dec_capability)) { +memcpy (&share_info->h264_slice_params, &inst->vsi->h264_slice_params, +sizeof (share_info->h264_slice_params)); +vdec_msg_queue_qbuf (&inst->ctx->dev->msg_queue_core_ctx, lat_buf); + } +mtk_vcodec_debug (inst,"dec num: %d lat crc: 0x%x 0x%x 0x%x" , inst->slice_dec_num, + inst->vsi->dec.crc[0 ], inst->vsi->dec.crc[1 ], inst->vsi->dec.crc[2 ]); inst->slice_dec_num++;return 0 ; err_scp_decode: +if (!IS_VDEC_INNER_RACING (inst->ctx->dev->dec_capability)) +vdec_msg_queue_qbuf (&inst->ctx->msg_queue.lat_ctx, lat_buf); err_free_fb_out:vdec_msg_queue_qbuf (&inst->ctx->msg_queue.lat_ctx, lat_buf);mtk_vcodec_err (inst,"slice dec number: %d err: %d" , inst->slice_dec_num, err);
Signature · 1 line
2.18.0