Skip to contentSkip to conversation

media: coda: Keep metas sync with hardware fifo

PATCH In review Benjamin Gaignard 2 participants 4 messages Nov 8, 2021 – Nov 12, 2021 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: coda: Keep metas sync with hardware fifo

After updating the output fifo position be sure that metas are also synchronised with this position.

---
 drivers/media/platform/coda/coda-bit.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/platform/coda/coda-bit.c +6 -0
index c484c008ab02..28c56286b0de 100644
@@ -2315,6 +2315,12 @@ static void coda_finish_decode(struct coda_ctx *ctx)
 	/* Update kfifo out pointer from coda bitstream read pointer */
 	coda_kfifo_sync_from_device(ctx);
 
+	/*
+	 * After updating the read pointer, we need to check if
+	 * any metas are consumed and should be released.
+	 */
+	coda_decoder_drop_used_metas(ctx);
+
 	/*
 	 * in stream-end mode, the read pointer can overshoot the write pointer
 	 * by up to 512 bytes
Signature · 1 line
2.30.2
#1 lore raw

Hi Benjamin,

Quoted 13 lines · Benjamin Gaignard

After updating the output fifo position be sure that metas are also synchronised with this position.

---
 drivers/media/platform/coda/coda-bit.c | 6 ++++++

 1 file changed, 6 insertions(+)
drivers/media/platform/coda/coda-bit.c +0 -0
index c484c008ab02..28c56286b0de 100644

drivers/media/platform/coda/coda-bit.c static void coda_finish_decode(struct coda_ctx *ctx) · line 2323

Quoted 9 lines
drivers/media/platform/coda/coda-bit.c +6 -0
@@ -2315,6 +2315,12 @@ static void coda_finish_decode(struct coda_ctx *ctx)
  	/* Update kfifo out pointer from coda bitstream read pointer */
  	coda_kfifo_sync_from_device(ctx);
 
+	/*
+	 * After updating the read pointer, we need to check if
+	 * any metas are consumed and should be released.
+	 */
+	coda_decoder_drop_used_metas(ctx);
+

This doesn't look right. If you drop all metas seen by the decoder right away, they can't be copied into the decoded picture's meta slot later in this function. I'd expect you run into the "empty timestamp list!" errors if you do this.

regards
Philipp

#2 lore raw

Le 11/11/2021 à 18:03, Philipp Zabel a écrit :

Quoted 19 lines

Hi Benjamin,

Quoted 16 lines · Benjamin Gaignard

After updating the output fifo position be sure that metas are also synchronised with this position.

---
  drivers/media/platform/coda/coda-bit.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/media/platform/coda/coda-bit.c +0 -0
index c484c008ab02..28c56286b0de 100644
@@ -2315,6 +2315,12 @@ static void coda_finish_decode(struct coda_ctx *ctx)
  	/* Update kfifo out pointer from coda bitstream read pointer */
  	coda_kfifo_sync_from_device(ctx);
 
Quoted 10 lines

drivers/media/platform/coda/coda-bit.c static void coda_finish_decode(struct coda_ctx *ctx) · line 2323

Quoted 6 lines
drivers/media/platform/coda/coda-bit.c +6 -0
+	/*
+	 * After updating the read pointer, we need to check if
+	 * any metas are consumed and should be released.
+	 */
+	coda_decoder_drop_used_metas(ctx);
+

This doesn't look right. If you drop all metas seen by the decoder right away, they can't be copied into the decoded picture's meta slot later in this function. I'd expect you run into the "empty timestamp list!" errors if you do this.

Hi Philipp,

I don't run into the "empty timestamp list!" errors. The only case I have seen metas been dropped here it is when an invalid/incomplete frame has been send into the decoder. When that happens I don't see any interrupt or error message but the erroneous frame stay in the list.
If that occur 4 times (I'm using CODA 960) then the decoder hang. Dropping the metas at this moment solve this problem.

Maybe you can guide me to a better solution ?

Regards,
Benjamin

Quoted 3 lines

regards
Philipp

#3 lore raw

Hi Benjamin,

Quoted 41 lines · Benjamin Gaignard

Le 11/11/2021 à 18:03, Philipp Zabel a écrit :

Quoted 19 lines

Hi Benjamin,

Quoted 16 lines · Benjamin Gaignard

After updating the output fifo position be sure that metas are also synchronised with this position.

---
  drivers/media/platform/coda/coda-bit.c | 6 ++++++

  1 file changed, 6 insertions(+)
drivers/media/platform/coda/coda-bit.c +0 -0
index c484c008ab02..28c56286b0de 100644
@@ -2315,6 +2315,12 @@ static void coda_finish_decode(struct coda_ctx *ctx)
   	/* Update kfifo out pointer from coda bitstream read pointer */
   	coda_kfifo_sync_from_device(ctx);
 
Quoted 10 lines

drivers/media/platform/coda/coda-bit.c static void coda_finish_decode(struct coda_ctx *ctx) · line 2323

Quoted 6 lines
drivers/media/platform/coda/coda-bit.c +6 -0
+	/*
+	 * After updating the read pointer, we need to check if
+	 * any metas are consumed and should be released.
+	 */
+	coda_decoder_drop_used_metas(ctx);
+

This doesn't look right. If you drop all metas seen by the decoder right away, they can't be copied into the decoded picture's meta slot later in this function. I'd expect you run into the "empty timestamp list!" errors if you do this.

Hi Philipp,

I don't run into the "empty timestamp list!" errors. The only case I have seen metas been dropped here it is when an invalid/incomplete frame has been send into the decoder. When that happens I don't see any interrupt or error message but the erroneous frame stay in the list.
If that occur 4 times (I'm using CODA 960) then the decoder hang. Dropping the metas at this moment solve this problem.

Quoted 1 line

Maybe you can guide me to a better solution ?

Hmm, the current code silently assumes that in the good case there's exactly one used meta (it just picks the first one from the list if decoded_idx is set).

We could list_cut_before() the used metas into a local list, let the decoded_idx code pick the timestamp from that list, and then drop the whole local list of used metas on return from coda_finish_decode().

regards
Philipp