diff mbox series

[v2,3/4] media: chips-media: wave5: Fix hang after seeking

Message ID 20241217045125.58-4-jackson.lee@chipsnmedia.com (mailing list archive)
State New
Headers show
Series Fix critical bugs | expand

Commit Message

jackson.lee Dec. 17, 2024, 4:51 a.m. UTC
While seeking, driver calls flush command. Before flush command is sent to
VPU, driver should handle display buffer flags and should get all decoded
information from VPU if VCORE is running.

Signed-off-by: Jackson.lee <jackson.lee@chipsnmedia.com>
Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
 .../platform/chips-media/wave5/wave5-vpu-dec.c  | 17 ++++++++++++++++-
 .../platform/chips-media/wave5/wave5-vpuapi.c   | 10 ++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

Comments

Nicolas Dufresne Dec. 17, 2024, 2:05 p.m. UTC | #1
Le mardi 17 décembre 2024 à 13:51 +0900, Jackson.lee a écrit :
> While seeking, driver calls flush command. Before flush command is sent to
> VPU, driver should handle display buffer flags and should get all decoded
> information from VPU if VCORE is running.
> 
> Signed-off-by: Jackson.lee <jackson.lee@chipsnmedia.com>
> Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

This one too please.

> ---
>  .../platform/chips-media/wave5/wave5-vpu-dec.c  | 17 ++++++++++++++++-
>  .../platform/chips-media/wave5/wave5-vpuapi.c   | 10 ++++++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> index d3ff420c52ce..882d5539630f 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> @@ -1369,6 +1369,16 @@ static int streamoff_output(struct vb2_queue *q)
>  	struct vb2_v4l2_buffer *buf;
>  	int ret;
>  	dma_addr_t new_rd_ptr;
> +	struct dec_output_info dec_info;
> +	unsigned int i;
> +
> +	for (i = 0; i < v4l2_m2m_num_dst_bufs_ready(m2m_ctx); i++) {
> +		ret = wave5_vpu_dec_set_disp_flag(inst, i);
> +		if (ret)
> +			dev_dbg(inst->dev->dev,
> +				"%s: Setting display flag of buf index: %u, fail: %d\n",
> +				__func__, i, ret);
> +	}
>  
>  	while ((buf = v4l2_m2m_src_buf_remove(m2m_ctx))) {
>  		dev_dbg(inst->dev->dev, "%s: (Multiplanar) buf type %4u | index %4u\n",
> @@ -1376,6 +1386,11 @@ static int streamoff_output(struct vb2_queue *q)
>  		v4l2_m2m_buf_done(buf, VB2_BUF_STATE_ERROR);
>  	}
>  
> +	while (wave5_vpu_dec_get_output_info(inst, &dec_info) == 0) {
> +		if (dec_info.index_frame_display >= 0)
> +			wave5_vpu_dec_set_disp_flag(inst, dec_info.index_frame_display);
> +	}
> +
>  	ret = wave5_vpu_flush_instance(inst);
>  	if (ret)
>  		return ret;
> @@ -1459,7 +1474,7 @@ static void wave5_vpu_dec_stop_streaming(struct vb2_queue *q)
>  			break;
>  
>  		if (wave5_vpu_dec_get_output_info(inst, &dec_output_info))
> -			dev_dbg(inst->dev->dev, "Getting decoding results from fw, fail\n");
> +			dev_dbg(inst->dev->dev, "there is no output info\n");
>  	}
>  
>  	v4l2_m2m_update_stop_streaming_state(m2m_ctx, q);
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> index e16b990041c2..e5e879a13e8b 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> @@ -75,6 +75,16 @@ int wave5_vpu_flush_instance(struct vpu_instance *inst)
>  				 inst->type == VPU_INST_TYPE_DEC ? "DECODER" : "ENCODER", inst->id);
>  			mutex_unlock(&inst->dev->hw_lock);
>  			return -ETIMEDOUT;
> +		} else if (ret == -EBUSY) {
> +			struct dec_output_info dec_info;
> +
> +			mutex_unlock(&inst->dev->hw_lock);
> +			wave5_vpu_dec_get_output_info(inst, &dec_info);
> +			ret = mutex_lock_interruptible(&inst->dev->hw_lock);
> +			if (ret)
> +				return ret;
> +			if (dec_info.index_frame_display > 0)
> +				wave5_vpu_dec_set_disp_flag(inst, dec_info.index_frame_display);
>  		}
>  	} while (ret != 0);
>  	mutex_unlock(&inst->dev->hw_lock);
jackson.lee Dec. 18, 2024, 3:06 a.m. UTC | #2
Hi Nicolas


> -----Original Message-----
> From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Sent: Tuesday, December 17, 2024 11:05 PM
> To: jackson.lee <jackson.lee@chipsnmedia.com>; mchehab@kernel.org;
> hverkuil-cisco@xs4all.nl; sebastian.fricke@collabora.com;
> bob.beckett@collabora.com; dafna.hirschfeld@collabora.com
> Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; lafley.kim
> <lafley.kim@chipsnmedia.com>; b-brnich@ti.com; hverkuil@xs4all.nl; Nas
> Chung <nas.chung@chipsnmedia.com>
> Subject: Re: [PATCH v2 3/4] media: chips-media: wave5: Fix hang after
> seeking
> 
> Le mardi 17 décembre 2024 à 13:51 +0900, Jackson.lee a écrit :
> > While seeking, driver calls flush command. Before flush command is
> > sent to VPU, driver should handle display buffer flags and should get
> > all decoded information from VPU if VCORE is running.
> >
> > Signed-off-by: Jackson.lee <jackson.lee@chipsnmedia.com>
> > Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
> > Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> 
> This one too please.


Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")

thanks


> 
> > ---
> >  .../platform/chips-media/wave5/wave5-vpu-dec.c  | 17 ++++++++++++++++-
> >  .../platform/chips-media/wave5/wave5-vpuapi.c   | 10 ++++++++++
> >  2 files changed, 26 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> > b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> > index d3ff420c52ce..882d5539630f 100644
> > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> > @@ -1369,6 +1369,16 @@ static int streamoff_output(struct vb2_queue *q)
> >  	struct vb2_v4l2_buffer *buf;
> >  	int ret;
> >  	dma_addr_t new_rd_ptr;
> > +	struct dec_output_info dec_info;
> > +	unsigned int i;
> > +
> > +	for (i = 0; i < v4l2_m2m_num_dst_bufs_ready(m2m_ctx); i++) {
> > +		ret = wave5_vpu_dec_set_disp_flag(inst, i);
> > +		if (ret)
> > +			dev_dbg(inst->dev->dev,
> > +				"%s: Setting display flag of buf index: %u,
> fail: %d\n",
> > +				__func__, i, ret);
> > +	}
> >
> >  	while ((buf = v4l2_m2m_src_buf_remove(m2m_ctx))) {
> >  		dev_dbg(inst->dev->dev, "%s: (Multiplanar) buf type %4u |
> index
> > %4u\n", @@ -1376,6 +1386,11 @@ static int streamoff_output(struct
> vb2_queue *q)
> >  		v4l2_m2m_buf_done(buf, VB2_BUF_STATE_ERROR);
> >  	}
> >
> > +	while (wave5_vpu_dec_get_output_info(inst, &dec_info) == 0) {
> > +		if (dec_info.index_frame_display >= 0)
> > +			wave5_vpu_dec_set_disp_flag(inst,
> dec_info.index_frame_display);
> > +	}
> > +
> >  	ret = wave5_vpu_flush_instance(inst);
> >  	if (ret)
> >  		return ret;
> > @@ -1459,7 +1474,7 @@ static void wave5_vpu_dec_stop_streaming(struct
> vb2_queue *q)
> >  			break;
> >
> >  		if (wave5_vpu_dec_get_output_info(inst, &dec_output_info))
> > -			dev_dbg(inst->dev->dev, "Getting decoding results from
> fw, fail\n");
> > +			dev_dbg(inst->dev->dev, "there is no output info\n");
> >  	}
> >
> >  	v4l2_m2m_update_stop_streaming_state(m2m_ctx, q); diff --git
> > a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > index e16b990041c2..e5e879a13e8b 100644
> > --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > @@ -75,6 +75,16 @@ int wave5_vpu_flush_instance(struct vpu_instance
> *inst)
> >  				 inst->type == VPU_INST_TYPE_DEC ? "DECODER" :
> "ENCODER", inst->id);
> >  			mutex_unlock(&inst->dev->hw_lock);
> >  			return -ETIMEDOUT;
> > +		} else if (ret == -EBUSY) {
> > +			struct dec_output_info dec_info;
> > +
> > +			mutex_unlock(&inst->dev->hw_lock);
> > +			wave5_vpu_dec_get_output_info(inst, &dec_info);
> > +			ret = mutex_lock_interruptible(&inst->dev->hw_lock);
> > +			if (ret)
> > +				return ret;
> > +			if (dec_info.index_frame_display > 0)
> > +				wave5_vpu_dec_set_disp_flag(inst,
> dec_info.index_frame_display);
> >  		}
> >  	} while (ret != 0);
> >  	mutex_unlock(&inst->dev->hw_lock);
diff mbox series

Patch

diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
index d3ff420c52ce..882d5539630f 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
@@ -1369,6 +1369,16 @@  static int streamoff_output(struct vb2_queue *q)
 	struct vb2_v4l2_buffer *buf;
 	int ret;
 	dma_addr_t new_rd_ptr;
+	struct dec_output_info dec_info;
+	unsigned int i;
+
+	for (i = 0; i < v4l2_m2m_num_dst_bufs_ready(m2m_ctx); i++) {
+		ret = wave5_vpu_dec_set_disp_flag(inst, i);
+		if (ret)
+			dev_dbg(inst->dev->dev,
+				"%s: Setting display flag of buf index: %u, fail: %d\n",
+				__func__, i, ret);
+	}
 
 	while ((buf = v4l2_m2m_src_buf_remove(m2m_ctx))) {
 		dev_dbg(inst->dev->dev, "%s: (Multiplanar) buf type %4u | index %4u\n",
@@ -1376,6 +1386,11 @@  static int streamoff_output(struct vb2_queue *q)
 		v4l2_m2m_buf_done(buf, VB2_BUF_STATE_ERROR);
 	}
 
+	while (wave5_vpu_dec_get_output_info(inst, &dec_info) == 0) {
+		if (dec_info.index_frame_display >= 0)
+			wave5_vpu_dec_set_disp_flag(inst, dec_info.index_frame_display);
+	}
+
 	ret = wave5_vpu_flush_instance(inst);
 	if (ret)
 		return ret;
@@ -1459,7 +1474,7 @@  static void wave5_vpu_dec_stop_streaming(struct vb2_queue *q)
 			break;
 
 		if (wave5_vpu_dec_get_output_info(inst, &dec_output_info))
-			dev_dbg(inst->dev->dev, "Getting decoding results from fw, fail\n");
+			dev_dbg(inst->dev->dev, "there is no output info\n");
 	}
 
 	v4l2_m2m_update_stop_streaming_state(m2m_ctx, q);
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
index e16b990041c2..e5e879a13e8b 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
@@ -75,6 +75,16 @@  int wave5_vpu_flush_instance(struct vpu_instance *inst)
 				 inst->type == VPU_INST_TYPE_DEC ? "DECODER" : "ENCODER", inst->id);
 			mutex_unlock(&inst->dev->hw_lock);
 			return -ETIMEDOUT;
+		} else if (ret == -EBUSY) {
+			struct dec_output_info dec_info;
+
+			mutex_unlock(&inst->dev->hw_lock);
+			wave5_vpu_dec_get_output_info(inst, &dec_info);
+			ret = mutex_lock_interruptible(&inst->dev->hw_lock);
+			if (ret)
+				return ret;
+			if (dec_info.index_frame_display > 0)
+				wave5_vpu_dec_set_disp_flag(inst, dec_info.index_frame_display);
 		}
 	} while (ret != 0);
 	mutex_unlock(&inst->dev->hw_lock);