From patchwork Mon Nov 24 09:05:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 5364041 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 2E5FEC11AC for ; Mon, 24 Nov 2014 09:05:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 242B42035E for ; Mon, 24 Nov 2014 09:05:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DC0AD20377 for ; Mon, 24 Nov 2014 09:05:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F3406E346; Mon, 24 Nov 2014 01:05:08 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E3FB6E346 for ; Mon, 24 Nov 2014 01:05:07 -0800 (PST) Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFJ00IX2D8IC7D0@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 24 Nov 2014 18:05:06 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.112]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id EA.F9.17016.1C4F2745; Mon, 24 Nov 2014 18:05:06 +0900 (KST) X-AuditID: cbfee68d-f79296d000004278-61-5472f4c16b25 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 36.A4.20081.1C4F2745; Mon, 24 Nov 2014 18:05:05 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.252.83.67]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NFJ008GFD8HS110@mmp1.samsung.com>; Mon, 24 Nov 2014 18:05:05 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Subject: drm/exynos: vidi: add component support Date: Mon, 24 Nov 2014 18:05:05 +0900 Message-id: <1416819905-7992-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsWyRsSkQPfQl6IQg/2zmSx6z51ksrjy9T2b xaT7E1gsZpzfx+TA4rH92wNWj/vdx5k8+rasYvT4vEkugCWKyyYlNSezLLVI3y6BK+N6cz9T wR3TircTKhsYb+h2MXJySAiYSHz5f48JwhaTuHBvPVsXIxeHkMBSRonlj94DORxgRb2HdCDi ixglpi3/wALhdDNJzL8F0c0moCoxccV9NhBbREBZ4u/EVYwgNrNAlMTyw0vZQWxhAQOJZVMn g9WwANVPvdUFZvMKOEssa3nMArFMQWLOJBuIgx6zSZw4ZQpRLiDxbfIhqBJZiU0HmCFKJCUO rrjBMoFRcAEjwypG0dSC5ILipPQiQ73ixNzi0rx0veT83E2MwEA8/e9Z7w7G2wesDzEKcDAq 8fB+2FgUIsSaWFZcmXuI0RRow0RmKdHkfGC455XEGxqbGVmYmpgaG5lbmimJ8ypK/QwWEkhP LEnNTk0tSC2KLyrNSS0+xMjEwSnVwGiz8/qDpIPf9gVb2c26/S5f53jTwUOyq14lxt0pUXr2 P6JKQeGOcuCRwgfWPW/23pl5V7/pRNPRKqOr87kr33xff2dtdX7Zp66ZCS7W+zSZOiNajKJn FHVtcFgsuY3ryqYbM9OY7vF4M2erPVCdpRdR28yqb/5pu6Vi/g7N0OqAwB3L2W5vcFZiKc5I NNRiLipOBAC52+gHPwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRmVeSWpSXmKPExsVy+t9jAd2DX4pCDBbuM7foPXeSyeLK1/ds FpPuT2CxmHF+H5MDi8f2bw9YPe53H2fy6NuyitHj8ya5AJaoBkabjNTElNQihdS85PyUzLx0 WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFslF58AXbfMHKCdSgpliTmlQKGAxOJiJX07TBNCQ9x0 LWAaI3R9Q4LgeowM0EDCGsaM6839TAV3TCveTqhsYLyh28XIwSEhYCLRe0ini5ETyBSTuHBv PVsXIxeHkMAiRolpyz+wQDjdTBLzb91jAqliE1CVmLjiPhuILSKgLPF34ipGEJtZIEpi+eGl 7CC2sICBxLKpk8FqWIDqp97qArN5BZwllrU8ZoFYrCAxZ5LNBEbuBYwMqxhFUwuSC4qT0nMN 9YoTc4tL89L1kvNzNzGCA/2Z1A7GlQ0WhxgFOBiVeHg/bCwKEWJNLCuuzD3EKMHBrCTCe/Zf YYgQb0piZVVqUX58UWlOavEhRlOg5ROZpUST84FRmFcSb2hsYmZkaWRuaGFkbK4kznvjZm6I kEB6YklqdmpqQWoRTB8TB6dUA6NBd2F9mJ/e3QKlwqaaovlFGrf1LG56LPpd31OVPb8/arHq RP0IjVrTx1a5bW4uHscXX/OymHvvdl3PkptVm/4vcHbYNKO8pt7r6909O1p+/b58guHpl2Sf K92V5tHFeycdFVv87+Ajr96doSnHmJ6vuvz067vtK6aunHdi20T1ro63tw7cyTusxFKckWio xVxUnAgAynXqaYoCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: linux-samsung-soc@vger.kernel.org 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 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; }