From: Vikash Garodia <quic_vgarodia@quicinc.com>
To: Dikshita Agarwal <quic_dikshita@quicinc.com>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Abhinav Kumar <quic_abhinavk@quicinc.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Stefan Schmidt <stefan.schmidt@linaro.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
"Bjorn Andersson" <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
"Rob Herring" <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
<linux-media@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH v2 01/23] media: iris: Skip destroying internal buffer if not dequeued
Date: Wed, 30 Apr 2025 12:52:03 +0530 [thread overview]
Message-ID: <50f12fea-fbc9-8880-5e34-3d3a49d9ca65@quicinc.com> (raw)
In-Reply-To: <32379a29-ab58-95b3-77f9-d1ada61e5359@quicinc.com>
On 4/30/2025 11:08 AM, Dikshita Agarwal wrote:
>
>
> On 4/29/2025 6:17 PM, Nicolas Dufresne wrote:
>> Not mine to review, but wanted to highlight some best practices,
>>
>> comment below...
>>
>> Le lundi 28 avril 2025 à 14:58 +0530, Dikshita Agarwal a écrit :
>>> Firmware might hold the DPB buffers for reference in case of sequence
>>> change, so skip destroying buffers for which QUEUED flag is not removed.
>>> Also, make sure that all buffers are released during streamoff.
>>>
>>> Cc: stable@vger.kernel.org
>>> Fixes: 73702f45db81 ("media: iris: allocate, initialize and queue internal buffers")
>>> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
>>> ---
>>> drivers/media/platform/qcom/iris/iris_buffer.c | 37 +++++++++++++++++++++++++-
>>> drivers/media/platform/qcom/iris/iris_buffer.h | 3 ++-
>>> drivers/media/platform/qcom/iris/iris_vdec.c | 4 +--
>>> drivers/media/platform/qcom/iris/iris_vidc.c | 6 +++--
>>> 4 files changed, 44 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
>>> index e5c5a564fcb8..606d76b10be2 100644
>>> --- a/drivers/media/platform/qcom/iris/iris_buffer.c
>>> +++ b/drivers/media/platform/qcom/iris/iris_buffer.c
>>> @@ -376,7 +376,7 @@ int iris_destroy_internal_buffer(struct iris_inst *inst, struct iris_buffer *buf
>>> return 0;
>>> }
>>>
>>> -int iris_destroy_internal_buffers(struct iris_inst *inst, u32 plane)
>>> +int iris_destroy_internal_buffers(struct iris_inst *inst, u32 plane, bool force)
>>
>> Its always tempting to just glue a boolean at the end of a parameter
>> list. But this has huge downside in code readability, see below...
>>
>>> {
>>> const struct iris_platform_data *platform_data = inst->core->iris_platform_data;
>>> struct iris_buffer *buf, *next;
>>> @@ -396,6 +396,14 @@ int iris_destroy_internal_buffers(struct iris_inst *inst, u32 plane)
>>> for (i = 0; i < len; i++) {
>>> buffers = &inst->buffers[internal_buf_type[i]];
>>> list_for_each_entry_safe(buf, next, &buffers->list, list) {
>>> + /*
>>> + * during stream on, skip destroying internal(DPB) buffer
>>> + * if firmware did not return it.
>>> + * during close, destroy all buffers irrespectively.
>>> + */
>>> + if (!force && buf->attr & BUF_ATTR_QUEUED)
>>> + continue;
>>> +
>>> ret = iris_destroy_internal_buffer(inst, buf);
>>> if (ret)
>>> return ret;
>>> @@ -446,6 +454,33 @@ static int iris_release_input_internal_buffers(struct iris_inst *inst)
>>> return 0;
>>> }
>>>
>>> +void iris_get_num_queued_internal_buffers(struct iris_inst *inst, u32 plane)
>>> +{
>>> + const struct iris_platform_data *platform_data = inst->core->iris_platform_data;
>>> + struct iris_buffer *buf, *next;
>>> + struct iris_buffers *buffers;
>>> + const u32 *internal_buf_type;
>>> + u32 internal_buffer_count, i;
>>> + u32 count = 0;
>>> +
>>> + if (V4L2_TYPE_IS_OUTPUT(plane)) {
>>> + internal_buf_type = platform_data->dec_ip_int_buf_tbl;
>>> + internal_buffer_count = platform_data->dec_ip_int_buf_tbl_size;
>>> + } else {
>>> + internal_buf_type = platform_data->dec_op_int_buf_tbl;
>>> + internal_buffer_count = platform_data->dec_op_int_buf_tbl_size;
>>> + }
>>> +
>>> + for (i = 0; i < internal_buffer_count; i++) {
>>> + buffers = &inst->buffers[internal_buf_type[i]];
>>> + list_for_each_entry_safe(buf, next, &buffers->list, list)
>>> + count++;
>>> + if (count)
>>> + dev_err(inst->core->dev, "%d buffer of type %d not released",
>>> + count, internal_buf_type[i]);
>>> + }
>>> +}
>>> +
>>> int iris_alloc_and_queue_persist_bufs(struct iris_inst *inst)
>>> {
>>> struct iris_buffers *buffers = &inst->buffers[BUF_PERSIST];
>>> diff --git a/drivers/media/platform/qcom/iris/iris_buffer.h b/drivers/media/platform/qcom/iris/iris_buffer.h
>>> index c36b6347b077..03a32b91cf21 100644
>>> --- a/drivers/media/platform/qcom/iris/iris_buffer.h
>>> +++ b/drivers/media/platform/qcom/iris/iris_buffer.h
>>> @@ -106,7 +106,8 @@ void iris_get_internal_buffers(struct iris_inst *inst, u32 plane);
>>> int iris_create_internal_buffers(struct iris_inst *inst, u32 plane);
>>> int iris_queue_internal_buffers(struct iris_inst *inst, u32 plane);
>>> int iris_destroy_internal_buffer(struct iris_inst *inst, struct iris_buffer *buffer);
>>> -int iris_destroy_internal_buffers(struct iris_inst *inst, u32 plane);
>>> +int iris_destroy_internal_buffers(struct iris_inst *inst, u32 plane, bool force);
>>> +void iris_get_num_queued_internal_buffers(struct iris_inst *inst, u32 plane);
>>> int iris_alloc_and_queue_persist_bufs(struct iris_inst *inst);
>>> int iris_alloc_and_queue_input_int_bufs(struct iris_inst *inst);
>>> int iris_queue_buffer(struct iris_inst *inst, struct iris_buffer *buf);
>>> diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/platform/qcom/iris/iris_vdec.c
>>> index 4143acedfc57..2c1a7162d2da 100644
>>> --- a/drivers/media/platform/qcom/iris/iris_vdec.c
>>> +++ b/drivers/media/platform/qcom/iris/iris_vdec.c
>>> @@ -408,7 +408,7 @@ int iris_vdec_streamon_input(struct iris_inst *inst)
>>>
>>> iris_get_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
>>>
>>> - ret = iris_destroy_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
>>> + ret = iris_destroy_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, false);
>>> if (ret)
>>> return ret;
>>>
>>> @@ -496,7 +496,7 @@ int iris_vdec_streamon_output(struct iris_inst *inst)
>>>
>>> iris_get_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
>>>
>>> - ret = iris_destroy_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
>>> + ret = iris_destroy_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, false);
>>
>> If I was reviewing some changes (or even debugging) this specific C
>> file, I would not be able to understanding what this "false" means. I
>> would have to spend extra time, opening the declaration, going back and
>> forth, and breaking the flow.
>>
>> An alternative approach is to keep the boolean parameter in a static
>> function (c local), and then add two function wrappers that have
>> explicit names.
>>
> Sure, I can implement the alternative approach, if recommended.
>
> If I understand correctly, you are suggesting to have one static helper and
> two wrappers around this. like:
>
> static int iris_destroy_internal_buffers(struct iris_inst *inst, u32 plane,
> bool force)
> {
> ...
> list_for_each_entry_safe(buf, next, &buffers->list, list) {
> if (!force && buf->attr & BUF_ATTR_QUEUED)
> continue;
> ...
> }
> ...
> }
>
> //called during stream on
> int iris_destroy_dequeued_internal_buffers(struct iris_inst *inst, u32 plane)
Name this iris_force_destroy...That way, it is easy for caller to understand
without the need to interpret the boolean.
Regards,
Vikash
> {
> return iris_destroy_internal_buffers(inst, plane, false)
> }
>
> //called during close
> int iris_destroy_all_internal_buffers(struct iris_inst *inst, u32 plane)
> {
> return iris_destroy_internal_buffers(inst, plane, true)
> }
>
> Thanks,
> Dikshita
>> regards,
>> Nicolas
>>
>>> if (ret)
>>> return ret;
>>>
>>> diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
>>> index ca0f4e310f77..56531a7f0dfe 100644
>>> --- a/drivers/media/platform/qcom/iris/iris_vidc.c
>>> +++ b/drivers/media/platform/qcom/iris/iris_vidc.c
>>> @@ -233,8 +233,10 @@ int iris_close(struct file *filp)
>>> iris_session_close(inst);
>>> iris_inst_change_state(inst, IRIS_INST_DEINIT);
>>> iris_v4l2_fh_deinit(inst);
>>> - iris_destroy_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
>>> - iris_destroy_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
>>> + iris_destroy_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, true);
>>> + iris_destroy_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, true);
>>> + iris_get_num_queued_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
>>> + iris_get_num_queued_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
>>> iris_remove_session(inst);
>>> mutex_unlock(&inst->lock);
>>> mutex_destroy(&inst->ctx_q_lock);
>>
next prev parent reply other threads:[~2025-04-30 7:22 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 9:28 [PATCH v2 00/23] Add support for HEVC and VP9 codecs in decoder Dikshita Agarwal
2025-04-28 9:28 ` [PATCH v2 01/23] media: iris: Skip destroying internal buffer if not dequeued Dikshita Agarwal
2025-04-29 9:24 ` Vikash Garodia
2025-04-29 9:27 ` Vikash Garodia
2025-04-29 11:07 ` Dikshita Agarwal
2025-04-29 9:43 ` Bryan O'Donoghue
2025-04-29 10:58 ` Dikshita Agarwal
2025-04-29 12:47 ` Nicolas Dufresne
2025-04-30 5:38 ` Dikshita Agarwal
2025-04-30 7:22 ` Vikash Garodia [this message]
2025-04-28 9:28 ` [PATCH v2 02/23] media: iris: Update CAPTURE format info based on OUTPUT format Dikshita Agarwal
2025-04-29 9:29 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 03/23] media: iris: Add handling for corrupt and drop frames Dikshita Agarwal
2025-04-29 9:35 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 04/23] media: iris: Avoid updating frame size to firmware during reconfig Dikshita Agarwal
2025-04-29 9:50 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 05/23] media: iris: Send V4L2_BUF_FLAG_ERROR for buffers with 0 filled length Dikshita Agarwal
2025-04-29 10:00 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 06/23] media: iris: Drop port check for session property response Dikshita Agarwal
2025-04-29 10:04 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 07/23] media: iris: Add handling for no show frames Dikshita Agarwal
2025-04-29 10:06 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 08/23] media: iris: Improve last flag handling Dikshita Agarwal
2025-04-29 10:17 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 09/23] media: iris: Skip flush on first sequence change Dikshita Agarwal
2025-04-29 10:19 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 10/23] media: iris: Prevent HFI queue writes when core is in deinit state Dikshita Agarwal
2025-04-29 10:23 ` Vikash Garodia
2025-04-28 9:28 ` [PATCH v2 11/23] media: iris: Remove redundant buffer count check in stream off Dikshita Agarwal
2025-04-29 10:24 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 12/23] media: iris: Remove deprecated property setting to firmware Dikshita Agarwal
2025-04-29 10:26 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 13/23] media: iris: Fix missing function pointer initialization Dikshita Agarwal
2025-04-29 10:30 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 14/23] media: iris: Fix NULL pointer dereference Dikshita Agarwal
2025-04-28 9:40 ` Dan Carpenter
2025-04-28 12:10 ` Dikshita Agarwal
2025-04-28 12:38 ` Dan Carpenter
2025-04-29 10:31 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 15/23] media: iris: Fix typo in depth variable Dikshita Agarwal
2025-04-29 10:32 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 16/23] media: iris: Add a comment to explain usage of MBPS Dikshita Agarwal
2025-04-29 10:34 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 17/23] media: iris: Track flush responses to prevent premature completion Dikshita Agarwal
2025-04-30 10:40 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 18/23] media: iris: Fix buffer preparation failure during resolution change Dikshita Agarwal
2025-04-29 10:46 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 19/23] media: iris: Add HEVC and VP9 formats for decoder Dikshita Agarwal
2025-04-30 10:29 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 20/23] media: iris: Add platform capabilities for HEVC and VP9 decoders Dikshita Agarwal
2025-04-30 10:30 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 21/23] media: iris: Set mandatory properties " Dikshita Agarwal
2025-04-30 10:32 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 22/23] media: iris: Add internal buffer calculation " Dikshita Agarwal
2025-04-30 10:33 ` Vikash Garodia
2025-04-28 9:29 ` [PATCH v2 23/23] media: iris: Add codec specific check for VP9 decoder drain handling Dikshita Agarwal
2025-04-30 10:35 ` Vikash Garodia
2025-04-28 11:07 ` [PATCH v2 00/23] Add support for HEVC and VP9 codecs in decoder Dmitry Baryshkov
2025-04-28 12:11 ` Dikshita Agarwal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50f12fea-fbc9-8880-5e34-3d3a49d9ca65@quicinc.com \
--to=quic_vgarodia@quicinc.com \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=hverkuil@xs4all.nl \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=nicolas.dufresne@collabora.com \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_dikshita@quicinc.com \
--cc=robh@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stefan.schmidt@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox