Skip to contentSkip to conversation

Fix critical bugs

PATCH In review Jackson.lee 2 participants 13 messages Dec 17, 2024 – Feb 3, 2025

Subsystems (2)
lore
Share & tools
lore

Jackson.lee

author maintainer
#0 lore raw

v2 cover Fix critical bugs

iThe wave5 codec driver is a stateful encoder/decoder.
The following patches is for improving decoder performance and fix critical bugs

v4l2-compliance results:
========================

v4l2-compliance 1.26.1-5142, 64 bits, 64-bit time_t

Buffer ioctls:
warn: v4l2-test-buffers.cpp(693): VIDIOC_CREATE_BUFS not supported
warn: v4l2-test-buffers.cpp(693): VIDIOC_CREATE_BUFS not supported
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test CREATE_BUFS maximum buffers: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Total for wave5-dec device /dev/video0: 46, Succeeded: 46, Failed: 0, Warnings: 2 Total for wave5-enc device /dev/video1: 46, Succeeded: 46, Failed: 0, Warnings: 0

Fluster test results:
=====================

Running test suite JCT-VC-HEVC_V1 with decoder GStreamer-H.265-V4L2-Gst1.0 Using 1 parallel job(s)
Ran 132/147 tests successfully in 68.608 secs

(1 test fails because of not supporting to parse multi frames, 1 test fails because of a missing frame and slight corruption,
2 tests fail because of sizes which are incompatible with the IP, 11 tests fail because of unsupported 10 bit format)

Running test suite JVT-AVC_V1 with decoder GStreamer-H.264-V4L2-Gst1.0 Using 1 parallel job(s)
Ran 78/135 tests successfully in 33.238 secs

(57 fail because the hardware is unable to decode MBAFF / FMO / Field / Extended profile streams.)

Change since v1:
=================
* For [PATCH v2 1/4] media: chips-media: wave5: Fix to display gray color
- Add Reviewed-by tag

* For [PATCH v2 2/4] media: chips-media: wave5: Avoid race condition for interrupt handling
- Add Reviewed-by tag

* For [PATCH v2 3/4] media: chips-media: wave5: Fix hang after seeking
- Add Reviewed-by tag

* For [PATCH v2 4/4] media: chips-media: wave5: Fix timeout while testing
- Add Reviewed-by tag

* Drop "media: chips-media: wave5: Improve performance of decoder"
- We will try to send this patch separately next time

Change since v0:
=================

* For [PATCH v1 3/5] media: chips-media: wave5: Improve performance of decoder
- Fix Null reference while testing fluster for more than 2 decoders
- Fix timeout while testing fluster for multi instances

Jackson.lee (4):
media: chips-media: wave5: Fix to display gray color on screen
media: chips-media: wave5: Avoid race condition for interrupt handling
media: chips-media: wave5: Fix hang after seeking
media: chips-media: wave5: Fix timeout while testing 10bit hevc
fluster

 .../platform/chips-media/wave5/wave5-hw.c     |  2 +-
 .../chips-media/wave5/wave5-vpu-dec.c         | 31 ++++++++++++++++++-
 .../platform/chips-media/wave5/wave5-vpu.c    |  4 +--
 .../platform/chips-media/wave5/wave5-vpuapi.c | 10 ++++++
 4 files changed, 43 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/4 media: chips-media: wave5: Fix to display gray color on screen

When a decoder instance is created, W5_CMD_ERR_CONCEAL register should be initialized to 0. If not set to 0, gray color can occasionally be displayed on screen while decoding.

---
 drivers/media/platform/chips-media/wave5/wave5-hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-hw.c +1 -1
index c8a905994109..d94cf84c3ee5 100644
@@ -585,7 +585,7 @@ int wave5_vpu_build_up_dec_param(struct vpu_instance *inst,
 		vpu_write_reg(inst->dev, W5_CMD_NUM_CQ_DEPTH_M1,
 			      WAVE521_COMMAND_QUEUE_DEPTH - 1);
 	}
-
+	vpu_write_reg(inst->dev, W5_CMD_ERR_CONCEAL, 0);
 	ret = send_firmware_command(inst, W5_CREATE_INSTANCE, true, NULL, NULL);
 	if (ret) {
 		wave5_vdi_free_dma_memory(vpu_dev, &p_dec_info->vb_work);
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v2 1/4] media: chips-media: wave5: Fix to display gray color on screen

Hi,

Le mardi 17 décembre 2024 à 13:51 +0900, Jackson.lee a écrit :

Quoted 7 lines

When a decoder instance is created, W5_CMD_ERR_CONCEAL register should be initialized to 0. If not set to 0, gray color can occasionally be displayed on screen while decoding.

You forgot to add Fixes: tags, can you find back which commit you fix, and send us the correctly formatted tag ? This will avoid the need of a resend.

Nicolas

Quoted 17 lines
---
 drivers/media/platform/chips-media/wave5/wave5-hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-hw.c +1 -1
index c8a905994109..d94cf84c3ee5 100644
@@ -585,7 +585,7 @@ int wave5_vpu_build_up_dec_param(struct vpu_instance *inst,
 		vpu_write_reg(inst->dev, W5_CMD_NUM_CQ_DEPTH_M1,
 			      WAVE521_COMMAND_QUEUE_DEPTH - 1);
 	}
-
+	vpu_write_reg(inst->dev, W5_CMD_ERR_CONCEAL, 0);
 	ret = send_firmware_command(inst, W5_CREATE_INSTANCE, true, NULL, NULL);
 	if (ret) {
 		wave5_vdi_free_dma_memory(vpu_dev, &p_dec_info->vb_work);
author maintainer
#3 lore raw

RE: [PATCH v2 1/4] media: chips-media: wave5: Fix to display gray color on screen

Hi Nicolas

Quoted 19 lines

-----Original Message-----
From: Nicolas Dufresne <[email protected]>
Sent: Tuesday, December 17, 2024 11:04 PM
To: jackson.lee <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; lafley.kim <[email protected]>; [email protected]; [email protected]; Nas Chung <[email protected]>
Subject: Re: [PATCH v2 1/4] media: chips-media: wave5: Fix to display gray color on screen

Hi,

Le mardi 17 décembre 2024 à 13:51 +0900, Jackson.lee a écrit :

Quoted 4 lines

When a decoder instance is created, W5_CMD_ERR_CONCEAL register should be initialized to 0. If not set to 0, gray color can occasionally be displayed on screen while decoding.

Quoted 8 lines
Quoted 3 lines

You forgot to add Fixes: tags, can you find back which commit you fix, and send us the correctly formatted tag ? This will avoid the need of a resend.

Nicolas

Thanks for your advice.

Fixes 45d1a2b93277 ("media: chips-media: wave5: Add vpuapi layer")

Thanks

Quoted 21 lines

drivers/media/platform/chips-media/wave5/wave5-hw.c int wave5_vpu_build_up_dec_param(struct vpu_instance

Quoted 11 lines
---
 drivers/media/platform/chips-media/wave5/wave5-hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-hw.c +0 -0
index c8a905994109..d94cf84c3ee5 100644
@@ -585,7 +585,7 @@ int wave5_vpu_build_up_dec_param(struct vpu_instance

*inst,

drivers/media/platform/chips-media/wave5/wave5-hw.c int wave5_vpu_build_up_dec_param(struct vpu_instance *inst,

Quoted 6 lines
drivers/media/platform/chips-media/wave5/wave5-hw.c +1 -1
 		vpu_write_reg(inst->dev, W5_CMD_NUM_CQ_DEPTH_M1,
 			      WAVE521_COMMAND_QUEUE_DEPTH - 1);
 	}
-
+	vpu_write_reg(inst->dev, W5_CMD_ERR_CONCEAL, 0);
 	ret = send_firmware_command(inst, W5_CREATE_INSTANCE, true, NULL,

NULL);

Quoted 2 lines
drivers/media/platform/chips-media/wave5/wave5-hw.c +0 -0
 	if (ret) {
 		wave5_vdi_free_dma_memory(vpu_dev, &p_dec_info->vb_work);
author maintainer
#4 lore raw

PATCH v2 2/4 media: chips-media: wave5: Avoid race condition for interrupt handling

In reply to Jackson.lee

In case of multi instance, interrupts can occur for other instances as soon as interrupt is cleared. If driver reads the instance_info after clearing the interrupt, it is not guaranteed that the instance_info is valid for the current interrupt.

Read the instance_info register for each interrupt before clearing the interrupt.

---
 drivers/media/platform/chips-media/wave5/wave5-vpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +2 -2
index 6b294a2d6717..63a607d10433 100644
@@ -55,12 +55,12 @@ static void wave5_vpu_handle_irq(void *dev_id)
 	struct vpu_device *dev = dev_id;
 
 	irq_reason = wave5_vdi_read_register(dev, W5_VPU_VINT_REASON);
+	seq_done = wave5_vdi_read_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO);
+	cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST);
 	wave5_vdi_write_register(dev, W5_VPU_VINT_REASON_CLR, irq_reason);
 	wave5_vdi_write_register(dev, W5_VPU_VINT_CLEAR, 0x1);
 
 	list_for_each_entry(inst, &dev->instances, list) {
-		seq_done = wave5_vdi_read_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO);
-		cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST);
 
 		if (irq_reason & BIT(INT_WAVE5_INIT_SEQ) ||
 		    irq_reason & BIT(INT_WAVE5_ENC_SET_PARAM)) {
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH v2 2/4] media: chips-media: wave5: Avoid race condition for interrupt handling

Le mardi 17 décembre 2024 à 13:51 +0900, Jackson.lee a écrit :

Quoted 11 lines

In case of multi instance, interrupts can occur for other instances as soon as interrupt is cleared. If driver reads the instance_info after clearing the interrupt, it is not guaranteed that the instance_info is valid for the current interrupt.

Read the instance_info register for each interrupt before clearing the interrupt.

Same, what is the Fixes tag ?

Quoted 23 lines
---
 drivers/media/platform/chips-media/wave5/wave5-vpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +2 -2
index 6b294a2d6717..63a607d10433 100644
@@ -55,12 +55,12 @@ static void wave5_vpu_handle_irq(void *dev_id)
 	struct vpu_device *dev = dev_id;
 
 	irq_reason = wave5_vdi_read_register(dev, W5_VPU_VINT_REASON);
+	seq_done = wave5_vdi_read_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO);
+	cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST);
 	wave5_vdi_write_register(dev, W5_VPU_VINT_REASON_CLR, irq_reason);
 	wave5_vdi_write_register(dev, W5_VPU_VINT_CLEAR, 0x1);
 
 	list_for_each_entry(inst, &dev->instances, list) {
-		seq_done = wave5_vdi_read_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO);
-		cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST);
 
 		if (irq_reason & BIT(INT_WAVE5_INIT_SEQ) ||
 		    irq_reason & BIT(INT_WAVE5_ENC_SET_PARAM)) {
author maintainer
#6 lore raw

RE: [PATCH v2 2/4] media: chips-media: wave5: Avoid race condition for interrupt handling

Hi Nicolas

Quoted 18 lines

-----Original Message-----
From: Nicolas Dufresne <[email protected]>
Sent: Tuesday, December 17, 2024 11:04 PM
To: jackson.lee <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; lafley.kim <[email protected]>; [email protected]; [email protected]; Nas Chung <[email protected]>
Subject: Re: [PATCH v2 2/4] media: chips-media: wave5: Avoid race condition for interrupt handling

Le mardi 17 décembre 2024 à 13:51 +0900, Jackson.lee a écrit :

Quoted 5 lines

In case of multi instance, interrupts can occur for other instances as soon as interrupt is cleared. If driver reads the instance_info after clearing the interrupt, it is not guaranteed that the instance_info is valid for the current interrupt.

Quoted 8 lines
Quoted 6 lines

Read the instance_info register for each interrupt before clearing the interrupt.

Same, what is the Fixes tag ?

Fixes ed7276ed2fd0 ("media: chips-media: wave5: Add hrtimer based polling support")

thanks

Quoted 28 lines
Quoted 11 lines
---
 drivers/media/platform/chips-media/wave5/wave5-vpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -0
index 6b294a2d6717..63a607d10433 100644

drivers/media/platform/chips-media/wave5/wave5-vpu.c static void wave5_vpu_handle_irq(void *dev_id) · line 58

Quoted 4 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +1 -0
@@ -55,12 +55,12 @@ static void wave5_vpu_handle_irq(void *dev_id)
 	struct vpu_device *dev = dev_id;
 
 	irq_reason = wave5_vdi_read_register(dev, W5_VPU_VINT_REASON);
+	seq_done = wave5_vdi_read_register(dev,

W5_RET_SEQ_DONE_INSTANCE_INFO);

drivers/media/platform/chips-media/wave5/wave5-vpu.c static void wave5_vpu_handle_irq(void *dev_id)

Quoted 6 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +1 -1
+	cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST);
 	wave5_vdi_write_register(dev, W5_VPU_VINT_REASON_CLR, irq_reason);
 	wave5_vdi_write_register(dev, W5_VPU_VINT_CLEAR, 0x1);
 
 	list_for_each_entry(inst, &dev->instances, list) {
-		seq_done = wave5_vdi_read_register(dev,

W5_RET_SEQ_DONE_INSTANCE_INFO);

drivers/media/platform/chips-media/wave5/wave5-vpu.c static void wave5_vpu_handle_irq(void *dev_id) · line 63

Quoted 1 line
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -1
-		cmd_done = wave5_vdi_read_register(dev,

W5_RET_QUEUE_CMD_DONE_INST);

Quoted 3 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -0
 		if (irq_reason & BIT(INT_WAVE5_INIT_SEQ) ||
 		    irq_reason & BIT(INT_WAVE5_ENC_SET_PARAM)) {
author maintainer
#7 lore raw

PATCH v2 3/4 media: chips-media: wave5: Fix hang after seeking

In reply to Jackson.lee

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.

---
 .../platform/chips-media/wave5/wave5-vpu-dec.c  | 17 ++++++++++++++++-
 .../platform/chips-media/wave5/wave5-vpuapi.c   | 10 ++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +16 -1
index d3ff420c52ce..882d5539630f 100644
@@ -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);
drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +10 -0
index e16b990041c2..e5e879a13e8b 100644
@@ -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);
Signature · 1 line
2.43.0
#8 lore raw

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 :

Quoted 7 lines

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.

This one too please.

Quoted 68 lines
---
 .../platform/chips-media/wave5/wave5-vpu-dec.c  | 17 ++++++++++++++++-
 .../platform/chips-media/wave5/wave5-vpuapi.c   | 10 ++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +16 -1
index d3ff420c52ce..882d5539630f 100644
@@ -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);
drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +10 -0
index e16b990041c2..e5e879a13e8b 100644
@@ -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);
author maintainer
#9 lore raw

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

Hi Nicolas

Quoted 17 lines

-----Original Message-----
From: Nicolas Dufresne <[email protected]>
Sent: Tuesday, December 17, 2024 11:05 PM
To: jackson.lee <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; lafley.kim <[email protected]>; [email protected]; [email protected]; Nas Chung <[email protected]>
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 :

Quoted 4 lines

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.

Quoted 5 lines
Quoted 3 lines

This one too please.

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

thanks

Quoted 80 lines
Quoted 13 lines
---
 .../platform/chips-media/wave5/wave5-vpu-dec.c  | 17 ++++++++++++++++-
 .../platform/chips-media/wave5/wave5-vpuapi.c   | 10 ++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +0 -0
index d3ff420c52ce..882d5539630f 100644
@@ -1369,6 +1369,16 @@ static int streamoff_output(struct vb2_queue *q)
 	struct vb2_v4l2_buffer *buf;

drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c static int streamoff_output(struct vb2_queue *q) · line 1379

Quoted 10 lines
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +8 -0
 	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",

drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c static int streamoff_output(struct vb2_queue *q)

Quoted 5 lines
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +2 -0
+				__func__, i, ret);
+	}
 
 	while ((buf = v4l2_m2m_src_buf_remove(m2m_ctx))) {
 		dev_dbg(inst->dev->dev, "%s: (Multiplanar) buf type %4u |

index

Quoted 1 line

%4u\n", @@ -1376,6 +1386,11 @@ static int streamoff_output(struct

vb2_queue *q)

drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c static int streamoff_output(struct vb2_queue *q)

Quoted 6 lines
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +3 -0
 		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);

drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c static void wave5_vpu_dec_stop_streaming(struct

Quoted 6 lines
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +2 -0
+	}
+
 	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)

drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c static void wave5_vpu_dec_stop_streaming(struct vb2_queue *q)

Quoted 4 lines
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +0 -1
 			break;
 
 		if (wave5_vpu_dec_get_output_info(inst, &dec_output_info))
-			dev_dbg(inst->dev->dev, "Getting decoding results from

fw, fail\n");

drivers/media/platform/chips-media/wave5/wave5-vpuapi.c int wave5_vpu_flush_instance(struct vpu_instance

Quoted 10 lines
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +1 -0
+			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

drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +0 -0
@@ -75,6 +75,16 @@ int wave5_vpu_flush_instance(struct vpu_instance

*inst)

drivers/media/platform/chips-media/wave5/wave5-vpuapi.c int wave5_vpu_flush_instance(struct vpu_instance · line 75

Quoted 1 line
drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +0 -0
 				 inst->type == VPU_INST_TYPE_DEC ? "DECODER" :

"ENCODER", inst->id);

drivers/media/platform/chips-media/wave5/wave5-vpuapi.c int wave5_vpu_flush_instance(struct vpu_instance *inst)

Quoted 12 lines
drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +10 -0
 			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);

Quoted 3 lines
drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +0 -0
 		}
 	} while (ret != 0);
 	mutex_unlock(&inst->dev->hw_lock);
author maintainer
#10 lore raw

PATCH v2 4/4 media: chips-media: wave5: Fix timeout while testing 10bit hevc fluster

In reply to Jackson.lee

521C Wave5 variant does not support 10 bit. When 10 bit support for 515 variant was added, the code which returns an error was removed. While testing 10bit hevc fluster on the 521C hw, timeout happened.

Fixes 143e7ab4d9a0 ("media: chips-media: wave5: support decoding HEVC Main10 profile")
---
 .../platform/chips-media/wave5/wave5-vpu-dec.c     | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +14 -0
index 882d5539630f..fd71f0c43ac3 100644
@@ -1345,10 +1345,24 @@ static int wave5_vpu_dec_start_streaming(struct vb2_queue *q, unsigned int count
 		if (ret)
 			goto free_bitstream_vbuf;
 	} else if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+		struct dec_initial_info *initial_info =
+			&inst->codec_info->dec_info.initial_info;
+
 		if (inst->state == VPU_INST_STATE_STOP)
 			ret = switch_state(inst, VPU_INST_STATE_INIT_SEQ);
 		if (ret)
 			goto return_buffers;
+
+		if (inst->state == VPU_INST_STATE_INIT_SEQ &&
+		    inst->dev->product_code == WAVE521C_CODE) {
+			if (initial_info->luma_bitdepth != 8) {
+				dev_info(inst->dev->dev, "%s: no support for %d bit depth",
+					 __func__, initial_info->luma_bitdepth);
+				ret = -EINVAL;
+				goto return_buffers;
+			}
+		}
+
 	}
 	pm_runtime_mark_last_busy(inst->dev->dev);
 	pm_runtime_put_autosuspend(inst->dev->dev);
Signature · 1 line
2.43.0
author maintainer
#11 lore raw
In reply to Jackson.lee

Hi Sebastian and Nicolas

Can you review the following patch series?

https://patchwork.linuxtv.org/project/linux-media/cover/[email protected]/

thanks
Jackson

Quoted 98 lines

-----Original Message-----
From: jackson.lee
Sent: Tuesday, December 17, 2024 1:52 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; jackson.lee <[email protected]>; lafley.kim <[email protected]>; b- [email protected]; [email protected]; Nas Chung <[email protected]>
Subject: [PATCH v2 0/4] Fix critical bugs

iThe wave5 codec driver is a stateful encoder/decoder. The following patches is for improving decoder performance and fix critical bugs

v4l2-compliance results:
========================

v4l2-compliance 1.26.1-5142, 64 bits, 64-bit time_t

Buffer ioctls:
warn: v4l2-test-buffers.cpp(693): VIDIOC_CREATE_BUFS not
supported
warn: v4l2-test-buffers.cpp(693): VIDIOC_CREATE_BUFS not
supported
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test CREATE_BUFS maximum buffers: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Total for wave5-dec device /dev/video0: 46, Succeeded: 46, Failed: 0,
Warnings: 2 Total for wave5-enc device /dev/video1: 46, Succeeded: 46,
Failed: 0, Warnings: 0

Fluster test results:
=====================

Running test suite JCT-VC-HEVC_V1 with decoder GStreamer-H.265-V4L2-Gst1.0 Using 1 parallel job(s)
Ran 132/147 tests successfully in 68.608 secs

(1 test fails because of not supporting to parse multi frames, 1 test fails because of a missing frame and slight corruption,
2 tests fail because of sizes which are incompatible with the IP, 11
tests fail because of unsupported 10 bit format)

Running test suite JVT-AVC_V1 with decoder GStreamer-H.264-V4L2-Gst1.0 Using 1 parallel job(s)
Ran 78/135 tests successfully in 33.238 secs

(57 fail because the hardware is unable to decode MBAFF / FMO / Field / Extended profile streams.)

Change since v1:
=================
* For [PATCH v2 1/4] media: chips-media: wave5: Fix to display gray color
- Add Reviewed-by tag

* For [PATCH v2 2/4] media: chips-media: wave5: Avoid race condition for interrupt handling
- Add Reviewed-by tag

* For [PATCH v2 3/4] media: chips-media: wave5: Fix hang after seeking
- Add Reviewed-by tag

* For [PATCH v2 4/4] media: chips-media: wave5: Fix timeout while testing
- Add Reviewed-by tag

* Drop "media: chips-media: wave5: Improve performance of decoder"
- We will try to send this patch separately next time

Change since v0:
=================

* For [PATCH v1 3/5] media: chips-media: wave5: Improve performance of decoder
- Fix Null reference while testing fluster for more than 2 decoders
- Fix timeout while testing fluster for multi instances

Jackson.lee (4):
media: chips-media: wave5: Fix to display gray color on screen
media: chips-media: wave5: Avoid race condition for interrupt handling
media: chips-media: wave5: Fix hang after seeking
media: chips-media: wave5: Fix timeout while testing 10bit hevc
fluster

 .../platform/chips-media/wave5/wave5-hw.c     |  2 +-
 .../chips-media/wave5/wave5-vpu-dec.c         | 31 ++++++++++++++++++-
 .../platform/chips-media/wave5/wave5-vpu.c    |  4 +--
 .../platform/chips-media/wave5/wave5-vpuapi.c | 10 ++++++
 4 files changed, 43 insertions(+), 4 deletions(-)

--
2.43.0

author maintainer
#12 lore raw

Hi Sebastian and Nicolas

Is there any thing for me to do for these patch series ?

Thanks
Jackson

Quoted 122 lines

-----Original Message-----
From: jackson.lee
Sent: Tuesday, January 7, 2025 10:39 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; lafley.kim <[email protected]>; [email protected]; [email protected]; Nas Chung <[email protected]>
Subject: RE: [PATCH v2 0/4] Fix critical bugs

Hi Sebastian and Nicolas

Can you review the following patch series?

https://patchwork.linuxtv.org/project/linux-media/cover/20241217045125.58-
[email protected]/

thanks
Jackson

Quoted 51 lines

-----Original Message-----
From: jackson.lee
Sent: Tuesday, December 17, 2024 1:52 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; jackson.lee <[email protected]>; lafley.kim <[email protected]>; b- [email protected]; [email protected]; Nas Chung <[email protected]>
Subject: [PATCH v2 0/4] Fix critical bugs

iThe wave5 codec driver is a stateful encoder/decoder. The following patches is for improving decoder performance and fix critical bugs

v4l2-compliance results:
========================

v4l2-compliance 1.26.1-5142, 64 bits, 64-bit time_t

Buffer ioctls:

                warn: v4l2-test-buffers.cpp(693): VIDIOC_CREATE_BUFS
not supported
                warn: v4l2-test-buffers.cpp(693): VIDIOC_CREATE_BUFS

not supported
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Total for wave5-dec device /dev/video0: 46, Succeeded: 46, Failed: 0,
Warnings: 2 Total for wave5-enc device /dev/video1: 46, Succeeded: 46,
Failed: 0, Warnings: 0

Fluster test results:
=====================

Running test suite JCT-VC-HEVC_V1 with decoder GStreamer-H.265-V4L2-Gst1.0 Using 1 parallel job(s)
Ran 132/147 tests successfully in 68.608 secs

(1 test fails because of not supporting to parse multi frames, 1 test fails because of a missing frame and slight corruption,
2 tests fail because of sizes which are incompatible with the IP, 11
tests fail because of unsupported 10 bit format)

Running test suite JVT-AVC_V1 with decoder GStreamer-H.264-V4L2-Gst1.0 Using 1 parallel job(s)
Ran 78/135 tests successfully in 33.238 secs

Quoted 6 lines

(57 fail because the hardware is unable to decode MBAFF / FMO / Field / Extended profile streams.)

Change since v1:
=================
* For [PATCH v2 1/4] media: chips-media: wave5: Fix to display gray

color

Quoted 10 lines

- Add Reviewed-by tag

* For [PATCH v2 2/4] media: chips-media: wave5: Avoid race condition for interrupt handling
- Add Reviewed-by tag

* For [PATCH v2 3/4] media: chips-media: wave5: Fix hang after seeking
- Add Reviewed-by tag

* For [PATCH v2 4/4] media: chips-media: wave5: Fix timeout while

testing

Quoted 32 lines

- Add Reviewed-by tag

* Drop "media: chips-media: wave5: Improve performance of decoder"
- We will try to send this patch separately next time

Change since v0:
=================

* For [PATCH v1 3/5] media: chips-media: wave5: Improve performance of decoder
- Fix Null reference while testing fluster for more than 2 decoders
- Fix timeout while testing fluster for multi instances

Jackson.lee (4):
media: chips-media: wave5: Fix to display gray color on screen
media: chips-media: wave5: Avoid race condition for interrupt handling
media: chips-media: wave5: Fix hang after seeking
media: chips-media: wave5: Fix timeout while testing 10bit hevc
fluster

 .../platform/chips-media/wave5/wave5-hw.c     |  2 +-
 .../chips-media/wave5/wave5-vpu-dec.c         | 31 ++++++++++++++++++-
 .../platform/chips-media/wave5/wave5-vpu.c    |  4 +--
 .../platform/chips-media/wave5/wave5-vpuapi.c | 10 ++++++
 4 files changed, 43 insertions(+), 4 deletions(-)

--
2.43.0