mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] media: Fix pm_runtime_set_suspended() with runtime pm enabled
@ 2024-11-01  9:40 Jinjie Ruan
  2024-11-01  9:40 ` [PATCH v2 1/3] media: i2c: dw9768: " Jinjie Ruan
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jinjie Ruan @ 2024-11-01  9:40 UTC (permalink / raw)
  To: sakari.ailus, mchehab, ming.qian, eagle.zhou,
	stanimir.k.varbanov, quic_vgarodia, bryan.odonoghue, shijie.qin,
	hverkuil-cisco, linux-media, linux-kernel, linux-arm-msm
  Cc: chenridong, ruanjinjie

Fix a few pm_runtime_set_suspended() with runtime
pm enabled issues.

Changes in v2:
- !pm_runtime_enabled() check -> !IS_ENABLED(CONFIG_PM) as Sakari suggested.
- Add suggested-by.
- Add fix tag.
- Add Cc stable.

Jinjie Ruan (3):
  media: i2c: dw9768: Fix pm_runtime_set_suspended() with runtime pm
    enabled
  media: amphion: Fix pm_runtime_set_suspended() with runtime pm enabled
  media: venus: Fix pm_runtime_set_suspended() with runtime pm enabled

 drivers/media/i2c/dw9768.c               | 10 +++++-----
 drivers/media/platform/amphion/vpu_drv.c |  2 +-
 drivers/media/platform/qcom/venus/core.c |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

-- 
2.34.1


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

* [PATCH v2 1/3] media: i2c: dw9768: Fix pm_runtime_set_suspended() with runtime pm enabled
  2024-11-01  9:40 [PATCH v2 0/3] media: Fix pm_runtime_set_suspended() with runtime pm enabled Jinjie Ruan
@ 2024-11-01  9:40 ` Jinjie Ruan
  2024-11-01  9:40 ` [PATCH v2 2/3] media: amphion: " Jinjie Ruan
  2024-11-01  9:40 ` [PATCH v2 3/3] media: venus: " Jinjie Ruan
  2 siblings, 0 replies; 7+ messages in thread
From: Jinjie Ruan @ 2024-11-01  9:40 UTC (permalink / raw)
  To: sakari.ailus, mchehab, ming.qian, eagle.zhou,
	stanimir.k.varbanov, quic_vgarodia, bryan.odonoghue, shijie.qin,
	hverkuil-cisco, linux-media, linux-kernel, linux-arm-msm
  Cc: chenridong, ruanjinjie

It is not valid to call pm_runtime_set_suspended() and
pm_runtime_set_active() for devices with runtime PM enabled because it
returns -EAGAIN if it is enabled already and working. So, adjust the
order to fix it.

Cc: stable@vger.kernel.org
Fixes: 5f9a089b6de3 ("dw9768: Enable low-power probe on ACPI")
Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v2:
- !pm_runtime_enabled() check -> !IS_ENABLED(CONFIG_PM).
- Add suggested-by.
- Cc stable.
---
 drivers/media/i2c/dw9768.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/dw9768.c b/drivers/media/i2c/dw9768.c
index 18ef2b35c9aa..87a7c3ceeb11 100644
--- a/drivers/media/i2c/dw9768.c
+++ b/drivers/media/i2c/dw9768.c
@@ -471,10 +471,9 @@ static int dw9768_probe(struct i2c_client *client)
 	 * to be powered on in an ACPI system. Similarly for power off in
 	 * remove.
 	 */
-	pm_runtime_enable(dev);
 	full_power = (is_acpi_node(dev_fwnode(dev)) &&
 		      acpi_dev_state_d0(dev)) ||
-		     (is_of_node(dev_fwnode(dev)) && !pm_runtime_enabled(dev));
+		     (is_of_node(dev_fwnode(dev)) && !IS_ENABLED(CONFIG_PM));
 	if (full_power) {
 		ret = dw9768_runtime_resume(dev);
 		if (ret < 0) {
@@ -484,6 +483,7 @@ static int dw9768_probe(struct i2c_client *client)
 		pm_runtime_set_active(dev);
 	}
 
+	pm_runtime_enable(dev);
 	ret = v4l2_async_register_subdev(&dw9768->sd);
 	if (ret < 0) {
 		dev_err(dev, "failed to register V4L2 subdev: %d", ret);
@@ -495,12 +495,12 @@ static int dw9768_probe(struct i2c_client *client)
 	return 0;
 
 err_power_off:
+	pm_runtime_disable(dev);
 	if (full_power) {
 		dw9768_runtime_suspend(dev);
 		pm_runtime_set_suspended(dev);
 	}
 err_clean_entity:
-	pm_runtime_disable(dev);
 	media_entity_cleanup(&dw9768->sd.entity);
 err_free_handler:
 	v4l2_ctrl_handler_free(&dw9768->ctrls);
@@ -517,12 +517,12 @@ static void dw9768_remove(struct i2c_client *client)
 	v4l2_async_unregister_subdev(&dw9768->sd);
 	v4l2_ctrl_handler_free(&dw9768->ctrls);
 	media_entity_cleanup(&dw9768->sd.entity);
+	pm_runtime_disable(dev);
 	if ((is_acpi_node(dev_fwnode(dev)) && acpi_dev_state_d0(dev)) ||
-	    (is_of_node(dev_fwnode(dev)) && !pm_runtime_enabled(dev))) {
+	    (is_of_node(dev_fwnode(dev)) && !IS_ENABLED(CONFIG_PM))) {
 		dw9768_runtime_suspend(dev);
 		pm_runtime_set_suspended(dev);
 	}
-	pm_runtime_disable(dev);
 }
 
 static const struct of_device_id dw9768_of_table[] = {
-- 
2.34.1


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

* [PATCH v2 2/3] media: amphion: Fix pm_runtime_set_suspended() with runtime pm enabled
  2024-11-01  9:40 [PATCH v2 0/3] media: Fix pm_runtime_set_suspended() with runtime pm enabled Jinjie Ruan
  2024-11-01  9:40 ` [PATCH v2 1/3] media: i2c: dw9768: " Jinjie Ruan
@ 2024-11-01  9:40 ` Jinjie Ruan
  2024-11-01 10:39   ` Bryan O'Donoghue
  2024-11-01  9:40 ` [PATCH v2 3/3] media: venus: " Jinjie Ruan
  2 siblings, 1 reply; 7+ messages in thread
From: Jinjie Ruan @ 2024-11-01  9:40 UTC (permalink / raw)
  To: sakari.ailus, mchehab, ming.qian, eagle.zhou,
	stanimir.k.varbanov, quic_vgarodia, bryan.odonoghue, shijie.qin,
	hverkuil-cisco, linux-media, linux-kernel, linux-arm-msm
  Cc: chenridong, ruanjinjie

It is not valid to call pm_runtime_set_suspended() for devices
with runtime PM enabled because it returns -EAGAIN if it is enabled
already and working. So, call pm_runtime_disable() before to fix it.

Cc: stable@vger.kernel.org
Fixes: b50a64fc54af ("media: amphion: add amphion vpu device driver")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v2:
- Add fix tag.
- Add Cc stable.
---
 drivers/media/platform/amphion/vpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/amphion/vpu_drv.c b/drivers/media/platform/amphion/vpu_drv.c
index 2bf70aafd2ba..51d5234869f5 100644
--- a/drivers/media/platform/amphion/vpu_drv.c
+++ b/drivers/media/platform/amphion/vpu_drv.c
@@ -151,8 +151,8 @@ static int vpu_probe(struct platform_device *pdev)
 	media_device_cleanup(&vpu->mdev);
 	v4l2_device_unregister(&vpu->v4l2_dev);
 err_vpu_deinit:
-	pm_runtime_set_suspended(dev);
 	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
 
 	return ret;
 }
-- 
2.34.1


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

* [PATCH v2 3/3] media: venus: Fix pm_runtime_set_suspended() with runtime pm enabled
  2024-11-01  9:40 [PATCH v2 0/3] media: Fix pm_runtime_set_suspended() with runtime pm enabled Jinjie Ruan
  2024-11-01  9:40 ` [PATCH v2 1/3] media: i2c: dw9768: " Jinjie Ruan
  2024-11-01  9:40 ` [PATCH v2 2/3] media: amphion: " Jinjie Ruan
@ 2024-11-01  9:40 ` Jinjie Ruan
  2024-11-01  9:59   ` Bryan O'Donoghue
  2024-11-01 11:02   ` Stanimir Varbanov
  2 siblings, 2 replies; 7+ messages in thread
From: Jinjie Ruan @ 2024-11-01  9:40 UTC (permalink / raw)
  To: sakari.ailus, mchehab, ming.qian, eagle.zhou,
	stanimir.k.varbanov, quic_vgarodia, bryan.odonoghue, shijie.qin,
	hverkuil-cisco, linux-media, linux-kernel, linux-arm-msm
  Cc: chenridong, ruanjinjie

It is not valid to call pm_runtime_set_suspended() for devices
with runtime PM enabled because it returns -EAGAIN if it is enabled
already and working. So, call pm_runtime_disable() before to fix it.

Cc: stable@vger.kernel.org
Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v2:
- Add Cc stable.
---
 drivers/media/platform/qcom/venus/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 84e95a46dfc9..cabcf710c046 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -412,8 +412,8 @@ static int venus_probe(struct platform_device *pdev)
 	of_platform_depopulate(dev);
 err_runtime_disable:
 	pm_runtime_put_noidle(dev);
-	pm_runtime_set_suspended(dev);
 	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
 	hfi_destroy(core);
 err_core_deinit:
 	hfi_core_deinit(core, false);
-- 
2.34.1


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

* Re: [PATCH v2 3/3] media: venus: Fix pm_runtime_set_suspended() with runtime pm enabled
  2024-11-01  9:40 ` [PATCH v2 3/3] media: venus: " Jinjie Ruan
@ 2024-11-01  9:59   ` Bryan O'Donoghue
  2024-11-01 11:02   ` Stanimir Varbanov
  1 sibling, 0 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2024-11-01  9:59 UTC (permalink / raw)
  To: Jinjie Ruan, sakari.ailus, mchehab, ming.qian, eagle.zhou,
	stanimir.k.varbanov, quic_vgarodia, shijie.qin, hverkuil-cisco,
	linux-media, linux-kernel, linux-arm-msm
  Cc: chenridong

On 01/11/2024 09:40, Jinjie Ruan wrote:
> It is not valid to call pm_runtime_set_suspended() for devices
> with runtime PM enabled because it returns -EAGAIN if it is enabled
> already and working. So, call pm_runtime_disable() before to fix it.
> 
> Cc: stable@vger.kernel.org
> Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v2:
> - Add Cc stable.
> ---
>   drivers/media/platform/qcom/venus/core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index 84e95a46dfc9..cabcf710c046 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -412,8 +412,8 @@ static int venus_probe(struct platform_device *pdev)
>   	of_platform_depopulate(dev);
>   err_runtime_disable:
>   	pm_runtime_put_noidle(dev);
> -	pm_runtime_set_suspended(dev);
>   	pm_runtime_disable(dev);
> +	pm_runtime_set_suspended(dev);
>   	hfi_destroy(core);
>   err_core_deinit:
>   	hfi_core_deinit(core, false);

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

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

* Re: [PATCH v2 2/3] media: amphion: Fix pm_runtime_set_suspended() with runtime pm enabled
  2024-11-01  9:40 ` [PATCH v2 2/3] media: amphion: " Jinjie Ruan
@ 2024-11-01 10:39   ` Bryan O'Donoghue
  0 siblings, 0 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2024-11-01 10:39 UTC (permalink / raw)
  To: Jinjie Ruan, sakari.ailus, mchehab, ming.qian, eagle.zhou,
	stanimir.k.varbanov, quic_vgarodia, shijie.qin, hverkuil-cisco,
	linux-media, linux-kernel, linux-arm-msm
  Cc: chenridong

On 01/11/2024 09:40, Jinjie Ruan wrote:
> It is not valid to call pm_runtime_set_suspended() for devices
> with runtime PM enabled because it returns -EAGAIN if it is enabled
> already and working. So, call pm_runtime_disable() before to fix it.
> 
> Cc: stable@vger.kernel.org
> Fixes: b50a64fc54af ("media: amphion: add amphion vpu device driver")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v2:
> - Add fix tag.
> - Add Cc stable.
> ---
>   drivers/media/platform/amphion/vpu_drv.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/amphion/vpu_drv.c b/drivers/media/platform/amphion/vpu_drv.c
> index 2bf70aafd2ba..51d5234869f5 100644
> --- a/drivers/media/platform/amphion/vpu_drv.c
> +++ b/drivers/media/platform/amphion/vpu_drv.c
> @@ -151,8 +151,8 @@ static int vpu_probe(struct platform_device *pdev)
>   	media_device_cleanup(&vpu->mdev);
>   	v4l2_device_unregister(&vpu->v4l2_dev);
>   err_vpu_deinit:
> -	pm_runtime_set_suspended(dev);
>   	pm_runtime_disable(dev);
> +	pm_runtime_set_suspended(dev);
>   
>   	return ret;
>   }
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

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

* Re: [PATCH v2 3/3] media: venus: Fix pm_runtime_set_suspended() with runtime pm enabled
  2024-11-01  9:40 ` [PATCH v2 3/3] media: venus: " Jinjie Ruan
  2024-11-01  9:59   ` Bryan O'Donoghue
@ 2024-11-01 11:02   ` Stanimir Varbanov
  1 sibling, 0 replies; 7+ messages in thread
From: Stanimir Varbanov @ 2024-11-01 11:02 UTC (permalink / raw)
  To: Jinjie Ruan, sakari.ailus, mchehab, ming.qian, eagle.zhou,
	quic_vgarodia, bryan.odonoghue, shijie.qin, hverkuil-cisco,
	linux-media, linux-kernel, linux-arm-msm
  Cc: chenridong



On 1.11.24 г. 11:40 ч., Jinjie Ruan wrote:
> It is not valid to call pm_runtime_set_suspended() for devices
> with runtime PM enabled because it returns -EAGAIN if it is enabled
> already and working. So, call pm_runtime_disable() before to fix it.
> 
> Cc: stable@vger.kernel.org
> Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v2:
> - Add Cc stable.
> ---
>   drivers/media/platform/qcom/venus/core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>

-- 
regards,
Stan

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

end of thread, other threads:[~2024-11-01 11:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-01  9:40 [PATCH v2 0/3] media: Fix pm_runtime_set_suspended() with runtime pm enabled Jinjie Ruan
2024-11-01  9:40 ` [PATCH v2 1/3] media: i2c: dw9768: " Jinjie Ruan
2024-11-01  9:40 ` [PATCH v2 2/3] media: amphion: " Jinjie Ruan
2024-11-01 10:39   ` Bryan O'Donoghue
2024-11-01  9:40 ` [PATCH v2 3/3] media: venus: " Jinjie Ruan
2024-11-01  9:59   ` Bryan O'Donoghue
2024-11-01 11:02   ` Stanimir Varbanov

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®