Skip to content

Commit a76f43a

Browse files
Stanimir Varbanovmchehab
authored andcommitted
media: venus: pm_helpers: Control core power domain manually
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 <[email protected]> Signed-off-by: Stanimir Varbanov <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 74c357f commit a76f43a

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ struct venus_format {
9191
* @clks: an array of struct clk pointers
9292
* @vcodec0_clks: an array of vcodec0 struct clk pointers
9393
* @vcodec1_clks: an array of vcodec1 struct clk pointers
94-
* @pd_dl_venus: pmdomain device-link for venus domain
9594
* @pmdomains: an array of pmdomains struct device pointers
9695
* @vdev_dec: a reference to video device structure for decoder instances
9796
* @vdev_enc: a reference to video device structure for encoder instances
@@ -128,7 +127,6 @@ struct venus_core {
128127
struct icc_path *cpucfg_path;
129128
struct opp_table *opp_table;
130129
bool has_opp_table;
131-
struct device_link *pd_dl_venus;
132130
struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX];
133131
struct device_link *opp_dl_venus;
134132
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
@@ -774,13 +774,6 @@ static int vcodec_domains_get(struct device *dev)
774774
core->pmdomains[i] = pd;
775775
}
776776

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

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

830-
if (core->pd_dl_venus)
831-
device_link_del(core->pd_dl_venus);
832-
833821
for (i = 0; i < res->vcodec_pmdomains_num; i++) {
834822
if (IS_ERR_OR_NULL(core->pmdomains[i]))
835823
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)