From: Tomasz Figa Date: Tue, 21 Jun 2016 04:27:34 +0000 (+0900) Subject: UPSTREAM: drm/rockchip: Finish initialization before registering DRM device X-Git-Tag: firefly_0821_release~944 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=51239bb2232fdde4921dff0153e7a2dd1dd8dccf;p=firefly-linux-kernel-4.4.55.git UPSTREAM: drm/rockchip: Finish initialization before registering DRM device Currently the driver calls drm_dev_register() directly after allocating the DRM device and then continues with further initialization. This is incorrect, because drm_dev_register() is supposed to be called after all initialization is done. This problem was masked by the fact that drm_dev_register() did not use to do anything special before, but recently it started to call drm_connector_register_all(), which leads to a crash if the driver is not fully initialized. This patch fixes the problem by moving the call to drm_dev_register() to the end of the initialization sequence and also removing the, now unnecessary, call to drm_connector_register_all() from driver code. Fixes: f706974a69b6 ("drm/rockchip: Drop drm_driver.load/unload callbacks") Signed-off-by: Tomasz Figa [danvet: Fix up cleanup labels a bit.] Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1466483254-35373-1-git-send-email-tfiga@chromium.org (cherry picked from commit 9127f99c4801f323ffbb3b755259f3a679f66c7c) Change-Id: Ie6d56242507c413db5e1b93e587d89a3a2200db6 Signed-off-by: Mark Yao --- diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index f9acb06b7998..f3d954d01201 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -775,23 +775,18 @@ static int rockchip_drm_bind(struct device *dev) { struct drm_device *drm_dev; struct rockchip_drm_private *private; - struct drm_connector *connector; int ret; drm_dev = drm_dev_alloc(&rockchip_drm_driver, dev); if (!drm_dev) return -ENOMEM; - ret = drm_dev_register(drm_dev, 0); - if (ret) - goto err_free; - dev_set_drvdata(dev, drm_dev); private = devm_kzalloc(drm_dev->dev, sizeof(*private), GFP_KERNEL); if (!private) { ret = -ENOMEM; - goto err_unregister; + goto err_free; } mutex_init(&private->commit.lock); @@ -817,12 +812,6 @@ static int rockchip_drm_bind(struct device *dev) if (ret) goto err_iommu_cleanup; - ret = drm_connector_register_all(drm_dev); - if (ret) { - dev_err(dev, "failed to register connectors\n"); - goto err_unbind; - } - /* init kms poll for handling hpd */ drm_kms_helper_poll_init(drm_dev); @@ -853,20 +842,23 @@ static int rockchip_drm_bind(struct device *dev) drm_dev->mode_config.allow_fb_modifiers = true; + ret = drm_dev_register(drm_dev, 0); + if (ret) + goto err_fbdev_fini; + return 0; +err_fbdev_fini: + rockchip_drm_fbdev_fini(drm_dev); err_vblank_cleanup: drm_vblank_cleanup(drm_dev); err_kms_helper_poll_fini: drm_kms_helper_poll_fini(drm_dev); -err_unbind: component_unbind_all(dev, drm_dev); err_iommu_cleanup: rockchip_iommu_cleanup(drm_dev); err_config_cleanup: drm_mode_config_cleanup(drm_dev); drm_dev->dev_private = NULL; -err_unregister: - drm_dev_unregister(drm_dev); err_free: drm_dev_unref(drm_dev); return ret; @@ -875,7 +867,6 @@ err_free: static void rockchip_drm_unbind(struct device *dev) { struct drm_device *drm_dev = dev_get_drvdata(dev); - struct rockchip_drm_private *private = drm_dev->dev_private; rockchip_drm_fbdev_fini(drm_dev); drm_vblank_cleanup(drm_dev);