From a7529251129a1b8f6100731d298e0a363970fa88 Mon Sep 17 00:00:00 2001 From: Abhijit Kulkarni Date: Tue, 17 Mar 2020 16:55:26 -0700 Subject: [PATCH] disp: msm: sde: re-factor probe time initialization This change moves the msm_driver power resource initialization from bind time to probe time. This keeps the resource vote on until all the devices are bound. This is required since the regulator and clock sync_state driver will remove the proxy votes as soon as msm_driver has probed. Change-Id: Icb0e59e4ff0290ef0c1bd3914d6fdbf99bf5d9fa Signed-off-by: Abhijit Kulkarni --- msm/msm_drv.c | 83 +++++++++++++++++++++++++++++++---------------- msm/sde/sde_kms.c | 5 --- 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/msm/msm_drv.c b/msm/msm_drv.c index 2302a36691..747def6b4f 100644 --- a/msm/msm_drv.c +++ b/msm/msm_drv.c @@ -669,9 +669,10 @@ static int msm_drm_display_thread_create(struct sched_param param, return 0; } -static struct msm_kms *_msm_drm_init_helper(struct msm_drm_private *priv, - struct drm_device *ddev, struct device *dev, - struct platform_device *pdev) +static struct msm_kms *_msm_drm_component_init_helper( + struct msm_drm_private *priv, + struct drm_device *ddev, struct device *dev, + struct platform_device *pdev) { int ret; struct msm_kms *kms; @@ -722,15 +723,13 @@ static struct msm_kms *_msm_drm_init_helper(struct msm_drm_private *priv, return kms; } -static int msm_drm_init(struct device *dev, struct drm_driver *drv) +static int msm_drm_device_init(struct platform_device *pdev, + struct drm_driver *drv) { - struct platform_device *pdev = to_platform_device(dev); + struct device *dev = &pdev->dev; struct drm_device *ddev; struct msm_drm_private *priv; - struct msm_kms *kms = NULL; - int ret; - struct sched_param param = { 0 }; - struct drm_crtc *crtc; + int i, ret; ddev = drm_dev_alloc(drv, dev); if (IS_ERR(ddev)) { @@ -750,16 +749,6 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ddev->dev_private = priv; priv->dev = ddev; - ret = msm_mdss_init(ddev); - if (ret) - goto mdss_init_fail; - - priv->wq = alloc_ordered_workqueue("msm_drm", 0); - init_waitqueue_head(&priv->pending_crtcs_event); - - INIT_LIST_HEAD(&priv->client_event_list); - INIT_LIST_HEAD(&priv->inactive_list); - ret = sde_power_resource_init(pdev, &priv->phandle); if (ret) { pr_err("sde power resource init failed\n"); @@ -772,6 +761,42 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) goto dbg_init_fail; } + for (i = 0; i < SDE_POWER_HANDLE_DBUS_ID_MAX; i++) + sde_power_data_bus_set_quota(&priv->phandle, i, + SDE_POWER_HANDLE_CONT_SPLASH_BUS_AB_QUOTA, + SDE_POWER_HANDLE_CONT_SPLASH_BUS_IB_QUOTA); + + return ret; + +dbg_init_fail: + sde_power_resource_deinit(pdev, &priv->phandle); +power_init_fail: +priv_alloc_fail: + drm_dev_put(ddev); + kfree(priv); + return ret; +} + +static int msm_drm_component_init(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct drm_device *ddev = platform_get_drvdata(pdev); + struct msm_drm_private *priv = ddev->dev_private; + struct msm_kms *kms = NULL; + int ret; + struct sched_param param = { 0 }; + struct drm_crtc *crtc; + + ret = msm_mdss_init(ddev); + if (ret) + goto mdss_init_fail; + + priv->wq = alloc_ordered_workqueue("msm_drm", 0); + init_waitqueue_head(&priv->pending_crtcs_event); + + INIT_LIST_HEAD(&priv->client_event_list); + INIT_LIST_HEAD(&priv->inactive_list); + /* Bind all our sub-components: */ ret = msm_component_bind_all(dev, ddev); if (ret) @@ -784,9 +809,9 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ddev->mode_config.funcs = &mode_config_funcs; ddev->mode_config.helper_private = &mode_config_helper_funcs; - kms = _msm_drm_init_helper(priv, ddev, dev, pdev); + kms = _msm_drm_component_init_helper(priv, ddev, dev, pdev); if (IS_ERR_OR_NULL(kms)) { - dev_err(dev, "msm_drm_init_helper failed\n"); + dev_err(dev, "msm_drm_component_init_helper failed\n"); goto fail; } @@ -879,15 +904,13 @@ fail: msm_drm_uninit(dev); return ret; bind_fail: - sde_dbg_destroy(); -dbg_init_fail: - sde_power_resource_deinit(pdev, &priv->phandle); -power_init_fail: msm_mdss_destroy(ddev); mdss_init_fail: - kfree(priv); -priv_alloc_fail: + sde_dbg_destroy(); + sde_power_resource_deinit(pdev, &priv->phandle); drm_dev_put(ddev); + kfree(priv); + return ret; } @@ -1895,7 +1918,7 @@ int msm_get_mixer_count(struct msm_drm_private *priv, static int msm_drm_bind(struct device *dev) { - return msm_drm_init(dev, &msm_driver); + return msm_drm_component_init(dev); } static void msm_drm_unbind(struct device *dev) @@ -1917,6 +1940,10 @@ static int msm_pdev_probe(struct platform_device *pdev) int ret; struct component_match *match = NULL; + ret = msm_drm_device_init(pdev, &msm_driver); + if (ret) + return ret; + ret = add_display_components(&pdev->dev, &match); if (ret) return ret; diff --git a/msm/sde/sde_kms.c b/msm/sde/sde_kms.c index e0a271354c..114ba761dd 100644 --- a/msm/sde/sde_kms.c +++ b/msm/sde/sde_kms.c @@ -3194,11 +3194,6 @@ static int _sde_kms_hw_init_blocks(struct sde_kms *sde_kms, struct sde_rm *rm = NULL; int i, rc = -EINVAL; - for (i = 0; i < SDE_POWER_HANDLE_DBUS_ID_MAX; i++) - sde_power_data_bus_set_quota(&priv->phandle, i, - SDE_POWER_HANDLE_CONT_SPLASH_BUS_AB_QUOTA, - SDE_POWER_HANDLE_CONT_SPLASH_BUS_IB_QUOTA); - _sde_kms_core_hw_rev_init(sde_kms); pr_info("sde hardware revision:0x%x\n", sde_kms->core_rev);