media: iris: misc fixes for fluster, seek and concurrency issues
Subsystems (4)
Dikshita Agarwal
maintainercover media: iris: misc fixes for fluster, seek and concurrency issues
This series contains a set of fixes addressing issues uncovered during fluster test, resolution-change, seek and concurrency on Iris.
---
Dikshita Agarwal (5):
media: iris: Add buffer to list only after successful allocation
media: iris: Skip resolution set on first IPSC
media: iris: gen1: Destroy internal buffers after FW releases Revert "media: iris: Add sanity check for stop streaming"
media: iris: gen2: Add sanity check for session stop
Vishnu Reddy (1):
media: iris: Prevent output buffer queuing before stream-on completes
drivers/media/platform/qcom/iris/iris_buffer.c | 7 +++++-- .../media/platform/qcom/iris/iris_hfi_gen1_command.c | 4 +++- .../media/platform/qcom/iris/iris_hfi_gen2_command.c | 3 +++ drivers/media/platform/qcom/iris/iris_vb2.c | 18 ++++++++++-------- 4 files changed, 21 insertions(+), 11 deletions(-)
---
base-commit: 1f2353f5a1af995efbf7bea44341aa0d03460b28
change-id: 20251216-iris-fixes-4be01def1c7f
Best regards,
Signature · 1 line
Dikshita Agarwal <[email protected]>
Dikshita Agarwal
maintainerPATCH 1/6 media: iris: Add buffer to list only after successful allocation
Move list_add_tail() to after dma_alloc_attrs() succeeds when creating internal buffers. Previously, the buffer was enqueued in buffers->list before the DMA allocation. If the allocation failed, the function returned -ENOMEM while leaving a partially initialized buffer in the list, which could lead to inconsistent state and potential leaks.
By adding the buffer to the list only after dma_alloc_attrs() succeeds, we ensure the list contains only valid, fully initialized buffers.
--- drivers/media/platform/qcom/iris/iris_buffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_buffer.c +5 -2
@@ -351,12 +351,15 @@ static int iris_create_internal_buffer(struct iris_inst *inst, buffer->index = index; buffer->buffer_size = buffers->size; buffer->dma_attrs =DMA_ATTR_WRITE_COMBINE |DMA_ATTR_NO_KERNEL_MAPPING ; -list_add_tail (&buffer->list, &buffers->list); buffer->kvaddr =dma_alloc_attrs (core->dev, buffer->buffer_size, &buffer->device_addr,GFP_KERNEL , buffer->dma_attrs); -if (!buffer->kvaddr) +if (!buffer->kvaddr) { +kfree (buffer);return -ENOMEM ; + } + +list_add_tail (&buffer->list, &buffers->list);return 0 ; }
Signature · 1 line
2.34.1
Re: [PATCH 1/6] media: iris: Add buffer to list only after successful allocation
Quoted 27 lines · Dikshita Agarwal
Move
list_add_tail()to afterdma_alloc_attrs()succeeds when creating internal buffers. Previously, the buffer was enqueued inbuffers->listbefore the DMA allocation. If the allocation failed, the function returned-ENOMEMwhile leaving a partially initialized buffer in the list, which could lead to inconsistent state and potential leaks.By adding the buffer to the list only after
dma_alloc_attrs()succeeds, we ensure the list contains only valid, fully initialized buffers.Signed-off-by Dikshita Agarwal <[email protected]>--- drivers/media/platform/qcom/iris/iris_buffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/media/platform/qcom/iris/iris_buffer.c +0
-1@@ -351,12 +351,15 @@ static int iris_create_internal_buffer(struct iris_inst *inst, buffer->index = index; buffer->buffer_size = buffers->size; buffer->dma_attrs =DMA_ATTR_WRITE_COMBINE |DMA_ATTR_NO_KERNEL_MAPPING ; -list_add_tail (&buffer->list, &buffers->list); buffer->kvaddr =dma_alloc_attrs (core->dev, buffer->buffer_size, &buffer->device_addr,GFP_KERNEL , buffer->dma_attrs);
drivers/media/platform/qcom/iris/iris_buffer.c static int iris_create_internal_buffer(struct iris_inst *inst, · line 365
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_buffer.c +5
-1-if (!buffer->kvaddr) +if (!buffer->kvaddr) { +kfree (buffer);return -ENOMEM ; + } + +list_add_tail (&buffer->list, &buffers->list);return 0 ; }
Missing an appropriate Fixes: tag.
---
bod
Dikshita Agarwal
maintainerPATCH 2/6 media: iris: Skip resolution set on first IPSC
In reply to Dikshita AgarwalThe resolution property is not supposed to be set during reconfig. Existing iris_drc_pending(inst) check is insufficient, as it doesn't cover the first port setting change.
Extend the conditional check to also skip resolution setting when the instance is in IRIS_INST_SUB_FIRST_IPSC.
--- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +1 -1
@@ -733,7 +733,7 @@ static int iris_hfi_gen1_set_resolution(struct iris_inst *inst, u32 plane)struct hfi_framesize fs;int ret; -if (!iris_drc_pending (inst)) { +if (!iris_drc_pending (inst) && !(inst->sub_state &IRIS_INST_SUB_FIRST_IPSC )) { fs.buffer_type =HFI_BUFFER_INPUT ; fs.width = inst->fmt_src->fmt.pix_mp.width; fs.height = inst->fmt_src->fmt.pix_mp.height;
Signature · 1 line
2.34.1
Re: [PATCH 2/6] media: iris: Skip resolution set on first IPSC
Quoted 19 lines · Dikshita Agarwal
The resolution property is not supposed to be set during reconfig. Existing
iris_drc_pending(inst)check is insufficient, as it doesn't cover the first port setting change.Extend the conditional check to also skip resolution setting when the instance is in
IRIS_INST_SUB_FIRST_IPSC.Fixes caf205548769 ("media: iris: Avoid updating frame size to firmware during reconfig")Signed-off-by Dikshita Agarwal <[email protected]>--- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +0
-0
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c static int iris_hfi_gen1_set_resolution(struct iris_inst *inst, u32 plane) · line 739
Quoted 8 lines
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +1
-1@@ -733,7 +733,7 @@ static int iris_hfi_gen1_set_resolution(struct iris_inst *inst, u32 plane)struct hfi_framesize fs;int ret; -if (!iris_drc_pending (inst)) { +if (!iris_drc_pending (inst) && !(inst->sub_state &IRIS_INST_SUB_FIRST_IPSC )) { fs.buffer_type =HFI_BUFFER_INPUT ; fs.width = inst->fmt_src->fmt.pix_mp.width; fs.height = inst->fmt_src->fmt.pix_mp.height;
Take this on trust I guess.
---
bod
Dikshita Agarwal
maintainerPATCH 3/6 media: iris: gen1: Destroy internal buffers after FW releases
In reply to Dikshita AgarwalAfter the firmware releases internal buffers, the driver was not destroying them. This left stale allocations that were no longer used, especially across resolution changes where new buffers are allocated per the updated requirements. As a result, memory was wasted until session close.
Destroy internal buffers once the release response is received from the firmware.
--- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +2 -0
@@ -441,6 +441,8 @@ static int iris_hfi_gen1_session_unset_buffers(struct iris_inst *inst, struct ir goto exit; ret =iris_wait_for_session_response (inst, false); +if (!ret) + ret =iris_destroy_internal_buffer (inst, buf); exit:kfree (pkt);
Signature · 1 line
2.34.1
Re: [PATCH 3/6] media: iris: gen1: Destroy internal buffers after FW releases
Quoted 30 lines · Dikshita Agarwal
After the firmware releases internal buffers, the driver was not destroying them. This left stale allocations that were no longer used, especially across resolution changes where new buffers are allocated per the updated requirements. As a result, memory was wasted until session close.
Destroy internal buffers once the release response is received from the firmware.
Fixes 73702f45db81 ("media: iris: allocate, initialize and queue internal buffers")Signed-off-by Dikshita Agarwal <[email protected]>--- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +2
-1@@ -441,6 +441,8 @@ static int iris_hfi_gen1_session_unset_buffers(struct iris_inst *inst, struct ir goto exit; ret =iris_wait_for_session_response (inst, false); +if (!ret) + ret =iris_destroy_internal_buffer (inst, buf); exit:kfree (pkt); --
Quoted 2 lines
2.34.1
Seems resonable.
---
bod
Dikshita Agarwal
maintainerPATCH 4/6 Revert "media: iris: Add sanity check for stop streaming"
In reply to Dikshita AgarwalRevert the check that skipped stop_streaming when the instance was in IRIS_INST_ERROR, as it caused multiple regressions:
1. Buffers were not returned to vb2 when the instance was already in error state, triggering warnings in the vb2 core because buffer completion was skipped.
2. If a session failed early (e.g. unsupported configuration), the instance transitioned to IRIS_INST_ERROR. When userspace attempted to stop streaming for cleanup, stop_streaming was skipped due to the added check, preventing proper teardown and leaving the firmware in an inconsistent state.
--- drivers/media/platform/qcom/iris/iris_vb2.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/media/platform/qcom/iris/iris_vb2.c +3 -5
@@ -231,8 +231,6 @@ void iris_vb2_stop_streaming(struct vb2_queue *q)return ;mutex_lock (&inst->lock); -if (inst->state ==IRIS_INST_ERROR ) - goto exit;if (!V4L2_TYPE_IS_OUTPUT (q->type) && !V4L2_TYPE_IS_CAPTURE (q->type))
@@ -243,10 +241,10 @@ void iris_vb2_stop_streaming(struct vb2_queue *q) goto exit; exit: -if (ret) { -iris_helper_buffers_done (inst, q->type,VB2_BUF_STATE_ERROR ); +iris_helper_buffers_done (inst, q->type,VB2_BUF_STATE_ERROR ); +if (ret)iris_inst_change_state (inst,IRIS_INST_ERROR ); - } +mutex_unlock (&inst->lock); }
Signature · 1 line
2.34.1
Bryan O'Donoghue
maintainerRe: [PATCH 4/6] Revert "media: iris: Add sanity check for stop streaming"
Quoted 47 lines · Dikshita Agarwal
Revert the check that skipped
stop_streamingwhen the instance was inIRIS_INST_ERROR, as it caused multiple regressions:1. Buffers were not returned to vb2 when the instance was already in error state, triggering warnings in the vb2 core because buffer completion was skipped.
2. If a session failed early (e.g. unsupported configuration), the instance transitioned to
IRIS_INST_ERROR. When userspace attempted to stop streaming for cleanup,stop_streamingwas skipped due to the added check, preventing proper teardown and leaving the firmware in an inconsistent state.Signed-off-by Dikshita Agarwal <[email protected]>--- drivers/media/platform/qcom/iris/iris_vb2.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/media/platform/qcom/iris/iris_vb2.c +3
-6@@ -231,8 +231,6 @@ void iris_vb2_stop_streaming(struct vb2_queue *q)return ;mutex_lock (&inst->lock); -if (inst->state ==IRIS_INST_ERROR ) - goto exit;if (!V4L2_TYPE_IS_OUTPUT (q->type) && !V4L2_TYPE_IS_CAPTURE (q->type))@@ -243,10 +241,10 @@ void iris_vb2_stop_streaming(struct vb2_queue *q) goto exit; exit: -if (ret) { -iris_helper_buffers_done (inst, q->type,VB2_BUF_STATE_ERROR ); +iris_helper_buffers_done (inst, q->type,VB2_BUF_STATE_ERROR ); +if (ret)iris_inst_change_state (inst,IRIS_INST_ERROR ); - } +mutex_unlock (&inst->lock); } --
Quoted 2 lines
2.34.1
A revert like this should very obliviously have a Fixes:
---
bod
Dikshita Agarwal
maintainerPATCH 5/6 media: iris: gen2: Add sanity check for session stop
In reply to Dikshita AgarwalIn iris_kill_session, inst->state is set to IRIS_INST_ERROR and session_close is executed, which will kfree(inst_hfi_gen2->packet). If stop_streaming is called afterward, it will cause a crash.
Add a NULL check for inst_hfi_gen2->packet before sendling STOP packet to firmware to fix that.
--- drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +3 -0
@@ -963,6 +963,9 @@ static int iris_hfi_gen2_session_stop(struct iris_inst *inst, u32 plane)struct iris_inst_hfi_gen2 *inst_hfi_gen2 =to_iris_inst_hfi_gen2 (inst);int ret =0 ; +if (!inst_hfi_gen2->packet) +return -EINVAL ; +reinit_completion (&inst->completion); iris_hfi_gen2_packet_session_command(inst,
Signature · 1 line
2.34.1
Bryan O'Donoghue
maintainerRe: [PATCH 5/6] media: iris: gen2: Add sanity check for session stop
Quoted 28 lines · Dikshita Agarwal
In
iris_kill_session,inst->stateis set toIRIS_INST_ERRORandsession_closeis executed, which willkfree(inst_hfi_gen2->packet). Ifstop_streamingis called afterward, it will cause a crash.Add a NULL check for
inst_hfi_gen2->packetbefore sendling STOP packet to firmware to fix that.Signed-off-by Dikshita Agarwal <[email protected]>--- drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 3 +++ 1 file changed, 3 insertions(+)drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +3
-1@@ -963,6 +963,9 @@ static int iris_hfi_gen2_session_stop(struct iris_inst *inst, u32 plane)struct iris_inst_hfi_gen2 *inst_hfi_gen2 =to_iris_inst_hfi_gen2 (inst);int ret =0 ; +if (!inst_hfi_gen2->packet) +return -EINVAL ; +reinit_completion (&inst->completion); iris_hfi_gen2_packet_session_command(inst, --
Quoted 2 lines
2.34.1
Most of these patches need Fixes: please add.
---
bod
Dikshita Agarwal
maintainerPATCH 6/6 media: iris: Prevent output buffer queuing before stream-on completes
In reply to Dikshita AgarwalFrom: Vishnu Reddy <[email protected]>
During normal playback, stream-on for input is followed by output, and only after input stream-on does actual streaming begin. However, when gst-play performs a seek, both input and output streams are stopped, and on restart, output stream-on occurs first. At this point, firmware has not yet started streaming. Queuing output buffers before the firmware begins streaming causes it to process buffers in an invalid state, leading to an error response. These buffers are returned to the driver as errors, forcing the driver into an error state and stopping playback.
Fix this by deferring output buffer queuing until stream-on completes. Input buffers can still be queued before stream-on as required.
--- drivers/media/platform/qcom/iris/iris_vb2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_vb2.c +7 -3
@@ -193,10 +193,14 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count) buf_type =iris_v4l2_type_to_driver (q->type);if (inst->domain ==DECODER ) { -if (inst->state ==IRIS_INST_STREAMING ) +if (buf_type ==BUF_INPUT ) + ret =iris_queue_deferred_buffers (inst,BUF_INPUT ); + +if (!ret && inst->state ==IRIS_INST_STREAMING ) { ret =iris_queue_internal_deferred_buffers (inst,BUF_DPB ); -if (!ret) - ret =iris_queue_deferred_buffers (inst, buf_type); +if (!ret) + ret =iris_queue_deferred_buffers (inst,BUF_OUTPUT ); + } }else {if (inst->state ==IRIS_INST_STREAMING ) { ret =iris_queue_deferred_buffers (inst,BUF_INPUT );
Signature · 1 line
2.34.1