From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, robdclark@gmail.com Cc: freedreno@lists.freedesktop.org, airlied@linux.ie, linux-arm-msm@vger.kernel.org, konrad.dybcio@somainline.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, jami.kettunen@somainline.org, maxime@cerno.tech, marijn.suijten@somainline.org, kernel@collabora.com, sean@poorly.run Subject: Re: [PATCH] drm/msm: Initialize MDSS irq domain at probe time Date: Mon, 29 Nov 2021 05:20:13 +0300 [thread overview] Message-ID: <bf1540f1-4a9f-a9d6-d487-929107c487fd@linaro.org> (raw) In-Reply-To: <20211125150947.354076-1-angelogioacchino.delregno@collabora.com> Hi, On 25/11/2021 18:09, AngeloGioacchino Del Regno wrote: > Since commit 8f59ee9a570c ("drm/msm/dsi: Adjust probe order"), the > DSI host gets initialized earlier, but this caused unability to probe > the entire stack of components because they all depend on interrupts > coming from the main `mdss` node (mdp5, or dpu1). > > To fix this issue, also anticipate probing mdp5 or dpu1 by initializing > them at msm_pdev_probe() time: this will make sure that we add the > required interrupt controller mapping before dsi and/or other components > try to initialize, finally satisfying the dependency. > > While at it, also change the allocation of msm_drm_private to use the > devm variant of kzalloc(). > > Fixes: 8f59ee9a570c ("drm/msm/dsi: Adjust probe order") > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> I have been thinking about this. I do not feel that this is the correct approach. Currently DRM device exists only when all components are bound. If any of the subdevices is removed, corresponding component is delteted (and thus all components are unbound), the DRM device is taken down. This results in the state cleanup, userspace notifications, etc. With your changes, DRM device will continue to exist even after one of subdevices is removed. This is not an expected behaviour, since subdrivers do not perform full cleanup, delegating that to DRM device takedown. I suppose that proper solution would be to split msm_drv.c into into: - generic components & drm code to be called from mdp4/mdp5/dpu driver (making mdp4, mdp5 or dpu1 the components master) - bare mdss driver, taking care only about IRQs, OF devices population - calling proper mdss_init/mdss_destroy functions. Most probably we can drop this part altogether and just make md5_mdss.c/dpu_mdss.c proper platform drivers. > --- > drivers/gpu/drm/msm/msm_drv.c | 81 ++++++++++++++++------------------- > 1 file changed, 38 insertions(+), 43 deletions(-) > > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c > index 7936e8d498dd..790acf4993c0 100644 > --- a/drivers/gpu/drm/msm/msm_drv.c > +++ b/drivers/gpu/drm/msm/msm_drv.c > @@ -512,45 +512,12 @@ static int msm_init_vram(struct drm_device *dev) > static int msm_drm_init(struct device *dev, const struct drm_driver *drv) > { > struct platform_device *pdev = to_platform_device(dev); > - struct drm_device *ddev; > - struct msm_drm_private *priv; > - struct msm_kms *kms; > - struct msm_mdss *mdss; > + struct drm_device *ddev = platform_get_drvdata(pdev); > + struct msm_drm_private *priv = ddev->dev_private; > + struct msm_kms *kms = priv->kms; > + struct msm_mdss *mdss = priv->mdss; > int ret, i; > > - ddev = drm_dev_alloc(drv, dev); > - if (IS_ERR(ddev)) { > - DRM_DEV_ERROR(dev, "failed to allocate drm_device\n"); > - return PTR_ERR(ddev); > - } > - > - platform_set_drvdata(pdev, ddev); > - > - priv = kzalloc(sizeof(*priv), GFP_KERNEL); > - if (!priv) { > - ret = -ENOMEM; > - goto err_put_drm_dev; > - } > - > - ddev->dev_private = priv; > - priv->dev = ddev; > - > - switch (get_mdp_ver(pdev)) { > - case KMS_MDP5: > - ret = mdp5_mdss_init(ddev); > - break; > - case KMS_DPU: > - ret = dpu_mdss_init(ddev); > - break; > - default: > - ret = 0; > - break; > - } > - if (ret) > - goto err_free_priv; > - > - mdss = priv->mdss; > - > priv->wq = alloc_ordered_workqueue("msm", 0); > priv->hangcheck_period = DRM_MSM_HANGCHECK_DEFAULT_PERIOD; > > @@ -685,11 +652,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) > err_destroy_mdss: > if (mdss && mdss->funcs) > mdss->funcs->destroy(ddev); > -err_free_priv: > - kfree(priv); > -err_put_drm_dev: > - drm_dev_put(ddev); > - platform_set_drvdata(pdev, NULL); > return ret; > } > > @@ -1382,12 +1344,42 @@ static const struct component_master_ops msm_drm_ops = { > static int msm_pdev_probe(struct platform_device *pdev) > { > struct component_match *match = NULL; > + struct msm_drm_private *priv; > + struct drm_device *ddev; > int ret; > > + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + ddev = drm_dev_alloc(&msm_driver, &pdev->dev); > + if (IS_ERR(ddev)) { > + DRM_DEV_ERROR(&pdev->dev, "failed to allocate drm_device\n"); > + return PTR_ERR(ddev); > + } > + > + platform_set_drvdata(pdev, ddev); > + ddev->dev_private = priv; > + priv->dev = ddev; > + > + switch (get_mdp_ver(pdev)) { > + case KMS_MDP5: > + ret = mdp5_mdss_init(ddev); > + break; > + case KMS_DPU: > + ret = dpu_mdss_init(ddev); > + break; > + default: > + ret = 0; > + break; > + } > + if (ret) > + goto err_put_drm_dev; > + > if (get_mdp_ver(pdev)) { > ret = add_display_components(pdev, &match); > if (ret) > - return ret; > + goto fail; > } > > ret = add_gpu_components(&pdev->dev, &match); > @@ -1409,6 +1401,9 @@ static int msm_pdev_probe(struct platform_device *pdev) > > fail: > of_platform_depopulate(&pdev->dev); > +err_put_drm_dev: > + drm_dev_put(ddev); > + platform_set_drvdata(pdev, NULL); > return ret; > } > > -- With best wishes Dmitry
WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, robdclark@gmail.com Cc: sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, maxime@cerno.tech, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, konrad.dybcio@somainline.org, marijn.suijten@somainline.org, jami.kettunen@somainline.org Subject: Re: [PATCH] drm/msm: Initialize MDSS irq domain at probe time Date: Mon, 29 Nov 2021 05:20:13 +0300 [thread overview] Message-ID: <bf1540f1-4a9f-a9d6-d487-929107c487fd@linaro.org> (raw) In-Reply-To: <20211125150947.354076-1-angelogioacchino.delregno@collabora.com> Hi, On 25/11/2021 18:09, AngeloGioacchino Del Regno wrote: > Since commit 8f59ee9a570c ("drm/msm/dsi: Adjust probe order"), the > DSI host gets initialized earlier, but this caused unability to probe > the entire stack of components because they all depend on interrupts > coming from the main `mdss` node (mdp5, or dpu1). > > To fix this issue, also anticipate probing mdp5 or dpu1 by initializing > them at msm_pdev_probe() time: this will make sure that we add the > required interrupt controller mapping before dsi and/or other components > try to initialize, finally satisfying the dependency. > > While at it, also change the allocation of msm_drm_private to use the > devm variant of kzalloc(). > > Fixes: 8f59ee9a570c ("drm/msm/dsi: Adjust probe order") > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> I have been thinking about this. I do not feel that this is the correct approach. Currently DRM device exists only when all components are bound. If any of the subdevices is removed, corresponding component is delteted (and thus all components are unbound), the DRM device is taken down. This results in the state cleanup, userspace notifications, etc. With your changes, DRM device will continue to exist even after one of subdevices is removed. This is not an expected behaviour, since subdrivers do not perform full cleanup, delegating that to DRM device takedown. I suppose that proper solution would be to split msm_drv.c into into: - generic components & drm code to be called from mdp4/mdp5/dpu driver (making mdp4, mdp5 or dpu1 the components master) - bare mdss driver, taking care only about IRQs, OF devices population - calling proper mdss_init/mdss_destroy functions. Most probably we can drop this part altogether and just make md5_mdss.c/dpu_mdss.c proper platform drivers. > --- > drivers/gpu/drm/msm/msm_drv.c | 81 ++++++++++++++++------------------- > 1 file changed, 38 insertions(+), 43 deletions(-) > > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c > index 7936e8d498dd..790acf4993c0 100644 > --- a/drivers/gpu/drm/msm/msm_drv.c > +++ b/drivers/gpu/drm/msm/msm_drv.c > @@ -512,45 +512,12 @@ static int msm_init_vram(struct drm_device *dev) > static int msm_drm_init(struct device *dev, const struct drm_driver *drv) > { > struct platform_device *pdev = to_platform_device(dev); > - struct drm_device *ddev; > - struct msm_drm_private *priv; > - struct msm_kms *kms; > - struct msm_mdss *mdss; > + struct drm_device *ddev = platform_get_drvdata(pdev); > + struct msm_drm_private *priv = ddev->dev_private; > + struct msm_kms *kms = priv->kms; > + struct msm_mdss *mdss = priv->mdss; > int ret, i; > > - ddev = drm_dev_alloc(drv, dev); > - if (IS_ERR(ddev)) { > - DRM_DEV_ERROR(dev, "failed to allocate drm_device\n"); > - return PTR_ERR(ddev); > - } > - > - platform_set_drvdata(pdev, ddev); > - > - priv = kzalloc(sizeof(*priv), GFP_KERNEL); > - if (!priv) { > - ret = -ENOMEM; > - goto err_put_drm_dev; > - } > - > - ddev->dev_private = priv; > - priv->dev = ddev; > - > - switch (get_mdp_ver(pdev)) { > - case KMS_MDP5: > - ret = mdp5_mdss_init(ddev); > - break; > - case KMS_DPU: > - ret = dpu_mdss_init(ddev); > - break; > - default: > - ret = 0; > - break; > - } > - if (ret) > - goto err_free_priv; > - > - mdss = priv->mdss; > - > priv->wq = alloc_ordered_workqueue("msm", 0); > priv->hangcheck_period = DRM_MSM_HANGCHECK_DEFAULT_PERIOD; > > @@ -685,11 +652,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) > err_destroy_mdss: > if (mdss && mdss->funcs) > mdss->funcs->destroy(ddev); > -err_free_priv: > - kfree(priv); > -err_put_drm_dev: > - drm_dev_put(ddev); > - platform_set_drvdata(pdev, NULL); > return ret; > } > > @@ -1382,12 +1344,42 @@ static const struct component_master_ops msm_drm_ops = { > static int msm_pdev_probe(struct platform_device *pdev) > { > struct component_match *match = NULL; > + struct msm_drm_private *priv; > + struct drm_device *ddev; > int ret; > > + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + ddev = drm_dev_alloc(&msm_driver, &pdev->dev); > + if (IS_ERR(ddev)) { > + DRM_DEV_ERROR(&pdev->dev, "failed to allocate drm_device\n"); > + return PTR_ERR(ddev); > + } > + > + platform_set_drvdata(pdev, ddev); > + ddev->dev_private = priv; > + priv->dev = ddev; > + > + switch (get_mdp_ver(pdev)) { > + case KMS_MDP5: > + ret = mdp5_mdss_init(ddev); > + break; > + case KMS_DPU: > + ret = dpu_mdss_init(ddev); > + break; > + default: > + ret = 0; > + break; > + } > + if (ret) > + goto err_put_drm_dev; > + > if (get_mdp_ver(pdev)) { > ret = add_display_components(pdev, &match); > if (ret) > - return ret; > + goto fail; > } > > ret = add_gpu_components(&pdev->dev, &match); > @@ -1409,6 +1401,9 @@ static int msm_pdev_probe(struct platform_device *pdev) > > fail: > of_platform_depopulate(&pdev->dev); > +err_put_drm_dev: > + drm_dev_put(ddev); > + platform_set_drvdata(pdev, NULL); > return ret; > } > > -- With best wishes Dmitry
next prev parent reply other threads:[~2021-11-29 2:20 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-25 15:09 [PATCH] drm/msm: Initialize MDSS irq domain at probe time AngeloGioacchino Del Regno 2021-11-25 15:09 ` AngeloGioacchino Del Regno 2021-11-25 15:23 ` Dmitry Baryshkov 2021-11-25 15:23 ` Dmitry Baryshkov 2021-11-25 22:39 ` Dmitry Baryshkov 2021-11-25 22:39 ` Dmitry Baryshkov 2021-11-26 0:06 ` Dmitry Baryshkov 2021-11-26 0:06 ` Dmitry Baryshkov 2021-11-26 9:26 ` AngeloGioacchino Del Regno 2021-11-26 9:26 ` AngeloGioacchino Del Regno 2021-11-26 21:12 ` Dmitry Baryshkov 2021-11-26 21:12 ` Dmitry Baryshkov 2021-11-26 16:08 ` AngeloGioacchino Del Regno 2021-11-26 16:08 ` AngeloGioacchino Del Regno 2021-11-29 2:20 ` Dmitry Baryshkov [this message] 2021-11-29 2:20 ` Dmitry Baryshkov 2021-11-29 14:14 ` AngeloGioacchino Del Regno 2021-11-29 14:14 ` AngeloGioacchino Del Regno 2021-11-29 14:53 ` Dmitry Baryshkov 2021-11-29 14:53 ` Dmitry Baryshkov 2021-11-29 14:56 ` AngeloGioacchino Del Regno 2021-11-29 14:56 ` AngeloGioacchino Del Regno 2021-12-01 10:52 [PATCH v3 2/2] " AngeloGioacchino Del Regno 2021-12-01 20:20 ` [PATCH] " Dmitry Baryshkov 2021-12-01 20:20 ` Dmitry Baryshkov 2021-12-03 10:43 ` AngeloGioacchino Del Regno 2021-12-03 10:43 ` AngeloGioacchino Del Regno 2021-12-03 13:14 ` Dmitry Baryshkov 2021-12-03 13:14 ` Dmitry Baryshkov 2021-12-03 13:17 ` AngeloGioacchino Del Regno 2021-12-03 13:17 ` AngeloGioacchino Del Regno
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bf1540f1-4a9f-a9d6-d487-929107c487fd@linaro.org \ --to=dmitry.baryshkov@linaro.org \ --cc=airlied@linux.ie \ --cc=angelogioacchino.delregno@collabora.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=freedreno@lists.freedesktop.org \ --cc=jami.kettunen@somainline.org \ --cc=kernel@collabora.com \ --cc=konrad.dybcio@somainline.org \ --cc=linux-arm-msm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=marijn.suijten@somainline.org \ --cc=maxime@cerno.tech \ --cc=robdclark@gmail.com \ --cc=sean@poorly.run \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.