media: s5p-mfc: Corrected NV12M/NV21M plane-sizes
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): CGME20250305055904epcas5p45828c732019a847a0852c26d9ef9f2db@epcas5p4.samsung.com
PATCH v3 1/1 media: s5p-mfc: Corrected NV12M/NV21M plane-sizes
There is a possibility of getting page fault if the overall buffer size is not aligned to 256bytes. Since MFC does read operation only and it won't corrupt the data values even if it reads the extra bytes.
Corrected luma and chroma plane sizes for V4L2_PIX_FMT_NV12M and V4L2_PIX_FMT_NV21M pixel format.
---
changelog:v2->v3
Patch link:https://patchwork.kernel.org/project/linux-media/patch/[email protected]/ Fixed checkpatch warning.
v1->v2
Patch link: https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
Removed duplicate code and aligned luma and chroma size
to multiple of 256bytes as suggested by Hans.
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c +3 -2
@@ -549,8 +549,9 @@ static void s5p_mfc_enc_calc_src_size_v6(struct s5p_mfc_ctx *ctx)case V4L2_PIX_FMT_NV21M : ctx->stride[0 ] =ALIGN (ctx->img_width,S5P_FIMV_NV12M_HALIGN_V6 ); ctx->stride[1 ] =ALIGN (ctx->img_width,S5P_FIMV_NV12M_HALIGN_V6 ); - ctx->luma_size = ctx->stride[0 ] *ALIGN (ctx->img_height,16 ); - ctx->chroma_size = ctx->stride[0 ] *ALIGN (ctx->img_height /2 ,16 ); + ctx->luma_size =ALIGN (ctx->stride[0 ] *ALIGN (ctx->img_height,16 ),256 ); + ctx->chroma_size =ALIGN (ctx->stride[0 ] * +ALIGN (ctx->img_height /2 ,16 ),256 );break ;case V4L2_PIX_FMT_YUV420M :case V4L2_PIX_FMT_YVU420M :
Signature · 1 line
2.17.1
PATCH v2 1/1 media: s5p-mfc: Support for handling RET_ENC_BUFFER_FULL interrupt
When output encoded buffer size provided by userspace is insufficient with current encoding parameters, it leads to RET_ENC_BUFFER_FULL interrupt which was not handled in IRQ handler.
On handling of RET_ENC_BUFFER_FULL interrupt leads to NAL_ABORT command from host to risc which in turn leads to RET_NAL_ABORT interrupt. On receiving RET_NAL_ABORT driver clears workbit and VB2 queues for cleaner closing of MFC instance.
When user encounters "Call on DQBUF after unrecoverable error", userspace should close fd and restart with larger output encoder buffer size.
---
changelog:v1->v2
Patch link: https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
Fixed build errors reported by Media CI robot.
.../media/platform/samsung/s5p-mfc/regs-mfc-v6.h | 1 + drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 14 ++++++++++++++ .../platform/samsung/s5p-mfc/s5p_mfc_common.h | 1 + .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 5 +++++ 4 files changed, 21 insertions(+)
drivers/media/platform/samsung/s5p-mfc/regs-mfc-v6.h +1 -0
@@ -45,6 +45,7 @@#define S5P_FIMV_H2R_CMD_WAKEUP_V6 8#define S5P_FIMV_CH_LAST_FRAME_V6 9#define S5P_FIMV_H2R_CMD_FLUSH_V6 10 +#define S5P_FIMV_H2R_CMD_NAL_ABORT_V6 11/* RMVME: REALLOC used? */ #define S5P_FIMV_CH_FRAME_START_REALLOC_V6 5
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c +14 -0
@@ -739,6 +739,20 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv) ctx->state =MFCINST_RUNNING ; goto irq_cleanup_hw; +case S5P_MFC_R2H_CMD_ENC_BUFFER_FUL_RET : + ctx->state =MFCINST_NAL_ABORT ; +s5p_mfc_hw_call (dev->mfc_ops, clear_int_flags, dev); +set_work_bit (ctx); +WARN_ON (test_and_clear_bit (0 , &dev->hw_lock) ==0 ); +s5p_mfc_hw_call (dev->mfc_ops, try_run, dev); +break ; + +case S5P_MFC_R2H_CMD_NAL_ABORT_RET : + ctx->state =MFCINST_ERROR ; +s5p_mfc_cleanup_queue (&ctx->dst_queue, &ctx->vq_dst); +s5p_mfc_cleanup_queue (&ctx->src_queue, &ctx->vq_src); + goto irq_cleanup_hw; +default :mfc_debug (2 ,"Unknown int reason\n" );s5p_mfc_hw_call (dev->mfc_ops, clear_int_flags, dev);
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h +1 -0
@@ -141,6 +141,7 @@ enum s5p_mfc_inst_state {MFCINST_RES_CHANGE_INIT ,MFCINST_RES_CHANGE_FLUSH ,MFCINST_RES_CHANGE_END , + MFCINST_NAL_ABORT, };/*
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c +5 -0
@@ -2229,6 +2229,11 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)case MFCINST_HEAD_PRODUCED : ret =s5p_mfc_run_init_enc_buffers (ctx);break ; +case MFCINST_NAL_ABORT : +mfc_write (dev, ctx->inst_no,S5P_FIMV_INSTANCE_ID_V6 ); +s5p_mfc_hw_call (dev->mfc_cmds, cmd_host2risc, + dev,S5P_FIMV_H2R_CMD_NAL_ABORT_V6 ,NULL ); +break ;default : ret = -EAGAIN ; }
Signature · 1 line
2.17.1
Re: [Patch v2] media: s5p-mfc: Support for handling RET_ENC_BUFFER_FULL interrupt
Quoted 11 lines · Aakarsh Jain
When output encoded buffer size provided by userspace is insufficient with current encoding parameters, it leads to
RET_ENC_BUFFER_FULLinterrupt which was not handled in IRQ handler.On handling of
RET_ENC_BUFFER_FULLinterrupt leads toNAL_ABORTcommand from host to risc which in turn leads toRET_NAL_ABORTinterrupt. On receivingRET_NAL_ABORTdriver clears workbit and VB2 queues for cleaner closing of MFC instance.
Quoted 5 lines
When user encounters "Call on DQBUF after unrecoverable error", userspace should close fd and restart with larger output encoder buffer size.
Signed-off-by Aakarsh Jain <[email protected]>
Quoted 66 lines
---
changelog:v1->v2
Patch link: https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
Fixed build errors reported by Media CI robot..../media/platform/samsung/s5p-mfc/regs-mfc-v6.h | 1 + drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 14 ++++++++++++++ .../platform/samsung/s5p-mfc/s5p_mfc_common.h | 1 + .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 5 +++++ 4 files changed, 21 insertions(+)drivers/media/platform/samsung/s5p-mfc/regs-mfc-v6.h +1
-0@@ -45,6 +45,7 @@#define S5P_FIMV_H2R_CMD_WAKEUP_V6 8#define S5P_FIMV_CH_LAST_FRAME_V6 9#define S5P_FIMV_H2R_CMD_FLUSH_V6 10 +#define S5P_FIMV_H2R_CMD_NAL_ABORT_V6 11/* RMVME: REALLOC used? */ #define S5P_FIMV_CH_FRAME_START_REALLOC_V6 5drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c +14
-0@@ -739,6 +739,20 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv) ctx->state =MFCINST_RUNNING ; goto irq_cleanup_hw; +case S5P_MFC_R2H_CMD_ENC_BUFFER_FUL_RET : + ctx->state =MFCINST_NAL_ABORT ; +s5p_mfc_hw_call (dev->mfc_ops, clear_int_flags, dev); +set_work_bit (ctx); +WARN_ON (test_and_clear_bit (0 , &dev->hw_lock) ==0 ); +s5p_mfc_hw_call (dev->mfc_ops, try_run, dev); +break ; + +case S5P_MFC_R2H_CMD_NAL_ABORT_RET : + ctx->state =MFCINST_ERROR ; +s5p_mfc_cleanup_queue (&ctx->dst_queue, &ctx->vq_dst); +s5p_mfc_cleanup_queue (&ctx->src_queue, &ctx->vq_src); + goto irq_cleanup_hw; +default :mfc_debug (2 ,"Unknown int reason\n" );s5p_mfc_hw_call (dev->mfc_ops, clear_int_flags, dev);drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h +1
-0@@ -141,6 +141,7 @@ enum s5p_mfc_inst_state {MFCINST_RES_CHANGE_INIT ,MFCINST_RES_CHANGE_FLUSH ,MFCINST_RES_CHANGE_END , + MFCINST_NAL_ABORT, };/* drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c +0
-0@@ -2229,6 +2229,11 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)case MFCINST_HEAD_PRODUCED :
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev) · line 2239
Quoted 10 lines
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c +5
-0ret =s5p_mfc_run_init_enc_buffers (ctx);break ; +case MFCINST_NAL_ABORT : +mfc_write (dev, ctx->inst_no,S5P_FIMV_INSTANCE_ID_V6 ); +s5p_mfc_hw_call (dev->mfc_cmds, cmd_host2risc, + dev,S5P_FIMV_H2R_CMD_NAL_ABORT_V6 ,NULL ); +break ;default : ret = -EAGAIN ; }
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland