Commit 1f50db2f authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Rob Clark

drm/msm/mdp5: move resource allocation to the _probe function

To let the probe function bail early if any of the resources is
unavailable, move resource allocattion from kms_init directly to the
probe callback.
Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/561630/Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 3c746826
...@@ -554,20 +554,16 @@ static int mdp5_kms_init(struct drm_device *dev) ...@@ -554,20 +554,16 @@ static int mdp5_kms_init(struct drm_device *dev)
struct platform_device *pdev; struct platform_device *pdev;
struct mdp5_kms *mdp5_kms; struct mdp5_kms *mdp5_kms;
struct mdp5_cfg *config; struct mdp5_cfg *config;
struct msm_kms *kms; struct msm_kms *kms = priv->kms;
struct msm_gem_address_space *aspace; struct msm_gem_address_space *aspace;
int irq, i, ret; int i, ret;
ret = mdp5_init(to_platform_device(dev->dev), dev); ret = mdp5_init(to_platform_device(dev->dev), dev);
if (ret) if (ret)
return ret; return ret;
/* priv->kms would have been populated by the MDP5 driver */
kms = priv->kms;
if (!kms)
return -ENOMEM;
mdp5_kms = to_mdp5_kms(to_mdp_kms(kms)); mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
pdev = mdp5_kms->pdev; pdev = mdp5_kms->pdev;
ret = mdp_kms_init(&mdp5_kms->base, &kms_funcs); ret = mdp_kms_init(&mdp5_kms->base, &kms_funcs);
...@@ -576,15 +572,6 @@ static int mdp5_kms_init(struct drm_device *dev) ...@@ -576,15 +572,6 @@ static int mdp5_kms_init(struct drm_device *dev)
goto fail; goto fail;
} }
irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
if (!irq) {
ret = -EINVAL;
DRM_DEV_ERROR(&pdev->dev, "failed to get irq\n");
goto fail;
}
kms->irq = irq;
config = mdp5_cfg_get_config(mdp5_kms->cfg); config = mdp5_cfg_get_config(mdp5_kms->cfg);
/* make sure things are off before attaching iommu (bootloader could /* make sure things are off before attaching iommu (bootloader could
...@@ -787,60 +774,23 @@ static int interface_init(struct mdp5_kms *mdp5_kms) ...@@ -787,60 +774,23 @@ static int interface_init(struct mdp5_kms *mdp5_kms)
static int mdp5_init(struct platform_device *pdev, struct drm_device *dev) static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)
{ {
struct msm_drm_private *priv = dev->dev_private; struct msm_drm_private *priv = dev->dev_private;
struct mdp5_kms *mdp5_kms; struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
struct mdp5_cfg *config; struct mdp5_cfg *config;
u32 major, minor; u32 major, minor;
int ret; int ret;
mdp5_kms = devm_kzalloc(&pdev->dev, sizeof(*mdp5_kms), GFP_KERNEL);
if (!mdp5_kms) {
ret = -ENOMEM;
goto fail;
}
spin_lock_init(&mdp5_kms->resource_lock);
mdp5_kms->dev = dev; mdp5_kms->dev = dev;
mdp5_kms->pdev = pdev;
ret = mdp5_global_obj_init(mdp5_kms); ret = mdp5_global_obj_init(mdp5_kms);
if (ret) if (ret)
goto fail; goto fail;
mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys");
if (IS_ERR(mdp5_kms->mmio)) {
ret = PTR_ERR(mdp5_kms->mmio);
goto fail;
}
/* mandatory clocks: */
ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus", true);
if (ret)
goto fail;
ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface", true);
if (ret)
goto fail;
ret = get_clk(pdev, &mdp5_kms->core_clk, "core", true);
if (ret)
goto fail;
ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync", true);
if (ret)
goto fail;
/* optional clocks: */
get_clk(pdev, &mdp5_kms->lut_clk, "lut", false);
get_clk(pdev, &mdp5_kms->tbu_clk, "tbu", false);
get_clk(pdev, &mdp5_kms->tbu_rt_clk, "tbu_rt", false);
/* we need to set a default rate before enabling. Set a safe /* we need to set a default rate before enabling. Set a safe
* rate first, then figure out hw revision, and then set a * rate first, then figure out hw revision, and then set a
* more optimal rate: * more optimal rate:
*/ */
clk_set_rate(mdp5_kms->core_clk, 200000000); clk_set_rate(mdp5_kms->core_clk, 200000000);
/* set uninit-ed kms */
priv->kms = &mdp5_kms->base.base;
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
mdp5_kms->rpm_enabled = true; mdp5_kms->rpm_enabled = true;
...@@ -931,15 +881,53 @@ static int mdp5_setup_interconnect(struct platform_device *pdev) ...@@ -931,15 +881,53 @@ static int mdp5_setup_interconnect(struct platform_device *pdev)
static int mdp5_dev_probe(struct platform_device *pdev) static int mdp5_dev_probe(struct platform_device *pdev)
{ {
int ret; struct mdp5_kms *mdp5_kms;
int ret, irq;
DBG(""); DBG("");
mdp5_kms = devm_kzalloc(&pdev->dev, sizeof(*mdp5_kms), GFP_KERNEL);
if (!mdp5_kms)
return -ENOMEM;
ret = mdp5_setup_interconnect(pdev); ret = mdp5_setup_interconnect(pdev);
if (ret) if (ret)
return ret; return ret;
return msm_drv_probe(&pdev->dev, mdp5_kms_init, NULL); mdp5_kms->pdev = pdev;
spin_lock_init(&mdp5_kms->resource_lock);
mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys");
if (IS_ERR(mdp5_kms->mmio))
return PTR_ERR(mdp5_kms->mmio);
/* mandatory clocks: */
ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus", true);
if (ret)
return ret;
ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface", true);
if (ret)
return ret;
ret = get_clk(pdev, &mdp5_kms->core_clk, "core", true);
if (ret)
return ret;
ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync", true);
if (ret)
return ret;
/* optional clocks: */
get_clk(pdev, &mdp5_kms->lut_clk, "lut", false);
get_clk(pdev, &mdp5_kms->tbu_clk, "tbu", false);
get_clk(pdev, &mdp5_kms->tbu_rt_clk, "tbu_rt", false);
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return dev_err_probe(&pdev->dev, irq, "failed to get irq\n");
mdp5_kms->base.base.irq = irq;
return msm_drv_probe(&pdev->dev, mdp5_kms_init, &mdp5_kms->base.base);
} }
static int mdp5_dev_remove(struct platform_device *pdev) static int mdp5_dev_remove(struct platform_device *pdev)
......
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