From patchwork Thu Apr 26 08:06:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 134422 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1933749lji; Thu, 26 Apr 2018 01:07:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+7cnu4fn/7mWjShRq6ucv6a1lDQTaXQTlBbpliwkPvf4iAXobZYeNVUWb9IfDPgBqleTYo X-Received: by 10.98.213.8 with SMTP id d8mr26159779pfg.234.1524730074371; Thu, 26 Apr 2018 01:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524730074; cv=none; d=google.com; s=arc-20160816; b=k2h9R7VOWoQrNSXiUuO+onU/hHIMdUvJfzpKnOY6hJKatQyuMJpvSi0G4Dkq5Ik2V5 mZe5EMc8l2N0HXj7jz8heqp71R/h74apcfoC6EXDCZFVDWMcACbDsjcHEOWIyFHOPawK 2vKTRLkUezzHmFA7fxMVsKe2oYlaPL0uJn3AyjE2R36GeRYIcq2k4PtupjCxIMRur5Mu Fsr0gs8EV6spBjDJDKW93JcFbTeZRk8z9osjefYaUr1qS9XnwwbEjuG/McDeB+ElL8Mi yM2JuL1JgHFg8X6KV5KfPOxbZmFzU9b7hR04Z6wATaED/qILMkyiRXWhLN9GdYehdsSQ 8DzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=+xUBSghP6ChSiK7fYhot3ye4nzgylQ7HJAAoHkaWqjA=; b=W0Fg7aQ63Oahdx9OtDkQiwWlm/Q3sKGRUoRGD5MzcLOhZyj8CATjDYAZIJzlv8tpH1 KwKllBmASmAa62+g+9fk+RXRdvMBuaIgFUAqd+ZXgHLnhGpjYUtN/FmvnCrX20nLdgEC VS8SXmlqsD+0UpEmLjaLP2V+KGgPu/dSCSj46b0H3OQEfmNj3csfgH6DGx0pU3eOORh+ nRoHyZZ3cMu8WEJ2khZWjzWcEdSf7Lm1P+3KDqCFCzOiGSe4aww/TCLLeD4pGH9tBFia cslHrdaCj4wf7+ZwvAqXKP+1Q2yl7XlN64H5xgTr4J7KGVEb9oL1ww1F2IWWB/Fsgw0X iDkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=wG/B0PYU; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id e12si14942214pgn.339.2018.04.26.01.07.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Apr 2018 01:07:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=wG/B0PYU; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A07A46E659; Thu, 26 Apr 2018 08:07:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 124AB6E648 for ; Thu, 26 Apr 2018 08:07:17 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w3Q878fM023153; Thu, 26 Apr 2018 03:07:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1524730028; bh=jYDN9c82RjXf3pEmHrnf0dKLyJcYFBTCR866HinxKdc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wG/B0PYU/UdL7xaVx8ov+0i1YCo1S9zNZH/iPXB7OZiDNcX07u5TPm43HrDcDYNEM 873wkFOsBlxFF4PQpQLTXuW/B7qDmWPwj3GKzqyGoZnlTDLgKoLutsu3AUz5zvs3bh R+5cEn2kJgYT7VlWf75A/N6Pa9+iNwmNnSZ1baoQ= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3Q878tm015489; Thu, 26 Apr 2018 03:07:08 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 26 Apr 2018 03:07:07 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Thu, 26 Apr 2018 03:07:07 -0500 Received: from jadmar.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3Q872lT014814; Thu, 26 Apr 2018 03:07:05 -0500 From: Jyri Sarha To: Subject: [PATCH v4 1/2] drm/panel: Remove drm_panel_detach() calls from all panel drives Date: Thu, 26 Apr 2018 11:06:59 +0300 Message-ID: <464b8d330d6b4c94cfb5aad2ca9ea7eb2c52d934.1524727888.git.jsarha@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, Jyri Sarha , tomi.valkeinen@ti.com, thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com, peda@axentia.se Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Remove all drm_panel_detach() calls from all panel drives update the kernel doc for drm_panel_detach(). Setting the connector and drm to NULL when the drm panel device is going away hardly serves any purpose. Usually the the whole memory structure is freed right after the remove call. However, calling the detach function from the master drm device, and setting the connector pointer to NULL, has the logic of marking the panel again as available for another drm master to attach. The usual situation would be the same drm master device binding again. Signed-off-by: Jyri Sarha Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_panel.c | 6 ++++++ drivers/gpu/drm/panel/panel-innolux-p079zca.c | 1 - drivers/gpu/drm/panel/panel-jdi-lt070me05000.c | 1 - drivers/gpu/drm/panel/panel-lvds.c | 1 - drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c | 1 - drivers/gpu/drm/panel/panel-seiko-43wvf1g.c | 1 - drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c | 1 - drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c | 1 - drivers/gpu/drm/panel/panel-simple.c | 1 - drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 1 - 10 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 308d442..71e4075 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -94,6 +94,9 @@ EXPORT_SYMBOL(drm_panel_remove); * * An error is returned if the panel is already attached to another connector. * + * When unloading, the driver should detach from the panel by calling + * drm_panel_detach(). + * * Return: 0 on success or a negative error code on failure. */ int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector) @@ -115,6 +118,9 @@ EXPORT_SYMBOL(drm_panel_attach); * Detaches a panel from the connector it is attached to. If a panel is not * attached to any connector this is effectively a no-op. * + * This function should not be called by the panel device itself. It + * is only for the drm device that called drm_panel_attach(). + * * Return: 0 on success or a negative error code on failure. */ int drm_panel_detach(struct drm_panel *panel) diff --git a/drivers/gpu/drm/panel/panel-innolux-p079zca.c b/drivers/gpu/drm/panel/panel-innolux-p079zca.c index 57df39b..bb53e08 100644 --- a/drivers/gpu/drm/panel/panel-innolux-p079zca.c +++ b/drivers/gpu/drm/panel/panel-innolux-p079zca.c @@ -292,7 +292,6 @@ static int innolux_panel_remove(struct mipi_dsi_device *dsi) DRM_DEV_ERROR(&dsi->dev, "failed to detach from DSI host: %d\n", err); - drm_panel_detach(&innolux->base); innolux_panel_del(innolux); return 0; diff --git a/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c b/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c index 0a94ab7..99caa78 100644 --- a/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c +++ b/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c @@ -500,7 +500,6 @@ static int jdi_panel_remove(struct mipi_dsi_device *dsi) dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret); - drm_panel_detach(&jdi->base); jdi_panel_del(jdi); return 0; diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c index 5185819..8a16878 100644 --- a/drivers/gpu/drm/panel/panel-lvds.c +++ b/drivers/gpu/drm/panel/panel-lvds.c @@ -282,7 +282,6 @@ static int panel_lvds_remove(struct platform_device *pdev) { struct panel_lvds *lvds = dev_get_drvdata(&pdev->dev); - drm_panel_detach(&lvds->panel); drm_panel_remove(&lvds->panel); panel_lvds_disable(&lvds->panel); diff --git a/drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c b/drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c index 74a8061..cb4dfb9 100644 --- a/drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c +++ b/drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c @@ -299,7 +299,6 @@ static int wuxga_nt_panel_remove(struct mipi_dsi_device *dsi) if (ret < 0) dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret); - drm_panel_detach(&wuxga_nt->base); wuxga_nt_panel_del(wuxga_nt); return 0; diff --git a/drivers/gpu/drm/panel/panel-seiko-43wvf1g.c b/drivers/gpu/drm/panel/panel-seiko-43wvf1g.c index 71c09ed..75f9253 100644 --- a/drivers/gpu/drm/panel/panel-seiko-43wvf1g.c +++ b/drivers/gpu/drm/panel/panel-seiko-43wvf1g.c @@ -292,7 +292,6 @@ static int seiko_panel_remove(struct platform_device *pdev) { struct seiko_panel *panel = dev_get_drvdata(&pdev->dev); - drm_panel_detach(&panel->base); drm_panel_remove(&panel->base); seiko_panel_disable(&panel->base); diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c index 6bf8730..02fc0f5 100644 --- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c +++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c @@ -418,7 +418,6 @@ static int sharp_panel_remove(struct mipi_dsi_device *dsi) if (err < 0) dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err); - drm_panel_detach(&sharp->base); sharp_panel_del(sharp); return 0; diff --git a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c index 494aa9b..e5cae00 100644 --- a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c +++ b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c @@ -327,7 +327,6 @@ static int sharp_nt_panel_remove(struct mipi_dsi_device *dsi) if (ret < 0) dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret); - drm_panel_detach(&sharp_nt->base); sharp_nt_panel_del(sharp_nt); return 0; diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index f2d96611..9388acf 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -364,7 +364,6 @@ static int panel_simple_remove(struct device *dev) { struct panel_simple *panel = dev_get_drvdata(dev); - drm_panel_detach(&panel->base); drm_panel_remove(&panel->base); panel_simple_disable(&panel->base); diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 358c64e..74284e5 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -419,7 +419,6 @@ static int st7789v_remove(struct spi_device *spi) { struct st7789v *ctx = spi_get_drvdata(spi); - drm_panel_detach(&ctx->panel); drm_panel_remove(&ctx->panel); if (ctx->backlight) From patchwork Thu Apr 26 08:07:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 134420 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1933380lji; Thu, 26 Apr 2018 01:07:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ojy+RccAJJPYdNq+7odFffqX+ICIE4y6WYbmbiAQmY52KNqBBmjvWbhB5QeInoMyyI/KP X-Received: by 10.99.106.4 with SMTP id f4mr25885581pgc.225.1524730046562; Thu, 26 Apr 2018 01:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524730046; cv=none; d=google.com; s=arc-20160816; b=gFE+jBGysKB3jz/X8eYOOLNqk7qgvSZ+NeFnIBRHqWLFGsLnCPG830qX+JFlkHCBf/ WLV9GXbBPFcK5enMYIG0ZJvEhavkj8CjTfmoQmQnK31x/9I6Vcu+tZJNNEDDH00mAOvM SBQDCJAiv+cisRntMokqB5NlM49w5wgOn9wdmhuZSKeA98Zsz/A0kymtzVqG+K61PgY1 Mze1K+rfgaaixedeyAtx1XvvsVQMVUrS3YR4ZjXwudw3XgiodJYGcUQDP8dcXS9ZdZVa g38G6Uy7q8LWq2ARoi2HWykMK4BSvnN13Q6YZvzwJBfwTAtzanjguFYLbndjdWHRFyKZ MVwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=pcefYDSZXUnPZqUjk/gti8X0Bn2dYXc0ErUv/tmiGOQ=; b=TGdd2Yh9oHVkBesVABFkuI7WWPit81hhnB5hm3Bl5I2Bor5NIJhcvgQDwEslIXlhNA 5P0BRq++aH7t7emrE+U9fy/LSlycneSlLn24OKr1DjkyTKTVP8Ou40yl98KINOApHZO5 69LDwrFFCHIwb/yw62L7lCLxXEXuU30HDhFjgDDpbWDXKSklaygqjBPvWXUrZtSH7AUF X7TX8Er698wPyPossrkKyqoBccvqcekCev8jVNxuV8271Gn9aWdjKg0cQ8Bctcs7a8ta 9WqF9659jjLeDg9MORmx10AcfaURpfUT+F8bAkhoNbfUmzfdPa6ZxfYTb6Z6tPaTWiLO bjuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=xjN4j04g; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id x32-v6si18283425pld.435.2018.04.26.01.07.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Apr 2018 01:07:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=xjN4j04g; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD0FB6E65B; Thu, 26 Apr 2018 08:07:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id BADC26E648 for ; Thu, 26 Apr 2018 08:07:17 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w3Q87ARd022543; Thu, 26 Apr 2018 03:07:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1524730030; bh=5SC0eea48ALAwBzM2jbe6zeWMpxIz/gZTvJi0BL4DX4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xjN4j04gp+En4afvyAGpK5TN/HO+fqM1Ri0aJZvkTt01bdSKseNf0P2jOA/0dWvJl +59Q6Jnm+Zn7RGNz3Ec+v1OW5AjvlFcjFJwOsveQ7Gmp0+o86APn75XCjTlyuqisPS MpC2aHcgWGNTVKAru0FtbX9aQo7TcIk5aOrC7jMw= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3Q87Amx012759; Thu, 26 Apr 2018 03:07:10 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 26 Apr 2018 03:07:10 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Thu, 26 Apr 2018 03:07:10 -0500 Received: from jadmar.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3Q872lU014814; Thu, 26 Apr 2018 03:07:07 -0500 From: Jyri Sarha To: Subject: [PATCH v4 2/2] drm/panel: Add device_link from panel device to drm device Date: Thu, 26 Apr 2018 11:07:00 +0300 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, Jyri Sarha , tomi.valkeinen@ti.com, thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com, peda@axentia.se Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add device_link from panel device (supplier) to drm device (consumer) when drm_panel_attach() is called. This patch should protect the master drm driver if an attached panel driver unbinds while it is in use. The device_link should make sure the drm device is unbound before the panel driver becomes unavailable. The device_link is removed when drm_panel_detach() is called. The drm_panel_detach() should be called by the consumer DRM driver, not the panel driver, otherwise both drivers are racing to delete the same link. Signed-off-by: Jyri Sarha Reviewed-by: Eric Anholt --- drivers/gpu/drm/drm_panel.c | 10 ++++++++++ include/drm/drm_panel.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 71e4075..965530a 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -104,6 +105,13 @@ int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector) if (panel->connector) return -EBUSY; + panel->link = device_link_add(connector->dev->dev, panel->dev, 0); + if (!panel->link) { + dev_err(panel->dev, "failed to link panel to %s\n", + dev_name(connector->dev->dev)); + return -EINVAL; + } + panel->connector = connector; panel->drm = connector->dev; @@ -125,6 +133,8 @@ EXPORT_SYMBOL(drm_panel_attach); */ int drm_panel_detach(struct drm_panel *panel) { + device_link_del(panel->link); + panel->connector = NULL; panel->drm = NULL; diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 14ac240..26a1b5f 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -89,6 +89,7 @@ struct drm_panel { struct drm_device *drm; struct drm_connector *connector; struct device *dev; + struct device_link *link; const struct drm_panel_funcs *funcs;