提交 00bd09db 编写于 作者: S Stanimir Varbanov 提交者: Zheng Zengkai

media: venus: pm_helpers: Control core power domain manually

stable inclusion
from stable-v5.10.94
commit 53f65afc260f962cb05bb1d1c29be6edabc2e939
bugzilla: https://gitee.com/openeuler/kernel/issues/I531X9

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=53f65afc260f962cb05bb1d1c29be6edabc2e939

--------------------------------

[ Upstream commit a76f43a4 ]

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: NFritz Koenig <frkoenig@chromium.org>
Signed-off-by: NStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 fe8c5ed2
...@@ -123,7 +123,6 @@ struct venus_caps { ...@@ -123,7 +123,6 @@ struct venus_caps {
* @clks: an array of struct clk pointers * @clks: an array of struct clk pointers
* @vcodec0_clks: an array of vcodec0 struct clk pointers * @vcodec0_clks: an array of vcodec0 struct clk pointers
* @vcodec1_clks: an array of vcodec1 struct clk pointers * @vcodec1_clks: an array of vcodec1 struct clk pointers
* @pd_dl_venus: pmdomain device-link for venus domain
* @pmdomains: an array of pmdomains struct device pointers * @pmdomains: an array of pmdomains struct device pointers
* @vdev_dec: a reference to video device structure for decoder instances * @vdev_dec: a reference to video device structure for decoder instances
* @vdev_enc: a reference to video device structure for encoder instances * @vdev_enc: a reference to video device structure for encoder instances
...@@ -161,7 +160,6 @@ struct venus_core { ...@@ -161,7 +160,6 @@ struct venus_core {
struct icc_path *cpucfg_path; struct icc_path *cpucfg_path;
struct opp_table *opp_table; struct opp_table *opp_table;
bool has_opp_table; bool has_opp_table;
struct device_link *pd_dl_venus;
struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX]; struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX];
struct device_link *opp_dl_venus; struct device_link *opp_dl_venus;
struct device *opp_pmdomain; struct device *opp_pmdomain;
......
...@@ -773,13 +773,6 @@ static int vcodec_domains_get(struct device *dev) ...@@ -773,13 +773,6 @@ static int vcodec_domains_get(struct device *dev)
core->pmdomains[i] = pd; 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: skip_pmdomains:
if (!core->has_opp_table) if (!core->has_opp_table)
return 0; return 0;
...@@ -806,14 +799,12 @@ static int vcodec_domains_get(struct device *dev) ...@@ -806,14 +799,12 @@ static int vcodec_domains_get(struct device *dev)
opp_dl_add_err: opp_dl_add_err:
dev_pm_opp_detach_genpd(core->opp_table); dev_pm_opp_detach_genpd(core->opp_table);
opp_attach_err: opp_attach_err:
if (core->pd_dl_venus) { for (i = 0; i < res->vcodec_pmdomains_num; i++) {
device_link_del(core->pd_dl_venus); if (IS_ERR_OR_NULL(core->pmdomains[i]))
for (i = 0; i < res->vcodec_pmdomains_num; i++) { continue;
if (IS_ERR_OR_NULL(core->pmdomains[i])) dev_pm_domain_detach(core->pmdomains[i], true);
continue;
dev_pm_domain_detach(core->pmdomains[i], true);
}
} }
return ret; return ret;
} }
...@@ -826,9 +817,6 @@ static void vcodec_domains_put(struct device *dev) ...@@ -826,9 +817,6 @@ static void vcodec_domains_put(struct device *dev)
if (!res->vcodec_pmdomains_num) if (!res->vcodec_pmdomains_num)
goto skip_pmdomains; goto skip_pmdomains;
if (core->pd_dl_venus)
device_link_del(core->pd_dl_venus);
for (i = 0; i < res->vcodec_pmdomains_num; i++) { for (i = 0; i < res->vcodec_pmdomains_num; i++) {
if (IS_ERR_OR_NULL(core->pmdomains[i])) if (IS_ERR_OR_NULL(core->pmdomains[i]))
continue; continue;
...@@ -916,16 +904,30 @@ static void core_put_v4(struct device *dev) ...@@ -916,16 +904,30 @@ static void core_put_v4(struct device *dev)
static int core_power_v4(struct device *dev, int on) static int core_power_v4(struct device *dev, int on)
{ {
struct venus_core *core = dev_get_drvdata(dev); struct venus_core *core = dev_get_drvdata(dev);
struct device *pmctrl = core->pmdomains[0];
int ret = 0; int ret = 0;
if (on == POWER_ON) { 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); ret = core_clks_enable(core);
if (ret < 0 && pmctrl)
pm_runtime_put_sync(pmctrl);
} else { } else {
/* Drop the performance state vote */ /* Drop the performance state vote */
if (core->opp_pmdomain) if (core->opp_pmdomain)
dev_pm_opp_set_rate(dev, 0); dev_pm_opp_set_rate(dev, 0);
core_clks_disable(core); core_clks_disable(core);
if (pmctrl)
pm_runtime_put_sync(pmctrl);
} }
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册