diff mbox series

[v3,04/19] media: venus: core: Set OPP clkname in a common code path

Message ID 20230911-topic-mars-v3-4-79f23b81c261@linaro.org (mailing list archive)
State Not Applicable
Headers show
Series Venus cleanups | expand

Commit Message

Konrad Dybcio March 27, 2024, 6:08 p.m. UTC
Calling devm_pm_opp_set_clkname() is repeated for all HFI versions in
pm_ops->core_power.

Move it to the common codepath.

This also lets us get rid of core_get_v1.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/media/platform/qcom/venus/core.c       |  5 +++++
 drivers/media/platform/qcom/venus/pm_helpers.c | 23 ++---------------------
 2 files changed, 7 insertions(+), 21 deletions(-)

Comments

Dikshita Agarwal April 5, 2024, 7:39 a.m. UTC | #1
On 3/27/2024 11:38 PM, Konrad Dybcio wrote:
> Calling devm_pm_opp_set_clkname() is repeated for all HFI versions in
> pm_ops->core_power.
> 
> Move it to the common codepath.
> 
> This also lets us get rid of core_get_v1.
> 
> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>  drivers/media/platform/qcom/venus/core.c       |  5 +++++
>  drivers/media/platform/qcom/venus/pm_helpers.c | 23 ++---------------------
>  2 files changed, 7 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index ce206b709754..5ab3c414ec0f 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -14,6 +14,7 @@
>  #include <linux/of.h>
>  #include <linux/of_platform.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_opp.h>
>  #include <linux/slab.h>
>  #include <linux/types.h>
>  #include <linux/pm_domain.h>
> @@ -319,6 +320,10 @@ static int venus_probe(struct platform_device *pdev)
>  	if (!core->pm_ops)
>  		return -ENODEV;
>  
> +	ret = devm_pm_opp_set_clkname(dev, "core");
> +	if (ret)
> +		return ret;
> +
>  	if (core->pm_ops->core_get) {
>  		ret = core->pm_ops->core_get(core);
>  		if (ret)
> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
> index cf91f50a33aa..ef4b0f0da36f 100644
> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
> @@ -318,21 +318,6 @@ static int load_scale_v1(struct venus_inst *inst)
>  	return ret;
>  }
>  
> -static int core_get_v1(struct venus_core *core)
> -{
> -	int ret;
> -
> -	ret = venus_clks_get(core);
> -	if (ret)
> -		return ret;
> -
> -	ret = devm_pm_opp_set_clkname(core->dev, "core");
> -	if (ret)
> -		return ret;
> -
> -	return 0;
> -}
> -
>  static void core_put_v1(struct venus_core *core)
>  {
>  }
> @@ -350,7 +335,7 @@ static int core_power_v1(struct venus_core *core, int on)
>  }
>  
>  static const struct venus_pm_ops pm_ops_v1 = {
> -	.core_get = core_get_v1,
> +	.core_get = venus_clks_get,
>  	.core_put = core_put_v1,
>  	.core_power = core_power_v1,
>  	.load_scale = load_scale_v1,
> @@ -423,7 +408,7 @@ static int venc_power_v3(struct device *dev, int on)
>  }
>  
>  static const struct venus_pm_ops pm_ops_v3 = {
> -	.core_get = core_get_v1,
> +	.core_get = venus_clks_get,
>  	.core_put = core_put_v1,
>  	.core_power = core_power_v1,
>  	.vdec_get = vdec_get_v3,
> @@ -1013,10 +998,6 @@ static int core_get_v4(struct venus_core *core)
>  	if (legacy_binding)
>  		return 0;
>  
> -	ret = devm_pm_opp_set_clkname(dev, "core");
> -	if (ret)
> -		return ret;
> -
>  	ret = vcodec_domains_get(core);
>  	if (ret)
>  		return ret;
> 
>
Reviewed-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index ce206b709754..5ab3c414ec0f 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -14,6 +14,7 @@ 
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/pm_opp.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/pm_domain.h>
@@ -319,6 +320,10 @@  static int venus_probe(struct platform_device *pdev)
 	if (!core->pm_ops)
 		return -ENODEV;
 
+	ret = devm_pm_opp_set_clkname(dev, "core");
+	if (ret)
+		return ret;
+
 	if (core->pm_ops->core_get) {
 		ret = core->pm_ops->core_get(core);
 		if (ret)
diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
index cf91f50a33aa..ef4b0f0da36f 100644
--- a/drivers/media/platform/qcom/venus/pm_helpers.c
+++ b/drivers/media/platform/qcom/venus/pm_helpers.c
@@ -318,21 +318,6 @@  static int load_scale_v1(struct venus_inst *inst)
 	return ret;
 }
 
-static int core_get_v1(struct venus_core *core)
-{
-	int ret;
-
-	ret = venus_clks_get(core);
-	if (ret)
-		return ret;
-
-	ret = devm_pm_opp_set_clkname(core->dev, "core");
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static void core_put_v1(struct venus_core *core)
 {
 }
@@ -350,7 +335,7 @@  static int core_power_v1(struct venus_core *core, int on)
 }
 
 static const struct venus_pm_ops pm_ops_v1 = {
-	.core_get = core_get_v1,
+	.core_get = venus_clks_get,
 	.core_put = core_put_v1,
 	.core_power = core_power_v1,
 	.load_scale = load_scale_v1,
@@ -423,7 +408,7 @@  static int venc_power_v3(struct device *dev, int on)
 }
 
 static const struct venus_pm_ops pm_ops_v3 = {
-	.core_get = core_get_v1,
+	.core_get = venus_clks_get,
 	.core_put = core_put_v1,
 	.core_power = core_power_v1,
 	.vdec_get = vdec_get_v3,
@@ -1013,10 +998,6 @@  static int core_get_v4(struct venus_core *core)
 	if (legacy_binding)
 		return 0;
 
-	ret = devm_pm_opp_set_clkname(dev, "core");
-	if (ret)
-		return ret;
-
 	ret = vcodec_domains_get(core);
 	if (ret)
 		return ret;