mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Dikshita Agarwal <quic_dikshita@quicinc.com>,
	Vikash Garodia <quic_vgarodia@quicinc.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: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	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 01/20] media: iris: Skip destroying internal buffer if not dequeued
Date: Mon, 14 Apr 2025 11:26:06 +0100	[thread overview]
Message-ID: <137c68d5-36c5-4977-921b-e4b07b22113c@linaro.org> (raw)
In-Reply-To: <811cd70e-dc27-4ce0-b7da-296fa5926f90@linaro.org>

On 11/04/2025 13:10, Bryan O'Donoghue wrote:
> On 08/04/2025 16:54, Dikshita Agarwal wrote:
>> Firmware might hold the DPB buffers for reference in case of sequence
>> change, so skip destroying buffers for which QUEUED flag is not removed.
>>
>> 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 | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/ 
>> media/platform/qcom/iris/iris_buffer.c
>> index e5c5a564fcb8..75fe63cc2327 100644
>> --- a/drivers/media/platform/qcom/iris/iris_buffer.c
>> +++ b/drivers/media/platform/qcom/iris/iris_buffer.c
>> @@ -396,6 +396,13 @@ 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) {
>> +            /*
>> +             * skip destroying internal(DPB) buffer if firmware
>> +             * did not return it.
>> +             */
>> +            if (buf->attr & BUF_ATTR_QUEUED)
>> +                continue;
>> +
>>               ret = iris_destroy_internal_buffer(inst, buf);
>>               if (ret)
>>                   return ret;
>>
> 
> iris_destroy_internal_buffers() is called from
> 
> - iris_vdec_streamon_output
> - iris_venc_streamon_output
> - iris_close
> 
> So if we skip releasing the buffer here, when will the memory be released ?
> 
> Particularly the kfree() in iris_destroy_internal_buffer() ?
> 
> iris_close -> iris_destroy_internal_buffers ! -> iris_destroy_buffer
> 
> Is a leak right ?
> 
> ---
> bod

Thinking about this some more, I believe we should have some sort of 
reaping routine.

- The firmware fails to release a buffer, it is up to APSS/Linux
   to run some kind of reaping routine.
   We can debate when is the right time to reset.
   Perhaps instead of ignoring the buffer as you have done here
   we schedule work with a timeout and if the timeout expires then
   this triggers a reset/reap routine.

- Since Linux allocates a buffer on the APSS side, you can't have a
   situation where firmware can indefinitely hold memory.

- APSS is in effect the bus master here since it can assert/deassert
   RESET lines to the firmware, can control regulators and clocks.

So we should have some kind of watchdog logic here.

As alluded to above, what exactly do you do if firmware never returns a 
buffer ? Accept memory leak on the APSS side ?

Rather we should agree when it is appropriate to run a watchdog routine to

1. Timeout firmware not returning a buffer
2. Put the iris/venus hardware into reset
3. Reap leaked memory
4. Restart

I see we have IRQ based watchdog logic but, I don't see that it reaps 
memory.

In any case we should have the ability to reset iris and reclaim/reap 
memory in this type of situation.

Perhaps I'm off on a rant here but, this seems like a problem we should 
address with a more comprehensive solution.

---
bod

  reply	other threads:[~2025-04-14 10:26 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08 15:54 [PATCH 00/20] Add support for HEVC and VP9 codecs in decoder Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 01/20] media: iris: Skip destroying internal buffer if not dequeued Dikshita Agarwal
2025-04-11 12:10   ` Bryan O'Donoghue
2025-04-14 10:26     ` Bryan O'Donoghue [this message]
2025-04-15  4:58       ` Dikshita Agarwal
2025-04-16 12:10         ` Bryan O'Donoghue
2025-04-16 16:40           ` Dikshita Agarwal
2025-04-17  8:35             ` Bryan O'Donoghue
2025-04-08 15:54 ` [PATCH 02/20] media: iris: Update CAPTURE format info based on OUTPUT format Dikshita Agarwal
2025-04-11 12:46   ` Bryan O'Donoghue
2025-04-08 15:54 ` [PATCH 03/20] media: iris: Add handling for corrupt and drop frames Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 04/20] media: iris: Avoid updating frame size to firmware during reconfig Dikshita Agarwal
2025-04-11 12:47   ` Bryan O'Donoghue
2025-04-15  4:33     ` Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 05/20] media: iris: Send V4L2_BUF_FLAG_ERROR for buffers with 0 filled length Dikshita Agarwal
2025-04-11 12:51   ` Bryan O'Donoghue
2025-04-15  4:31     ` Dikshita Agarwal
2025-04-16 13:42       ` Nicolas Dufresne
2025-04-08 15:54 ` [PATCH 06/20] media: iris: Add handling for no show frames Dikshita Agarwal
2025-04-22 20:23   ` Bryan O'Donoghue
2025-04-23  9:03     ` Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 07/20] media: iris: Improve last flag handling Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 08/20] media: iris: Skip flush on first sequence change Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 09/20] media: iris: Prevent HFI queue writes when core is in deinit state Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 10/20] media: iris: Remove redundant buffer count check in stream off Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 11/20] media: iris: Remove deprecated property setting to firmware Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 12/20] media: iris: Fix missing function pointer initialization Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 13/20] media: iris: Fix NULL pointer dereference Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 14/20] media: iris: Fix typo in depth variable Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 15/20] media: iris: Add a comment to explain usage of MBPS Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 16/20] media: iris: Add HEVC and VP9 formats for decoder Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 17/20] media: iris: Add platform capabilities for HEVC and VP9 decoders Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 18/20] media: iris: Set mandatory properties " Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 19/20] media: iris: Add internal buffer calculation " Dikshita Agarwal
2025-04-08 15:54 ` [PATCH 20/20] media: iris: Add codec specific check for VP9 decoder drain handling Dikshita Agarwal
2025-04-08 18:37 ` [PATCH 00/20] Add support for HEVC and VP9 codecs in decoder Nicolas Dufresne
2025-04-21 11:05   ` Dikshita Agarwal
2025-04-09 14:29 ` Bryan O'Donoghue
2025-04-09 14:37   ` Bryan O'Donoghue
2025-04-09 16:26   ` Neil Armstrong
2025-04-09 17:59     ` Vikash Garodia
2025-04-10  7:20       ` neil.armstrong
2025-04-10  7:23         ` Vikash Garodia
2025-04-10  7:17   ` 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=137c68d5-36c5-4977-921b-e4b07b22113c@linaro.org \
    --to=bryan.odonoghue@linaro.org \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --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=quic_abhinavk@quicinc.com \
    --cc=quic_dikshita@quicinc.com \
    --cc=quic_vgarodia@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

all inboxes | Powered by JetHome®