linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Dikshita Agarwal <quic_dikshita@quicinc.com>,
	Vikash Garodia <quic_vgarodia@quicinc.com>,
	Abhinav Kumar <abhinav.kumar@linux.dev>,
	Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: iris: fix module removal if firmware download failed
Date: Thu, 21 Aug 2025 14:27:15 +0200	[thread overview]
Message-ID: <802b5a3c-15c7-4291-8e3e-e598b5587fb8@linaro.org> (raw)
In-Reply-To: <6c93b790-6d84-aec5-5b4d-2584d249f74e@quicinc.com>

On 21/08/2025 11:42, Dikshita Agarwal wrote:
> 
> 
> On 8/20/2025 10:36 PM, Neil Armstrong wrote:
>> Fix remove if firmware failed to load:
>> qcom-iris aa00000.video-codec: Direct firmware load for qcom/vpu/vpu33_p4.mbn failed with error -2
>> qcom-iris aa00000.video-codec: firmware download failed
>> qcom-iris aa00000.video-codec: core init failed
>>
>> then:
>> $ echo aa00000.video-codec > /sys/bus/platform/drivers/qcom-iris/unbind
>>
>> Triggers:
>> genpd genpd:1:aa00000.video-codec: Runtime PM usage count underflow!
>> ------------[ cut here ]------------
>> video_cc_mvs0_clk already disabled
>> WARNING: drivers/clk/clk.c:1206 at clk_core_disable+0xa4/0xac, CPU#1: sh/542
>> <snip>
>> pc : clk_core_disable+0xa4/0xac
>> lr : clk_core_disable+0xa4/0xac
>> <snip>
>> Call trace:
>>   clk_core_disable+0xa4/0xac (P)
>>   clk_disable+0x30/0x4c
>>   iris_disable_unprepare_clock+0x20/0x48 [qcom_iris]
>>   iris_vpu_power_off_hw+0x48/0x58 [qcom_iris]
>>   iris_vpu33_power_off_hardware+0x44/0x230 [qcom_iris]
>>   iris_vpu_power_off+0x34/0x84 [qcom_iris]
>>   iris_core_deinit+0x44/0xc8 [qcom_iris]
>>   iris_remove+0x20/0x48 [qcom_iris]
>>   platform_remove+0x20/0x30
>>   device_remove+0x4c/0x80
>> <snip>
>> ---[ end trace 0000000000000000 ]---
>> ------------[ cut here ]------------
>> video_cc_mvs0_clk already unprepared
>> WARNING: drivers/clk/clk.c:1065 at clk_core_unprepare+0xf0/0x110, CPU#2: sh/542
>> <snip>
>> pc : clk_core_unprepare+0xf0/0x110
>> lr : clk_core_unprepare+0xf0/0x110
>> <snip>
>> Call trace:
>>   clk_core_unprepare+0xf0/0x110 (P)
>>   clk_unprepare+0x2c/0x44
>>   iris_disable_unprepare_clock+0x28/0x48 [qcom_iris]
>>   iris_vpu_power_off_hw+0x48/0x58 [qcom_iris]
>>   iris_vpu33_power_off_hardware+0x44/0x230 [qcom_iris]
>>   iris_vpu_power_off+0x34/0x84 [qcom_iris]
>>   iris_core_deinit+0x44/0xc8 [qcom_iris]
>>   iris_remove+0x20/0x48 [qcom_iris]
>>   platform_remove+0x20/0x30
>>   device_remove+0x4c/0x80
>> <snip>
>> ---[ end trace 0000000000000000 ]---
>> genpd genpd:0:aa00000.video-codec: Runtime PM usage count underflow!
>> ------------[ cut here ]------------
>> gcc_video_axi0_clk already disabled
>> WARNING: drivers/clk/clk.c:1206 at clk_core_disable+0xa4/0xac, CPU#4: sh/542
>> <snip>
>> pc : clk_core_disable+0xa4/0xac
>> lr : clk_core_disable+0xa4/0xac
>> <snip>
>> Call trace:
>>   clk_core_disable+0xa4/0xac (P)
>>   clk_disable+0x30/0x4c
>>   iris_disable_unprepare_clock+0x20/0x48 [qcom_iris]
>>   iris_vpu33_power_off_controller+0x17c/0x428 [qcom_iris]
>>   iris_vpu_power_off+0x48/0x84 [qcom_iris]
>>   iris_core_deinit+0x44/0xc8 [qcom_iris]
>>   iris_remove+0x20/0x48 [qcom_iris]
>>   platform_remove+0x20/0x30
>>   device_remove+0x4c/0x80
>> <snip>
>> ------------[ cut here ]------------
>> gcc_video_axi0_clk already unprepared
>> WARNING: drivers/clk/clk.c:1065 at clk_core_unprepare+0xf0/0x110, CPU#4: sh/542
>> <snip>
>> pc : clk_core_unprepare+0xf0/0x110
>> lr : clk_core_unprepare+0xf0/0x110
>> <snip>
>> Call trace:
>>   clk_core_unprepare+0xf0/0x110 (P)
>>   clk_unprepare+0x2c/0x44
>>   iris_disable_unprepare_clock+0x28/0x48 [qcom_iris]
>>   iris_vpu33_power_off_controller+0x17c/0x428 [qcom_iris]
>>   iris_vpu_power_off+0x48/0x84 [qcom_iris]
>>   iris_core_deinit+0x44/0xc8 [qcom_iris]
>>   iris_remove+0x20/0x48 [qcom_iris]
>>   platform_remove+0x20/0x30
>>   device_remove+0x4c/0x80
>> <snip>
>> ---[ end trace 0000000000000000 ]---
>>
>> Skip deinit if initialization never succeeded.
>>
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>> ---
>>   drivers/media/platform/qcom/iris/iris_core.c | 10 ++++++----
>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/iris/iris_core.c b/drivers/media/platform/qcom/iris/iris_core.c
>> index 0fa0a3b549a23877af57c9950a5892e821b9473a..8406c48d635b6eba0879396ce9f9ae2292743f09 100644
>> --- a/drivers/media/platform/qcom/iris/iris_core.c
>> +++ b/drivers/media/platform/qcom/iris/iris_core.c
>> @@ -15,10 +15,12 @@ void iris_core_deinit(struct iris_core *core)
>>   	pm_runtime_resume_and_get(core->dev);
>>   
>>   	mutex_lock(&core->lock);
>> -	iris_fw_unload(core);
>> -	iris_vpu_power_off(core);
>> -	iris_hfi_queues_deinit(core);
>> -	core->state = IRIS_CORE_DEINIT;
>> +	if (core->state != IRIS_CORE_DEINIT) {
>> +		iris_fw_unload(core);
>> +		iris_vpu_power_off(core);
>> +		iris_hfi_queues_deinit(core);
>> +		core->state = IRIS_CORE_DEINIT;
>> +	}
>>   	mutex_unlock(&core->lock);
>>   
>>   	pm_runtime_put_sync(core->dev);
>>
> 
> The iris_core_deinit() API should ideally not be called when core->state is
> in IRIS_CORE_DEINIT. Better to handle this check in the caller itself.

Checking core->state in iris_remove() won't be protected by the core->lock,
so the check and call to iris_core_deinit() should be done _after_ unregistering
the v4l2 devices to make sure there's no more users of core.

As you want, I think my approach is simpler and don't change the state if
already in deinit state.

Neil

> 
>> ---
>> base-commit: 5303936d609e09665deda94eaedf26a0e5c3a087
>> change-id: 20250820-topic-sm8x50-iris-remove-fix-76f86621d6ac
>>
>> Best regards,


  reply	other threads:[~2025-08-21 12:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 17:06 [PATCH] media: iris: fix module removal if firmware download failed Neil Armstrong
2025-08-21  8:00 ` Bryan O'Donoghue
2025-08-21  9:42 ` Dikshita Agarwal
2025-08-21 12:27   ` Neil Armstrong [this message]
2025-08-22  5:29     ` 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=802b5a3c-15c7-4291-8e3e-e598b5587fb8@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=abhinav.kumar@linux.dev \
    --cc=bryan.odonoghue@linaro.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=quic_dikshita@quicinc.com \
    --cc=quic_vgarodia@quicinc.com \
    /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;
as well as URLs for NNTP newsgroup(s).