From: Archit Taneja <architt@codeaurora.org>
To: robdclark@gmail.com
Cc: daniel@ffwll.ch, dri-devel@lists.freedesktop.org,
linux-arm-msm@vger.kernel.org, twp@codeaurora.org,
Archit Taneja <architt@codeaurora.org>
Subject: [PATCH v3 3/3] drm/msm: Drop load/unload drm_driver ops
Date: Mon, 2 May 2016 11:05:54 +0530 [thread overview]
Message-ID: <1462167354-3014-4-git-send-email-architt@codeaurora.org> (raw)
In-Reply-To: <1462167354-3014-1-git-send-email-architt@codeaurora.org>
The load/unload drm_driver ops are deprecated. They should be removed as
they result in creation of devices visible to userspace even before
the drm_device is registered.
Drop these ops and use drm_dev_alloc/register and drm_dev_unregister/unref
to explicitly create and destroy the drm device in the msm platform
driver's bind and unbind ops. With this in use, the drm connectors are
only registered once the drm_device is registered.
It also fixes the issue of stray debugfs files after the msm module is
removed. With this, all the debugfs files are removed, and allows
successive module insertions/removals.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
drivers/gpu/drm/msm/msm_drv.c | 125 ++++++++++++++++++++++++------------------
1 file changed, 71 insertions(+), 54 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 8c5b257..a6db6e6 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -173,13 +173,11 @@ static int vblank_ctrl_queue_work(struct msm_drm_private *priv,
return 0;
}
-/*
- * DRM operations:
- */
-
-static int msm_unload(struct drm_device *dev)
+static int msm_drm_uninit(struct device *dev)
{
- struct msm_drm_private *priv = dev->dev_private;
+ 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 = priv->kms;
struct msm_gpu *gpu = priv->gpu;
struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl;
@@ -195,33 +193,34 @@ static int msm_unload(struct drm_device *dev)
kfree(vbl_ev);
}
- drm_kms_helper_poll_fini(dev);
+ drm_kms_helper_poll_fini(ddev);
+
+ drm_connector_unregister_all(ddev);
- drm_connector_unregister_all(dev);
+ drm_dev_unregister(ddev);
#ifdef CONFIG_DRM_FBDEV_EMULATION
if (fbdev && priv->fbdev)
- msm_fbdev_free(dev);
+ msm_fbdev_free(ddev);
#endif
- drm_mode_config_cleanup(dev);
- drm_vblank_cleanup(dev);
+ drm_mode_config_cleanup(ddev);
- pm_runtime_get_sync(dev->dev);
- drm_irq_uninstall(dev);
- pm_runtime_put_sync(dev->dev);
+ pm_runtime_get_sync(dev);
+ drm_irq_uninstall(ddev);
+ pm_runtime_put_sync(dev);
flush_workqueue(priv->wq);
destroy_workqueue(priv->wq);
if (kms) {
- pm_runtime_disable(dev->dev);
+ pm_runtime_disable(dev);
kms->funcs->destroy(kms);
}
if (gpu) {
- mutex_lock(&dev->struct_mutex);
+ mutex_lock(&ddev->struct_mutex);
gpu->funcs->pm_suspend(gpu);
- mutex_unlock(&dev->struct_mutex);
+ mutex_unlock(&ddev->struct_mutex);
gpu->funcs->destroy(gpu);
}
@@ -229,13 +228,14 @@ static int msm_unload(struct drm_device *dev)
DEFINE_DMA_ATTRS(attrs);
dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs);
drm_mm_takedown(&priv->vram.mm);
- dma_free_attrs(dev->dev, priv->vram.size, NULL,
- priv->vram.paddr, &attrs);
+ dma_free_attrs(dev, priv->vram.size, NULL,
+ priv->vram.paddr, &attrs);
}
- component_unbind_all(dev->dev, dev);
+ component_unbind_all(dev, ddev);
- dev->dev_private = NULL;
+ ddev->dev_private = NULL;
+ drm_dev_unref(ddev);
kfree(priv);
@@ -323,20 +323,30 @@ static int msm_init_vram(struct drm_device *dev)
return ret;
}
-static int msm_load(struct drm_device *dev, unsigned long flags)
+static int msm_drm_init(struct device *dev, struct drm_driver *drv)
{
- struct platform_device *pdev = dev->platformdev;
+ struct platform_device *pdev = to_platform_device(dev);
+ struct drm_device *ddev;
struct msm_drm_private *priv;
struct msm_kms *kms;
int ret;
+ ddev = drm_dev_alloc(drv, dev);
+ if (!ddev) {
+ dev_err(dev, "failed to allocate drm_device\n");
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, ddev);
+ ddev->platformdev = pdev;
+
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
- dev_err(dev->dev, "failed to allocate private data\n");
+ drm_dev_unref(ddev);
return -ENOMEM;
}
- dev->dev_private = priv;
+ ddev->dev_private = priv;
priv->wq = alloc_ordered_workqueue("msm", 0);
init_waitqueue_head(&priv->fence_event);
@@ -348,25 +358,26 @@ static int msm_load(struct drm_device *dev, unsigned long flags)
INIT_WORK(&priv->vblank_ctrl.work, vblank_ctrl_worker);
spin_lock_init(&priv->vblank_ctrl.lock);
- drm_mode_config_init(dev);
-
- platform_set_drvdata(pdev, dev);
+ drm_mode_config_init(ddev);
/* Bind all our sub-components: */
- ret = component_bind_all(dev->dev, dev);
- if (ret)
+ ret = component_bind_all(dev, ddev);
+ if (ret) {
+ kfree(priv);
+ drm_dev_unref(ddev);
return ret;
+ }
- ret = msm_init_vram(dev);
+ ret = msm_init_vram(ddev);
if (ret)
goto fail;
switch (get_mdp_ver(pdev)) {
case 4:
- kms = mdp4_kms_init(dev);
+ kms = mdp4_kms_init(ddev);
break;
case 5:
- kms = mdp5_kms_init(dev);
+ kms = mdp5_kms_init(ddev);
break;
default:
kms = ERR_PTR(-ENODEV);
@@ -380,7 +391,7 @@ static int msm_load(struct drm_device *dev, unsigned long flags)
* and (for example) use dmabuf/prime to share buffers with
* imx drm driver on iMX5
*/
- dev_err(dev->dev, "failed to load kms\n");
+ dev_err(dev, "failed to load kms\n");
ret = PTR_ERR(kms);
goto fail;
}
@@ -388,56 +399,64 @@ static int msm_load(struct drm_device *dev, unsigned long flags)
priv->kms = kms;
if (kms) {
- pm_runtime_enable(dev->dev);
+ pm_runtime_enable(dev);
ret = kms->funcs->hw_init(kms);
if (ret) {
- dev_err(dev->dev, "kms hw init failed: %d\n", ret);
+ dev_err(dev, "kms hw init failed: %d\n", ret);
goto fail;
}
}
- dev->mode_config.funcs = &mode_config_funcs;
+ ddev->mode_config.funcs = &mode_config_funcs;
- ret = drm_vblank_init(dev, priv->num_crtcs);
+ ret = drm_vblank_init(ddev, priv->num_crtcs);
if (ret < 0) {
- dev_err(dev->dev, "failed to initialize vblank\n");
+ dev_err(dev, "failed to initialize vblank\n");
goto fail;
}
- pm_runtime_get_sync(dev->dev);
- ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
- pm_runtime_put_sync(dev->dev);
+ pm_runtime_get_sync(dev);
+ ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
+ pm_runtime_put_sync(dev);
if (ret < 0) {
- dev_err(dev->dev, "failed to install IRQ handler\n");
+ dev_err(dev, "failed to install IRQ handler\n");
goto fail;
}
- ret = drm_connector_register_all(dev);
+ ret = drm_dev_register(ddev, 0);
+ if (ret)
+ goto fail;
+
+ ret = drm_connector_register_all(ddev);
if (ret) {
- dev_err(dev->dev, "failed to register connectors\n");
+ dev_err(dev, "failed to register connectors\n");
goto fail;
}
- drm_mode_config_reset(dev);
+ drm_mode_config_reset(ddev);
#ifdef CONFIG_DRM_FBDEV_EMULATION
if (fbdev)
- priv->fbdev = msm_fbdev_init(dev);
+ priv->fbdev = msm_fbdev_init(ddev);
#endif
- ret = msm_debugfs_late_init(dev);
+ ret = msm_debugfs_late_init(ddev);
if (ret)
goto fail;
- drm_kms_helper_poll_init(dev);
+ drm_kms_helper_poll_init(ddev);
return 0;
fail:
- msm_unload(dev);
+ msm_drm_uninit(dev);
return ret;
}
+/*
+ * DRM operations:
+ */
+
static void load_gpu(struct drm_device *dev)
{
static DEFINE_MUTEX(init_lock);
@@ -960,8 +979,6 @@ static struct drm_driver msm_driver = {
DRIVER_RENDER |
DRIVER_ATOMIC |
DRIVER_MODESET,
- .load = msm_load,
- .unload = msm_unload,
.open = msm_open,
.preclose = msm_preclose,
.lastclose = msm_lastclose,
@@ -1061,12 +1078,12 @@ static int add_components(struct device *dev, struct component_match **matchptr,
static int msm_drm_bind(struct device *dev)
{
- return drm_platform_init(&msm_driver, to_platform_device(dev));
+ return msm_drm_init(dev, &msm_driver);
}
static void msm_drm_unbind(struct device *dev)
{
- drm_put_dev(platform_get_drvdata(to_platform_device(dev)));
+ msm_drm_uninit(dev);
}
static const struct component_master_ops msm_drm_ops = {
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
prev parent reply other threads:[~2016-05-02 5:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 10:56 [PATCH 0/3] drm/msm: Remove drm_driver load/unload ops Archit Taneja
2016-04-19 10:56 ` [PATCH 1/3] drm/msm/hdmi: Prevent gpio_free related kernel warnings Archit Taneja
2016-04-19 15:49 ` Bjorn Andersson
[not found] ` <CAF6AEGv0uJhvkhsOWeZvZ9iXZO3eMdCnr6PCq5bpx0bNTJHj9g@mail.gmail.com>
[not found] ` <CAF6AEGuHq96komyBscvB6jfVSRUn0djp_W6Ui_0xi7VEE2mGsw@mail.gmail.com>
[not found] ` <CAF6AEGuMTZ0dr26oC4v2whFKoFY3Wc4SY=Ryst7QCoD-Ko2_AQ@mail.gmail.com>
[not found] ` <CAF6AEGsTPw8GPqfUuzVPjKoGM0FTq=XTtS0mEk5BxwvRUdbVfw@mail.gmail.com>
[not found] ` <CAF6AEGvTp2xEo6H2P-VOoFrg5aSd3T7eEbd6vDm_kMm8-FkfpQ@mail.gmail.com>
[not found] ` <CAF6AEGsX7F4Q=8__Y-SP_gs6e6CfX6JuocK5jVKJO0CkE10_Hw@mail.gmail.com>
2016-04-19 17:44 ` Rob Clark
2016-04-19 18:25 ` Bjorn Andersson
2016-04-20 6:03 ` Archit Taneja
2016-04-19 10:56 ` [PATCH 2/3] drm/msm: Centralize connector registration/unregistration Archit Taneja
2016-04-19 12:10 ` Daniel Vetter
2016-04-20 4:40 ` Archit Taneja
2016-04-19 10:56 ` [PATCH 3/3] drm/msm: Drop load/unload drm_driver ops Archit Taneja
2016-04-25 10:16 ` [PATCH v2 0/3] drm/msm: Remove drm_driver load/unload ops Archit Taneja
2016-04-25 10:16 ` [PATCH v2 1/3] drm/msm/hdmi: Prevent gpio_free related kernel warnings Archit Taneja
2016-04-25 17:48 ` twp
2016-04-27 4:55 ` Archit Taneja
2016-04-25 10:16 ` [PATCH v2 2/3] drm/msm: Centralize connector registration/unregistration Archit Taneja
2016-04-25 10:16 ` [PATCH v2 3/3] drm/msm: Drop load/unload drm_driver ops Archit Taneja
2016-05-02 5:35 ` [PATCH v3 0/3] drm/msm: Remove drm_driver load/unload ops Archit Taneja
2016-05-02 5:35 ` [PATCH v3 1/3] drm/msm/hdmi: Prevent gpio_free related kernel warnings Archit Taneja
2016-05-02 5:35 ` [PATCH v3 2/3] drm/msm: Centralize connector registration/unregistration Archit Taneja
2016-05-02 5:35 ` Archit Taneja [this message]
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=1462167354-3014-4-git-send-email-architt@codeaurora.org \
--to=architt@codeaurora.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=robdclark@gmail.com \
--cc=twp@codeaurora.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).