From patchwork Mon Nov 24 09:05:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 5364071 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 609209F2F5 for ; Mon, 24 Nov 2014 09:05:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E05D2037B for ; Mon, 24 Nov 2014 09:05:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23317202FF for ; Mon, 24 Nov 2014 09:05:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752951AbaKXJFj (ORCPT ); Mon, 24 Nov 2014 04:05:39 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:36018 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752751AbaKXJFg (ORCPT ); Mon, 24 Nov 2014 04:05:36 -0500 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFJ007QZD9B9RD0@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Mon, 24 Nov 2014 18:05:35 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.113]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 93.BA.18167.ED4F2745; Mon, 24 Nov 2014 18:05:35 +0900 (KST) X-AuditID: cbfee690-f79ab6d0000046f7-18-5472f4dedf2d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 1B.C5.09430.ED4F2745; Mon, 24 Nov 2014 18:05:34 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.252.83.67]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NFJ00I98D9AJ6J0@mmp2.samsung.com>; Mon, 24 Nov 2014 18:05:34 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Cc: airlied@linux.ie, linux-samsung-soc@vger.kernel.org, Inki Dae Subject: [PATCH] drm/exynos: vidi: add component support Date: Mon, 24 Nov 2014 18:05:34 +0900 Message-id: <1416819934-8046-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHLMWRmVeSWpSXmKPExsWyRsSkUPf+l6IQg4bFLBa9504yWVz5+p7N YtL9CSwWM87vY3Jg8dj+7QGrx/3u40wefVtWMXp83iQXwBLFZZOSmpNZllqkb5fAlXG9uZ+p 4I5pxdsJlQ2MN3S7GDk5JARMJI6dnM0IYYtJXLi3nq2LkYtDSGApo8SDBSsYYYqmbznPApGY zijx6OYsqKpuJomXj5awglSxCahKTFxxnw3EFhFQlvg7cRVYN7NAlMTyw0vZQWxhAQuJk/+f MIPYLED1T7Z9A4vzCjhLHOneCVTPAbRNQWLOJBuQ+RICj9kkJk25yQ5RLyDxbfIhFogaWYlN B5ghjpOUOLjiBssERsEFjAyrGEVTC5ILipPSi0z0ihNzi0vz0vWS83M3MQKD8fS/ZxN2MN47 YH2IUYCDUYmH98PGohAh1sSy4srcQ4ymQBsmMkuJJucDQz6vJN7Q2MzIwtTE1NjI3NJMSZz3 tdTPYCGB9MSS1OzU1ILUovii0pzU4kOMTBycUg2MDNKbZslkzy48aW+ia+6QYsy0/ue2O1XT Sh38mt07d01I3+B+elnm6akrl4VMmjdfO/Coi4nxpMNvHZv9rs1OWpPUdltWYGNFZxlHVL3A jOlXOr+xshVZ3GXoV35wwVJa64j252rlVzKzNBZme9VmR0zyen/FIYMh6c6DRT9Mvs6oyqho jPRXYinOSDTUYi4qTgQAAyz4RUECAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsVy+t9jQd17X4pCDDZNtbDoPXeSyeLK1/ds FpPuT2CxmHF+H5MDi8f2bw9YPe53H2fy6NuyitHj8ya5AJaoBkabjNTElNQihdS85PyUzLx0 WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFslF58AXbfMHKCdSgpliTmlQKGAxOJiJX07TBNCQ9x0 LWAaI3R9Q4LgeowM0EDCGsaM6839TAV3TCveTqhsYLyh28XIySEhYCIxfct5FghbTOLCvfVs XYxcHEIC0xklHt2cBeV0M0m8fLSEFaSKTUBVYuKK+2wgtoiAssTfiasYQWxmgSiJ5YeXsoPY wgIWEif/P2EGsVmA6p9s+wYW5xVwljjSvROongNom4LEnEk2Exi5FzAyrGIUTS1ILihOSs81 0itOzC0uzUvXS87P3cQIDvVn0jsYVzVYHGIU4GBU4uGdsb4oRIg1say4MvcQowQHs5II79l/ hSFCvCmJlVWpRfnxRaU5qcWHGE2Blk9klhJNzgfGYV5JvKGxiZmRpZG5oYWRsbmSOO+Nm7kh QgLpiSWp2ampBalFMH1MHJxSDYyq59g3P39oxLfYSVFLyyB9032nuULhrKa3Hb6ENlRc0+l6 5mDxSid14unUtLVM69/zL4puab098TTjgZ1OkYUJOv/5brxdc4bH6Wuf+P77lcb8m0uPd28o 23iHKXpetlWYwUUBbpacd5+8zDP9Srqab88rCN96PnXDIam5plevsWo8WxBU3arEUpyRaKjF XFScCADCKn/jiwIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This patch adds component support for vidi driver. vidi driver is a kms driver so it doesn't need to be registered to exynos_drm_subdrv_list. For this, it changes for the component framework to be used for vidi driver. This patch fixes below error also, # echo 1 > /sys/devices/platform/exynos-drm-vidi/connection [ 55.618529] ------------[ cut here ]------------ [ 55.621960] WARNING: CPU: 0 PID: 1397 at drivers/gpu/drm/drm_irq.c:1203 exynos_drm_crtc_dpms+0x88/0x17c() [ 55.631268] Modules linked in: [ 55.634278] CPU: 0 PID: 1397 Comm: sh Not tainted 3.18.0-rc2-146253-g31449d7 #1154 [ 55.641885] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 55.649597] [] (show_stack) from [] (dump_stack+0x84/0xc4) [ 55.656802] [] (dump_stack) from [] (warn_slowpath_common+0x6c/0x88) [ 55.664866] [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24) [ 55.673632] [] (warn_slowpath_null) from [] (exynos_drm_crtc_dpms+0x88/0x17c) [ 55.682482] [] (exynos_drm_crtc_dpms) from [] (exynos_drm_crtc_commit+0x14/0x44) [ 55.691622] [] (exynos_drm_crtc_commit) from [] (drm_crtc_helper_set_mode+0x3d0/0x51c) [ 55.701233] [] (drm_crtc_helper_set_mode) from [] (drm_crtc_helper_set_config+0x87c/0x9dc) [ 55.711230] [] (drm_crtc_helper_set_config) from [] (drm_mode_set_config_internal+0x58/0xd4) [ 55.721380] [] (drm_mode_set_config_internal) from [] (restore_fbdev_mode+0xcc/0xec) [ 55.730834] [] (restore_fbdev_mode) from [] (drm_fb_helper_restore_fbdev_mode_unlocked+0x1c/0x30) [ 55.741424] [] (drm_fb_helper_restore_fbdev_mode_unlocked) from [] (drm_fb_helper_set_par+0x1c/0x60) [ 55.752271] [] (drm_fb_helper_set_par) from [] (drm_fb_helper_hotplug_event+0x88/0xc4) [ 55.761906] [] (drm_fb_helper_hotplug_event) from [] (drm_helper_hpd_irq_event+0xc8/0x134) [ 55.771898] [] (drm_helper_hpd_irq_event) from [] (vidi_store_connection+0x90/0xc8) [ 55.781268] [] (vidi_store_connection) from [] (kernfs_fop_write+0xc0/0x180) [ 55.790045] [] (kernfs_fop_write) from [] (vfs_write+0xa0/0x1ac) [ 55.797757] [] (vfs_write) from [] (SyS_write+0x44/0x9c) [ 55.804790] [] (SyS_write) from [] (ret_fast_syscall+0x0/0x30) [ 55.812328] ---[ end trace 3c0fe4386702d4dd ]--- This issue occurs when modeset to vidi is tried in case that drm_vblank_init is called prior to crtc creation of vidi driver. In this case, crtc number of vidi is invalid so any requests with the crtc number will fail. This patch guarantees drm_vblank_init to be called after all kms drivers are ready by using component framework. Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 61 ++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 3b6fdd6..45899fb 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -14,6 +14,7 @@ #include #include +#include #include @@ -48,11 +49,11 @@ struct vidi_win_data { struct vidi_context { struct exynos_drm_manager manager; struct exynos_drm_display display; + struct platform_device *pdev; struct drm_device *drm_dev; struct drm_crtc *crtc; struct drm_encoder *encoder; struct drm_connector connector; - struct exynos_drm_subdrv subdrv; struct vidi_win_data win_data[WINDOWS_NR]; struct edid *raw_edid; unsigned int clkdiv; @@ -560,9 +561,10 @@ static struct exynos_drm_display_ops vidi_display_ops = { .create_connector = vidi_create_connector, }; -static int vidi_subdrv_probe(struct drm_device *drm_dev, struct device *dev) +static int vidi_bind(struct device *dev, struct device *master, void *data) { struct vidi_context *ctx = dev_get_drvdata(dev); + struct drm_device *drm_dev = data; struct drm_crtc *crtc = ctx->crtc; int ret; @@ -584,9 +586,18 @@ static int vidi_subdrv_probe(struct drm_device *drm_dev, struct device *dev) return 0; } + +static void vidi_unbind(struct device *dev, struct device *master, void *data) +{ +} + +static const struct component_ops vidi_component_ops = { + .bind = vidi_bind, + .unbind = vidi_unbind, +}; + static int vidi_probe(struct platform_device *pdev) { - struct exynos_drm_subdrv *subdrv; struct vidi_context *ctx; int ret; @@ -599,6 +610,17 @@ static int vidi_probe(struct platform_device *pdev) ctx->display.type = EXYNOS_DISPLAY_TYPE_VIDI; ctx->display.ops = &vidi_display_ops; ctx->default_win = 0; + ctx->pdev = pdev; + + ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC, + ctx->manager.type); + if (ret) + return ret; + + ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR, + ctx->display.type); + if (ret) + goto err_del_crtc_component; INIT_WORK(&ctx->work, vidi_fake_vblank_handler); @@ -606,23 +628,26 @@ static int vidi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ctx); - subdrv = &ctx->subdrv; - subdrv->dev = &pdev->dev; - subdrv->probe = vidi_subdrv_probe; - - ret = exynos_drm_subdrv_register(subdrv); - if (ret < 0) { - dev_err(&pdev->dev, "failed to register drm vidi device\n"); - return ret; - } - ret = device_create_file(&pdev->dev, &dev_attr_connection); if (ret < 0) { - exynos_drm_subdrv_unregister(subdrv); - DRM_INFO("failed to create connection sysfs.\n"); + DRM_ERROR("failed to create connection sysfs.\n"); + goto err_del_conn_component; } - return 0; + ret = component_add(&pdev->dev, &vidi_component_ops); + if (ret) + goto err_remove_file; + + return ret; + +err_remove_file: + device_remove_file(&pdev->dev, &dev_attr_connection); +err_del_conn_component: + exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR); +err_del_crtc_component: + exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC); + + return ret; } static int vidi_remove(struct platform_device *pdev) @@ -636,6 +661,10 @@ static int vidi_remove(struct platform_device *pdev) return -EINVAL; } + component_del(&pdev->dev, &vidi_component_ops); + exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR); + exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC); + return 0; }