From patchwork Tue Feb 20 22:21:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 10230957 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2117A601E7 for ; Tue, 20 Feb 2018 22:22:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0309F2894C for ; Tue, 20 Feb 2018 22:22:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC09528958; Tue, 20 Feb 2018 22:22:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5A5B52894C for ; Tue, 20 Feb 2018 22:22:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 906336EEBD; Tue, 20 Feb 2018 22:22:01 +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 A1BDF6EEBD for ; Tue, 20 Feb 2018 22:22:00 +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 w1KMLt4r021038; Tue, 20 Feb 2018 16:21:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519165315; bh=IJSuiCudP1hOLkhWwVZf5LTwcxpNSCdGh6H2npOql+I=; h=From:To:CC:Subject:Date; b=jf9VEU7PWBw8hJyZhqXSFAJath5md8U1faG79QCTaFAMyYuStIknW67fGyyVQ1PBW wDxA1aLZA5G9UlxIWnk1PNHP24qG3R43d3DXYh4KSQv7GQAGY02ZhR1DLUDtjgfi0L TBY+Fe+AqjsipVT3Xds9UbXvbeoOGS4SuizAOggQ= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1KMLtpb026928; Tue, 20 Feb 2018 16:21:55 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) 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.1261.35; Tue, 20 Feb 2018 16:21:54 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Tue, 20 Feb 2018 16:21:54 -0600 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 w1KMLqGU008630; Tue, 20 Feb 2018 16:21:53 -0600 From: Jyri Sarha To: Subject: [PATCH RFC] drm/bridge: panel: Add device_link between panel and master drm device Date: Wed, 21 Feb 2018 00:21:50 +0200 Message-ID: <1519165310-28713-1-git-send-email-jsarha@ti.com> X-Mailer: git-send-email 2.7.4 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, laurent.pinchart@ideasonboard.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently the master drm driver is not protected against the attached panel driver from becoming unavailable. Adding a device_link with DL_FLAG_AUTOREMOVE flag unbinds the master drm device (the consumer) when the panel device (the supplier) becomes unavailable. Signed-off-by: Jyri Sarha Suggested-by: Thierry Reding cc: eric@anholt.net cc: laurent.pinchart@ideasonboard.com --- It still annoys me that the unbound master drm device does not probe again if the panel device becomes available again. If there is no remedy to this, may be we should consider applying the module get/put patch[1] too. Hmmm... there was an obvious reasons not to add module gets and puts to drm_panel_attach/detach(), but is there any such reasons for not to add and remove the device link there? The bridge side look more complicated as there is no public drm_bridge_detach(), and I am not sure if the drm_bridge_remove() should remove the device link. I guess it should, if the link is there. [1] https://lists.freedesktop.org/archives/dri-devel/2018-February/166350.html drivers/gpu/drm/bridge/panel.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index 6d99d4a..d71ddd8 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -22,6 +22,7 @@ struct panel_bridge { struct drm_connector connector; struct drm_panel *panel; u32 connector_type; + struct device_link *link; /* link to master drm dev */ }; static inline struct panel_bridge * @@ -57,6 +58,22 @@ static const struct drm_connector_funcs panel_bridge_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; +static int panel_bridge_link_to_master(struct panel_bridge *panel_bridge) +{ + struct device *mdev = panel_bridge->bridge.dev->dev; + struct device *pdev = panel_bridge->panel->dev; + u32 flags = DL_FLAG_AUTOREMOVE; + + panel_bridge->link = device_link_add(mdev, pdev, flags); + if (!panel_bridge->link) { + dev_err(pdev, "failed to link panel %s to %s\n", + dev_name(pdev), dev_name(mdev)); + return -EINVAL; + } + + return 0; +} + static int panel_bridge_attach(struct drm_bridge *bridge) { struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge); @@ -82,6 +99,9 @@ static int panel_bridge_attach(struct drm_bridge *bridge) drm_mode_connector_attach_encoder(&panel_bridge->connector, bridge->encoder); + if (panel_bridge_link_to_master(panel_bridge)) + return -EINVAL; + ret = drm_panel_attach(panel_bridge->panel, &panel_bridge->connector); if (ret < 0) return ret; @@ -94,6 +114,8 @@ static void panel_bridge_detach(struct drm_bridge *bridge) struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge); drm_panel_detach(panel_bridge->panel); + + device_link_del(panel_bridge->link); } static void panel_bridge_pre_enable(struct drm_bridge *bridge)