From patchwork Wed Jul 28 13:32:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12405813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A17A0C4320A for ; Wed, 28 Jul 2021 13:32:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24B3661051 for ; Wed, 28 Jul 2021 13:32:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 24B3661051 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D63D6E9E6; Wed, 28 Jul 2021 13:32:40 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7E1676E9E6 for ; Wed, 28 Jul 2021 13:32:38 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id EBDE3580B89; Wed, 28 Jul 2021 09:32:37 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 28 Jul 2021 09:32:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=s1/AGqxR15g+h Pk2op+DrdT6xO3KSQkr55JaRssrGcY=; b=S4RIe9lWYsv7BQi3qSJKjL6zckLrC C4hClnsa4/3gIWlspEhNzsJWdS1RQaH8kpbnCWyHWzZ3LkrxEn1NVrTClsRDlXsh 0iEXtA+iNeYvSxkPrnA/L3rcBcj4OMrhS7fuF7INwMN/F458sVbARP7qdqNnzubN jOGhJ2EIGWHqTn6bgLPwyFPQoku4hJBLvJmB0yiySd70hkOibchWVXsalwG7g8bs b7/+NaVMuW9R+4/t8IodPDBBuM/qUCg4ReYYRoTCrEM7ZDQVq9euiOFvlibwZHWN lVZy29fZwYH9YboGV5fb8pmXPUrILk0ThP+NTJx2iycBRNZn682v6qCew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=s1/AGqxR15g+hPk2op+DrdT6xO3KSQkr55JaRssrGcY=; b=fiy/ciDZ olclcVZJcc3IRh1EsV32IMWz9JEByU+/bVx3fMw8ercbvRD1OH+lfW8PzyPUE6AS OV7wuS4J2tcbSnto4iL6ZzNnwF56xZFFWZFZOu5pbvcy3FpflIf5NcuM/MJ6wAQ6 wkjxzHH2dGHbw4Mh0uMM6cs2gveTDrFjcn+oSYp9yh2bld4P7wnaLKiUqUiOqvm2 Nyo5XDu6rUIt4WlJ6v/3s1vGRYxeKIAFxGtGJIZcoJIpgCGRlABQCbYhGFP1u+1N HGjzLrQkphL2ezzs6W0M8stKB16T/Rjq+eDmgUGa9rnPDyDb/B7nsPLcfnArMHa8 YV5JH03ynGmLiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jul 2021 09:32:35 -0400 (EDT) From: Maxime Ripard To: Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Neil Armstrong , Andrzej Hajda , Jonas Karlman , Robert Foss Subject: [PATCH v2 1/8] Revert "drm/vc4: dsi: Only register our component once a DSI device is attached" Date: Wed, 28 Jul 2021 15:32:22 +0200 Message-Id: <20210728133229.2247965-2-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728133229.2247965-1-maxime@cerno.tech> References: <20210728133229.2247965-1-maxime@cerno.tech> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This reverts commit 7213246a803f9b8da0677adb9ae06a3d8b806d02. The commit 7213246a803f ("drm/vc4: dsi: Only register our component once a DSI device is attached") aimed at preventing an endless probe loop between the DSI host driver and its panel/bridge where both would wait for each other to probe. The solution implemented in that commit however relies on the fact that MIPI-DSI device will either be a MIPI-DSI device, or would call mipi_dsi_device_register_full() at probe time. This assumption isn't true for bridges though where most drivers will do so in the bridge attach hook. However, the drm_bridge_attach is usually called in the DSI host bind hook, and thus we never get this far, resulting in a DSI bridge that will never have its attach run, and the DSI host that will never be bound, effectively creating the same situation we were trying to avoid for panels. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_dsi.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index a55256ed0955..6dfcbd9e234e 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -1257,12 +1257,10 @@ static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host, return ret; } -static const struct component_ops vc4_dsi_ops; static int vc4_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct vc4_dsi *dsi = host_to_dsi(host); - int ret; dsi->lanes = device->lanes; dsi->channel = device->channel; @@ -1297,12 +1295,6 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host, return 0; } - ret = component_add(&dsi->pdev->dev, &vc4_dsi_ops); - if (ret) { - mipi_dsi_host_unregister(&dsi->dsi_host); - return ret; - } - return 0; } @@ -1689,6 +1681,7 @@ static int vc4_dsi_dev_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct vc4_dsi *dsi; + int ret; dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); if (!dsi) @@ -1696,10 +1689,26 @@ static int vc4_dsi_dev_probe(struct platform_device *pdev) dev_set_drvdata(dev, dsi); dsi->pdev = pdev; + + /* Note, the initialization sequence for DSI and panels is + * tricky. The component bind above won't get past its + * -EPROBE_DEFER until the panel/bridge probes. The + * panel/bridge will return -EPROBE_DEFER until it has a + * mipi_dsi_host to register its device to. So, we register + * the host during pdev probe time, so vc4 as a whole can then + * -EPROBE_DEFER its component bind process until the panel + * successfully attaches. + */ dsi->dsi_host.ops = &vc4_dsi_host_ops; dsi->dsi_host.dev = dev; mipi_dsi_host_register(&dsi->dsi_host); + ret = component_add(&pdev->dev, &vc4_dsi_ops); + if (ret) { + mipi_dsi_host_unregister(&dsi->dsi_host); + return ret; + } + return 0; } From patchwork Wed Jul 28 13:32:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12405815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37C47C432BE for ; Wed, 28 Jul 2021 13:32:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 04C1660D07 for ; Wed, 28 Jul 2021 13:32:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 04C1660D07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 86B6F6EA1C; Wed, 28 Jul 2021 13:32:44 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5ED656EA1C for ; Wed, 28 Jul 2021 13:32:42 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id CC730580B89; Wed, 28 Jul 2021 09:32:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 28 Jul 2021 09:32:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=I5+dNCfxn/tqf 5HmxMjvJPr+kWU7D9vVbvwGazRUVJo=; b=gIE7mwjbwCPWm9DH56tvB7MMY9FKY LFPXdqW0XM6DThc8Q2jupggkYGaaTOhhw+9/r/WYHqwuRNXaveBKAwSBWgOYJpKi jAmBVS7vFv+RUO0MbbLYpC6fV+QQqQcRaI6lQgz7XKZ5iq9soL1aESlWDDo9J470 N4D5bMXKD6pG5OaGD05PJRPw0o8FewjIYYa4SNkr4X0Z/xlO3ik0hwR0iXEEcyfu Ul5cEvnCagHYI7B9X7WRWO2AJ48f3CIVJp4D5BOxXY5UHrBNuJwbQzVVa3bYQ8pt 3lbtQ5W+bfrzow7a5eMoBT/BI8l7OX39eDhPPANB9rSrMVyJHh0+QFxTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=I5+dNCfxn/tqf5HmxMjvJPr+kWU7D9vVbvwGazRUVJo=; b=gFL4XecR i7OVlhluVFThd9/r/N3pPfL2w/ProTbdhGLJHGb/jzitAMrbIVRr+eKkYnJx4oVn ywCklzz4Sed7ni6OnDQbUzokpJCwCfCoUb6RMQVqpap1fDDprl9PV0w8OyR12Z/i 8ErpPS/MG3aEU74D9734acasV7eyyVYTCEkuFHLosoSPeiXWjVCvE8HExyQtG7MC 5/1r9LC9uiuqKMmduf+zvPvhG2X94HSWs2MRUQ9aI53lg9WntijTOYjk9NIzyohZ lM3J3ETQqK4we1Ln7QrBHAvJpKGwxyjkS03x6UVOMmnc/GsH1jFydsIhQD4oFeeD C8F4NoC96CmHzw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jul 2021 09:32:41 -0400 (EDT) From: Maxime Ripard To: Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Neil Armstrong , Andrzej Hajda , Jonas Karlman , Robert Foss Subject: [PATCH v2 2/8] drm/bridge: Add a function to abstract away panels Date: Wed, 28 Jul 2021 15:32:23 +0200 Message-Id: <20210728133229.2247965-3-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728133229.2247965-1-maxime@cerno.tech> References: <20210728133229.2247965-1-maxime@cerno.tech> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Display drivers so far need to have a lot of boilerplate to first retrieve either the panel or bridge that they are connected to using drm_of_find_panel_or_bridge(), and then either deal with each with ad-hoc functions or create a drm panel bridge through drm_panel_bridge_add. In order to reduce the boilerplate and hopefully create a path of least resistance towards using the DRM panel bridge layer, let's create the function devm_drm_of_get_next to reduce that boilerplate. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/drm_bridge.c | 42 ++++++++++++++++++++++++++++++++---- drivers/gpu/drm/drm_of.c | 3 +++ include/drm/drm_bridge.h | 2 ++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 044acd07c153..426ce7442c86 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "drm_crtc_internal.h" @@ -50,10 +51,8 @@ * * Display drivers are responsible for linking encoders with the first bridge * in the chains. This is done by acquiring the appropriate bridge with - * of_drm_find_bridge() or drm_of_find_panel_or_bridge(), or creating it for a - * panel with drm_panel_bridge_add_typed() (or the managed version - * devm_drm_panel_bridge_add_typed()). Once acquired, the bridge shall be - * attached to the encoder with a call to drm_bridge_attach(). + * devm_drm_of_get_bridge(). Once acquired, the bridge shall be attached to the + * encoder with a call to drm_bridge_attach(). * * Bridges are responsible for linking themselves with the next bridge in the * chain, if any. This is done the same way as for encoders, with the call to @@ -1223,6 +1222,41 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np) return NULL; } EXPORT_SYMBOL(of_drm_find_bridge); + +/** + * devm_drm_of_get_bridge - Return next bridge in the chain + * @dev: device to tie the bridge lifetime to + * @np: device tree node containing encoder output ports + * @port: port in the device tree node + * @endpoint: endpoint in the device tree node + * + * Given a DT node's port and endpoint number, finds the connected node + * and returns the associated bridge if any, or creates and returns a + * drm panel bridge instance if a panel is connected. + * + * Returns a pointer to the bridge if successful, or an error pointer + * otherwise. + */ +struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, + struct device_node *np, + unsigned int port, + unsigned int endpoint) +{ + struct drm_bridge *bridge; + struct drm_panel *panel; + int ret; + + ret = drm_of_find_panel_or_bridge(np, port, endpoint, + &panel, &bridge); + if (ret) + return ERR_PTR(ret); + + if (panel) + bridge = devm_drm_panel_bridge_add(dev, panel); + + return bridge; +} +EXPORT_SYMBOL(devm_drm_of_get_bridge); #endif MODULE_AUTHOR("Ajay Kumar "); diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 997b8827fed2..37c34146eea8 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -231,6 +231,9 @@ EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint); * return either the associated struct drm_panel or drm_bridge device. Either * @panel or @bridge must not be NULL. * + * This function is deprecated and should not be used in new drivers. Use + * devm_drm_of_get_bridge() instead. + * * Returns zero if successful, or one of the standard error codes if it fails. */ int drm_of_find_panel_or_bridge(const struct device_node *np, diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 46bdfa48c413..f70c88ca96ef 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -911,6 +911,8 @@ struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev, struct drm_panel *panel, u32 connector_type); +struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *node, + unsigned int port, unsigned int endpoint); struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge); #endif From patchwork Wed Jul 28 13:32:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12405817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27A6AC4338F for ; Wed, 28 Jul 2021 13:32:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E056060D07 for ; Wed, 28 Jul 2021 13:32:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E056060D07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64FD26EA1E; Wed, 28 Jul 2021 13:32:49 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 18B146EA1E for ; Wed, 28 Jul 2021 13:32:46 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 8226E580B85; Wed, 28 Jul 2021 09:32:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 28 Jul 2021 09:32:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=gBLF9/web37jc 0sR1lKbGPZeTeNlB6xH7qPvpoJe3vw=; b=kUGewio9Xge2fC03bR981X033hi7Z NFVBBt/xJs0v9UF6AOkFsMP0JYTVLgc+sPQay8aA+ky/kM/M7UcZ6YU72SjbNLy6 a2TXdiQL0jPO2czdILAp2n1aUINGcNJuuPHF3oY71BmJ3J/VMxuHPKXhyC593Jaq DndhMiR229n02bYAF5ZrjnXpO9nVG2BOnTYd/fYz3JikSAFNyDn+RYDZGuQXhwY6 /GOKRmkubFpJ4ope0EUbGhCeh5YFIvaW5HxcMictvQBhpCUzHAI7qZbttoYbSi4+ R8N4bShGRc4TKL/MX0fTY56ZXb3OQ80EJgP99kK5GQcXdIpmaT+Tyutog== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=gBLF9/web37jc0sR1lKbGPZeTeNlB6xH7qPvpoJe3vw=; b=ifZZvvfA 2E9chGFwjMocx957UDXa56r7KMaC+VGbQBr58ZktI2zBlkfVuhCF0fBtzAR2bN3k 6P9RuRKHBkhj/OXcQoI82Zn4K1eZYg0DLQHOFtm2aaNIcb5+6CMI33e7KAphN7Xq r3MObaueTOmzWeSMfXG++XQ38b/tXVOUYjLqTVPzUNKC35kEhklUnVfJeH+yEElp AqhXePrgvTSK1R9uavfTPoIBFyGBWdjbe5Vs6CAvvwf6vSL3JrUBhcxZ8sqFhQ+c LcbKGRUDGbgPHIcssMRXz62xL7lj2lBu2PhUC5nWDuQjaz9gcHcVoSAP26YCLtjX P19wLtqre6N2pA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jul 2021 09:32:43 -0400 (EDT) From: Maxime Ripard To: Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Neil Armstrong , Andrzej Hajda , Jonas Karlman , Robert Foss Subject: [PATCH v2 3/8] drm/bridge: Add documentation sections Date: Wed, 28 Jul 2021 15:32:24 +0200 Message-Id: <20210728133229.2247965-4-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728133229.2247965-1-maxime@cerno.tech> References: <20210728133229.2247965-1-maxime@cerno.tech> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The bridge documentation overview is quite packed already, and we'll add some more documentation that isn't part of an overview at all. Let's add some sections to the documentation to separate each bits. Reviewed-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- Documentation/gpu/drm-kms-helpers.rst | 6 ++++++ drivers/gpu/drm/drm_bridge.c | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Documentation/gpu/drm-kms-helpers.rst b/Documentation/gpu/drm-kms-helpers.rst index 389892f36185..10f8df7aecc0 100644 --- a/Documentation/gpu/drm-kms-helpers.rst +++ b/Documentation/gpu/drm-kms-helpers.rst @@ -151,6 +151,12 @@ Overview .. kernel-doc:: drivers/gpu/drm/drm_bridge.c :doc: overview +Display Driver Integration +-------------------------- + +.. kernel-doc:: drivers/gpu/drm/drm_bridge.c + :doc: display driver integration + Bridge Operations ----------------- diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 426ce7442c86..71d3370ce209 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -49,6 +49,15 @@ * Chaining multiple bridges to the output of a bridge, or the same bridge to * the output of different bridges, is not supported. * + * &drm_bridge, like &drm_panel, aren't &drm_mode_object entities like planes, + * CRTCs, encoders or connectors and hence are not visible to userspace. They + * just provide additional hooks to get the desired output at the end of the + * encoder chain. + */ + +/** + * DOC: display driver integration + * * Display drivers are responsible for linking encoders with the first bridge * in the chains. This is done by acquiring the appropriate bridge with * devm_drm_of_get_bridge(). Once acquired, the bridge shall be attached to the @@ -83,11 +92,6 @@ * helper to create the &drm_connector, or implement it manually on top of the * connector-related operations exposed by the bridge (see the overview * documentation of bridge operations for more details). - * - * &drm_bridge, like &drm_panel, aren't &drm_mode_object entities like planes, - * CRTCs, encoders or connectors and hence are not visible to userspace. They - * just provide additional hooks to get the desired output at the end of the - * encoder chain. */ static DEFINE_MUTEX(bridge_lock); From patchwork Wed Jul 28 13:32:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12405819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A60BEC4320A for ; Wed, 28 Jul 2021 13:32:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6FC2560EC0 for ; Wed, 28 Jul 2021 13:32:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6FC2560EC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4437E6EA6B; Wed, 28 Jul 2021 13:32:50 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A0476EA1E for ; Wed, 28 Jul 2021 13:32:48 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id C5F51580B89; Wed, 28 Jul 2021 09:32:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 28 Jul 2021 09:32:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=n2kX7j4p1fO2w 1C+PjBmTewZIHMsxhZO45DlOqT2O4Y=; b=FDX+ngQH8N4rCBmz4gqGHwPV4SW// 9cXnitKdLnWUNjUANU/0DFSffUvHxRQpu8LPIzVWZEV4Hc5xaTgy80S3t+aW6OVy CX06IMDzhJt7QYCpMAopYm+oa0SfXDWWgw6hPYQL2cyCzB6sOxPSllqrLnBDCSNV yh0vlo/20ovtbzWJOojlhADKHYEcPNbSr5FJIWR6wd6Xr86iu182mkosLnFnwPIe BIOP2WGc7y+tKpH3b7r9qBtNcU7Mjw7xHn37Uqb2k/hOoRWnhFD9tChSFCxOUNUQ ujsfL5L9UJ0tQQbzI1eJ5hT5txpOu4YM9iWB+ud+JNsH1+wvu7+g8Qtrw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=n2kX7j4p1fO2w1C+PjBmTewZIHMsxhZO45DlOqT2O4Y=; b=UrZohK23 +Xzrh+zEk6e7cAJkwoDMY02R9L7aLmdkjcpfnHAgyElkn3FmDwNCr/R3p5V0JMWD 6JwG0zGsa93g2CD/ZWpZcwIBB5zwGVbuEYaA/9ZZ34lG80WGdKgAmaysJ3UvQZ4n 86gYyRAoPSHDuJwP7x7bfT/bLD0+rvFZVwSceucQQIeGVdTQNvspJ0Qx3rf3Jyc7 ax/UNi48c7uvJTc4OfSTtA3APmg/Ot6CBE8W9S4QMQmdNoTyPI+9tVHJGD3VeNW/ YUjbCZcOyiZdibbVdaER1yxgCtqdZW/+CmMmTYpzbT1ENwXBbaM+6OWmraQdCwdS wCF8P+NCpzahZQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jul 2021 09:32:47 -0400 (EDT) From: Maxime Ripard To: Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Neil Armstrong , Andrzej Hajda , Jonas Karlman , Robert Foss Subject: [PATCH v2 4/8] drm/bridge: Document the probe issue with MIPI-DSI bridges Date: Wed, 28 Jul 2021 15:32:25 +0200 Message-Id: <20210728133229.2247965-5-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728133229.2247965-1-maxime@cerno.tech> References: <20210728133229.2247965-1-maxime@cerno.tech> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Interactions between bridges, panels, MIPI-DSI host and the component framework are not trivial and can lead to probing issues when implementing a display driver. Let's document the various cases we need too consider, and the solution to support all the cases. Signed-off-by: Maxime Ripard --- Documentation/gpu/drm-kms-helpers.rst | 6 +++ drivers/gpu/drm/drm_bridge.c | 60 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/Documentation/gpu/drm-kms-helpers.rst b/Documentation/gpu/drm-kms-helpers.rst index 10f8df7aecc0..ec2f65b31930 100644 --- a/Documentation/gpu/drm-kms-helpers.rst +++ b/Documentation/gpu/drm-kms-helpers.rst @@ -157,6 +157,12 @@ Display Driver Integration .. kernel-doc:: drivers/gpu/drm/drm_bridge.c :doc: display driver integration +Special Care with MIPI-DSI bridges +---------------------------------- + +.. kernel-doc:: drivers/gpu/drm/drm_bridge.c + :doc: special care dsi + Bridge Operations ----------------- diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 71d3370ce209..fd01f1ce7976 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -94,6 +94,66 @@ * documentation of bridge operations for more details). */ +/** + * DOC: special care dsi + * + * The interaction between the bridges and other frameworks involved in + * the probing of the display driver and the bridge driver can be + * challenging. Indeed, there's multiple cases that needs to be + * considered: + * + * - The display driver doesn't use the component framework and isn't a + * MIPI-DSI host. In this case, the bridge driver will probe at some + * point and the display driver should try to probe again by returning + * EPROBE_DEFER as long as the bridge driver hasn't probed. + * + * - The display driver doesn't use the component framework, but is a + * MIPI-DSI host. The bridge device uses the MIPI-DCS commands to be + * controlled. In this case, the bridge device is a child of the + * display device and when it will probe it's assured that the display + * device (and MIPI-DSI host) is present. The display driver will be + * assured that the bridge driver is connected between the + * &mipi_dsi_host_ops.attach and &mipi_dsi_host_ops.detach operations. + * Therefore, it must run mipi_dsi_host_register() in its probe + * function, and then run drm_bridge_attach() in its + * &mipi_dsi_host_ops.attach hook. + * + * - The display driver uses the component framework and is a MIPI-DSI + * host. The bridge device uses the MIPI-DCS commands to be + * controlled. This is the same situation than above, and can run + * mipi_dsi_host_register() in either its probe or bind hooks. + * + * - The display driver uses the component framework and is a MIPI-DSI + * host. The bridge device uses a separate bus (such as I2C) to be + * controlled. In this case, there's no correlation between the probe + * of the bridge and display drivers, so care must be taken to avoid + * an endless EPROBE_DEFER loop, with each driver waiting for the + * other to probe. + * + * The ideal pattern to cover the last item (and all the others in the + * display driver case) is to split the operations like this: + * + * - In the display driver must run mipi_dsi_host_register() and + * component_add in its probe hook. It will make sure that the + * MIPI-DSI host sticks around, and that the driver's bind can be + * called. + * + * - In its probe hook, the bridge driver must not try to find its + * MIPI-DSI host or register as a MIPI-DSI device. As far as the + * framework is concerned, it must only call drm_bridge_add(). + * + * - In its bind hook, the display driver must try to find the bridge + * and return -EPROBE_DEFER if it doesn't find it. If it's there, it + * must call drm_bridge_attach(). The MIPI-DSI host is now functional. + * + * - In its &drm_bridge_funcs.attach hook, the bridge driver can now try + * to find its MIPI-DSI host and can register as a MIPI-DSI device. + * + * At this point, we're now certain that both the display driver and the + * bridge driver are functional and we can't have a deadlock-like + * situation when probing. + */ + static DEFINE_MUTEX(bridge_lock); static LIST_HEAD(bridge_list); From patchwork Wed Jul 28 13:32:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12405823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25A6EC4320E for ; Wed, 28 Jul 2021 13:32:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE37460FED for ; Wed, 28 Jul 2021 13:32:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DE37460FED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB3E66EA6C; Wed, 28 Jul 2021 13:32:56 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88EEC6EA23 for ; Wed, 28 Jul 2021 13:32:50 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id F1305580B85; Wed, 28 Jul 2021 09:32:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 28 Jul 2021 09:32:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=xK+xD/otmXwAY dn2EDRnzk0bEqEcAIq0hkn3HmHu00Y=; b=YaM8T8mma5KKG/SbB27kTdU173Upo PatXj4WpsvXqx3AK7lxThSpyOcIO5oVYuadBSf0uExot5dQevfoNOMIF77Nog6H9 JsKWuCc+d/A7a4PBqqkkQr+/EJOrZPL2mHJVG2rJOYU3P2RtVXkuaS4Gwawaft5P 8QnxL+FlYKpq8Gz+rN0yYDu+4AE8iZ75vusKos+hs+Nn7V6fz6b7hzZeQuVYvgVN 7nZtU/Hq1vq7UhLAeZfjxGKF97gG5WimREgbjmvw1SUhl/EUg+D6H9t05xH1x/oA tAMiO7Xm+XLmbVkF6LeiV0rLJz519GYrYUfpF7K/nCzY2vCD7Jsfkgriw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=xK+xD/otmXwAYdn2EDRnzk0bEqEcAIq0hkn3HmHu00Y=; b=AYqd1tJ/ 9+K21e4IxaLaHXTzRrrjRAoQf5/EmS5GVs82bUSJ4HNYlzOWbuivvIuALm9AZx8H AcdnpD0gB3graOxPkDgzoM3okiKQMQWoL8RKCxHqDZshKlbLGUKTr5vrTqU8M3MZ 6U87wJCD1zlQBspnv3fSPoXXiyikacVF8YewVkj0FNTfrxwGH/q1ZI8zuVULewz5 je04HwVhoiknpIpdF61WZm6ViPUvVKcAUm+qRyhQNI4KMeab1MBtXfQrjPZl9VxP B3uM1VKvBCZCHY8dRYqcHTUFfAd1cCozbX7Eh67fCTMN06FwFY3UmZAvIWJGF3ME GWKQVnSLNf40Aw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jul 2021 09:32:49 -0400 (EDT) From: Maxime Ripard To: Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Neil Armstrong , Andrzej Hajda , Jonas Karlman , Robert Foss Subject: [PATCH v2 5/8] drm/panel: Create attach and detach callbacks Date: Wed, 28 Jul 2021 15:32:26 +0200 Message-Id: <20210728133229.2247965-6-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728133229.2247965-1-maxime@cerno.tech> References: <20210728133229.2247965-1-maxime@cerno.tech> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This is a partial revert of 87154ff86bf6 ("drm: Remove unnecessary drm_panel_attach and drm_panel_detach"). In order to make the probe order expectation more consistent between bridges, let's create attach and detach hooks for the panels as well to match what is there for bridges. Most drivers have changed significantly since the reverted commit, so we only brought back the calls in the panel bridge to lessen the risk of regressions, and since panel bridge is what we're converging to these days, it's not a big deal anyway. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/panel.c | 6 +++++ drivers/gpu/drm/drm_panel.c | 47 ++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 27 +++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index c916f4b8907e..0b06e0dbad00 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -82,6 +82,10 @@ static int panel_bridge_attach(struct drm_bridge *bridge, drm_connector_attach_encoder(&panel_bridge->connector, bridge->encoder); + ret = drm_panel_attach(panel_bridge->panel, &panel_bridge->connector); + if (ret < 0) + return ret; + return 0; } @@ -90,6 +94,8 @@ static void panel_bridge_detach(struct drm_bridge *bridge) struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge); struct drm_connector *connector = &panel_bridge->connector; + drm_panel_detach(panel_bridge->panel); + /* * Cleanup the connector if we know it was initialized. * diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index f634371c717a..10716b740685 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -93,6 +93,53 @@ void drm_panel_remove(struct drm_panel *panel) } EXPORT_SYMBOL(drm_panel_remove); +/** + * drm_panel_attach - attach a panel to a connector + * @panel: DRM panel + * @connector: DRM connector + * + * After obtaining a pointer to a DRM panel a display driver calls this + * function to attach a panel to a connector. + * + * 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) +{ + if (!panel) + return -EINVAL; + + if (panel->funcs && panel->funcs->attach) + return panel->funcs->attach(panel); + + return 0; +} +EXPORT_SYMBOL(drm_panel_attach); + +/** + * drm_panel_detach - detach a panel from a connector + * @panel: DRM panel + * + * 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(). + */ +void drm_panel_detach(struct drm_panel *panel) +{ + if (!panel) + return; + + if (panel->funcs && panel->funcs->detach) + panel->funcs->detach(panel); +} +EXPORT_SYMBOL(drm_panel_detach); + /** * drm_panel_prepare - power on a panel * @panel: DRM panel diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 4602f833eb51..33d139e98b19 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -68,6 +68,30 @@ enum drm_panel_orientation; * does not need to implement the functionality to enable/disable backlight. */ struct drm_panel_funcs { + /** + * @attach: + * + * This callback is invoked whenever our panel is being attached + * to its DRM connector. + * + * The @attach callback is optional. + * + * RETURNS: + * + * Zero on success, error code on failure. + */ + int (*attach)(struct drm_panel *panel); + + /** + * @detach: + * + * This callback is invoked whenever our panel is being detached + * from its DRM connector. + * + * The @detach callback is optional. + */ + void (*detach)(struct drm_panel *panel); + /** * @prepare: * @@ -180,6 +204,9 @@ void drm_panel_init(struct drm_panel *panel, struct device *dev, void drm_panel_add(struct drm_panel *panel); void drm_panel_remove(struct drm_panel *panel); +int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector); +void drm_panel_detach(struct drm_panel *panel); + int drm_panel_prepare(struct drm_panel *panel); int drm_panel_unprepare(struct drm_panel *panel); From patchwork Wed Jul 28 13:32:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12405821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83AC6C432BE for ; Wed, 28 Jul 2021 13:32:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 528F960D07 for ; Wed, 28 Jul 2021 13:32:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 528F960D07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD98D6EA23; Wed, 28 Jul 2021 13:32:56 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id C39616EA23 for ; Wed, 28 Jul 2021 13:32:52 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 3AB42580B85; Wed, 28 Jul 2021 09:32:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 28 Jul 2021 09:32:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=Y/RFajgQTdM2f 0RaknpC8EEIRDdwxRYMg7nhQGMQRD8=; b=bkgBFNOESyrfQhfpKofvLRUMejBiU II0CIzryDOcoXFpKs+GON8rF5egyv3xmtgsvvvjqVJReEspZaNS/QfvfR/rL6rD6 IGetJbj+RqlsZ4wSC/BFGQLVOS291XrhyRmBSCcLReJeJEllZJwT0mt2whojhcBl h5gTwXZCUTtKTCRLkNGmEJtJ4gZyK5qXhtNYbVkTmGk7hY9HZ+h1KFMEVu2bgb10 Gca1oE1Dby0TFsunU6sndWpWJj+ZJQrX5ID4GEy+rOO82Z+qEk297MfRGLlVpDJm EK+WD2n0qoWAHg7Z37Hy64TP7adk+rhZi7kJpCU4cZFDRwcJc4IN+CXMQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=Y/RFajgQTdM2f0RaknpC8EEIRDdwxRYMg7nhQGMQRD8=; b=f4M3NRAn BMqW2UF9N9ZSx6wQOUUqLIVIxjzo5tsR6aX+beKJdtaG0lsRuxU7t5A0N5YYYM1B vT+CoOxAp1IJE/0JfRf4BWmXWXaAH8iFO9DLr5M9w1BX6oROhY+aziyikH+0LZpd +wLUCVU28/lFWRP/x9vMFqmAvosuI2QtuA5PIZGHgAASyK272o8lIBo6bc3NLZw3 R+exokOYUjm9bbuRbLUq7Po2lP/PzWj6+06jLk/WO2bE1JgDFgxUguk04IISmwwZ AKM5cDyKmTxFQzfLynOZnXJzKfFXDosWM15QKqtUoBKn2IrecMb2lYkrawVC65r1 uJyYENOl0LlQMA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jul 2021 09:32:51 -0400 (EDT) From: Maxime Ripard To: Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Neil Armstrong , Andrzej Hajda , Jonas Karlman , Robert Foss Subject: [PATCH v2 6/8] drm/vc4: dsi: Switch to drm_of_get_bridge Date: Wed, 28 Jul 2021 15:32:27 +0200 Message-Id: <20210728133229.2247965-7-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728133229.2247965-1-maxime@cerno.tech> References: <20210728133229.2247965-1-maxime@cerno.tech> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The new drm_of_get_bridge removes most of the boilerplate we have to deal with. Let's switch to it. Signed-off-by: Maxime Ripard fixup! drm/vc4: dsi: Switch to drm_of_get_bridge --- drivers/gpu/drm/vc4/vc4_drv.c | 2 ++ drivers/gpu/drm/vc4/vc4_dsi.c | 28 ++++------------------------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index 73335feb712f..ff056ee8bc4b 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -25,7 +25,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 6dfcbd9e234e..3db03c95707f 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -1489,7 +1489,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) struct drm_device *drm = dev_get_drvdata(master); struct vc4_dsi *dsi = dev_get_drvdata(dev); struct vc4_dsi_encoder *vc4_dsi_encoder; - struct drm_panel *panel; const struct of_device_id *match; dma_cap_mask_t dma_mask; int ret; @@ -1601,27 +1600,9 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) return ret; } - ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, - &panel, &dsi->bridge); - if (ret) { - /* If the bridge or panel pointed by dev->of_node is not - * enabled, just return 0 here so that we don't prevent the DRM - * dev from being registered. Of course that means the DSI - * encoder won't be exposed, but that's not a problem since - * nothing is connected to it. - */ - if (ret == -ENODEV) - return 0; - - return ret; - } - - if (panel) { - dsi->bridge = devm_drm_panel_bridge_add_typed(dev, panel, - DRM_MODE_CONNECTOR_DSI); - if (IS_ERR(dsi->bridge)) - return PTR_ERR(dsi->bridge); - } + dsi->bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0); + if (IS_ERR(dsi->bridge)) + return PTR_ERR(dsi->bridge); /* The esc clock rate is supposed to always be 100Mhz. */ ret = clk_set_rate(dsi->escape_clock, 100 * 1000000); @@ -1661,8 +1642,7 @@ static void vc4_dsi_unbind(struct device *dev, struct device *master, { struct vc4_dsi *dsi = dev_get_drvdata(dev); - if (dsi->bridge) - pm_runtime_disable(dev); + pm_runtime_disable(dev); /* * Restore the bridge_chain so the bridge detach procedure can happen From patchwork Wed Jul 28 13:32:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12405827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 923EAC432BE for ; Wed, 28 Jul 2021 13:33:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3791B60D07 for ; Wed, 28 Jul 2021 13:33:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3791B60D07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C01B56EA77; Wed, 28 Jul 2021 13:33:07 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 639FF6EA23 for ; Wed, 28 Jul 2021 13:32:56 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id C99FE580B89; Wed, 28 Jul 2021 09:32:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 28 Jul 2021 09:32:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=rpqGJA8BzP498 VRthL+GNLGbJX6smf0yyUoSj3bk7lg=; b=T7QPu9DZcrvJ9+DUbEM2WWuxIgvsA aITQ042/uKsM3KruhSU0AE4u17DCinRfDhHJ411KfCKTqHJMfErqcrmOmbHZbQou pv7o1qhZAAv5m4su4JKIy/cHbAjT1r2sg3zRwsFnfnuJQeM81j2gweCQTRmXPpEp +Dejvo9qy+ujNYiXxaaEwGFRCWLfLyKMRPUt7cWWfqjEcHCPnyMCDpITJ/M7zHeL 0yFUePKHq6p2k98yssDPwzK8WbyQS/FTmCdtlwTK6OgqAfWGsY6S/4gToqmt1X5b bjFqBV7hJ6deK29Il+b44wVaTNdwwfSPI6fqdcKPbeyxewjKzae9qtUdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=rpqGJA8BzP498VRthL+GNLGbJX6smf0yyUoSj3bk7lg=; b=mzkBpZBj MFoDsZ2rHfeXCJsmwG+9bmw+xSYn9Ok8xtbCoysdJw9h80OmmUOnOpBMheKFRB5Q ulD2Gr2Y7q7hFTikZhL0KIHLaaYU9Ab2AKOxeR1yM9OYJ2t2vW5cew0sEt52Hvmn EvoNcZhBfKhQTH+x6HJXRdvl25gfpIx1BfiXInkhhjuahf8IsCejx8j4kCjxU5Dl XE9q3UaESs0v4y7uEXXMeWpr3iyXIB0UTZSYpfG5l3orGYAFZXl1X7aPP+ukD5jM H4ryNloUl1HMBMYVTAfOGeAcIaQmR0HltX0A35x7U5fSf22tmDEPGxVfhG37s0QG NKaLa+m/1OT1yg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeelgdeifecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jul 2021 09:32:53 -0400 (EDT) From: Maxime Ripard To: Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Neil Armstrong , Andrzej Hajda , Jonas Karlman , Robert Foss Subject: [PATCH v2 7/8] drm/panel: raspberrypi-touchscreen: Use the attach hook Date: Wed, 28 Jul 2021 15:32:28 +0200 Message-Id: <20210728133229.2247965-8-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728133229.2247965-1-maxime@cerno.tech> References: <20210728133229.2247965-1-maxime@cerno.tech> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Now that we have an attach hook available for panels as well, let's use it for the RaspberryPi 7" DSI panel. This now mimics what all the other bridges in a similar situation are doing, and we avoid our probe order issue entirely. Signed-off-by: Maxime Ripard --- .../drm/panel/panel-raspberrypi-touchscreen.c | 135 ++++++++++-------- 1 file changed, 77 insertions(+), 58 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c index 462faae0f446..995c5cafb970 100644 --- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c +++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c @@ -346,7 +346,83 @@ static int rpi_touchscreen_get_modes(struct drm_panel *panel, return num; } +static int rpi_touchscreen_attach(struct drm_panel *panel) +{ + struct rpi_touchscreen *ts = panel_to_ts(panel); + struct device *dev = &ts->i2c->dev; + struct device_node *endpoint, *dsi_host_node; + struct mipi_dsi_device *dsi; + struct mipi_dsi_host *host; + int ret; + + struct mipi_dsi_device_info info = { + .type = RPI_DSI_DRIVER_NAME, + .channel = 0, + .node = NULL, + }; + + /* Look up the DSI host. It needs to probe before we do. */ + endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); + if (!endpoint) + return -ENODEV; + + dsi_host_node = of_graph_get_remote_port_parent(endpoint); + if (!dsi_host_node) { + of_node_put(endpoint); + return -ENODEV; + } + + host = of_find_mipi_dsi_host_by_node(dsi_host_node); + of_node_put(dsi_host_node); + if (!host) { + of_node_put(endpoint); + return -EPROBE_DEFER; + } + + info.node = of_graph_get_remote_port(endpoint); + if (!info.node) { + of_node_put(endpoint); + return -ENODEV; + } + + of_node_put(endpoint); + + dsi = mipi_dsi_device_register_full(host, &info); + if (IS_ERR(dsi)) { + dev_err(dev, "DSI device registration failed: %ld\n", + PTR_ERR(dsi)); + return PTR_ERR(dsi); + } + + ts->dsi = dsi; + + dsi->mode_flags = (MIPI_DSI_MODE_VIDEO | + MIPI_DSI_MODE_VIDEO_SYNC_PULSE | + MIPI_DSI_MODE_LPM); + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->lanes = 1; + + ret = mipi_dsi_attach(dsi); + if (ret) { + dev_err(&dsi->dev, "failed to attach dsi to host: %d\n", ret); + return ret; + } + + return 0; +} + +static void rpi_touchscreen_detach(struct drm_panel *panel) +{ + struct rpi_touchscreen *ts = panel_to_ts(panel); + + mipi_dsi_detach(ts->dsi); + mipi_dsi_device_unregister(ts->dsi); +} + static const struct drm_panel_funcs rpi_touchscreen_funcs = { + .attach = rpi_touchscreen_attach, + .detach = rpi_touchscreen_detach, + .disable = rpi_touchscreen_disable, .unprepare = rpi_touchscreen_noop, .prepare = rpi_touchscreen_noop, @@ -359,14 +435,7 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c, { struct device *dev = &i2c->dev; struct rpi_touchscreen *ts; - struct device_node *endpoint, *dsi_host_node; - struct mipi_dsi_host *host; int ver; - struct mipi_dsi_device_info info = { - .type = RPI_DSI_DRIVER_NAME, - .channel = 0, - .node = NULL, - }; ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); if (!ts) @@ -394,35 +463,6 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c, /* /\* Turn off at boot, so we can cleanly sequence powering on. *\/ */ /* rpi_touchscreen_i2c_write(ts, REG_POWERON, 0); */ - /* Look up the DSI host. It needs to probe before we do. */ - endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); - if (!endpoint) - return -ENODEV; - - dsi_host_node = of_graph_get_remote_port_parent(endpoint); - if (!dsi_host_node) - goto error; - - host = of_find_mipi_dsi_host_by_node(dsi_host_node); - of_node_put(dsi_host_node); - if (!host) { - of_node_put(endpoint); - return -EPROBE_DEFER; - } - - info.node = of_graph_get_remote_port(endpoint); - if (!info.node) - goto error; - - of_node_put(endpoint); - - ts->dsi = mipi_dsi_device_register_full(host, &info); - if (IS_ERR(ts->dsi)) { - dev_err(dev, "DSI device registration failed: %ld\n", - PTR_ERR(ts->dsi)); - return PTR_ERR(ts->dsi); - } - drm_panel_init(&ts->base, dev, &rpi_touchscreen_funcs, DRM_MODE_CONNECTOR_DSI); @@ -432,41 +472,20 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c, drm_panel_add(&ts->base); return 0; - -error: - of_node_put(endpoint); - return -ENODEV; } static int rpi_touchscreen_remove(struct i2c_client *i2c) { struct rpi_touchscreen *ts = i2c_get_clientdata(i2c); - mipi_dsi_detach(ts->dsi); - drm_panel_remove(&ts->base); - mipi_dsi_device_unregister(ts->dsi); - return 0; } static int rpi_touchscreen_dsi_probe(struct mipi_dsi_device *dsi) { - int ret; - - dsi->mode_flags = (MIPI_DSI_MODE_VIDEO | - MIPI_DSI_MODE_VIDEO_SYNC_PULSE | - MIPI_DSI_MODE_LPM); - dsi->format = MIPI_DSI_FMT_RGB888; - dsi->lanes = 1; - - ret = mipi_dsi_attach(dsi); - - if (ret) - dev_err(&dsi->dev, "failed to attach dsi to host: %d\n", ret); - - return ret; + return 0; } static struct mipi_dsi_driver rpi_touchscreen_dsi_driver = { From patchwork Wed Jul 28 13:32:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12405825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41361C43214 for ; Wed, 28 Jul 2021 13:33:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14C7B60D07 for ; Wed, 28 Jul 2021 13:33:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 14C7B60D07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 97B626EA76; Wed, 28 Jul 2021 13:33:03 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id F0F986EA76 for ; Wed, 28 Jul 2021 13:32:59 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 69D39580B92; Wed, 28 Jul 2021 09:32:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 28 Jul 2021 09:32:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=oj0uWTcP4eN/7 CWZDuDel6GfjZzcOM2ouml6hFdmYPA=; b=Slc460qMfo8dv8eoJrvCksRwXJP26 FdN2UhmRDlnfq0LcrMhc+R43iu79h22MNTB4lCSBxc9Bd/V9i51IM5CQtWg0FdD1 IPTPRcaBY8OBuJDvH3ngDPsCp7ITToLHVgyxcmBKQa3bMYcLUpr2fgdF7irkLDbu qRXewaVGlE5DVlDOWOT0Zcd2yXg+VRz67PzR1vJNtPDr4bdSy5tfpU4u+Qrm2zLb BJXHw8JciJpQhtZ6ofyt2OJWhQvOUgJEu9RuPtIqU3YDhkoucn4Qr8vZIUfk7BaT qxFaFQt89P2wGwxDAzHkve7Z5U2pSwChpl96IfsqiI6bKwoP20fEt6HRA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=oj0uWTcP4eN/7CWZDuDel6GfjZzcOM2ouml6hFdmYPA=; b=E9ipdD5t ZlcBQy9QTB1kPmrL7dwvrn7EgRasv8XwE68licTQuITnJP9PSsnFTlXV+Y5aWh4R tzIg3og5O+dUdoiOFtJ5uut9RLz9FEYBK+JWiPOnzSAerOJQ63XmbuPyPmeNKvB4 nZ1RMGmoxF4LZ+pDkyQtG9PgGirMnTSyuAz1ZgEX7m8Ko+553wgzpIC9PWwtY/lb QSXKurF3nnyC6tCbiL20aisxaXQzN9SdxZSR7ZXtCfQXcFwr1tzZQPaqIKXxRWQY 01WRpiIWdgi1PPj2a6RswqI9p7NA8vtK+fZ6EwndTsXbObatamyZCRFjSLeD/TTo V0rkwg5hKSaUPQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jul 2021 09:32:57 -0400 (EDT) From: Maxime Ripard To: Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Neil Armstrong , Andrzej Hajda , Jonas Karlman , Robert Foss Subject: [PATCH v2 8/8] drm/panel: raspberrypi-touchscreen: Remove MIPI-DSI driver Date: Wed, 28 Jul 2021 15:32:29 +0200 Message-Id: <20210728133229.2247965-9-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728133229.2247965-1-maxime@cerno.tech> References: <20210728133229.2247965-1-maxime@cerno.tech> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The driver was using a two-steps initialisation when probing with the i2c probe first registering the MIPI-DSI device, and then when that device was probed the driver would attach the device to its host. This resulted in a fairly non-standard probe logic. The previous commit changed that logic entirely though, resulting in a completely empty MIPI-DSI device probe. Let's simplify the driver by removing it entirely and just behave as a normal i2c driver. Signed-off-by: Maxime Ripard --- .../drm/panel/panel-raspberrypi-touchscreen.c | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c index 995c5cafb970..09937aa26c6a 100644 --- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c +++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c @@ -483,16 +483,6 @@ static int rpi_touchscreen_remove(struct i2c_client *i2c) return 0; } -static int rpi_touchscreen_dsi_probe(struct mipi_dsi_device *dsi) -{ - return 0; -} - -static struct mipi_dsi_driver rpi_touchscreen_dsi_driver = { - .driver.name = RPI_DSI_DRIVER_NAME, - .probe = rpi_touchscreen_dsi_probe, -}; - static const struct of_device_id rpi_touchscreen_of_ids[] = { { .compatible = "raspberrypi,7inch-touchscreen-panel" }, { } /* sentinel */ @@ -507,20 +497,7 @@ static struct i2c_driver rpi_touchscreen_driver = { .probe = rpi_touchscreen_probe, .remove = rpi_touchscreen_remove, }; - -static int __init rpi_touchscreen_init(void) -{ - mipi_dsi_driver_register(&rpi_touchscreen_dsi_driver); - return i2c_add_driver(&rpi_touchscreen_driver); -} -module_init(rpi_touchscreen_init); - -static void __exit rpi_touchscreen_exit(void) -{ - i2c_del_driver(&rpi_touchscreen_driver); - mipi_dsi_driver_unregister(&rpi_touchscreen_dsi_driver); -} -module_exit(rpi_touchscreen_exit); +module_i2c_driver(rpi_touchscreen_driver); MODULE_AUTHOR("Eric Anholt "); MODULE_DESCRIPTION("Raspberry Pi 7-inch touchscreen driver");