Skip to content

Commit 53f65af

Browse files
Stanimir Varbanovgregkh
authored andcommitted
media: venus: pm_helpers: Control core power domain manually
[ Upstream commit a76f43a ] 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. Tested-by: Fritz Koenig <frkoenig@chromium.org> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 89f518b commit 53f65af

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

‎drivers/media/platform/qcom/venus/core.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ struct venus_caps {
123123
* @clks: an array of struct clk pointers
124124
* @vcodec0_clks: an array of vcodec0 struct clk pointers
125125
* @vcodec1_clks: an array of vcodec1 struct clk pointers
126-
* @pd_dl_venus: pmdomain device-link for venus domain
127126
* @pmdomains: an array of pmdomains struct device pointers
128127
* @vdev_dec: a reference to video device structure for decoder instances
129128
* @vdev_enc: a reference to video device structure for encoder instances
@@ -161,7 +160,6 @@ struct venus_core {
161160
struct icc_path *cpucfg_path;
162161
struct opp_table *opp_table;
163162
bool has_opp_table;
164-
struct device_link *pd_dl_venus;
165163
struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX];
166164
struct device_link *opp_dl_venus;
167165
struct device *opp_pmdomain;

‎drivers/media/platform/qcom/venus/pm_helpers.c‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,6 @@ static int vcodec_domains_get(struct device *dev)
773773
core->pmdomains[i] = pd;
774774
}
775775

776-
core->pd_dl_venus = device_link_add(dev, core->pmdomains[0],
777-
DL_FLAG_PM_RUNTIME |
778-
DL_FLAG_STATELESS |
779-
DL_FLAG_RPM_ACTIVE);
780-
if (!core->pd_dl_venus)
781-
return -ENODEV;
782-
783776
skip_pmdomains:
784777
if (!core->has_opp_table)
785778
return 0;
@@ -806,14 +799,12 @@ static int vcodec_domains_get(struct device *dev)
806799
opp_dl_add_err:
807800
dev_pm_opp_detach_genpd(core->opp_table);
808801
opp_attach_err:
809-
if (core->pd_dl_venus) {
810-
device_link_del(core->pd_dl_venus);
811-
for (i = 0; i < res->vcodec_pmdomains_num; i++) {
812-
if (IS_ERR_OR_NULL(core->pmdomains[i]))
813-
continue;
814-
dev_pm_domain_detach(core->pmdomains[i], true);
815-
}
802+
for (i = 0; i < res->vcodec_pmdomains_num; i++) {
803+
if (IS_ERR_OR_NULL(core->pmdomains[i]))
804+
continue;
805+
dev_pm_domain_detach(core->pmdomains[i], true);
816806
}
807+
817808
return ret;
818809
}
819810

@@ -826,9 +817,6 @@ static void vcodec_domains_put(struct device *dev)
826817
if (!res->vcodec_pmdomains_num)
827818
goto skip_pmdomains;
828819

829-
if (core->pd_dl_venus)
830-
device_link_del(core->pd_dl_venus);
831-
832820
for (i = 0; i < res->vcodec_pmdomains_num; i++) {
833821
if (IS_ERR_OR_NULL(core->pmdomains[i]))
834822
continue;
@@ -916,16 +904,30 @@ static void core_put_v4(struct device *dev)
916904
static int core_power_v4(struct device *dev, int on)
917905
{
918906
struct venus_core *core = dev_get_drvdata(dev);
907+
struct device *pmctrl = core->pmdomains[0];
919908
int ret = 0;
920909

921910
if (on == POWER_ON) {
911+
if (pmctrl) {
912+
ret = pm_runtime_get_sync(pmctrl);
913+
if (ret < 0) {
914+
pm_runtime_put_noidle(pmctrl);
915+
return ret;
916+
}
917+
}
918+
922919
ret = core_clks_enable(core);
920+
if (ret < 0 && pmctrl)
921+
pm_runtime_put_sync(pmctrl);
923922
} else {
924923
/* Drop the performance state vote */
925924
if (core->opp_pmdomain)
926925
dev_pm_opp_set_rate(dev, 0);
927926

928927
core_clks_disable(core);
928+
929+
if (pmctrl)
930+
pm_runtime_put_sync(pmctrl);
929931
}
930932

931933
return ret;

0 commit comments

Comments
 (0)