From patchwork Tue Nov 18 13:53:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 5333981 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 204CAC11AE for ; Wed, 19 Nov 2014 01:22:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11230201CE for ; Wed, 19 Nov 2014 01:22:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8FAE8201EF for ; Wed, 19 Nov 2014 01:22:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6D286F045; Tue, 18 Nov 2014 17:22:23 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [93.93.135.160]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B2A36E4D0 for ; Tue, 18 Nov 2014 05:53:54 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id B9635600058 From: Javier Martinez Canillas To: Inki Dae Subject: [RFC PATCH 1/1] drm/exynos: Move platform drivers registration to module init Date: Tue, 18 Nov 2014 14:53:41 +0100 Message-Id: <1416318821-7925-1-git-send-email-javier.martinez@collabora.co.uk> X-Mailer: git-send-email 2.1.0 X-Mailman-Approved-At: Tue, 18 Nov 2014 17:22:18 -0800 Cc: Krzysztof Kozlowski , Kevin Hilman , dri-devel@lists.freedesktop.org, Andrzej Hajda , linux-samsung-soc@vger.kernel.org, Javier Martinez Canillas X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Exynos DRM driver register its sub-devices platform drivers in the probe function but after commit 43c0767 ("of/platform: Move platform devices under /sys/devices/platform"), this is causing a deadlock in __driver_attach(). Fix this by moving the platform drivers registration to exynos_drm_init(). Suggested-by: Andrzej Hajda Signed-off-by: Javier Martinez Canillas --- This issue was reported by both Krzysztof Kozlowski [0] and Kevin Hilman [1]. Inki Dae said that he will fix it property by separating the Exynos DRM driver in different sub-modules but I post this patch as RFC anyways so others can test if this fixes their boot issue. [0]: https://lkml.org/lkml/2014/11/6/125 [1]: http://www.spinics.net/lists/linux-samsung-soc/msg39050.html drivers/gpu/drm/exynos/exynos_drm_drv.c | 163 ++++++++++++++++---------------- 1 file changed, 79 insertions(+), 84 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index e277d4f..5386fea 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -559,15 +559,58 @@ static const struct component_master_ops exynos_drm_ops = { static int exynos_drm_platform_probe(struct platform_device *pdev) { struct component_match *match; - int ret; pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls); + match = exynos_drm_match_add(&pdev->dev); + if (IS_ERR(match)) + return PTR_ERR(match); + + return component_master_add_with_match(&pdev->dev, &exynos_drm_ops, + match); +} + +static int exynos_drm_platform_remove(struct platform_device *pdev) +{ + component_master_del(&pdev->dev, &exynos_drm_ops); + return 0; +} + +static struct platform_driver exynos_drm_platform_driver = { + .probe = exynos_drm_platform_probe, + .remove = exynos_drm_platform_remove, + .driver = { + .name = "exynos-drm", + .pm = &exynos_drm_pm_ops, + }, +}; + +static int exynos_drm_init(void) +{ + int ret; + + /* + * Register device object only in case of Exynos SoC. + * + * Below codes resolves temporarily infinite loop issue incurred + * by Exynos drm driver when using multi-platform kernel. + * So these codes will be replaced with more generic way later. + */ + if (!of_machine_is_compatible("samsung,exynos3") && + !of_machine_is_compatible("samsung,exynos4") && + !of_machine_is_compatible("samsung,exynos5")) + return -ENODEV; + + exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1, + NULL, 0); + if (IS_ERR(exynos_drm_pdev)) + return PTR_ERR(exynos_drm_pdev); + #ifdef CONFIG_DRM_EXYNOS_FIMD ret = platform_driver_register(&fimd_driver); if (ret < 0) - return ret; + goto err_unregister_pdev; #endif #ifdef CONFIG_DRM_EXYNOS_DP @@ -591,21 +634,10 @@ static int exynos_drm_platform_probe(struct platform_device *pdev) goto err_unregister_mixer_drv; #endif - match = exynos_drm_match_add(&pdev->dev); - if (IS_ERR(match)) { - ret = PTR_ERR(match); - goto err_unregister_hdmi_drv; - } - - ret = component_master_add_with_match(&pdev->dev, &exynos_drm_ops, - match); - if (ret < 0) - goto err_unregister_hdmi_drv; - #ifdef CONFIG_DRM_EXYNOS_G2D ret = platform_driver_register(&g2d_driver); if (ret < 0) - goto err_del_component_master; + goto err_unregister_hdmi_drv; #endif #ifdef CONFIG_DRM_EXYNOS_FIMC @@ -636,9 +668,27 @@ static int exynos_drm_platform_probe(struct platform_device *pdev) goto err_unregister_ipp_drv; #endif - return ret; +#ifdef CONFIG_DRM_EXYNOS_VIDI + ret = exynos_drm_probe_vidi(); + if (ret < 0) + goto err_unregister_ipp_dev; +#endif + + ret = platform_driver_register(&exynos_drm_platform_driver); + if (ret) + goto err_remove_vidi; + + return 0; + +err_remove_vidi: +#ifdef CONFIG_DRM_EXYNOS_VIDI + exynos_drm_remove_vidi(); +err_unregister_pd: +#endif #ifdef CONFIG_DRM_EXYNOS_IPP +err_unregister_ipp_dev: + exynos_platform_device_ipp_unregister(); err_unregister_ipp_drv: platform_driver_unregister(&ipp_driver); err_unregister_gsc_drv: @@ -661,11 +711,9 @@ err_unregister_g2d_drv: #ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister(&g2d_driver); -err_del_component_master: +err_unregister_hdmi_drv: #endif - component_master_del(&pdev->dev, &exynos_drm_ops); -err_unregister_hdmi_drv: #ifdef CONFIG_DRM_EXYNOS_HDMI platform_driver_unregister(&hdmi_driver); err_unregister_mixer_drv: @@ -686,11 +734,21 @@ err_unregister_fimd_drv: #ifdef CONFIG_DRM_EXYNOS_FIMD platform_driver_unregister(&fimd_driver); #endif + +err_unregister_pdev: + platform_device_unregister(exynos_drm_pdev); + return ret; } -static int exynos_drm_platform_remove(struct platform_device *pdev) +static void exynos_drm_exit(void) { + platform_driver_unregister(&exynos_drm_platform_driver); + +#ifdef CONFIG_DRM_EXYNOS_VIDI + exynos_drm_remove_vidi(); +#endif + #ifdef CONFIG_DRM_EXYNOS_IPP exynos_platform_device_ipp_unregister(); platform_driver_unregister(&ipp_driver); @@ -721,75 +779,12 @@ static int exynos_drm_platform_remove(struct platform_device *pdev) platform_driver_unregister(&fimd_driver); #endif -#ifdef CONFIG_DRM_EXYNOS_DSI - platform_driver_unregister(&dsi_driver); -#endif - #ifdef CONFIG_DRM_EXYNOS_DP platform_driver_unregister(&dp_driver); #endif - component_master_del(&pdev->dev, &exynos_drm_ops); - return 0; -} -static struct platform_driver exynos_drm_platform_driver = { - .probe = exynos_drm_platform_probe, - .remove = exynos_drm_platform_remove, - .driver = { - .name = "exynos-drm", - .pm = &exynos_drm_pm_ops, - }, -}; - -static int exynos_drm_init(void) -{ - int ret; - - /* - * Register device object only in case of Exynos SoC. - * - * Below codes resolves temporarily infinite loop issue incurred - * by Exynos drm driver when using multi-platform kernel. - * So these codes will be replaced with more generic way later. - */ - if (!of_machine_is_compatible("samsung,exynos3") && - !of_machine_is_compatible("samsung,exynos4") && - !of_machine_is_compatible("samsung,exynos5")) - return -ENODEV; - - exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1, - NULL, 0); - if (IS_ERR(exynos_drm_pdev)) - return PTR_ERR(exynos_drm_pdev); - -#ifdef CONFIG_DRM_EXYNOS_VIDI - ret = exynos_drm_probe_vidi(); - if (ret < 0) - goto err_unregister_pd; -#endif - - ret = platform_driver_register(&exynos_drm_platform_driver); - if (ret) - goto err_remove_vidi; - - return 0; - -err_remove_vidi: -#ifdef CONFIG_DRM_EXYNOS_VIDI - exynos_drm_remove_vidi(); - -err_unregister_pd: -#endif - platform_device_unregister(exynos_drm_pdev); - - return ret; -} - -static void exynos_drm_exit(void) -{ - platform_driver_unregister(&exynos_drm_platform_driver); -#ifdef CONFIG_DRM_EXYNOS_VIDI - exynos_drm_remove_vidi(); +#ifdef CONFIG_DRM_EXYNOS_DSI + platform_driver_unregister(&dsi_driver); #endif platform_device_unregister(exynos_drm_pdev); }