diff mbox series

[v3,3/3] venus: pm_helpers: Remove dead code and simplify power management

Message ID 20250115-switch_gdsc_mode-v3-3-9a24d2fd724c@quicinc.com (mailing list archive)
State New
Headers show
Series Use APIs in gdsc genpd to switch gdsc mode for venus v4 core | expand

Commit Message

Renjiang Han Jan. 15, 2025, 9:30 a.m. UTC
The functions poweron_coreid(), poweroff_coreid() and vcodec_control_v4()
are only used for v4 and v6. Remove the dead code by:
- Removing vcodec_control_v4() function
- Removing the check for !IS_V6(core) && !IS_V4(core) in poweron_coreid()
and poweroff_coreid()

Directly call dev_pm_genpd_set_hwmode() without vcodec_control_v4().

Signed-off-by: Renjiang Han <quic_renjiang@quicinc.com>
---
 drivers/media/platform/qcom/venus/pm_helpers.c | 73 +++-----------------------
 1 file changed, 8 insertions(+), 65 deletions(-)

Comments

Dmitry Baryshkov Jan. 15, 2025, 10:01 a.m. UTC | #1
On Wed, Jan 15, 2025 at 03:00:54PM +0530, Renjiang Han wrote:
> The functions poweron_coreid(), poweroff_coreid() and vcodec_control_v4()
> are only used for v4 and v6. Remove the dead code by:
> - Removing vcodec_control_v4() function
> - Removing the check for !IS_V6(core) && !IS_V4(core) in poweron_coreid()
> and poweroff_coreid()
> 
> Directly call dev_pm_genpd_set_hwmode() without vcodec_control_v4().
> 
> Signed-off-by: Renjiang Han <quic_renjiang@quicinc.com>
> ---
>  drivers/media/platform/qcom/venus/pm_helpers.c | 73 +++-----------------------
>  1 file changed, 8 insertions(+), 65 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
> index a2062b366d4aedba3eb5e4be456a005847eaec0b..846aa765edbb33df0b0c39bb463dd68c16ce1b68 100644
> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
> @@ -406,74 +406,29 @@ static const struct venus_pm_ops pm_ops_v3 = {
>  	.load_scale = load_scale_v1,
>  };
>  
> -static int vcodec_control_v4(struct venus_core *core, u32 coreid, bool enable)
> -{
> -	void __iomem *ctrl, *stat;
> -	u32 val;
> -	int ret;
> -
> -	if (IS_V6(core) || IS_V4(core))
> -		return dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[coreid], !enable);
> -	else if (coreid == VIDC_CORE_ID_1) {
> -		ctrl = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL;
> -		stat = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_STATUS;
> -	} else {
> -		ctrl = core->wrapper_base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL;
> -		stat = core->wrapper_base + WRAPPER_VCODEC1_MMCC_POWER_STATUS;
> -	}
> -
> -	if (enable) {
> -		writel(0, ctrl);
> -
> -		ret = readl_poll_timeout(stat, val, val & BIT(1), 1, 100);
> -		if (ret)
> -			return ret;
> -	} else {
> -		writel(1, ctrl);
> -
> -		ret = readl_poll_timeout(stat, val, !(val & BIT(1)), 1, 100);
> -		if (ret)
> -			return ret;
> -	}
> -
> -	return 0;
> -}
> -
>  static int poweroff_coreid(struct venus_core *core, unsigned int coreid_mask)
>  {
>  	int ret;
>  
>  	if (coreid_mask & VIDC_CORE_ID_1) {
> -		ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
> +		ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_1], false);
>  		if (ret)
>  			return ret;
>  
>  		vcodec_clks_disable(core, core->vcodec0_clks);
>  
> -		if (!IS_V6(core) && !IS_V4(core)) {
> -			ret = vcodec_control_v4(core, VIDC_CORE_ID_1, false);
> -			if (ret)
> -				return ret;
> -		}
> -
>  		ret = pm_runtime_put_sync(core->pmdomains->pd_devs[1]);
>  		if (ret < 0)
>  			return ret;
>  	}
>  
>  	if (coreid_mask & VIDC_CORE_ID_2) {
> -		ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
> +		ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_2], false);
>  		if (ret)
>  			return ret;
>  
>  		vcodec_clks_disable(core, core->vcodec1_clks);
>  
> -		if (!IS_V6(core) && !IS_V4(core)) {
> -			ret = vcodec_control_v4(core, VIDC_CORE_ID_2, false);
> -			if (ret)
> -				return ret;
> -		}
> -
>  		ret = pm_runtime_put_sync(core->pmdomains->pd_devs[2]);
>  		if (ret < 0)
>  			return ret;
> @@ -491,17 +446,11 @@ static int poweron_coreid(struct venus_core *core, unsigned int coreid_mask)
>  		if (ret < 0)
>  			return ret;
>  
> -		if (!IS_V6(core) && !IS_V4(core)) {
> -			ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
> -			if (ret)
> -				return ret;
> -		}
> -
>  		ret = vcodec_clks_enable(core, core->vcodec0_clks);
>  		if (ret)
>  			return ret;
>  
> -		ret = vcodec_control_v4(core, VIDC_CORE_ID_1, false);
> +		ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_1], true);
>  		if (ret < 0)
>  			return ret;
>  	}
> @@ -511,17 +460,11 @@ static int poweron_coreid(struct venus_core *core, unsigned int coreid_mask)
>  		if (ret < 0)
>  			return ret;
>  
> -		if (!IS_V6(core) && !IS_V4(core)) {
> -			ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
> -			if (ret)
> -				return ret;
> -		}
> -
>  		ret = vcodec_clks_enable(core, core->vcodec1_clks);
>  		if (ret)
>  			return ret;
>  
> -		ret = vcodec_control_v4(core, VIDC_CORE_ID_2, false);
> +		ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_2], true);
>  		if (ret < 0)
>  			return ret;
>  	}
> @@ -802,7 +745,7 @@ static int vdec_power_v4(struct device *dev, int on)
>  	if (!legacy_binding)
>  		return 0;
>  
> -	ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
> +	ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_1], false);
>  	if (ret)
>  		return ret;
>  
> @@ -811,7 +754,7 @@ static int vdec_power_v4(struct device *dev, int on)
>  	else
>  		vcodec_clks_disable(core, core->vcodec0_clks);
>  
> -	vcodec_control_v4(core, VIDC_CORE_ID_1, false);
> +	dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_1], true);

Check for the error here.

>  
>  	return ret;
>  }
> @@ -847,7 +790,7 @@ static int venc_power_v4(struct device *dev, int on)
>  	if (!legacy_binding)
>  		return 0;
>  
> -	ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
> +	ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_2], false);
>  	if (ret)
>  		return ret;
>  
> @@ -856,7 +799,7 @@ static int venc_power_v4(struct device *dev, int on)
>  	else
>  		vcodec_clks_disable(core, core->vcodec1_clks);
>  
> -	vcodec_control_v4(core, VIDC_CORE_ID_2, false);
> +	dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_2], true);


Check for the error here.

>  
>  	return ret;
>  }
> 
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
index a2062b366d4aedba3eb5e4be456a005847eaec0b..846aa765edbb33df0b0c39bb463dd68c16ce1b68 100644
--- a/drivers/media/platform/qcom/venus/pm_helpers.c
+++ b/drivers/media/platform/qcom/venus/pm_helpers.c
@@ -406,74 +406,29 @@  static const struct venus_pm_ops pm_ops_v3 = {
 	.load_scale = load_scale_v1,
 };
 
-static int vcodec_control_v4(struct venus_core *core, u32 coreid, bool enable)
-{
-	void __iomem *ctrl, *stat;
-	u32 val;
-	int ret;
-
-	if (IS_V6(core) || IS_V4(core))
-		return dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[coreid], !enable);
-	else if (coreid == VIDC_CORE_ID_1) {
-		ctrl = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL;
-		stat = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_STATUS;
-	} else {
-		ctrl = core->wrapper_base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL;
-		stat = core->wrapper_base + WRAPPER_VCODEC1_MMCC_POWER_STATUS;
-	}
-
-	if (enable) {
-		writel(0, ctrl);
-
-		ret = readl_poll_timeout(stat, val, val & BIT(1), 1, 100);
-		if (ret)
-			return ret;
-	} else {
-		writel(1, ctrl);
-
-		ret = readl_poll_timeout(stat, val, !(val & BIT(1)), 1, 100);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
-}
-
 static int poweroff_coreid(struct venus_core *core, unsigned int coreid_mask)
 {
 	int ret;
 
 	if (coreid_mask & VIDC_CORE_ID_1) {
-		ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
+		ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_1], false);
 		if (ret)
 			return ret;
 
 		vcodec_clks_disable(core, core->vcodec0_clks);
 
-		if (!IS_V6(core) && !IS_V4(core)) {
-			ret = vcodec_control_v4(core, VIDC_CORE_ID_1, false);
-			if (ret)
-				return ret;
-		}
-
 		ret = pm_runtime_put_sync(core->pmdomains->pd_devs[1]);
 		if (ret < 0)
 			return ret;
 	}
 
 	if (coreid_mask & VIDC_CORE_ID_2) {
-		ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
+		ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_2], false);
 		if (ret)
 			return ret;
 
 		vcodec_clks_disable(core, core->vcodec1_clks);
 
-		if (!IS_V6(core) && !IS_V4(core)) {
-			ret = vcodec_control_v4(core, VIDC_CORE_ID_2, false);
-			if (ret)
-				return ret;
-		}
-
 		ret = pm_runtime_put_sync(core->pmdomains->pd_devs[2]);
 		if (ret < 0)
 			return ret;
@@ -491,17 +446,11 @@  static int poweron_coreid(struct venus_core *core, unsigned int coreid_mask)
 		if (ret < 0)
 			return ret;
 
-		if (!IS_V6(core) && !IS_V4(core)) {
-			ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
-			if (ret)
-				return ret;
-		}
-
 		ret = vcodec_clks_enable(core, core->vcodec0_clks);
 		if (ret)
 			return ret;
 
-		ret = vcodec_control_v4(core, VIDC_CORE_ID_1, false);
+		ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_1], true);
 		if (ret < 0)
 			return ret;
 	}
@@ -511,17 +460,11 @@  static int poweron_coreid(struct venus_core *core, unsigned int coreid_mask)
 		if (ret < 0)
 			return ret;
 
-		if (!IS_V6(core) && !IS_V4(core)) {
-			ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
-			if (ret)
-				return ret;
-		}
-
 		ret = vcodec_clks_enable(core, core->vcodec1_clks);
 		if (ret)
 			return ret;
 
-		ret = vcodec_control_v4(core, VIDC_CORE_ID_2, false);
+		ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_2], true);
 		if (ret < 0)
 			return ret;
 	}
@@ -802,7 +745,7 @@  static int vdec_power_v4(struct device *dev, int on)
 	if (!legacy_binding)
 		return 0;
 
-	ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
+	ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_1], false);
 	if (ret)
 		return ret;
 
@@ -811,7 +754,7 @@  static int vdec_power_v4(struct device *dev, int on)
 	else
 		vcodec_clks_disable(core, core->vcodec0_clks);
 
-	vcodec_control_v4(core, VIDC_CORE_ID_1, false);
+	dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_1], true);
 
 	return ret;
 }
@@ -847,7 +790,7 @@  static int venc_power_v4(struct device *dev, int on)
 	if (!legacy_binding)
 		return 0;
 
-	ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
+	ret = dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_2], false);
 	if (ret)
 		return ret;
 
@@ -856,7 +799,7 @@  static int venc_power_v4(struct device *dev, int on)
 	else
 		vcodec_clks_disable(core, core->vcodec1_clks);
 
-	vcodec_control_v4(core, VIDC_CORE_ID_2, false);
+	dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[VIDC_CORE_ID_2], true);
 
 	return ret;
 }