Skip to content

Commit 7309f62

Browse files
Dikshita Agarwalgregkh
authored andcommitted
media: iris: Track flush responses to prevent premature completion
commit 9bf58db upstream. Currently, two types of flush commands are queued to the firmware, the first flush queued as part of sequence change, does not wait for a response, while the second flush queued as part of stop, expects a completion response before proceeding further. Due to timing issue, the flush response corresponding to the first command could arrive after the second flush is issued. This casuses the driver to incorrectly assume that the second flush has completed, leading to the premature signaling of flush_completion. To address this, introduce a counter to track the number of pending flush responses and signal flush completion only when all expected responses are received. Cc: stable@vger.kernel.org Fixes: 11712ce ("media: iris: implement vb2 streaming ops") Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-HDK Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-QRD Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com> Tested-by: Vikash Garodia <quic_vgarodia@quicinc.com> # on sa8775p-ride Signed-off-by: Bryan O'Donoghue <bod@kernel.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fcb27af commit 7309f62

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,10 @@ static int iris_hfi_gen1_session_stop(struct iris_inst *inst, u32 plane)
208208
flush_pkt.flush_type = flush_type;
209209

210210
ret = iris_hfi_queue_cmd_write(core, &flush_pkt, flush_pkt.shdr.hdr.size);
211-
if (!ret)
211+
if (!ret) {
212+
inst->flush_responses_pending++;
212213
ret = iris_wait_for_session_response(inst, true);
214+
}
213215
}
214216

215217
return ret;

drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ static void iris_hfi_gen1_event_seq_changed(struct iris_inst *inst,
207207
flush_pkt.shdr.hdr.pkt_type = HFI_CMD_SESSION_FLUSH;
208208
flush_pkt.shdr.session_id = inst->session_id;
209209
flush_pkt.flush_type = HFI_FLUSH_OUTPUT;
210-
iris_hfi_queue_cmd_write(inst->core, &flush_pkt, flush_pkt.shdr.hdr.size);
210+
if (!iris_hfi_queue_cmd_write(inst->core, &flush_pkt, flush_pkt.shdr.hdr.size))
211+
inst->flush_responses_pending++;
211212
}
212213

213214
iris_vdec_src_change(inst);
@@ -408,7 +409,9 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_inst *inst, void *packet)
408409
flush_pkt.shdr.hdr.pkt_type = HFI_CMD_SESSION_FLUSH;
409410
flush_pkt.shdr.session_id = inst->session_id;
410411
flush_pkt.flush_type = HFI_FLUSH_OUTPUT;
411-
iris_hfi_queue_cmd_write(core, &flush_pkt, flush_pkt.shdr.hdr.size);
412+
if (!iris_hfi_queue_cmd_write(core, &flush_pkt, flush_pkt.shdr.hdr.size))
413+
inst->flush_responses_pending++;
414+
412415
iris_inst_sub_state_change_drain_last(inst);
413416

414417
return;
@@ -564,7 +567,6 @@ static void iris_hfi_gen1_handle_response(struct iris_core *core, void *response
564567
const struct iris_hfi_gen1_response_pkt_info *pkt_info;
565568
struct device *dev = core->dev;
566569
struct hfi_session_pkt *pkt;
567-
struct completion *done;
568570
struct iris_inst *inst;
569571
bool found = false;
570572
u32 i;
@@ -625,9 +627,12 @@ static void iris_hfi_gen1_handle_response(struct iris_core *core, void *response
625627
if (shdr->error_type != HFI_ERR_NONE)
626628
iris_inst_change_state(inst, IRIS_INST_ERROR);
627629

628-
done = pkt_info->pkt == HFI_MSG_SESSION_FLUSH ?
629-
&inst->flush_completion : &inst->completion;
630-
complete(done);
630+
if (pkt_info->pkt == HFI_MSG_SESSION_FLUSH) {
631+
if (!(--inst->flush_responses_pending))
632+
complete(&inst->flush_completion);
633+
} else {
634+
complete(&inst->completion);
635+
}
631636
}
632637
mutex_unlock(&inst->lock);
633638

drivers/media/platform/qcom/iris/iris_instance.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @crop: structure of crop info
2828
* @completion: structure of signal completions
2929
* @flush_completion: structure of signal completions for flush cmd
30+
* @flush_responses_pending: counter to track number of pending flush responses
3031
* @fw_caps: array of supported instance firmware capabilities
3132
* @buffers: array of different iris buffers
3233
* @fw_min_count: minimnum count of buffers needed by fw
@@ -57,6 +58,7 @@ struct iris_inst {
5758
struct iris_hfi_rect_desc crop;
5859
struct completion completion;
5960
struct completion flush_completion;
61+
u32 flush_responses_pending;
6062
struct platform_inst_fw_cap fw_caps[INST_FW_CAP_MAX];
6163
struct iris_buffers buffers[BUF_TYPE_MAX];
6264
u32 fw_min_count;

0 commit comments

Comments
 (0)