Skip to contentSkip to conversation

media: venus: vdec: fix error state assignment for zero bytesused

PATCH In review Renjiang Han 3 participants 4 messages Dec 11, 2025 – Dec 12, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 media: venus: vdec: fix error state assignment for zero bytesused

When hfi_session_flush is issued, all queued buffers are returned to the V4L2 driver. Some of these buffers are not processed and have bytesused = 0. Currently, the driver marks such buffers as error even during drain operations, which can incorrectly flag EOS buffers.

Only capture buffers with zero payload (and not EOS) should be marked with VB2_BUF_STATE_ERROR. The check is performed inside the non-EOS branch to ensure correct handling.

Fixes 51df3c81ba10b ("media: venus: vdec: Mark flushed buffers with error state")

---
The error state assignment in the Venus vdec driver for Qualcomm
platforms is updated to ensure that VB2_BUF_STATE_ERROR is applied
only to non-EOS capture buffers with zero bytesused. Ensures false
error reports do not occur during drain operations.
---
Changes in v3:
- 1, Update commit message.
- 2, Move empty line between tags.
- 3, Update cover letter message.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- 1. Update commit message.
- 2. Add a Fixes tag.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/media/platform/qcom/venus/vdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/vdec.c +3 -3
index 4a6641fdffcf79705893be58c7ec5cf485e2fab9..d0bd2d86a31f9a18cb68b08ba66affdf8fc5092d 100644
@@ -1440,10 +1440,10 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type,
 				inst->drain_active = false;
 				inst->codec_state = VENUS_DEC_STATE_STOPPED;
 			}
+		} else {
+			if (!bytesused)
+				state = VB2_BUF_STATE_ERROR;
 		}
-
-		if (!bytesused)
-			state = VB2_BUF_STATE_ERROR;
 	} else {
 		vbuf->sequence = inst->sequence_out++;
 	}

---
base-commit: 663d0d1af3faefe673cabf4b6b077149a87ad71f
change-id: 20251126-fix-error-state-24183a8538cd

Best regards,

Signature · 1 line
Renjiang Han <[email protected]>
maintainer
#1 lore raw
Quoted 54 lines · Renjiang Han

When hfi_session_flush is issued, all queued buffers are returned to the V4L2 driver. Some of these buffers are not processed and have bytesused = 0. Currently, the driver marks such buffers as error even during drain operations, which can incorrectly flag EOS buffers.

Only capture buffers with zero payload (and not EOS) should be marked with VB2_BUF_STATE_ERROR. The check is performed inside the non-EOS branch to ensure correct handling.

Fixes 51df3c81ba10b ("media: venus: vdec: Mark flushed buffers with error state")

---
The error state assignment in the Venus vdec driver for Qualcomm
platforms is updated to ensure that VB2_BUF_STATE_ERROR is applied
only to non-EOS capture buffers with zero bytesused. Ensures false
error reports do not occur during drain operations.
---
Changes in v3:
- 1, Update commit message.
- 2, Move empty line between tags.
- 3, Update cover letter message.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- 1. Update commit message.
- 2. Add a Fixes tag.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
  drivers/media/platform/qcom/venus/vdec.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/vdec.c +3 -4
index 4a6641fdffcf79705893be58c7ec5cf485e2fab9..d0bd2d86a31f9a18cb68b08ba66affdf8fc5092d 100644
@@ -1440,10 +1440,10 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type,
  				inst->drain_active = false;
  				inst->codec_state = VENUS_DEC_STATE_STOPPED;
  			}
+		} else {
+			if (!bytesused)
+				state = VB2_BUF_STATE_ERROR;
  		}
-
-		if (!bytesused)
-			state = VB2_BUF_STATE_ERROR;
  	} else {
  		vbuf->sequence = inst->sequence_out++;
  	}
 
---

base-commit: 663d0d1af3faefe673cabf4b6b077149a87ad71f
change-id: 20251126-fix-error-state-24183a8538cd

Quoted 4 lines

Best regards,
--
Renjiang Han <[email protected]>

Dikshita, Vikash.

This change makes sense to me. If you are NAKing please do so now.

---
bod

maintainer
#2 lore raw

Hi Bryan,

Quoted 58 lines · Bryan O'Donoghue
Quoted 57 lines · Renjiang Han

When hfi_session_flush is issued, all queued buffers are returned to the V4L2 driver. Some of these buffers are not processed and have bytesused = 0. Currently, the driver marks such buffers as error even during drain operations, which can incorrectly flag EOS buffers.

Only capture buffers with zero payload (and not EOS) should be marked with VB2_BUF_STATE_ERROR. The check is performed inside the non-EOS branch to ensure correct handling.

Fixes 51df3c81ba10b ("media: venus: vdec: Mark flushed buffers with error state")

---
The error state assignment in the Venus vdec driver for Qualcomm platforms is updated to ensure that VB2_BUF_STATE_ERROR is applied only to non-EOS capture buffers with zero bytesused. Ensures false error reports do not occur during drain operations.
---
Changes in v3:
- 1, Update commit message.
- 2, Move empty line between tags.
- 3, Update cover letter message.
- Link to v2: https://lore.kernel.org/r/20251208-fix-error-state-
[email protected]

Changes in v2:
- 1. Update commit message.
- 2. Add a Fixes tag.
- Link to v1: https://lore.kernel.org/r/20251126-fix-error-state-
[email protected]
---
  drivers/media/platform/qcom/venus/vdec.c | 6 +++---

  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/vdec.c +3 -3
index 4a6641fdffcf79705893be58c7ec5cf485e2fab9..d0bd2d86a31f9a18cb68b08ba66affdf8fc5092d 100644
@@ -1440,10 +1440,10 @@ static void vdec_buf_done(struct venus_inst 
 *inst, unsigned int buf_type,
                   inst->drain_active = false;
                   inst->codec_state = VENUS_DEC_STATE_STOPPED;
               }
+        } else {
+            if (!bytesused)
+                state = VB2_BUF_STATE_ERROR;
           }
-
-        if (!bytesused)
-            state = VB2_BUF_STATE_ERROR;
       } else {
           vbuf->sequence = inst->sequence_out++;

      }

---
base-commit: 663d0d1af3faefe673cabf4b6b077149a87ad71f
change-id: 20251126-fix-error-state-24183a8538cd

Quoted 9 lines
Quoted 4 lines

Best regards,

Signature · 1 line
Renjiang Han <[email protected]>

Dikshita, Vikash.

This change makes sense to me. If you are NAKing please do so now.

This is good to go.

Regards,
Vikash

maintainer Reviewed-by on v3 1/1
#3 lore raw
In reply to Renjiang Han
Quoted 41 lines · Renjiang Han

When hfi_session_flush is issued, all queued buffers are returned to the V4L2 driver. Some of these buffers are not processed and have bytesused = 0. Currently, the driver marks such buffers as error even during drain operations, which can incorrectly flag EOS buffers.

Only capture buffers with zero payload (and not EOS) should be marked with VB2_BUF_STATE_ERROR. The check is performed inside the non-EOS branch to ensure correct handling.

Fixes 51df3c81ba10b ("media: venus: vdec: Mark flushed buffers with error state")

---
The error state assignment in the Venus vdec driver for Qualcomm
platforms is updated to ensure that VB2_BUF_STATE_ERROR is applied
only to non-EOS capture buffers with zero bytesused. Ensures false
error reports do not occur during drain operations.
---
Changes in v3:
- 1, Update commit message.
- 2, Move empty line between tags.
- 3, Update cover letter message.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- 1. Update commit message.
- 2. Add a Fixes tag.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
  drivers/media/platform/qcom/venus/vdec.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/vdec.c +2 -0
index 4a6641fdffcf79705893be58c7ec5cf485e2fab9..d0bd2d86a31f9a18cb68b08ba66affdf8fc5092d 100644
@@ -1440,10 +1440,10 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type,
  				inst->drain_active = false;
  				inst->codec_state = VENUS_DEC_STATE_STOPPED;
  			}
+		} else {
+			if (!bytesused)

drivers/media/platform/qcom/venus/vdec.c static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type,

Quoted 10 lines
drivers/media/platform/qcom/venus/vdec.c +1 -4
+				state = VB2_BUF_STATE_ERROR;
  		}
-
-		if (!bytesused)
-			state = VB2_BUF_STATE_ERROR;
  	} else {
  		vbuf->sequence = inst->sequence_out++;
  	}
 
---