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: 128982 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp5123390ljc; Tue, 20 Feb 2018 14:22:02 -0800 (PST) X-Google-Smtp-Source: AH8x227Kf3bSK8YfIs3PbrLuxRTdAekFPZ+E01cMFTdAy3ikFHVg1CAsB+pOW1oRbWPPugt/tcAH X-Received: by 10.101.90.10 with SMTP id y10mr911203pgs.34.1519165322760; Tue, 20 Feb 2018 14:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519165322; cv=none; d=google.com; s=arc-20160816; b=M8Vo/QDAWmwKm2CUbTidjXetwyBK6F51PanXdZOzrzNRoVqNNt30+rEj82fm0llFOa RbRmrpLyf4ui3hefA4DISlZ15niWlQCHrVqV4c46tzBt9GsXYZ2Pa1LPsHl8rtS1AsFb 0ZXeGKizyN87+JsoydBe4nWRztkCUfuq9O33KyUTy1BA4Z6TYgNmQmiFXiWXL2nZcOQ5 W4UpC2+DDQaY/DxdbPb0x1eEYNEEQr8XTi5lT9Ivm2WzNExWvtIrcqXruXogO36ZiQxL MpQsNZ72OKGxpJeOOV7c+3CZHEtN4B+A6JvxYK2r83rZpnnr4lF+WkE4UzOfP7UZ+ETm kzaw== 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:message-id:date:subject:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=VZoeKTwwTNGz24MvuvxLuV48cIJtbMj6Wk9LiwsqdTw=; b=eoiM9pFLIKt9YY7LI1G37GbvTNQPq7Xbao5QywGrNiuis9lxG+7c3TvdEh6HgQrbMC BdJ7UkOHzeN7JAKFfXUu3WPgR7+N4NgNF0k6iwlufIFGTM565IUMF1wwE+DOpAZMT0ey Y/eUBVAAvmJuJoVO68MZB11Ttf5g938moTuTToljzBcXC6Yni9JjgynLpBp4dN1kT85D aKq3VVnnEaMrdeeK6Qr+7tvdqSe+p6jeUCjZWU0zFso3afVJ4rL8FR0OJvNTJuqsNCC9 E7V4+NEYeJUyXpi3m5zlCAR5O37mCdO320ptblZZNFKaTOHPTvdBtn4RvHqKiAhBlOd4 ixEg== 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=jf9VEU7P; 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 a4si1666401pgn.327.2018.02.20.14.22.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Feb 2018 14:22:02 -0800 (PST) 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=jf9VEU7P; 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 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" 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)