From patchwork Mon Jul 9 13:48:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 10514627 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 C84E56032C for ; Mon, 9 Jul 2018 13:48:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B569428AE0 for ; Mon, 9 Jul 2018 13:48:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A966C28B11; Mon, 9 Jul 2018 13:48:53 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 5952A28AE0 for ; Mon, 9 Jul 2018 13:48:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F34116E4B8; Mon, 9 Jul 2018 13:48:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 78C106E4AF for ; Mon, 9 Jul 2018 13:48:44 +0000 (UTC) Received: from wd0142.dip.tu-dresden.de ([141.76.108.142] helo=phil.dip.tu-dresden.de) by gloria.sntech.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1fcWWw-0005PY-Eu; Mon, 09 Jul 2018 15:48:42 +0200 From: Heiko Stuebner To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 3/8] drm/bridge/synopsys: dsi: add ability to check dsi-device attachment Date: Mon, 9 Jul 2018 15:48:29 +0200 Message-Id: <20180709134834.11035-4-heiko@sntech.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180709134834.11035-1-heiko@sntech.de> References: <20180709134834.11035-1-heiko@sntech.de> 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: mark.rutland@arm.com, devicetree@vger.kernel.org, briannorris@chromium.org, hoegsberg@gmail.com, philippe.cornu@st.com, yannick.fertre@st.com, linux-rockchip@lists.infradead.org, nickey.yang@rock-chips.com, robh+dt@kernel.org, thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com, mka@chromium.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly: dw_mipi_dsi_bind() __dw_mipi_dsi_probe() creates dsi bus creates panel device triggers panel module load panel not probed (module not loaded or panel probe slow) drm_bridge_attach fails with -EINVAL due to empty panel_bridge Additionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running. The newly added function provides the ability for glue drivers to check if a dsi device was actually attached and also protects the attach part to prevent concurrency issues from panel-assignment and drm_bridge_create. Using that check glue drivers are able to for example defer probe/bind in the case that the panel is not completely set up yet. Signed-off-by: Heiko Stuebner --- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 25 +++++++++++++++++++ include/drm/bridge/dw_mipi_dsi.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index bb4aeca5c0f9..88fed22ff3f6 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -219,6 +220,7 @@ struct dw_mipi_dsi { struct drm_bridge bridge; struct mipi_dsi_host dsi_host; struct drm_bridge *panel_bridge; + struct mutex panel_mutex; struct device *dev; void __iomem *base; @@ -296,10 +298,14 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host, return PTR_ERR(bridge); } + mutex_lock(&dsi->panel_mutex); + dsi->panel_bridge = bridge; drm_bridge_add(&dsi->bridge); + mutex_unlock(&dsi->panel_mutex); + return 0; } @@ -308,13 +314,30 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, { struct dw_mipi_dsi *dsi = host_to_dsi(host); + mutex_lock(&dsi->panel_mutex); + + dsi->panel_bridge = NULL; drm_of_panel_bridge_remove(host->dev->of_node, 1, 0); drm_bridge_remove(&dsi->bridge); + mutex_unlock(&dsi->panel_mutex); + return 0; } +bool dw_mipi_dsi_device_attached(struct dw_mipi_dsi *dsi) +{ + bool output; + + mutex_lock(&dsi->panel_mutex); + output = !!dsi->panel_bridge; + mutex_unlock(&dsi->panel_mutex); + + return output; +} +EXPORT_SYMBOL_GPL(dw_mipi_dsi_device_attached); + static void dw_mipi_message_config(struct dw_mipi_dsi *dsi, const struct mipi_dsi_msg *msg) { @@ -867,6 +890,8 @@ __dw_mipi_dsi_probe(struct platform_device *pdev, dsi->dev = dev; dsi->plat_data = plat_data; + mutex_init(&dsi->panel_mutex); + if (!plat_data->phy_ops->init || !plat_data->phy_ops->get_lane_mbps) { DRM_ERROR("Phy not properly configured\n"); return ERR_PTR(-ENODEV); diff --git a/include/drm/bridge/dw_mipi_dsi.h b/include/drm/bridge/dw_mipi_dsi.h index 6d7f8eb5d9f2..131ff2569ed4 100644 --- a/include/drm/bridge/dw_mipi_dsi.h +++ b/include/drm/bridge/dw_mipi_dsi.h @@ -31,6 +31,7 @@ struct dw_mipi_dsi_plat_data { void *priv_data; }; +bool dw_mipi_dsi_device_attached(struct dw_mipi_dsi *dsi); struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev, const struct dw_mipi_dsi_plat_data *plat_data);