linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: iris: fix module removal if firmware download failed
@ 2025-08-20 17:06 Neil Armstrong
  2025-08-21  8:00 ` Bryan O'Donoghue
  2025-08-21  9:42 ` Dikshita Agarwal
  0 siblings, 2 replies; 5+ messages in thread
From: Neil Armstrong @ 2025-08-20 17:06 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, linux-kernel, Neil Armstrong

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);

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

Best regards,
-- 
Neil Armstrong <neil.armstrong@linaro.org>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: iris: fix module removal if firmware download failed
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Bryan O'Donoghue @ 2025-08-21  8:00 UTC (permalink / raw)
  To: Neil Armstrong, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, linux-kernel

On 20/08/2025 18:06, 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);
> 
> ---
> base-commit: 5303936d609e09665deda94eaedf26a0e5c3a087
> change-id: 20250820-topic-sm8x50-iris-remove-fix-76f86621d6ac
> 
> Best regards,

missing a fixes tag, once included please add

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: iris: fix module removal if firmware download failed
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Dikshita Agarwal @ 2025-08-21  9:42 UTC (permalink / raw)
  To: Neil Armstrong, Vikash Garodia, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, linux-kernel



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.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: iris: fix module removal if firmware download failed
  2025-08-21  9:42 ` Dikshita Agarwal
@ 2025-08-21 12:27   ` Neil Armstrong
  2025-08-22  5:29     ` Dikshita Agarwal
  0 siblings, 1 reply; 5+ messages in thread
From: Neil Armstrong @ 2025-08-21 12:27 UTC (permalink / raw)
  To: Dikshita Agarwal, Vikash Garodia, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, linux-kernel

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,


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: iris: fix module removal if firmware download failed
  2025-08-21 12:27   ` Neil Armstrong
@ 2025-08-22  5:29     ` Dikshita Agarwal
  0 siblings, 0 replies; 5+ messages in thread
From: Dikshita Agarwal @ 2025-08-22  5:29 UTC (permalink / raw)
  To: Neil Armstrong, Vikash Garodia, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, linux-kernel



On 8/21/2025 5:57 PM, Neil Armstrong wrote:
> 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.

Agree.

Reviewed-by: Dikshita Agarwal <quic_dikshita@quicinc.com>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-22  5:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-08-22  5:29     ` Dikshita Agarwal

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).