* [PATCH] venus: pm_helpers: Control core power domain manually
@ 2021-01-09 7:21 Stanimir Varbanov
2021-01-11 22:05 ` Fritz Koenig
0 siblings, 1 reply; 2+ messages in thread
From: Stanimir Varbanov @ 2021-01-09 7:21 UTC (permalink / raw)
To: linux-media, linux-arm-msm, linux-kernel
Cc: Vikash Garodia, Dikshita Agarwal, Mansur Alisha Shaik, Stanimir Varbanov
Presently we use device_link to control core power domain. But this
leads to issues because the genpd doesn't guarantee synchronous on/off
for supplier devices. Switch to manually control by pmruntime calls.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
---
drivers/media/platform/qcom/venus/core.h | 1 -
.../media/platform/qcom/venus/pm_helpers.c | 36 ++++++++++---------
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index dfc13b2f371f..74d9fd3d51cc 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -128,7 +128,6 @@ struct venus_core {
struct icc_path *cpucfg_path;
struct opp_table *opp_table;
bool has_opp_table;
- struct device_link *pd_dl_venus;
struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX];
struct device_link *opp_dl_venus;
struct device *opp_pmdomain;
diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
index 94219a3093cb..e0338932a720 100644
--- a/drivers/media/platform/qcom/venus/pm_helpers.c
+++ b/drivers/media/platform/qcom/venus/pm_helpers.c
@@ -774,13 +774,6 @@ static int vcodec_domains_get(struct device *dev)
core->pmdomains[i] = pd;
}
- core->pd_dl_venus = device_link_add(dev, core->pmdomains[0],
- DL_FLAG_PM_RUNTIME |
- DL_FLAG_STATELESS |
- DL_FLAG_RPM_ACTIVE);
- if (!core->pd_dl_venus)
- return -ENODEV;
-
skip_pmdomains:
if (!core->has_opp_table)
return 0;
@@ -807,14 +800,12 @@ static int vcodec_domains_get(struct device *dev)
opp_dl_add_err:
dev_pm_opp_detach_genpd(core->opp_table);
opp_attach_err:
- if (core->pd_dl_venus) {
- device_link_del(core->pd_dl_venus);
- for (i = 0; i < res->vcodec_pmdomains_num; i++) {
- if (IS_ERR_OR_NULL(core->pmdomains[i]))
- continue;
- dev_pm_domain_detach(core->pmdomains[i], true);
- }
+ for (i = 0; i < res->vcodec_pmdomains_num; i++) {
+ if (IS_ERR_OR_NULL(core->pmdomains[i]))
+ continue;
+ dev_pm_domain_detach(core->pmdomains[i], true);
}
+
return ret;
}
@@ -827,9 +818,6 @@ static void vcodec_domains_put(struct device *dev)
if (!res->vcodec_pmdomains_num)
goto skip_pmdomains;
- if (core->pd_dl_venus)
- device_link_del(core->pd_dl_venus);
-
for (i = 0; i < res->vcodec_pmdomains_num; i++) {
if (IS_ERR_OR_NULL(core->pmdomains[i]))
continue;
@@ -917,16 +905,30 @@ static void core_put_v4(struct device *dev)
static int core_power_v4(struct device *dev, int on)
{
struct venus_core *core = dev_get_drvdata(dev);
+ struct device *pmctrl = core->pmdomains[0];
int ret = 0;
if (on == POWER_ON) {
+ if (pmctrl) {
+ ret = pm_runtime_get_sync(pmctrl);
+ if (ret < 0) {
+ pm_runtime_put_noidle(pmctrl);
+ return ret;
+ }
+ }
+
ret = core_clks_enable(core);
+ if (ret < 0 && pmctrl)
+ pm_runtime_put_sync(pmctrl);
} else {
/* Drop the performance state vote */
if (core->opp_pmdomain)
dev_pm_opp_set_rate(dev, 0);
core_clks_disable(core);
+
+ if (pmctrl)
+ pm_runtime_put_sync(pmctrl);
}
return ret;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] venus: pm_helpers: Control core power domain manually
2021-01-09 7:21 [PATCH] venus: pm_helpers: Control core power domain manually Stanimir Varbanov
@ 2021-01-11 22:05 ` Fritz Koenig
0 siblings, 0 replies; 2+ messages in thread
From: Fritz Koenig @ 2021-01-11 22:05 UTC (permalink / raw)
To: Stanimir Varbanov
Cc: Linux Media Mailing List, linux-arm-msm, LKML, Vikash Garodia,
Dikshita Agarwal, Mansur Alisha Shaik
On Fri, Jan 8, 2021 at 11:23 PM Stanimir Varbanov
<stanimir.varbanov@linaro.org> wrote:
>
> Presently we use device_link to control core power domain. But this
> leads to issues because the genpd doesn't guarantee synchronous on/off
> for supplier devices. Switch to manually control by pmruntime calls.
>
> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> ---
> drivers/media/platform/qcom/venus/core.h | 1 -
> .../media/platform/qcom/venus/pm_helpers.c | 36 ++++++++++---------
> 2 files changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
> index dfc13b2f371f..74d9fd3d51cc 100644
> --- a/drivers/media/platform/qcom/venus/core.h
> +++ b/drivers/media/platform/qcom/venus/core.h
> @@ -128,7 +128,6 @@ struct venus_core {
> struct icc_path *cpucfg_path;
> struct opp_table *opp_table;
> bool has_opp_table;
> - struct device_link *pd_dl_venus;
remove from comment at start of struct as well.
* @pd_dl_venus: pmdomain device-link for venus domain
The patch gives huge improvements in encoder stability!
Tested-by: Fritz Koenig <frkoenig@chromium.org>
> struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX];
> struct device_link *opp_dl_venus;
> struct device *opp_pmdomain;
> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
> index 94219a3093cb..e0338932a720 100644
> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
> @@ -774,13 +774,6 @@ static int vcodec_domains_get(struct device *dev)
> core->pmdomains[i] = pd;
> }
>
> - core->pd_dl_venus = device_link_add(dev, core->pmdomains[0],
> - DL_FLAG_PM_RUNTIME |
> - DL_FLAG_STATELESS |
> - DL_FLAG_RPM_ACTIVE);
> - if (!core->pd_dl_venus)
> - return -ENODEV;
> -
> skip_pmdomains:
> if (!core->has_opp_table)
> return 0;
> @@ -807,14 +800,12 @@ static int vcodec_domains_get(struct device *dev)
> opp_dl_add_err:
> dev_pm_opp_detach_genpd(core->opp_table);
> opp_attach_err:
> - if (core->pd_dl_venus) {
> - device_link_del(core->pd_dl_venus);
> - for (i = 0; i < res->vcodec_pmdomains_num; i++) {
> - if (IS_ERR_OR_NULL(core->pmdomains[i]))
> - continue;
> - dev_pm_domain_detach(core->pmdomains[i], true);
> - }
> + for (i = 0; i < res->vcodec_pmdomains_num; i++) {
> + if (IS_ERR_OR_NULL(core->pmdomains[i]))
> + continue;
> + dev_pm_domain_detach(core->pmdomains[i], true);
> }
> +
> return ret;
> }
>
> @@ -827,9 +818,6 @@ static void vcodec_domains_put(struct device *dev)
> if (!res->vcodec_pmdomains_num)
> goto skip_pmdomains;
>
> - if (core->pd_dl_venus)
> - device_link_del(core->pd_dl_venus);
> -
> for (i = 0; i < res->vcodec_pmdomains_num; i++) {
> if (IS_ERR_OR_NULL(core->pmdomains[i]))
> continue;
> @@ -917,16 +905,30 @@ static void core_put_v4(struct device *dev)
> static int core_power_v4(struct device *dev, int on)
> {
> struct venus_core *core = dev_get_drvdata(dev);
> + struct device *pmctrl = core->pmdomains[0];
> int ret = 0;
>
> if (on == POWER_ON) {
> + if (pmctrl) {
> + ret = pm_runtime_get_sync(pmctrl);
> + if (ret < 0) {
> + pm_runtime_put_noidle(pmctrl);
> + return ret;
> + }
> + }
> +
> ret = core_clks_enable(core);
> + if (ret < 0 && pmctrl)
> + pm_runtime_put_sync(pmctrl);
> } else {
> /* Drop the performance state vote */
> if (core->opp_pmdomain)
> dev_pm_opp_set_rate(dev, 0);
>
> core_clks_disable(core);
> +
> + if (pmctrl)
> + pm_runtime_put_sync(pmctrl);
> }
>
> return ret;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-11 22:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-09 7:21 [PATCH] venus: pm_helpers: Control core power domain manually Stanimir Varbanov
2021-01-11 22:05 ` Fritz Koenig
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).