Commit 11120e93 authored by Yangtao Li's avatar Yangtao Li Committed by Rob Clark

drm/msm: Convert to use resource-managed OPP API

Use resource-managed OPP API to simplify code.
Signed-off-by: default avatarYangtao Li <tiny.windzz@gmail.com>
Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210314163408.22292-12-digetx@gmail.comReviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 46188352
...@@ -1705,7 +1705,7 @@ static void check_speed_bin(struct device *dev) ...@@ -1705,7 +1705,7 @@ static void check_speed_bin(struct device *dev)
nvmem_cell_put(cell); nvmem_cell_put(cell);
} }
dev_pm_opp_set_supported_hw(dev, &val, 1); devm_pm_opp_set_supported_hw(dev, &val, 1);
} }
struct msm_gpu *a5xx_gpu_init(struct drm_device *dev) struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
......
...@@ -1346,7 +1346,7 @@ static int a6xx_gmu_pwrlevels_probe(struct a6xx_gmu *gmu) ...@@ -1346,7 +1346,7 @@ static int a6xx_gmu_pwrlevels_probe(struct a6xx_gmu *gmu)
* The GMU handles its own frequency switching so build a list of * The GMU handles its own frequency switching so build a list of
* available frequencies to send during initialization * available frequencies to send during initialization
*/ */
ret = dev_pm_opp_of_add_table(gmu->dev); ret = devm_pm_opp_of_add_table(gmu->dev);
if (ret) { if (ret) {
DRM_DEV_ERROR(gmu->dev, "Unable to set the OPP table for the GMU\n"); DRM_DEV_ERROR(gmu->dev, "Unable to set the OPP table for the GMU\n");
return ret; return ret;
......
...@@ -1339,9 +1339,6 @@ static void a6xx_destroy(struct msm_gpu *gpu) ...@@ -1339,9 +1339,6 @@ static void a6xx_destroy(struct msm_gpu *gpu)
adreno_gpu_cleanup(adreno_gpu); adreno_gpu_cleanup(adreno_gpu);
if (a6xx_gpu->opp_table)
dev_pm_opp_put_supported_hw(a6xx_gpu->opp_table);
kfree(a6xx_gpu); kfree(a6xx_gpu);
} }
...@@ -1474,7 +1471,6 @@ static u32 fuse_to_supp_hw(struct device *dev, u32 revn, u32 fuse) ...@@ -1474,7 +1471,6 @@ static u32 fuse_to_supp_hw(struct device *dev, u32 revn, u32 fuse)
static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu, static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
u32 revn) u32 revn)
{ {
struct opp_table *opp_table;
u32 supp_hw = UINT_MAX; u32 supp_hw = UINT_MAX;
u16 speedbin; u16 speedbin;
int ret; int ret;
...@@ -1497,11 +1493,10 @@ static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu, ...@@ -1497,11 +1493,10 @@ static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
supp_hw = fuse_to_supp_hw(dev, revn, speedbin); supp_hw = fuse_to_supp_hw(dev, revn, speedbin);
done: done:
opp_table = dev_pm_opp_set_supported_hw(dev, &supp_hw, 1); ret = devm_pm_opp_set_supported_hw(dev, &supp_hw, 1);
if (IS_ERR(opp_table)) if (ret)
return PTR_ERR(opp_table); return ret;
a6xx_gpu->opp_table = opp_table;
return 0; return 0;
} }
......
...@@ -33,8 +33,6 @@ struct a6xx_gpu { ...@@ -33,8 +33,6 @@ struct a6xx_gpu {
void *llc_slice; void *llc_slice;
void *htw_llc_slice; void *htw_llc_slice;
bool have_mmu500; bool have_mmu500;
struct opp_table *opp_table;
}; };
#define to_a6xx_gpu(x) container_of(x, struct a6xx_gpu, base) #define to_a6xx_gpu(x) container_of(x, struct a6xx_gpu, base)
......
...@@ -841,7 +841,7 @@ static void adreno_get_pwrlevels(struct device *dev, ...@@ -841,7 +841,7 @@ static void adreno_get_pwrlevels(struct device *dev,
if (!of_find_property(dev->of_node, "operating-points-v2", NULL)) if (!of_find_property(dev->of_node, "operating-points-v2", NULL))
ret = adreno_get_legacy_pwrlevels(dev); ret = adreno_get_legacy_pwrlevels(dev);
else { else {
ret = dev_pm_opp_of_add_table(dev); ret = devm_pm_opp_of_add_table(dev);
if (ret) if (ret)
DRM_DEV_ERROR(dev, "Unable to set the OPP table\n"); DRM_DEV_ERROR(dev, "Unable to set the OPP table\n");
} }
......
...@@ -1141,21 +1141,21 @@ static int dpu_bind(struct device *dev, struct device *master, void *data) ...@@ -1141,21 +1141,21 @@ static int dpu_bind(struct device *dev, struct device *master, void *data)
if (!dpu_kms) if (!dpu_kms)
return -ENOMEM; return -ENOMEM;
dpu_kms->opp_table = dev_pm_opp_set_clkname(dev, "core"); ret = devm_pm_opp_set_clkname(dev, "core");
if (IS_ERR(dpu_kms->opp_table)) if (ret)
return PTR_ERR(dpu_kms->opp_table); return ret;
/* OPP table is optional */ /* OPP table is optional */
ret = dev_pm_opp_of_add_table(dev); ret = devm_pm_opp_of_add_table(dev);
if (ret && ret != -ENODEV) { if (ret && ret != -ENODEV) {
dev_err(dev, "invalid OPP table in device tree\n"); dev_err(dev, "invalid OPP table in device tree\n");
goto put_clkname; return ret;
} }
mp = &dpu_kms->mp; mp = &dpu_kms->mp;
ret = msm_dss_parse_clock(pdev, mp); ret = msm_dss_parse_clock(pdev, mp);
if (ret) { if (ret) {
DPU_ERROR("failed to parse clocks, ret=%d\n", ret); DPU_ERROR("failed to parse clocks, ret=%d\n", ret);
goto err; return ret;
} }
platform_set_drvdata(pdev, dpu_kms); platform_set_drvdata(pdev, dpu_kms);
...@@ -1163,7 +1163,7 @@ static int dpu_bind(struct device *dev, struct device *master, void *data) ...@@ -1163,7 +1163,7 @@ static int dpu_bind(struct device *dev, struct device *master, void *data)
ret = msm_kms_init(&dpu_kms->base, &kms_funcs); ret = msm_kms_init(&dpu_kms->base, &kms_funcs);
if (ret) { if (ret) {
DPU_ERROR("failed to init kms, ret=%d\n", ret); DPU_ERROR("failed to init kms, ret=%d\n", ret);
goto err; return ret;
} }
dpu_kms->dev = ddev; dpu_kms->dev = ddev;
dpu_kms->pdev = pdev; dpu_kms->pdev = pdev;
...@@ -1172,11 +1172,7 @@ static int dpu_bind(struct device *dev, struct device *master, void *data) ...@@ -1172,11 +1172,7 @@ static int dpu_bind(struct device *dev, struct device *master, void *data)
dpu_kms->rpm_enabled = true; dpu_kms->rpm_enabled = true;
priv->kms = &dpu_kms->base; priv->kms = &dpu_kms->base;
return ret;
err:
dev_pm_opp_of_remove_table(dev);
put_clkname:
dev_pm_opp_put_clkname(dpu_kms->opp_table);
return ret; return ret;
} }
...@@ -1192,9 +1188,6 @@ static void dpu_unbind(struct device *dev, struct device *master, void *data) ...@@ -1192,9 +1188,6 @@ static void dpu_unbind(struct device *dev, struct device *master, void *data)
if (dpu_kms->rpm_enabled) if (dpu_kms->rpm_enabled)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
dev_pm_opp_of_remove_table(dev);
dev_pm_opp_put_clkname(dpu_kms->opp_table);
} }
static const struct component_ops dpu_ops = { static const struct component_ops dpu_ops = {
......
...@@ -128,8 +128,6 @@ struct dpu_kms { ...@@ -128,8 +128,6 @@ struct dpu_kms {
struct platform_device *pdev; struct platform_device *pdev;
bool rpm_enabled; bool rpm_enabled;
struct opp_table *opp_table;
struct dss_module_power mp; struct dss_module_power mp;
/* reference count bandwidth requests, so we know when we can /* reference count bandwidth requests, so we know when we can
......
...@@ -77,8 +77,6 @@ struct dp_ctrl_private { ...@@ -77,8 +77,6 @@ struct dp_ctrl_private {
struct dp_parser *parser; struct dp_parser *parser;
struct dp_catalog *catalog; struct dp_catalog *catalog;
struct opp_table *opp_table;
struct completion idle_comp; struct completion idle_comp;
struct completion video_comp; struct completion video_comp;
}; };
...@@ -1941,20 +1939,17 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, ...@@ -1941,20 +1939,17 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
ctrl->opp_table = dev_pm_opp_set_clkname(dev, "ctrl_link"); ret = devm_pm_opp_set_clkname(dev, "ctrl_link");
if (IS_ERR(ctrl->opp_table)) { if (ret) {
dev_err(dev, "invalid DP OPP table in device tree\n"); dev_err(dev, "invalid DP OPP table in device tree\n");
/* caller do PTR_ERR(ctrl->opp_table) */ /* caller do PTR_ERR(opp_table) */
return (struct dp_ctrl *)ctrl->opp_table; return (struct dp_ctrl *)ERR_PTR(ret);
} }
/* OPP table is optional */ /* OPP table is optional */
ret = dev_pm_opp_of_add_table(dev); ret = devm_pm_opp_of_add_table(dev);
if (ret) { if (ret)
dev_err(dev, "failed to add DP OPP table\n"); dev_err(dev, "failed to add DP OPP table\n");
dev_pm_opp_put_clkname(ctrl->opp_table);
ctrl->opp_table = NULL;
}
init_completion(&ctrl->idle_comp); init_completion(&ctrl->idle_comp);
init_completion(&ctrl->video_comp); init_completion(&ctrl->video_comp);
...@@ -1970,16 +1965,3 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, ...@@ -1970,16 +1965,3 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link,
return &ctrl->dp_ctrl; return &ctrl->dp_ctrl;
} }
void dp_ctrl_put(struct dp_ctrl *dp_ctrl)
{
struct dp_ctrl_private *ctrl;
ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl);
if (ctrl->opp_table) {
dev_pm_opp_of_remove_table(ctrl->dev);
dev_pm_opp_put_clkname(ctrl->opp_table);
ctrl->opp_table = NULL;
}
}
...@@ -33,6 +33,5 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, ...@@ -33,6 +33,5 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link,
struct dp_panel *panel, struct drm_dp_aux *aux, struct dp_panel *panel, struct drm_dp_aux *aux,
struct dp_power *power, struct dp_catalog *catalog, struct dp_power *power, struct dp_catalog *catalog,
struct dp_parser *parser); struct dp_parser *parser);
void dp_ctrl_put(struct dp_ctrl *dp_ctrl);
#endif /* _DP_CTRL_H_ */ #endif /* _DP_CTRL_H_ */
...@@ -747,7 +747,6 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data) ...@@ -747,7 +747,6 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)
static void dp_display_deinit_sub_modules(struct dp_display_private *dp) static void dp_display_deinit_sub_modules(struct dp_display_private *dp)
{ {
dp_debug_put(dp->debug); dp_debug_put(dp->debug);
dp_ctrl_put(dp->ctrl);
dp_panel_put(dp->panel); dp_panel_put(dp->panel);
dp_aux_put(dp->aux); dp_aux_put(dp->aux);
dp_audio_put(dp->audio); dp_audio_put(dp->audio);
...@@ -841,13 +840,11 @@ static int dp_init_sub_modules(struct dp_display_private *dp) ...@@ -841,13 +840,11 @@ static int dp_init_sub_modules(struct dp_display_private *dp)
rc = PTR_ERR(dp->audio); rc = PTR_ERR(dp->audio);
pr_err("failed to initialize audio, rc = %d\n", rc); pr_err("failed to initialize audio, rc = %d\n", rc);
dp->audio = NULL; dp->audio = NULL;
goto error_audio; goto error_ctrl;
} }
return rc; return rc;
error_audio:
dp_ctrl_put(dp->ctrl);
error_ctrl: error_ctrl:
dp_panel_put(dp->panel); dp_panel_put(dp->panel);
error_link: error_link:
......
...@@ -114,8 +114,6 @@ struct msm_dsi_host { ...@@ -114,8 +114,6 @@ struct msm_dsi_host {
struct clk *pixel_clk_src; struct clk *pixel_clk_src;
struct clk *byte_intf_clk; struct clk *byte_intf_clk;
struct opp_table *opp_table;
u32 byte_clk_rate; u32 byte_clk_rate;
u32 pixel_clk_rate; u32 pixel_clk_rate;
u32 esc_clk_rate; u32 esc_clk_rate;
...@@ -1885,14 +1883,13 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) ...@@ -1885,14 +1883,13 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
goto fail; goto fail;
} }
msm_host->opp_table = dev_pm_opp_set_clkname(&pdev->dev, "byte"); ret = devm_pm_opp_set_clkname(&pdev->dev, "byte");
if (IS_ERR(msm_host->opp_table)) if (ret)
return PTR_ERR(msm_host->opp_table); return ret;
/* OPP table is optional */ /* OPP table is optional */
ret = dev_pm_opp_of_add_table(&pdev->dev); ret = devm_pm_opp_of_add_table(&pdev->dev);
if (ret && ret != -ENODEV) { if (ret && ret != -ENODEV) {
dev_err(&pdev->dev, "invalid OPP table in device tree\n"); dev_err(&pdev->dev, "invalid OPP table in device tree\n");
dev_pm_opp_put_clkname(msm_host->opp_table);
return ret; return ret;
} }
...@@ -1931,8 +1928,6 @@ void msm_dsi_host_destroy(struct mipi_dsi_host *host) ...@@ -1931,8 +1928,6 @@ void msm_dsi_host_destroy(struct mipi_dsi_host *host)
mutex_destroy(&msm_host->cmd_mutex); mutex_destroy(&msm_host->cmd_mutex);
mutex_destroy(&msm_host->dev_mutex); mutex_destroy(&msm_host->dev_mutex);
dev_pm_opp_of_remove_table(&msm_host->pdev->dev);
dev_pm_opp_put_clkname(msm_host->opp_table);
pm_runtime_disable(&msm_host->pdev->dev); pm_runtime_disable(&msm_host->pdev->dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment