From patchwork Thu Oct 21 07:39: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: 12574139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CE0EC433EF for ; Thu, 21 Oct 2021 07:40:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9E55611F2 for ; Thu, 21 Oct 2021 07:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231439AbhJUHmR (ORCPT ); Thu, 21 Oct 2021 03:42:17 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:47233 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231380AbhJUHmO (ORCPT ); Thu, 21 Oct 2021 03:42:14 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 23B102B012EF; Thu, 21 Oct 2021 03:39:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 21 Oct 2021 03:39: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=fm1; bh=jf5aJah++UV+M Th4CVC9+SEI69qBu7q3NX/pnOTWeXY=; b=cLmbFkQsEc72FIAxu6FKVrzTYEwTA SUKxiKFkXjOcYtYdVbURn192QLNpEB/VSgsNJQDHkwg7hoKTvQLjrat7m5/RZc8t Octwm24AX3dCV3cJVsYFLyzz05SGkmZpV79afIyj9PuL0QXJ4cYLFKuod2+8QsOv 25H9Mg5YJrI9wfPqKg2sm3Ziq/8NOfCPWLTomnFCzvSKMHdlRaWEHyax25mnMvsy JynxfMbZUHfrIs1H3kB1vM3yI86a7ldzK5TVUik9bVf3Wmp8kfV7vpGfY0P/gSyx tcA0i6gHcZrkVDN7+v8B28MMZGDtEkf+OhVLlOd+CKRXVDnctNLDzYwNw== 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= fm1; bh=jf5aJah++UV+MTh4CVC9+SEI69qBu7q3NX/pnOTWeXY=; b=kMAHnTGf zfZFoOhCDgA6vimE3DawRuSjt9iu/u5KL0Rwd9uLRJHh53PB//e1EdKV36rujzdk mgPJeC7VjzSsJsj/BQM9NwlBxoFcUT3Dzf79mrK/mFy1SMYDY1G/8m8NW7paHj4A zfkrR02AV6iZ9ghzD7lyNcfrVGDdeE4MRJoYxPCwqaPjljbWYmSSVsDBO6RarwlF sy8kYwgcOpwXV/otL4M8hJQQRyxagYNPMxP5aUkC7w0pp8EBwB6Mx8+L+v8FnPTM flP7lVBrgO2/m6g1WDrUN2EGorLlVRzoAggB6SivNDCvjGSr2fx2+v5K/3FqI178 9SOz5bppDda/AA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:39:56 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 01/21] drm/bridge: adv7533: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:27 +0200 Message-Id: <20211021073947.499373-2-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. This also avoids leaking the device when we detach the bridge. Acked-by: Sam Ravnborg Tested-by: John Stultz Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/adv7511/adv7511.h | 1 - drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 2 -- drivers/gpu/drm/bridge/adv7511/adv7533.c | 20 ++++---------------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bridge/adv7511/adv7511.h index 05e3abb5a0c9..592ecfcf00ca 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h @@ -401,7 +401,6 @@ void adv7533_mode_set(struct adv7511 *adv, const struct drm_display_mode *mode); int adv7533_patch_registers(struct adv7511 *adv); int adv7533_patch_cec_registers(struct adv7511 *adv); int adv7533_attach_dsi(struct adv7511 *adv); -void adv7533_detach_dsi(struct adv7511 *adv); int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv); #ifdef CONFIG_DRM_I2C_ADV7511_AUDIO diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index 76555ae64e9c..9e3585f23cf1 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1307,8 +1307,6 @@ static int adv7511_remove(struct i2c_client *i2c) { struct adv7511 *adv7511 = i2c_get_clientdata(i2c); - if (adv7511->type == ADV7533 || adv7511->type == ADV7535) - adv7533_detach_dsi(adv7511); i2c_unregister_device(adv7511->i2c_cec); clk_disable_unprepare(adv7511->cec_clk); diff --git a/drivers/gpu/drm/bridge/adv7511/adv7533.c b/drivers/gpu/drm/bridge/adv7511/adv7533.c index 59d718bde8c4..eb7579dec40a 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7533.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7533.c @@ -153,11 +153,10 @@ int adv7533_attach_dsi(struct adv7511 *adv) return -EPROBE_DEFER; } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { dev_err(dev, "failed to create dsi device\n"); - ret = PTR_ERR(dsi); - goto err_dsi_device; + return PTR_ERR(dsi); } adv->dsi = dsi; @@ -167,24 +166,13 @@ int adv7533_attach_dsi(struct adv7511 *adv) dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_VIDEO_HSE; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { dev_err(dev, "failed to attach dsi to host\n"); - goto err_dsi_attach; + return ret; } return 0; - -err_dsi_attach: - mipi_dsi_device_unregister(dsi); -err_dsi_device: - return ret; -} - -void adv7533_detach_dsi(struct adv7511 *adv) -{ - mipi_dsi_detach(adv->dsi); - mipi_dsi_device_unregister(adv->dsi); } int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv) From patchwork Thu Oct 21 07:39: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: 12574141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26B17C4332F for ; Thu, 21 Oct 2021 07:40:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 134B36135F for ; Thu, 21 Oct 2021 07:40:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231518AbhJUHmd (ORCPT ); Thu, 21 Oct 2021 03:42:33 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:38707 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbhJUHmV (ORCPT ); Thu, 21 Oct 2021 03:42:21 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 5A0092B01309; Thu, 21 Oct 2021 03:40:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 21 Oct 2021 03:40:05 -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=fm1; bh=5Gfw0Ye3DNK3r X7uzANKxwehGkFTMuyO1T3oqn+/K9k=; b=mUYoLNefos0oyMTHxyQzb6chVUBUW 9OwxHF1x1JVdo+srGiKB1k5CicggExjga8HwFmKckbv7v350M4jAs80fikRfEHcm 6+YApNeN5J7/NZeQ5TSBGMMKJcnvlsnpxjWR+ypFGvCiFaWThM6gmmUPdhRDdU7l /hoeZ9XJ1rJiNRZRFUhQ7KDfIfOYkGsDT8GVTaYKv3eTmaUhxZENxyNYv5lNu1qZ bt/k9gqhOZ5qpbbjNT3Xfi1GxC7W37nQhe/99rRB0309LHESgKpWh0/Gp8ruLpoA KL+SBWLGJDkIuFV1myM44lJuIuDolKRMqNixMtH3vZYKHKgMlPc2iNnDg== 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= fm1; bh=5Gfw0Ye3DNK3rX7uzANKxwehGkFTMuyO1T3oqn+/K9k=; b=T/tnVtey Lj6bDuTLOAQY9OBYy04TcL5e7bFlrD+kKyq6ElMlyQepd6Y8ZQE8wHPchzZjpQee SgPcaSYsFKHnMVYCQTvcHCHsSYy2Z0ihlxh0/0NElq3CLLb8v968o1DESFBoP6kW lGQegh/nM9HETuZ813ZhaUDkvgmqQvSDVpswlVjJIXl4RxuP7Mprk6X81dpWeI1H puxsUGk6WbKc7w5dKJSE7gLcM3pMRhOaobDrf8o6Bq7Ula0WZGNcypYcS5rfj35m Ia5R5IFcfZJZE9vTs5hZJIRZ1Yt9PWp0XPuBnBBeqwwuiKwZKuGRHYxMd1x5GiDk uqqa++IR/cpcjw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:01 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 02/21] drm/bridge: adv7511: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:28 +0200 Message-Id: <20211021073947.499373-3-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Tested-by: John Stultz Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index 9e3585f23cf1..f8e5da148599 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -910,9 +910,6 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge, return ret; } - if (adv->type == ADV7533 || adv->type == ADV7535) - ret = adv7533_attach_dsi(adv); - if (adv->i2c_main->irq) regmap_write(adv->regmap, ADV7511_REG_INT_ENABLE(0), ADV7511_INT0_HPD); @@ -1288,8 +1285,18 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) drm_bridge_add(&adv7511->bridge); adv7511_audio_init(dev, adv7511); + + if (adv7511->type == ADV7533 || adv7511->type == ADV7535) { + ret = adv7533_attach_dsi(adv7511); + if (ret) + goto err_unregister_audio; + } + return 0; +err_unregister_audio: + adv7511_audio_exit(adv7511); + drm_bridge_remove(&adv7511->bridge); err_unregister_cec: i2c_unregister_device(adv7511->i2c_cec); clk_disable_unprepare(adv7511->cec_clk); From patchwork Thu Oct 21 07:39: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: 12574143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E9AEC4332F for ; Thu, 21 Oct 2021 07:40:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF1CC610EA for ; Thu, 21 Oct 2021 07:40:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231574AbhJUHmu (ORCPT ); Thu, 21 Oct 2021 03:42:50 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:58755 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbhJUHm0 (ORCPT ); Thu, 21 Oct 2021 03:42:26 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id DC1902B01317; Thu, 21 Oct 2021 03:40:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 21 Oct 2021 03:40:11 -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=fm1; bh=f9BQnijAQr4DY oEIbbbe0kkw4raHj0/3cZnDXHN/PgY=; b=K3v63ZGEZ/gO68tO8YtPquDkjAzBv 3BD2faSb+iuFSq3vAXm0iLRwG3CPZmnngfz6XQO0j1ishb+/RzQvpMh0g62j3jmi TwVF1qbcIRDntAL5GNRxmkiZiRT7H23uiwHwBS/AlK7fC81EvFGGAJeyIGRUV88i MmiAgJd1kVW0jFEhfIxUX4brUpPG60GXAUueuUbh6yh4hnoiVORzbzeMmTJ68xnh u+yEREEJEXljqP/zxC3jomvc7w0BhW3bLd5TD7/FH40TZLjWZHsnTGAn8I2gEtMl +QxN0E5nqyKK8zrGNjtRpbNJBsaTKH6z8VUWqxTVImj7kcS4U7CxC7AJA== 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= fm1; bh=f9BQnijAQr4DYoEIbbbe0kkw4raHj0/3cZnDXHN/PgY=; b=L+a+eKW6 W8oPzki8dKr61DYy8Wyvk2hdymsGAufNUPV2EyHV3Pdxzf7FlP5IQmjhrcSRryfm BmFjcK8xnpFx2VCsiCiQV2GS2XC9DTezJZ3yHNFBBJmKtXLytjZnualp6FwQHXur q2y3tFoXph2jZwhBA9cu0ntFGNKmPSm60iHTXeIFN2Xhr7C5bg0eajwNyaTeQOm1 hCHNe972qlYjriuL17sRyrrkOmV/cABP004UfAMc0AWyOQJM1GNoOCQgxYZhjBJN 3TEk6aJTsmakKDG0eirxC81cSQOg+wgoiLuDQx/8NdyC0V1026hTQqAiufjgfe1I j5SqihnM9xKFKg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:07 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 03/21] drm/bridge: anx7625: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:29 +0200 Message-Id: <20211021073947.499373-4-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/analogix/anx7625.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 1a871f6b6822..4adeb2bad03a 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1316,6 +1316,7 @@ static int anx7625_attach_dsi(struct anx7625_data *ctx) .channel = 0, .node = NULL, }; + int ret; DRM_DEV_DEBUG_DRIVER(dev, "attach dsi\n"); @@ -1325,7 +1326,7 @@ static int anx7625_attach_dsi(struct anx7625_data *ctx) return -EINVAL; } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { DRM_DEV_ERROR(dev, "fail to create dsi device.\n"); return -EINVAL; @@ -1337,10 +1338,10 @@ static int anx7625_attach_dsi(struct anx7625_data *ctx) MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_VIDEO_HSE; - if (mipi_dsi_attach(dsi) < 0) { + ret = devm_mipi_dsi_attach(dev, dsi); + if (ret) { DRM_DEV_ERROR(dev, "fail to attach dsi to host.\n"); - mipi_dsi_device_unregister(dsi); - return -EINVAL; + return ret; } ctx->dsi = dsi; @@ -1350,16 +1351,6 @@ static int anx7625_attach_dsi(struct anx7625_data *ctx) return 0; } -static void anx7625_bridge_detach(struct drm_bridge *bridge) -{ - struct anx7625_data *ctx = bridge_to_anx7625(bridge); - - if (ctx->dsi) { - mipi_dsi_detach(ctx->dsi); - mipi_dsi_device_unregister(ctx->dsi); - } -} - static int anx7625_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -1624,7 +1615,6 @@ static struct edid *anx7625_bridge_get_edid(struct drm_bridge *bridge, static const struct drm_bridge_funcs anx7625_bridge_funcs = { .attach = anx7625_bridge_attach, - .detach = anx7625_bridge_detach, .disable = anx7625_bridge_disable, .mode_valid = anx7625_bridge_mode_valid, .mode_set = anx7625_bridge_mode_set, From patchwork Thu Oct 21 07:39:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2C53C433EF for ; Thu, 21 Oct 2021 07:40:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98BD961378 for ; Thu, 21 Oct 2021 07:40:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbhJUHnB (ORCPT ); Thu, 21 Oct 2021 03:43:01 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:48615 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbhJUHmb (ORCPT ); Thu, 21 Oct 2021 03:42:31 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id A929C2B01301; Thu, 21 Oct 2021 03:40:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 21 Oct 2021 03:40:15 -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=fm1; bh=5DYu0cvmP8Ovg zPcAQBqcadRggWOBGnej15W0Sy1/ns=; b=frf6ixAAgk8gfXoePOUjIetNMXMX0 syKAoDiqgHsHMeRgC0g6VuRwbzUB/3kQuHveuIeqdtf61epvZ3SIzYuuslciFVrD Bf5cBDfWCqiRyFI/wV4VvrRcODSlm3CsCwnueGSC9dziG3A0JumskEr8WHogyieb 3ktII+qw4mUZpV9lO6hHhVPl3zLAjZ+D0JhAr/NeJXPemcWFKiAjprW/zODFiMsF EU7bNfl+G/50R3FNoNl0y8gy85zzNFHSCCjkAWM03+Vbl/CqHe8pBQ/lIWgqRfpW /4ipa0/jyoMQxJ3P/Dg+iANZvlT4LmAtqUnDuD83YcZkOmzvQPWCTCOJA== 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= fm1; bh=5DYu0cvmP8OvgzPcAQBqcadRggWOBGnej15W0Sy1/ns=; b=TC+cH+wM QZ8NNj3mjJiEpavlSzGXMYG8mfud4Jq5diA0ziJdilr65MD7Lj1uG1oXXTG9ns39 QpNo5bxktl0kkdnAB4M6UdOrnD7Q9920YkYwm5ilEyUN7T9qvBJ7GouzzIh2D5n8 w0YJC5BoGzCSMa1tj02gnOb8m+hkGQugSmsnz/njpnTNlqj5uK2kfOYmssMCpeOD HOKX/dzi0sxoGBF7u5wHiWL2cSB6xW6/zr5z7b/Enbh3FZfZgcwYlebexp2Ymzos V2KufcN9kc6/5exKW1gqJP9U/8xQmrK7zXllkliyCgY+87rHuC5ei/acB05eUR1h I+jlsg/0pUJ6Cw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:12 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 04/21] drm/bridge: anx7625: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:30 +0200 Message-Id: <20211021073947.499373-5-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/analogix/anx7625.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 4adeb2bad03a..d0317651cd75 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1367,12 +1367,6 @@ static int anx7625_bridge_attach(struct drm_bridge *bridge, return -ENODEV; } - err = anx7625_attach_dsi(ctx); - if (err) { - DRM_DEV_ERROR(dev, "Fail to attach to dsi : %d\n", err); - return err; - } - if (ctx->pdata.panel_bridge) { err = drm_bridge_attach(bridge->encoder, ctx->pdata.panel_bridge, @@ -1845,10 +1839,24 @@ static int anx7625_i2c_probe(struct i2c_client *client, platform->bridge.type = DRM_MODE_CONNECTOR_eDP; drm_bridge_add(&platform->bridge); + ret = anx7625_attach_dsi(platform); + if (ret) { + DRM_DEV_ERROR(dev, "Fail to attach to dsi : %d\n", ret); + goto unregister_bridge; + } + DRM_DEV_DEBUG_DRIVER(dev, "probe done\n"); return 0; +unregister_bridge: + drm_bridge_remove(&platform->bridge); + + if (!platform->pdata.low_power_mode) + pm_runtime_put_sync_suspend(&client->dev); + + anx7625_unregister_i2c_dummy_clients(platform); + free_wq: if (platform->workqueue) destroy_workqueue(platform->workqueue); From patchwork Thu Oct 21 07:39:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 565CFC433EF for ; Thu, 21 Oct 2021 07:40:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38315610CF for ; Thu, 21 Oct 2021 07:40:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231419AbhJUHnD (ORCPT ); Thu, 21 Oct 2021 03:43:03 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:47291 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbhJUHmf (ORCPT ); Thu, 21 Oct 2021 03:42:35 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 066E02B0130E; Thu, 21 Oct 2021 03:40:17 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 21 Oct 2021 03:40:19 -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=fm1; bh=l+O22JDiqkqJM EtaGeqIDet4bD6VhA1ltwhW7Yd/nGM=; b=MvCKg0zoZmQWIofgJY+5SG7pqi3NB ei5Iu+F6jCd48HZh81CVZfRXUKwkB3avnEIqBuaqRZVSzig+OoKW/ih0whOuqVNP +HR1lPXKAlVP6LxBc2RBTXisk6k+j95nxDuexTPFFP1ulWvWWaRz3PxhFKka3iVF EbPKp9yxH+tExTymDFfR0qnop5aP6b3wUFT0+YiBNSqO5+I59lKhKhloZF8Z/dGY p4vD5RTnKbKQd/Dm84Nkroa3S8CHKwgJnwpXHw+gE7TZEuTIdduOagGpJWH90xHz AoUESWF2bZdvsJ6F7/bs98ZLZ51yk3pMzLnsxvX7eReU5BolJurRj9HSQ== 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= fm1; bh=l+O22JDiqkqJMEtaGeqIDet4bD6VhA1ltwhW7Yd/nGM=; b=MgheI22t 5ZdDf4eT0DljKZ+0jkSAcm8PZaqysfnOzsk0mKCKDz8f7CwoH3OBFh9jhP7m2mJV eXfD+FTMX9hRFd34qOFKOfFIgBSU7aUMilbygr1aIqalbtI2Le3YL5dxAWt9SmqI vd2ppDGAHs8ZA7dPynm+AVXEyNNqRWYiAecSkjGS1ldmk5wn2plwW44tzUEUdp4L DEBmatllV5kmoTB+ulI3DdHr1k0w4LsTXAM9S1phQHJTiHPi3uS+SmkvZvpq2m8V beDMKS9rV+y7e8K7gdMPBv601F/HH7vMboCQIEwBYA1VlPTUIAtwPgcGKUo+ijVx UQ2nPEFZmKibBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:16 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 05/21] drm/bridge: lt8912b: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:31 +0200 Message-Id: <20211021073947.499373-6-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/lontium-lt8912b.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c index 1b0c7eaf6c84..cc968d65936b 100644 --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c @@ -472,11 +472,11 @@ static int lt8912_attach_dsi(struct lt8912 *lt) return -EPROBE_DEFER; } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { ret = PTR_ERR(dsi); dev_err(dev, "failed to create dsi device (%d)\n", ret); - goto err_dsi_device; + return ret; } lt->dsi = dsi; @@ -489,24 +489,13 @@ static int lt8912_attach_dsi(struct lt8912 *lt) MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_NO_EOT_PACKET; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { dev_err(dev, "failed to attach dsi to host\n"); - goto err_dsi_attach; + return ret; } return 0; - -err_dsi_attach: - mipi_dsi_device_unregister(dsi); -err_dsi_device: - return ret; -} - -static void lt8912_detach_dsi(struct lt8912 *lt) -{ - mipi_dsi_detach(lt->dsi); - mipi_dsi_device_unregister(lt->dsi); } static int lt8912_bridge_connector_init(struct drm_bridge *bridge) @@ -573,7 +562,6 @@ static void lt8912_bridge_detach(struct drm_bridge *bridge) struct lt8912 *lt = bridge_to_lt8912(bridge); if (lt->is_attached) { - lt8912_detach_dsi(lt); lt8912_hard_power_off(lt); drm_connector_unregister(<->connector); drm_connector_cleanup(<->connector); From patchwork Thu Oct 21 07:39:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9FE2C433EF for ; Thu, 21 Oct 2021 07:40:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DAB16115B for ; Thu, 21 Oct 2021 07:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231676AbhJUHnJ (ORCPT ); Thu, 21 Oct 2021 03:43:09 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:34565 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbhJUHmj (ORCPT ); Thu, 21 Oct 2021 03:42:39 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 7921D2B0131F; Thu, 21 Oct 2021 03:40:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 21 Oct 2021 03:40:24 -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=fm1; bh=pV3hE2oY3D0Ef gDyvbcrui+MkjjAnltQDBA8ecItqP8=; b=PWNcqDeCBK858nlsHvN7/57PCBcqE 8sDyTiBCzeXuKd+SfXXWBWqLVDmVSWZw89eHVTz7cTCS/5OUfWE15yzqDZbpsf3x cqYHirZ2MILW5x9Kh3xEDo/XeZWD3l65SQJOWaACFmjQVLMlKWV7f/XM5oZJdnfc qeV+JUaNgTRwy+ecxP/MA91eN1MdZYz4nLHhSIBRIIWQH8OK8SEmdRWqKPULgTb+ ruzWjAyiIO82ouWOabzjCKwm0hnmd82SvHwnXOOnbOi4TNLIm2hFN/ZvcB5fzBDV iSfIYWGn5jPwXOUq7ayyVJdhhP1YFoyVmdQtGmhV6D++8Vnm8iNZlRWPA== 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= fm1; bh=pV3hE2oY3D0EfgDyvbcrui+MkjjAnltQDBA8ecItqP8=; b=c3qur6nU ekbWoCf/rT5KbmFeVux33ea43dXa47pwANCzf7j39Q1qcI8laljTi3PdXXiRbxOL g1T1i5pZ2XItM7HGhUw+rDLy4RE+ToIJivWqNFTMww4rp57/mlw1rzT71B9Ychka WxwNVmmeoavw24l5F9z6RCXny+Ax+hMXD+nKL5jJwGsYRCfg4GavO5TzIyiZlDK0 /cj15Hy1QpwVRQAsNjlSNLU3sxEqS737MuGHbROa1BHi86lgS+qTdTjvo31S4DHA kerFHEynVdrMIEgf23+FpQM3sG5n6hXbxeHNzd7hToAFYoyZVukKhNJNmz7bv5Ow XpC8RoEHz/0ZjQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:21 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 06/21] drm/bridge: lt8912b: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:32 +0200 Message-Id: <20211021073947.499373-7-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/lontium-lt8912b.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c index cc968d65936b..c642d1e02b2f 100644 --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c @@ -544,10 +544,6 @@ static int lt8912_bridge_attach(struct drm_bridge *bridge, if (ret) goto error; - ret = lt8912_attach_dsi(lt); - if (ret) - goto error; - lt->is_attached = true; return 0; @@ -706,8 +702,15 @@ static int lt8912_probe(struct i2c_client *client, drm_bridge_add(<->bridge); + ret = lt8912_attach_dsi(lt); + if (ret) + goto err_attach; + return 0; +err_attach: + drm_bridge_remove(<->bridge); + lt8912_free_i2c(lt); err_i2c: lt8912_put_dt(lt); err_dt_parse: From patchwork Thu Oct 21 07:39:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD253C433F5 for ; Thu, 21 Oct 2021 07:41:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 944BC60F6E for ; Thu, 21 Oct 2021 07:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231723AbhJUHnP (ORCPT ); Thu, 21 Oct 2021 03:43:15 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:57469 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbhJUHmo (ORCPT ); Thu, 21 Oct 2021 03:42:44 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id C97472B01326; Thu, 21 Oct 2021 03:40:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 21 Oct 2021 03:40:28 -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=fm1; bh=Z7ANxwSCuwS0R URLyvuze3uqYVQmNE0MSkpaXoK8tPE=; b=S1EzMFnxy4kNWJo+cTu2XtTqcpphR D3XH1/o7K8R9yLShBNpgQ8+Dm+LsSREMt0FtUyX6WybOTk8X7yrgSR1orFq6Vxg1 oPvHYR1pXmBLU52pxByDkTmysXnA0vyK9mj9QZI/YFh3tpeD7J/IKska6j7MN1uh PY7rXv+x0hcXHFx12YsACALyfgpNR76rtmA6wBETJ8OTo5H5mNvCllIs/Jjgjiej gZ5W7a6qQDZbtY6XrBK0JlVRevu4xVHvBzJYXZxbs4S21iKgR/T8pcDWpmcC2INy Vmkr0GvolbqcN5qLyLlpNf+hhs5M8PZ2+J2i//Q63uIa1Qk9UW0h/3sjQ== 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= fm1; bh=Z7ANxwSCuwS0RURLyvuze3uqYVQmNE0MSkpaXoK8tPE=; b=giF8fL1D 1OeOW0QDfp7EvRHqtSETGDuhyr5gyLK9mMWoZcgWpBrAiQ8DwUFeFiTnqojTM2Ng 1h087Ch3E9L3pYIz/wzPh0VYa0bDs8dspatLEhcyIfJVkD5WAfQiqn6gSh1HfIUB lSCaPU4kSI2By50Di5zJI4x2myRtyLnchstibCJFhsnUvVUjZruN2wtJQk+TR/4P 8e0ju+DB8mNYLXovh9GE21s+c/4UBoATqDzGG5CHOMm8XA+EdcMRuTbozsFcIdFO 9QFz2C+bmzU+laVoLEcr8XKu+R9LdpY08WWDXfgYX1eyTHab9PazasRP7AvUQzZb CNmTXVMM5NBgVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:25 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 07/21] drm/bridge: lt9611: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:33 +0200 Message-Id: <20211021073947.499373-8-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. Acked-by: Sam Ravnborg Tested-by: John Stultz Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/lontium-lt9611.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611.c b/drivers/gpu/drm/bridge/lontium-lt9611.c index 29b1ce2140ab..654131aca5ed 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611.c @@ -760,6 +760,7 @@ static struct mipi_dsi_device *lt9611_attach_dsi(struct lt9611 *lt9611, const struct mipi_dsi_device_info info = { "lt9611", 0, NULL }; struct mipi_dsi_device *dsi; struct mipi_dsi_host *host; + struct device *dev = lt9611->dev; int ret; host = of_find_mipi_dsi_host_by_node(dsi_node); @@ -768,7 +769,7 @@ static struct mipi_dsi_device *lt9611_attach_dsi(struct lt9611 *lt9611, return ERR_PTR(-EPROBE_DEFER); } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { dev_err(lt9611->dev, "failed to create dsi device\n"); return dsi; @@ -779,29 +780,15 @@ static struct mipi_dsi_device *lt9611_attach_dsi(struct lt9611 *lt9611, dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_VIDEO_HSE; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { - dev_err(lt9611->dev, "failed to attach dsi to host\n"); - mipi_dsi_device_unregister(dsi); + dev_err(dev, "failed to attach dsi to host\n"); return ERR_PTR(ret); } return dsi; } -static void lt9611_bridge_detach(struct drm_bridge *bridge) -{ - struct lt9611 *lt9611 = bridge_to_lt9611(bridge); - - if (lt9611->dsi1) { - mipi_dsi_detach(lt9611->dsi1); - mipi_dsi_device_unregister(lt9611->dsi1); - } - - mipi_dsi_detach(lt9611->dsi0); - mipi_dsi_device_unregister(lt9611->dsi0); -} - static int lt9611_connector_init(struct drm_bridge *bridge, struct lt9611 *lt9611) { int ret; @@ -855,9 +842,7 @@ static int lt9611_bridge_attach(struct drm_bridge *bridge, return 0; err_unregister_dsi0: - lt9611_bridge_detach(bridge); drm_connector_cleanup(<9611->connector); - mipi_dsi_device_unregister(lt9611->dsi0); return ret; } @@ -952,7 +937,6 @@ static void lt9611_bridge_hpd_enable(struct drm_bridge *bridge) static const struct drm_bridge_funcs lt9611_bridge_funcs = { .attach = lt9611_bridge_attach, - .detach = lt9611_bridge_detach, .mode_valid = lt9611_bridge_mode_valid, .enable = lt9611_bridge_enable, .disable = lt9611_bridge_disable, From patchwork Thu Oct 21 07:39:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 451C9C433EF for ; Thu, 21 Oct 2021 07:41:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29BB46115B for ; Thu, 21 Oct 2021 07:41:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231496AbhJUHnS (ORCPT ); Thu, 21 Oct 2021 03:43:18 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:58431 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbhJUHmt (ORCPT ); Thu, 21 Oct 2021 03:42:49 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 589AE2B01331; Thu, 21 Oct 2021 03:40:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 21 Oct 2021 03:40:33 -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=fm1; bh=pwgSELP5dT/2C DHLV12oEtfj6zG5D1L9hu7xC1kNBUc=; b=JlndOIGl5tAZyOkLZVC7uZYmUUTjk w70qe2S1XP5lcth0o9h99EerQiC+l9eWWSPkRskuovBjyAkDn0CT0dWx2Nvr5fiL h/2UmyRX8jM3p/6PzOLRkabJaPEpqXFmDRvz98nVTZa1jVUMaccx4d+TvrvMX2Ig rLoAxhidRFAJMDCUgEaXnPth45gLBzpzHFiSbccWmY1l3pqtPIQXlDUKyH0+DAuC chX86yU5NpAswDtx1bn5lU0fXdF0KtnsAXaUSQVou6vLK6RiiaBomap9xwU19VAp teO7LzVANWCYGpKqAi+XmC51O6RPl7vcNnJBHkfG9e1Mdrm7t7XaYPC2A== 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= fm1; bh=pwgSELP5dT/2CDHLV12oEtfj6zG5D1L9hu7xC1kNBUc=; b=TUFxoRW/ 1+jxNvo+HlikdlI+Buxz84FeX1jzBlkJLvF9NHpvyGzSgdV2vHiIFY65PESNuPCG sZW8SmScvzYkssZYoGJ4qYVV/Q2mNavfLMzVQcqy9ZjBDgxq5cjDzROc7xIKjiq/ E2fbuLLUoTuYXb+zYMIC7gmJzO5Lg01po568uLjVcN2fkt/IPvWz64q4IZ0D7mBm KTe52TbAtj90J8tg6B51n48SHO3vlfmm/JYJLqElh+S1ZEvtcJrWOMfMnRJ5woWx Dl8NQ0lIpmjBO+NuQkvop7jiHGWsBghzQJcn6qYAgj4yQRRELQWgXhnqhHAkZxnC DfAicfqG388HjQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:30 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 08/21] drm/bridge: lt9611: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:34 +0200 Message-Id: <20211021073947.499373-9-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Tested-by: John Stultz Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/lontium-lt9611.c | 38 ++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611.c b/drivers/gpu/drm/bridge/lontium-lt9611.c index 654131aca5ed..d2f45a0f79c8 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611.c @@ -825,26 +825,7 @@ static int lt9611_bridge_attach(struct drm_bridge *bridge, return ret; } - /* Attach primary DSI */ - lt9611->dsi0 = lt9611_attach_dsi(lt9611, lt9611->dsi0_node); - if (IS_ERR(lt9611->dsi0)) - return PTR_ERR(lt9611->dsi0); - - /* Attach secondary DSI, if specified */ - if (lt9611->dsi1_node) { - lt9611->dsi1 = lt9611_attach_dsi(lt9611, lt9611->dsi1_node); - if (IS_ERR(lt9611->dsi1)) { - ret = PTR_ERR(lt9611->dsi1); - goto err_unregister_dsi0; - } - } - return 0; - -err_unregister_dsi0: - drm_connector_cleanup(<9611->connector); - - return ret; } static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge, @@ -1165,10 +1146,29 @@ static int lt9611_probe(struct i2c_client *client, drm_bridge_add(<9611->bridge); + /* Attach primary DSI */ + lt9611->dsi0 = lt9611_attach_dsi(lt9611, lt9611->dsi0_node); + if (IS_ERR(lt9611->dsi0)) { + ret = PTR_ERR(lt9611->dsi0); + goto err_remove_bridge; + } + + /* Attach secondary DSI, if specified */ + if (lt9611->dsi1_node) { + lt9611->dsi1 = lt9611_attach_dsi(lt9611, lt9611->dsi1_node); + if (IS_ERR(lt9611->dsi1)) { + ret = PTR_ERR(lt9611->dsi1); + goto err_remove_bridge; + } + } + lt9611_enable_hpd_interrupts(lt9611); return lt9611_audio_init(dev, lt9611); +err_remove_bridge: + drm_bridge_remove(<9611->bridge); + err_disable_regulators: regulator_bulk_disable(ARRAY_SIZE(lt9611->supplies), lt9611->supplies); From patchwork Thu Oct 21 07:39:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C57DC4332F for ; Thu, 21 Oct 2021 07:41:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 760836115B for ; Thu, 21 Oct 2021 07:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231599AbhJUHnV (ORCPT ); Thu, 21 Oct 2021 03:43:21 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:36833 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbhJUHmx (ORCPT ); Thu, 21 Oct 2021 03:42:53 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 0DF1D2B01341; Thu, 21 Oct 2021 03:40:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 21 Oct 2021 03:40: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=fm1; bh=RyGY+A4bMARCP Cc0cLwmXfEa8Ojs0eyLuWNCplLnI/w=; b=U7ALZ4/pTf6yJ1Koo+KUqL9ouLPE+ VBN8X5YgAoEc2EXj8agZOdowhulx8qnZH8ihrIbytgiEsKq3XQ1yeToWg5SYQ3C6 dUNPeCmlIATmQHor4h0KTZVsVr2AZDLbFm/T9C1t+hhnrxsISz7mmagszafVTftM MvhqclLDuhLI2D8E3676D5EoASlU00+YrEYKPxhOaD4Y3Q3JCyGqWUlxfnEKPwdS IbzdI6CqEGJ2Q6vv73MewK3McOmWr0hnKu8jvVKWFi9C9xFPTYaqGrbzVbxXjgz5 r4HNSVYzTYe2k6uaEBMhENw76nDiM6CAxrNLvJJ0bkarjZFXR1BbWNMcQ== 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= fm1; bh=RyGY+A4bMARCPCc0cLwmXfEa8Ojs0eyLuWNCplLnI/w=; b=EUqe09NE eF2xYGIuvQ2xNqhXrbzoLJijng1fX8mwN9wQAXMRQoQqrE7ERKamOybLSkpT3M21 51hFFRrnHG5PbgrkwaKtRf0ZqkK7S/DkhzxqJ53TRURMtX6jaRE7/jJMkKEOnmTV j1vjEcRI6JUz+/GweGhfeEb3CQncrQOwIsJ48AhrPUbKwQH1b+cUprnE0r8teW/+ r3aN25hRLqQ72L8St2Br/eQOM/lfyHvVbVB6ffQaJgkOYVWv1FQ0uulRM1cdRJHy G1UFPKvIvnVIvFPEiEzWvZENAEqE7JVNSGmgiWbjSTU/AH03+T3N4fIMypPQgXqa yvLy9JbGvyGv5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:34 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 09/21] drm/bridge: lt9611uxc: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:35 +0200 Message-Id: <20211021073947.499373-10-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 38 +++++----------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c index 010657ea7af7..ab1a0c00aad8 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c @@ -258,17 +258,18 @@ static struct mipi_dsi_device *lt9611uxc_attach_dsi(struct lt9611uxc *lt9611uxc, const struct mipi_dsi_device_info info = { "lt9611uxc", 0, NULL }; struct mipi_dsi_device *dsi; struct mipi_dsi_host *host; + struct device *dev = lt9611uxc->dev; int ret; host = of_find_mipi_dsi_host_by_node(dsi_node); if (!host) { - dev_err(lt9611uxc->dev, "failed to find dsi host\n"); + dev_err(dev, "failed to find dsi host\n"); return ERR_PTR(-EPROBE_DEFER); } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { - dev_err(lt9611uxc->dev, "failed to create dsi device\n"); + dev_err(dev, "failed to create dsi device\n"); return dsi; } @@ -277,10 +278,9 @@ static struct mipi_dsi_device *lt9611uxc_attach_dsi(struct lt9611uxc *lt9611uxc, dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_VIDEO_HSE; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { - dev_err(lt9611uxc->dev, "failed to attach dsi to host\n"); - mipi_dsi_device_unregister(dsi); + dev_err(dev, "failed to attach dsi to host\n"); return ERR_PTR(ret); } @@ -355,19 +355,6 @@ static int lt9611uxc_connector_init(struct drm_bridge *bridge, struct lt9611uxc return drm_connector_attach_encoder(<9611uxc->connector, bridge->encoder); } -static void lt9611uxc_bridge_detach(struct drm_bridge *bridge) -{ - struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge); - - if (lt9611uxc->dsi1) { - mipi_dsi_detach(lt9611uxc->dsi1); - mipi_dsi_device_unregister(lt9611uxc->dsi1); - } - - mipi_dsi_detach(lt9611uxc->dsi0); - mipi_dsi_device_unregister(lt9611uxc->dsi0); -} - static int lt9611uxc_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -388,19 +375,11 @@ static int lt9611uxc_bridge_attach(struct drm_bridge *bridge, /* Attach secondary DSI, if specified */ if (lt9611uxc->dsi1_node) { lt9611uxc->dsi1 = lt9611uxc_attach_dsi(lt9611uxc, lt9611uxc->dsi1_node); - if (IS_ERR(lt9611uxc->dsi1)) { - ret = PTR_ERR(lt9611uxc->dsi1); - goto err_unregister_dsi0; - } + if (IS_ERR(lt9611uxc->dsi1)) + return PTR_ERR(lt9611uxc->dsi1); } return 0; - -err_unregister_dsi0: - mipi_dsi_detach(lt9611uxc->dsi0); - mipi_dsi_device_unregister(lt9611uxc->dsi0); - - return ret; } static enum drm_mode_status @@ -544,7 +523,6 @@ static struct edid *lt9611uxc_bridge_get_edid(struct drm_bridge *bridge, static const struct drm_bridge_funcs lt9611uxc_bridge_funcs = { .attach = lt9611uxc_bridge_attach, - .detach = lt9611uxc_bridge_detach, .mode_valid = lt9611uxc_bridge_mode_valid, .mode_set = lt9611uxc_bridge_mode_set, .detect = lt9611uxc_bridge_detect, From patchwork Thu Oct 21 07:39:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20401C433F5 for ; Thu, 21 Oct 2021 07:41:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 029CD60F6E for ; Thu, 21 Oct 2021 07:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231522AbhJUHn2 (ORCPT ); Thu, 21 Oct 2021 03:43:28 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:59287 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231769AbhJUHm5 (ORCPT ); Thu, 21 Oct 2021 03:42:57 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id 61AB42B01344; Thu, 21 Oct 2021 03:40:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 21 Oct 2021 03:40:42 -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=fm1; bh=V2ECKODejaAuL jYVZGAyrUq9Ivh4nxZakGL2AQusnM8=; b=f7M/Yoi+B44CPGuKeKO21MHz1NxJC TAuwB27fI6oWQBlyIc+jTL7V4bVxRaw+1jrq8rwJfa9KAmigKSgjjG8Wj7k10cYo Kqnq1SqNJSlIX8i0JFOOdEjq7U9Vfvv8m/iL9EqN+vLpRRNzmnjDG+fMaG4EaGEw Rj8m9FpwFT5VXoR8Mi2MoBrfyqWF0xkWfk4uRXrx9hcZVuKXUch1QUo8gHuGDwNi 2axOZbZwpIlYqi8q+wIHudir/ey6tzERvSMEsv9kxGAHgo8Dl8uMJWxgLY2nN8RU UosbG9KpqKTklPqjbXD7RETxPa3ydGQTPRP7fmW76hNCgctw85y+BwOWA== 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= fm1; bh=V2ECKODejaAuLjYVZGAyrUq9Ivh4nxZakGL2AQusnM8=; b=iwrVMsUd 1xyikiPls12Yxwm5YO5GVEdtYszhnKvWrSge8ZOmio1LMgFP4MlRziksVkH11oeN 8T4k8L2HGZgpA78oBB88+YFB1lPaOu5xHI7AETl+OG6LNQq48mTUfCDRjVo/Hl+T cVN7dFAPcp6V81wARL1vVa40EjY5OOd2tiwD79QxU2yaJHsYpBfFQH9PwcZnnVK8 A+SH3kk9dUa0I5+vkbTs71qTJB31JNcahsPRyDjc5w2GwfYrVfodtVTClzS6r45Y ljtzPssHO7vFWUTLGEsB72LbnDfJP2RT2BUhkgmQe1MO9BE8qCOd7IOPomvzPHkb DNxK1bCEtaohuQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:39 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 10/21] drm/bridge: lt9611uxc: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:36 +0200 Message-Id: <20211021073947.499373-11-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c index ab1a0c00aad8..33f9716da0ee 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c @@ -367,18 +367,6 @@ static int lt9611uxc_bridge_attach(struct drm_bridge *bridge, return ret; } - /* Attach primary DSI */ - lt9611uxc->dsi0 = lt9611uxc_attach_dsi(lt9611uxc, lt9611uxc->dsi0_node); - if (IS_ERR(lt9611uxc->dsi0)) - return PTR_ERR(lt9611uxc->dsi0); - - /* Attach secondary DSI, if specified */ - if (lt9611uxc->dsi1_node) { - lt9611uxc->dsi1 = lt9611uxc_attach_dsi(lt9611uxc, lt9611uxc->dsi1_node); - if (IS_ERR(lt9611uxc->dsi1)) - return PTR_ERR(lt9611uxc->dsi1); - } - return 0; } @@ -958,8 +946,27 @@ static int lt9611uxc_probe(struct i2c_client *client, drm_bridge_add(<9611uxc->bridge); + /* Attach primary DSI */ + lt9611uxc->dsi0 = lt9611uxc_attach_dsi(lt9611uxc, lt9611uxc->dsi0_node); + if (IS_ERR(lt9611uxc->dsi0)) { + ret = PTR_ERR(lt9611uxc->dsi0); + goto err_remove_bridge; + } + + /* Attach secondary DSI, if specified */ + if (lt9611uxc->dsi1_node) { + lt9611uxc->dsi1 = lt9611uxc_attach_dsi(lt9611uxc, lt9611uxc->dsi1_node); + if (IS_ERR(lt9611uxc->dsi1)) { + ret = PTR_ERR(lt9611uxc->dsi1); + goto err_remove_bridge; + } + } + return lt9611uxc_audio_init(dev, lt9611uxc); +err_remove_bridge: + drm_bridge_remove(<9611uxc->bridge); + err_disable_regulators: regulator_bulk_disable(ARRAY_SIZE(lt9611uxc->supplies), lt9611uxc->supplies); From patchwork Thu Oct 21 07:39:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41421C4332F for ; Thu, 21 Oct 2021 07:41:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BBF8610CF for ; Thu, 21 Oct 2021 07:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbhJUHnc (ORCPT ); Thu, 21 Oct 2021 03:43:32 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:53023 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231628AbhJUHnC (ORCPT ); Thu, 21 Oct 2021 03:43:02 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id B40312B0134C; Thu, 21 Oct 2021 03:40:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 21 Oct 2021 03:40:46 -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=fm1; bh=iaT5PVQQV1J3N O3ZCJQqw6ZfLRU5QGqUsJkfrgMTcgM=; b=QA2AfUgJTN6Odfzl/Os8U1ZwheHj+ +VCJ/6g0ff+Xf9V/vdxJcVJEcxaJprwUt7y11VxUpI3i8/PaDfQpapAXlTGnzcni Jf5GWuWjblhxYBQ3zNAjZIkwMeq1uIRZ+E0PImXm2XlTCwvvfMANPi4Yeo10vRf3 cMyQ7O3RSXZtO9MH+A4BYEWiJ/M4cNwypCDl189Rcc+DIw296lsfygxnc13HqvRW 9mpYYrgomGVSSL7KGmgSLQMXHTLrGKJiCcS+DEqsGoDbe97B2ytNBTyzOItrFypI LxcPgkvFIC/Df5gJ9QQ7HX/7XVWP95jpxBmsblYYmLKdSOau3fIJa/2hQ== 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= fm1; bh=iaT5PVQQV1J3NO3ZCJQqw6ZfLRU5QGqUsJkfrgMTcgM=; b=abp4hxHn Htc/1yVOEeIw0IckS+SonQ2uQzjyj4a1y8I4mhmQsXauEBxBi4ZE5JS9J+leMNHy SA9tR4PgPa2b09qfLf0mriyBxRdATSpDRwayGeyO59dbQEsAU2MUSZexCBUoGNeI T3HfpzwkhXMHJ3cmZUO5ju6hphvIDKby5CrrqB4K2IFki/9FY/UbLc4z6sWkKU65 TLKGICMT9rhnSn6DUZbQhddkB08U6j1uyR1h1pEMmJTXkpGYJITcKXsvWRKa8V26 ckynuieMZRxDCRDNqrtxRe65q2+rR9MAcVdbefl4g9ngmKfc3xEFc6WOuDTHiI+e q4Cq6yo7FciEKw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:43 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 11/21] drm/bridge: ps8640: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:37 +0200 Message-Id: <20211021073947.499373-12-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. This also avoids leaking the device on removal. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/parade-ps8640.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c index 3aaa90913bf8..5ae15fc407c5 100644 --- a/drivers/gpu/drm/bridge/parade-ps8640.c +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -428,7 +428,7 @@ static int ps8640_bridge_attach(struct drm_bridge *bridge, if (!host) return -ENODEV; - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { dev_err(dev, "failed to create dsi device\n"); ret = PTR_ERR(dsi); @@ -442,27 +442,22 @@ static int ps8640_bridge_attach(struct drm_bridge *bridge, MIPI_DSI_MODE_VIDEO_SYNC_PULSE; dsi->format = MIPI_DSI_FMT_RGB888; dsi->lanes = NUM_MIPI_LANES; - ret = mipi_dsi_attach(dsi); + + ret = devm_mipi_dsi_attach(dev, dsi); if (ret) { dev_err(dev, "failed to attach dsi device: %d\n", ret); - goto err_dsi_attach; + return ret; } ret = drm_dp_aux_register(&ps_bridge->aux); if (ret) { dev_err(dev, "failed to register DP AUX channel: %d\n", ret); - goto err_aux_register; + return ret; } /* Attach the panel-bridge to the dsi bridge */ return drm_bridge_attach(bridge->encoder, ps_bridge->panel_bridge, &ps_bridge->bridge, flags); - -err_aux_register: - mipi_dsi_detach(dsi); -err_dsi_attach: - mipi_dsi_device_unregister(dsi); - return ret; } static void ps8640_bridge_detach(struct drm_bridge *bridge) From patchwork Thu Oct 21 07:39:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11C31C433EF for ; Thu, 21 Oct 2021 07:41:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1CB36115B for ; Thu, 21 Oct 2021 07:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbhJUHnd (ORCPT ); Thu, 21 Oct 2021 03:43:33 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:59285 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231651AbhJUHnG (ORCPT ); Thu, 21 Oct 2021 03:43:06 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 0199D2B0134D; Thu, 21 Oct 2021 03:40:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 21 Oct 2021 03:40:50 -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=fm1; bh=yrvr1Otm7mUsB ldmX+/88d0Z/Hg66+YUbEVXmQwCzeY=; b=RvTEktepwLYrfRYkxcUXpzO0x1Yhb /oKyuSyKSJAclU4ykw+VhDXOMeTKynKMFE1KvsqsrfZj5bXBrzDNykZ21VF4EHRG k0IKt5Gr2UKEOO28lJ4HpEaOkYEYiYj1Bo8pB7vxjqoI0AsDVrpTXirQzvDxd6nL jQ2X/dxaJnRBKv9v4fTcyABx/NwpBEnzuOj7RS8iB2seW8xxZA/07Qg54pKlLgoQ REVsr561bAXHrKapriAZG6Y/ACilNV5UHwWKlYF4QOogOipa8Jus8lA8UOwxr1HI hIAZFOc0e5W4ZN2smMCfv9O9F+e5nxxSmuJdUHeN7HQV3TDVhZcxA+phw== 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= fm1; bh=yrvr1Otm7mUsBldmX+/88d0Z/Hg66+YUbEVXmQwCzeY=; b=MYojQJ4q YIjJTVKQmV2KCqLZO12YKW/6t8jL4q7ADkp4mBrtY0JAdlk/LgpSCX/notBAugkc sNGQyXropLYBUhy2SucRpGES2haN+xW15amGjZFpa3yc/j/soywtv/xQpXJesha0 AqQjvhRv+sLiyZHB/hHawdbw2aSOHM6cG9i6NWl6byUJlofxag/5Mr92U9PCGLAg EsgscbsMgW5Lvf31HknCw8OLatgwZ/05JJL6GRNtTLtgjOmKvJFV5rAqRfujGWHP aPKr0xF17+qcBKSOL2FJKoUJGTPJiy4wCuzu24LFgqtQN4qJibHBSZCSRgDra2CF /5TlzT1gA9LY3A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:48 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 12/21] drm/bridge: ps8640: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:38 +0200 Message-Id: <20211021073947.499373-13-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/parade-ps8640.c | 100 ++++++++++++++----------- 1 file changed, 55 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c index 5ae15fc407c5..5f70eaca175b 100644 --- a/drivers/gpu/drm/bridge/parade-ps8640.c +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -400,55 +400,10 @@ static int ps8640_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct ps8640 *ps_bridge = bridge_to_ps8640(bridge); - struct device *dev = &ps_bridge->page[0]->dev; - struct device_node *in_ep, *dsi_node; - struct mipi_dsi_device *dsi; - struct mipi_dsi_host *host; - int ret; - const struct mipi_dsi_device_info info = { .type = "ps8640", - .channel = 0, - .node = NULL, - }; if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) return -EINVAL; - /* port@0 is ps8640 dsi input port */ - in_ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); - if (!in_ep) - return -ENODEV; - - dsi_node = of_graph_get_remote_port_parent(in_ep); - of_node_put(in_ep); - if (!dsi_node) - return -ENODEV; - - host = of_find_mipi_dsi_host_by_node(dsi_node); - of_node_put(dsi_node); - if (!host) - return -ENODEV; - - dsi = devm_mipi_dsi_device_register_full(dev, host, &info); - if (IS_ERR(dsi)) { - dev_err(dev, "failed to create dsi device\n"); - ret = PTR_ERR(dsi); - return ret; - } - - ps_bridge->dsi = dsi; - - dsi->host = host; - dsi->mode_flags = MIPI_DSI_MODE_VIDEO | - MIPI_DSI_MODE_VIDEO_SYNC_PULSE; - dsi->format = MIPI_DSI_FMT_RGB888; - dsi->lanes = NUM_MIPI_LANES; - - ret = devm_mipi_dsi_attach(dev, dsi); - if (ret) { - dev_err(dev, "failed to attach dsi device: %d\n", ret); - return ret; - } - ret = drm_dp_aux_register(&ps_bridge->aux); if (ret) { dev_err(dev, "failed to register DP AUX channel: %d\n", ret); @@ -507,6 +462,53 @@ static const struct drm_bridge_funcs ps8640_bridge_funcs = { .pre_enable = ps8640_pre_enable, }; +static int ps8640_bridge_host_attach(struct device *dev, struct ps8640 *ps_bridge) +{ + struct device_node *in_ep, *dsi_node; + struct mipi_dsi_device *dsi; + struct mipi_dsi_host *host; + int ret; + const struct mipi_dsi_device_info info = { .type = "ps8640", + .channel = 0, + .node = NULL, + }; + + /* port@0 is ps8640 dsi input port */ + in_ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); + if (!in_ep) + return -ENODEV; + + dsi_node = of_graph_get_remote_port_parent(in_ep); + of_node_put(in_ep); + if (!dsi_node) + return -ENODEV; + + host = of_find_mipi_dsi_host_by_node(dsi_node); + of_node_put(dsi_node); + if (!host) + return -EPROBE_DEFER; + + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); + if (IS_ERR(dsi)) { + dev_err(dev, "failed to create dsi device\n"); + return PTR_ERR(dsi); + } + + ps_bridge->dsi = dsi; + + dsi->host = host; + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | + MIPI_DSI_MODE_VIDEO_SYNC_PULSE; + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->lanes = NUM_MIPI_LANES; + + ret = devm_mipi_dsi_attach(dev, dsi); + if (ret) + return ret; + + return 0; +} + static int ps8640_probe(struct i2c_client *client) { struct device *dev = &client->dev; @@ -584,7 +586,15 @@ static int ps8640_probe(struct i2c_client *client) drm_bridge_add(&ps_bridge->bridge); + ret = ps8640_bridge_host_attach(dev, ps_bridge); + if (ret) + goto err_bridge_remove; + return 0; + +err_bridge_remove: + drm_bridge_remove(&ps_bridge->bridge); + return ret; } static int ps8640_remove(struct i2c_client *client) From patchwork Thu Oct 21 07:39:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B6FAC433EF for ; Thu, 21 Oct 2021 07:41:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 396E461251 for ; Thu, 21 Oct 2021 07:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231967AbhJUHng (ORCPT ); Thu, 21 Oct 2021 03:43:36 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:34667 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbhJUHnL (ORCPT ); Thu, 21 Oct 2021 03:43:11 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 947B92B01324; Thu, 21 Oct 2021 03:40:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 21 Oct 2021 03:40: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=fm1; bh=r1YAMUMbYh8TB z8LKCCpgMzm2QMxfhcouzSjIrys2jM=; b=K+9/UMTd3DYjSXs3xz2YxytyV0jbJ ZSa9qH9SGAvg00qoGXmnjvUrhA+6CY0oNdBVCWKIpVAV3gJkiGzAtk21kDhG2LEW KN5g12uwAObnWJ7IsvQw5QJWeAEJ7Zx/9Xd7+9MkVQX10fQTZO+zcSibnavTOmUS 66PjBR1n8A1Q60+awDDN7sUFOf1cl04f2+MqJIJivh7ql/IQA8a5K/48SL2Qa77W 8gmDO/ygQf9QlRdx8XhoO0Zhjwx9eTmCaSqlRMpx+IeqYhJHn9OaTGhi7+7Io7CC 8FtKw/e4IYdR9eI6rhDpMcn/NyfXWhNC1NthTRxJ8ugzZptfANCRuzl7w== 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= fm1; bh=r1YAMUMbYh8TBz8LKCCpgMzm2QMxfhcouzSjIrys2jM=; b=GXe9tVuh Y189C23kwB3Dv6xlnm31NpLXpIQCjhUbiq61u7usMTgCNAxJaPoYOEMkQNYM0us7 i1QYHmqxEy+/H3nr4xCDvP3tccVj1ZTXoz0DIEX1A5upVuuweiamNEHBFO/x5+Jh ople7YSc9rmKwZddQ3sanBDuWd7YUCDOMFxpSkkW/4oZu4lqf0GERbTyqoY/3vIE cj4wkB+ArLN3T4549FWB/4ss7ycZ2ugqly4gVB/5ss+HdjgH9DeH2Dkw5VypSKLK jKqlCJJNwgKLeP4Cra1p6kbLSGfl408zPOl6KnMZtpgH0NnHkHJEif/EQXmVIOzg pa4kVZlYe29Y1Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:52 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org, Marek Vasut Subject: [PATCH v5 13/21] drm/bridge: sn65dsi83: Fix bridge removal Date: Thu, 21 Oct 2021 09:39:39 +0200 Message-Id: <20211021073947.499373-14-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Commit 24417d5b0c00 ("drm/bridge: ti-sn65dsi83: Implement .detach callback") moved the unregistration of the bridge DSI device and bridge itself to the detach callback. While this is correct for the DSI device detach and unregistration, the bridge is added in the driver probe, and should thus be removed as part of its remove callback. Cc: Marek Vasut Fixes: 24417d5b0c00 ("drm/bridge: ti-sn65dsi83: Implement .detach callback") Signed-off-by: Maxime Ripard Reviewed-by: Marek Vasut --- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c index 52030a82f3e1..3bfd07caf8d7 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c @@ -297,7 +297,6 @@ static void sn65dsi83_detach(struct drm_bridge *bridge) mipi_dsi_detach(ctx->dsi); mipi_dsi_device_unregister(ctx->dsi); - drm_bridge_remove(&ctx->bridge); ctx->dsi = NULL; } @@ -693,6 +692,7 @@ static int sn65dsi83_remove(struct i2c_client *client) { struct sn65dsi83 *ctx = i2c_get_clientdata(client); + drm_bridge_remove(&ctx->bridge); of_node_put(ctx->host_node); return 0; From patchwork Thu Oct 21 07:39:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACF90C433EF for ; Thu, 21 Oct 2021 07:41:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9791C610CF for ; Thu, 21 Oct 2021 07:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232000AbhJUHnk (ORCPT ); Thu, 21 Oct 2021 03:43:40 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:33187 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231811AbhJUHnP (ORCPT ); Thu, 21 Oct 2021 03:43:15 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 054392B01360; Thu, 21 Oct 2021 03:40:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 21 Oct 2021 03:40: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=fm1; bh=aINb3yyNPEGy8 1/IksR4f28ybF+VpRvrF3mAjvmMCck=; b=QQV2Mvx2KRkeTQPYhTlSUGsWBUPNJ SGTjldOlRPc2TNNwI4shLSorfsohptZkId8P0WAFON1rur7BCufxYcSr+Yxs2TyH dHfSgc7F2xSHK1ukDdUS7wJriLUqzgNvH/Y7Ie72a2q964AcjjDw8OaL2pEDMK42 KLn4FyPElDg8gIQuETnhq/7Rsfllzl9VnZZ1vGJz5vzi5gorBpd0XZtuRRjb1P04 OpzHLgkjxmr95OCc9GWvPqbhC1X7coy1VAXbzNF7hkrw18hjZbLHvc5F8r40MWMI dWKZ/T/mdDtzaL98HPpME0Wl8bDFahIDoW7G4rqWoPRuHcB4QkiSM8HSw== 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= fm1; bh=aINb3yyNPEGy81/IksR4f28ybF+VpRvrF3mAjvmMCck=; b=nNqTSuhb 2J0GUp8g9neMvh6xfWrr2Ej3+PvHifgCQgNw66iDF6jY4a1I0DcL52vSt/0UhxdI fLaEpOQp2sHQlo3ivbcnoANpZ7eeO7yoQcYRskSaOtnOfcevt6FatrpbvXmknn8d sO9ZFYAJnYJdd0OV4utl73fdwAH0cUCifZREcG5kNis5jLHRZkDxL5uu4/VvoF7s m12Aqv9nn8QKeQt3Q2C4xC5ukgAKQY/KCps2AbqdoFJjXhITah22aR2UKqzjf8jK 0k4g890ByL+bMSg7NwgXLEba+nY7armTcDzgfOXMn2pDEHY0OBG/aOp4+mQS/mDl kie0GOWMR3DTqw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:40:56 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org, Laurent Pinchart Subject: [PATCH v5 14/21] drm/bridge: sn65dsi83: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:40 +0200 Message-Id: <20211021073947.499373-15-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. This also avoids leaking the device when we detach the bridge but don't remove its driver. Acked-by: Sam Ravnborg Tested-by: Laurent Pinchart Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c index 3bfd07caf8d7..539edd2c19f5 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c @@ -262,7 +262,7 @@ static int sn65dsi83_attach(struct drm_bridge *bridge, return -EPROBE_DEFER; } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { return dev_err_probe(dev, PTR_ERR(dsi), "failed to create dsi device\n"); @@ -274,18 +274,14 @@ static int sn65dsi83_attach(struct drm_bridge *bridge, dsi->format = MIPI_DSI_FMT_RGB888; dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { dev_err(dev, "failed to attach dsi to host\n"); - goto err_dsi_attach; + return ret; } return drm_bridge_attach(bridge->encoder, ctx->panel_bridge, &ctx->bridge, flags); - -err_dsi_attach: - mipi_dsi_device_unregister(dsi); - return ret; } static void sn65dsi83_detach(struct drm_bridge *bridge) @@ -295,8 +291,6 @@ static void sn65dsi83_detach(struct drm_bridge *bridge) if (!ctx->dsi) return; - mipi_dsi_detach(ctx->dsi); - mipi_dsi_device_unregister(ctx->dsi); ctx->dsi = NULL; } From patchwork Thu Oct 21 07:39:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D087C433FE for ; Thu, 21 Oct 2021 07:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33E996115B for ; Thu, 21 Oct 2021 07:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231389AbhJUHoL (ORCPT ); Thu, 21 Oct 2021 03:44:11 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:34341 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231872AbhJUHnU (ORCPT ); Thu, 21 Oct 2021 03:43:20 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 53F8A2B01369; Thu, 21 Oct 2021 03:41:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 21 Oct 2021 03:41:04 -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=fm1; bh=0jRcvudXPXM/a o9XoLGKBfJZiC+x5dQANxi83lap800=; b=i0DVqyBnsgn61Oug3e6F+qsKn3uLr oHieJUvqsbmE5+oIOjYj9QSddX9SCznqQnKRb3l38mZqItabypEpc+6gmzrX+gg6 eDDYrihtVf2qVffz8A8u1ekWj5GhFgprcFnZnPTc/N/cuzZZuoQXQa7AxCzTXeDO NWKpMJq1TeuZFRjpCmXNfGs4OXSEEBQYWk9+1LW61p18WlcUG6g4alhvkxoHsQHa 32AQ4IfIiQrbOeHlVZUVrSx2PZ8cK3UZ3VY0Jfw/9nXQSkZ1YXwJiw8h0kur70fZ R8/vyMGT3icdsMP+9837Wi8mqbPRZQyhTO6YdAYTVi55e0ObGRMoZ2iFw== 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= fm1; bh=0jRcvudXPXM/ao9XoLGKBfJZiC+x5dQANxi83lap800=; b=EQHjyDMc ISKgCe3Y7JB5VoKirdU7szRzg3R7hYZoF3az9GZOc/ioJppa8aeQe+WYNrFZ5RJ4 pKEYdBELm8N2JmhSTkgrSfV0/d/DgUhG+R2srZ2cjDje9NoS/pKyxm+WIX/tcll+ LHwpdGLZRr5oU2aPvQl4GS5D5So5mh7Ar182rszMe0p/03APNU5n0S/XFU9P80lL AdtJNGPKcOqewBTzeozaU3cKKpfBo3ACavV3sf+3DmNIB0Z5h9c82gp4xudgGJYz +KB6B9XBHphFc4Y5KuDdEl21rE7pVeLf2+oFavZ/hmZAZpdgv93ITe0yyDP+B2zq dT7UMJK7fddn5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:41:01 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org, Laurent Pinchart Subject: [PATCH v5 15/21] drm/bridge: sn65dsi83: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:41 +0200 Message-Id: <20211021073947.499373-16-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Tested-by: Laurent Pinchart Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 80 +++++++++++++++------------ 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c index 539edd2c19f5..945f08de45f1 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c @@ -245,40 +245,6 @@ static int sn65dsi83_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge); - struct device *dev = ctx->dev; - struct mipi_dsi_device *dsi; - struct mipi_dsi_host *host; - int ret = 0; - - const struct mipi_dsi_device_info info = { - .type = "sn65dsi83", - .channel = 0, - .node = NULL, - }; - - host = of_find_mipi_dsi_host_by_node(ctx->host_node); - if (!host) { - dev_err(dev, "failed to find dsi host\n"); - return -EPROBE_DEFER; - } - - dsi = devm_mipi_dsi_device_register_full(dev, host, &info); - if (IS_ERR(dsi)) { - return dev_err_probe(dev, PTR_ERR(dsi), - "failed to create dsi device\n"); - } - - ctx->dsi = dsi; - - dsi->lanes = ctx->dsi_lanes; - dsi->format = MIPI_DSI_FMT_RGB888; - dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST; - - ret = devm_mipi_dsi_attach(dev, dsi); - if (ret < 0) { - dev_err(dev, "failed to attach dsi to host\n"); - return ret; - } return drm_bridge_attach(bridge->encoder, ctx->panel_bridge, &ctx->bridge, flags); @@ -636,6 +602,44 @@ static int sn65dsi83_parse_dt(struct sn65dsi83 *ctx, enum sn65dsi83_model model) return 0; } +static int sn65dsi83_host_attach(struct sn65dsi83 *ctx) +{ + struct device *dev = ctx->dev; + struct mipi_dsi_device *dsi; + struct mipi_dsi_host *host; + const struct mipi_dsi_device_info info = { + .type = "sn65dsi83", + .channel = 0, + .node = NULL, + }; + int ret; + + host = of_find_mipi_dsi_host_by_node(ctx->host_node); + if (!host) { + dev_err(dev, "failed to find dsi host\n"); + return -EPROBE_DEFER; + } + + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); + if (IS_ERR(dsi)) + return dev_err_probe(dev, PTR_ERR(dsi), + "failed to create dsi device\n"); + + ctx->dsi = dsi; + + dsi->lanes = ctx->dsi_lanes; + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST; + + ret = devm_mipi_dsi_attach(dev, dsi); + if (ret < 0) { + dev_err(dev, "failed to attach dsi to host: %d\n", ret); + return ret; + } + + return 0; +} + static int sn65dsi83_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -679,7 +683,15 @@ static int sn65dsi83_probe(struct i2c_client *client, ctx->bridge.of_node = dev->of_node; drm_bridge_add(&ctx->bridge); + ret = sn65dsi83_host_attach(ctx); + if (ret) + goto err_remove_bridge; + return 0; + +err_remove_bridge: + drm_bridge_remove(&ctx->bridge); + return ret; } static int sn65dsi83_remove(struct i2c_client *client) From patchwork Thu Oct 21 07:39:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CDFEC433FE for ; Thu, 21 Oct 2021 07:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17CF3610CF for ; Thu, 21 Oct 2021 07:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231573AbhJUHoO (ORCPT ); Thu, 21 Oct 2021 03:44:14 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:59681 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbhJUHnY (ORCPT ); Thu, 21 Oct 2021 03:43:24 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id D4BDE2B01362; Thu, 21 Oct 2021 03:41:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 21 Oct 2021 03:41:08 -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=fm1; bh=R42zJVFPqXWis ftwmhRtrrTmMiiujU+L/s0xKJb/r2o=; b=Ve5FuXreqcW5s8yaQ57TY8cqWF0Mn X7rVMHZlmysTlXXYtuLF2bKCB1SMfBUkayHBhetIFmBTtzC34FPmujgmzzzW7N7C 9saPIQ/28xVQN7DDK/EZ0UzNoF0em2JYW+tRVqaN1iPnCOi0HXek8jPzMHpjQEfH CSvuIjUv8lrNRmTm+B5k2hluHQ8UtA1XZByjxohS2Fsyth245LxqcDjUjfI4b6x5 AzRzm+MbkiSX5IljAFZNYB1sgp1DDDP1g2+7tZM41f8KY3hkvkkb3ccBtrh7sptC W4DIMh25bLsbGL8v/olDfxQpOH9ltvvw/eLiQAKXWMOCdF1087dFNVRuw== 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= fm1; bh=R42zJVFPqXWisftwmhRtrrTmMiiujU+L/s0xKJb/r2o=; b=bbPguaPW hWfirR9U1m+UYX5PsZLYsUt262l+CTFntR+ytG9PLhle7+tr7JZI227bZ+mNNV5J Urz+QKUUOPdgVTDwTPbIhPtsczYlpLg7en92Edxfm9zOtbRC8vF6mlSdelSjeUwN TrPexa91VU9fSQ6QfuLTrjCMC7Erf8tDFzAPyOzI8Aaopkc34szK3yxgUZII2rWY LGotj6Z0pH2lstrkiFtzBoiy24mlSB4qxB5RPl4Dx9AFcz0R3qzX863ik4LAyEnX xXLwLxS6GBt31dDTy8skjll7y0H6BZD9JtCXyeDzapvwrNmfHa40FcxNvitqRJKq XzELclE/IbKh2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:41:05 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 16/21] drm/bridge: sn65dsi86: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:42 +0200 Message-Id: <20211021073947.499373-17-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. This also avoids leaking the device when we detach the bridge. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 6154bed0af5b..36a82e3d17ab 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -662,6 +662,7 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); struct mipi_dsi_host *host; struct mipi_dsi_device *dsi; + struct device *dev = pdata->dev; const struct mipi_dsi_device_info info = { .type = "ti_sn_bridge", .channel = 0, .node = NULL, @@ -701,7 +702,7 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, goto err_dsi_host; } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { DRM_ERROR("failed to create dsi device\n"); ret = PTR_ERR(dsi); @@ -714,16 +715,16 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, dsi->mode_flags = MIPI_DSI_MODE_VIDEO; /* check if continuous dsi clock is required or not */ - pm_runtime_get_sync(pdata->dev); + pm_runtime_get_sync(dev); regmap_read(pdata->regmap, SN_DPPLL_SRC_REG, &val); - pm_runtime_put_autosuspend(pdata->dev); + pm_runtime_put_autosuspend(dev); if (!(val & DPPLL_CLK_SRC_DSICLK)) dsi->mode_flags |= MIPI_DSI_CLOCK_NON_CONTINUOUS; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { DRM_ERROR("failed to attach dsi to host\n"); - goto err_dsi_attach; + goto err_dsi_host; } pdata->dsi = dsi; @@ -734,14 +735,10 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, ret = drm_bridge_attach(bridge->encoder, pdata->next_bridge, &pdata->bridge, flags); if (ret < 0) - goto err_dsi_detach; + goto err_dsi_host; return 0; -err_dsi_detach: - mipi_dsi_detach(dsi); -err_dsi_attach: - mipi_dsi_device_unregister(dsi); err_dsi_host: drm_connector_cleanup(&pdata->connector); err_conn_init: @@ -1237,11 +1234,6 @@ static void ti_sn_bridge_remove(struct auxiliary_device *adev) if (!pdata) return; - if (pdata->dsi) { - mipi_dsi_detach(pdata->dsi); - mipi_dsi_device_unregister(pdata->dsi); - } - drm_bridge_remove(&pdata->bridge); of_node_put(pdata->host_node); From patchwork Thu Oct 21 07:39:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EA2BC433EF for ; Thu, 21 Oct 2021 07:42:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6805E610CB for ; Thu, 21 Oct 2021 07:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbhJUHoY (ORCPT ); Thu, 21 Oct 2021 03:44:24 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:57147 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231770AbhJUHn3 (ORCPT ); Thu, 21 Oct 2021 03:43:29 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 369122B0041E; Thu, 21 Oct 2021 03:41:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 21 Oct 2021 03:41:13 -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=fm1; bh=IjJ7Xg/H84lYB rLNnbeRdHfHU/7mTRchCznYNagdcAY=; b=LyUaKYLH0kcqISbLnmU7sV/YXwVDW ZK+PFB/ikBYxIRt68IJ/5hhqvdPT67JRYSFehAGwBsdlkN+512JrGFLY9lFUo1wq wF0fYONzSi9K4b3W7pdiRvbqElia23ZhW+yd+fmBn69XAowp7yTw8ySFx820AdnR E8hg0pkrWjDk43dEzQV+ulRWgI13RyOhjUrTEbleBD0D5PoDW4Xlks2HM8zbaHbj q0S6BAHDNiGGe8iJtLDdZQYTizHoZ0Hp0E4k/4TxDGvamHqgQOnF405Ow954YI/E JnphBWBVNOIp97KueoVp9s4tsoDUtINCqz2F244W5uqhyW42FF9eZ3QDw== 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= fm1; bh=IjJ7Xg/H84lYBrLNnbeRdHfHU/7mTRchCznYNagdcAY=; b=eKCsAx4T OIsGhqbGD3/BfVNYl4xAVnV6IuBCGNV8lo824neSJ9Q0JBRxcJWGMLXOH/tmAAzl 5nHmiLJNVvkgtBpzmST98uG2Ik6HutWL2dzoWns3ML9Wrf64YUyAriGunE71C1bm 5D2T/LiQv3e2C2hKR4ci9kwm3XmQ52r0MupwLJZps+hSJAxs34fwNYhu6OmQ4Gez Xa2so4NPoMpl/v5eybeh+k9tjxXruwj7DYszOP7tikRGaA7aQzeJFN13xOz+YFbV S3wSJGPuQoIhuZrUFZLTLEMzWT3aR8e97FaPuYX1cmh/0Ok0JhSYjit+BPzkRkwV 54u+8Edhigz8GQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:41:10 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 17/21] drm/bridge: sn65dsi86: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:43 +0200 Message-Id: <20211021073947.499373-18-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 77 ++++++++++++++------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 36a82e3d17ab..b6ce6776cdf1 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -655,58 +655,27 @@ static struct ti_sn65dsi86 *bridge_to_ti_sn65dsi86(struct drm_bridge *bridge) return container_of(bridge, struct ti_sn65dsi86, bridge); } -static int ti_sn_bridge_attach(struct drm_bridge *bridge, - enum drm_bridge_attach_flags flags) +static int ti_sn_attach_host(struct ti_sn65dsi86 *pdata) { int ret, val; - struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); struct mipi_dsi_host *host; struct mipi_dsi_device *dsi; struct device *dev = pdata->dev; const struct mipi_dsi_device_info info = { .type = "ti_sn_bridge", .channel = 0, .node = NULL, - }; + }; - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) { - DRM_ERROR("Fix bridge driver to make connector optional!"); - return -EINVAL; - } - - pdata->aux.drm_dev = bridge->dev; - ret = drm_dp_aux_register(&pdata->aux); - if (ret < 0) { - drm_err(bridge->dev, "Failed to register DP AUX channel: %d\n", ret); - return ret; - } - - ret = ti_sn_bridge_connector_init(pdata); - if (ret < 0) - goto err_conn_init; - - /* - * TODO: ideally finding host resource and dsi dev registration needs - * to be done in bridge probe. But some existing DSI host drivers will - * wait for any of the drm_bridge/drm_panel to get added to the global - * bridge/panel list, before completing their probe. So if we do the - * dsi dev registration part in bridge probe, before populating in - * the global bridge list, then it will cause deadlock as dsi host probe - * will never complete, neither our bridge probe. So keeping it here - * will satisfy most of the existing host drivers. Once the host driver - * is fixed we can move the below code to bridge probe safely. - */ host = of_find_mipi_dsi_host_by_node(pdata->host_node); if (!host) { DRM_ERROR("failed to find dsi host\n"); - ret = -ENODEV; - goto err_dsi_host; + return -ENODEV; } dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { DRM_ERROR("failed to create dsi device\n"); - ret = PTR_ERR(dsi); - goto err_dsi_host; + return PTR_ERR(dsi); } /* TODO: setting to 4 MIPI lanes always for now */ @@ -721,12 +690,38 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, if (!(val & DPPLL_CLK_SRC_DSICLK)) dsi->mode_flags |= MIPI_DSI_CLOCK_NON_CONTINUOUS; + pdata->dsi = dsi; + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { DRM_ERROR("failed to attach dsi to host\n"); - goto err_dsi_host; + return ret; } - pdata->dsi = dsi; + + return 0; +} + +static int ti_sn_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); + int ret; + + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) { + DRM_ERROR("Fix bridge driver to make connector optional!"); + return -EINVAL; + } + + pdata->aux.drm_dev = bridge->dev; + ret = drm_dp_aux_register(&pdata->aux); + if (ret < 0) { + drm_err(bridge->dev, "Failed to register DP AUX channel: %d\n", ret); + return ret; + } + + ret = ti_sn_bridge_connector_init(pdata); + if (ret < 0) + goto err_conn_init; /* We never want the next bridge to *also* create a connector: */ flags |= DRM_BRIDGE_ATTACH_NO_CONNECTOR; @@ -1224,7 +1219,15 @@ static int ti_sn_bridge_probe(struct auxiliary_device *adev, drm_bridge_add(&pdata->bridge); + ret = ti_sn_attach_host(pdata); + if (ret) + goto err_remove_bridge; + return 0; + +err_remove_bridge: + drm_bridge_remove(&pdata->bridge); + return ret; } static void ti_sn_bridge_remove(struct auxiliary_device *adev) From patchwork Thu Oct 21 07:39:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF852C433EF for ; Thu, 21 Oct 2021 07:42:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D971A60EFE for ; Thu, 21 Oct 2021 07:42:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbhJUHo0 (ORCPT ); Thu, 21 Oct 2021 03:44:26 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:59285 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbhJUHnd (ORCPT ); Thu, 21 Oct 2021 03:43:33 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 7671D2B0042E; Thu, 21 Oct 2021 03:41:16 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 21 Oct 2021 03:41:18 -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=fm1; bh=/QMqV2xNvARcz 7m7ICXmWasIz89maW9VgPKXP0jtMvU=; b=PLx4Mhb9V0yDcsTDRaURj711s5uX6 htj8S5ID2MAXA1VsjVSJ8457d+YNa/GO5YkiH+5GHCw6T3uUTjiQTh4vvXa7cBcm 32kIgP1n5x/oeDyxy6ubXBbkdV5Nfh/074WJmOKTJo5WMlBRexaGdcAwTy+0Hfys vM2QAyEUrAUTWXy/u7UhwwOLsPd5n839iHb8ODbw4zLIhLtU6XR0IvebjyBUIT6o NoO3NSBqgIl7CbjBSMN9gNA/E+9/iutbTUP3a6cYlOl669PMv0rTUZVJF243Ja87 HEcNDU+zYuD+xfEan0wHqVKnlpQhayeY2jfKJMVTNTO/90+7ayac3ALXA== 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= fm1; bh=/QMqV2xNvARcz7m7ICXmWasIz89maW9VgPKXP0jtMvU=; b=Uixp2Sc7 zZnuMw0I3RAGtQ7Ihj9VFlE7dfd2gisFnvia19VFPii+c0MbCY5GaMpNcJbRrDdM LpmwtFcsftbhCAFipdqDMLaJetRz6E9qegEScQxVigTudAXA/dUXWTATNbyOnNev OEOw7M5PwZoajjMBTrLnQy/QioQijR1tGp7vJwy4Go3GJzI0v8q6fWJZmoM/cZEw QyfQRQGdOPPmAq9/wKwdekSgnU9et5hMUH3t5YaoH7K3wGbnwO7wBXiZtzlEnLyZ hwMgU5cimOhaPckqiwxgfHdO1Fbjy/aR5LtlKky4pohK3uFSfgHwimYlsOQHLTFQ coYTTVXPTzmmug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:41:14 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 18/21] drm/bridge: tc358775: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:44 +0200 Message-Id: <20211021073947.499373-19-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. This also avoids leaking the device when we detach the bridge. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/tc358775.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c index 2272adcc5b4a..35e66d1b6456 100644 --- a/drivers/gpu/drm/bridge/tc358775.c +++ b/drivers/gpu/drm/bridge/tc358775.c @@ -610,11 +610,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge, return -EPROBE_DEFER; } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { dev_err(dev, "failed to create dsi device\n"); - ret = PTR_ERR(dsi); - goto err_dsi_device; + return PTR_ERR(dsi); } tc->dsi = dsi; @@ -623,19 +622,15 @@ static int tc_bridge_attach(struct drm_bridge *bridge, dsi->format = MIPI_DSI_FMT_RGB888; dsi->mode_flags = MIPI_DSI_MODE_VIDEO; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { dev_err(dev, "failed to attach dsi to host\n"); - goto err_dsi_attach; + return ret; } /* Attach the panel-bridge to the dsi bridge */ return drm_bridge_attach(bridge->encoder, tc->panel_bridge, &tc->bridge, flags); -err_dsi_attach: - mipi_dsi_device_unregister(dsi); -err_dsi_device: - return ret; } static const struct drm_bridge_funcs tc_bridge_funcs = { From patchwork Thu Oct 21 07:39:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B39FC433EF for ; Thu, 21 Oct 2021 07:42:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 867CB6109F for ; Thu, 21 Oct 2021 07:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231683AbhJUHo3 (ORCPT ); Thu, 21 Oct 2021 03:44:29 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:46245 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231975AbhJUHni (ORCPT ); Thu, 21 Oct 2021 03:43:38 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id C7ACA2B00466; Thu, 21 Oct 2021 03:41:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 21 Oct 2021 03:41:22 -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=fm1; bh=TnAZqTSQxUIP5 JiuZiFJ75+OX+YvdvRPsxfEzIZePQM=; b=UDEuMd1k1lFvWpdAnoIo2Oma49cec 50Ur1Q0HhQIZrPwHDcSJo4avmRdbxDRHDsQ1C1uLhapBB1r2j6+91SO2OlGZ1M1x zrDW0kgb7U23AnRuBkqSi6wHfAgW/b3HLEwMRiJRN5IWm81tPgf0benMnTCECrXo CDnTHjPAsvbFf0uZU31HkIUtyu5XYL1ZF8BwBeysSPQGdFtNgMUABYxDibSZAI4y 8f3ebt7XTuDfnq7s4CbG0eQXoLPof7+JVoWqpaiAi/zV+40sw2l+TkoJV72oV1GL KgFK+RuWoCjgDXYsM3E/0QkxYHBbHACykGa5jflkjPFjyib4AMgzULTVg== 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= fm1; bh=TnAZqTSQxUIP5JiuZiFJ75+OX+YvdvRPsxfEzIZePQM=; b=hWjlK+rA LlSoqppAi0AZ78MjBK43ID/WIcrE5dKmcKsk861kqnr+OWcSdPib8Jj0hOoV2e1/ aPdZmBQ1M1kwB+w4lF1hUkB9oFj1NJsUMWV8n2upx2vMJfg50tIauEyITgPbz8d3 G7FinYJHmDKlNK54HVW1aMmcAPmRB2pLy6ij0mvHD+IGRfXv367nZFg34yNUhbL4 /d14sBJVhKgdAIqF4GS0ykLZ7yqHc0f/cL1+hX07AC1rJGjE71LUetAXq6HU2Mgf 2KQrd6jutxS1agUAO67Lm0Jhfu91gB8In0XSABkz1dicGyowPOqXz+OGn29Mxi4Z hAX2mGRDbyp6+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:41:19 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 19/21] drm/bridge: tc358775: Register and attach our DSI device at probe Date: Thu, 21 Oct 2021 09:39:45 +0200 Message-Id: <20211021073947.499373-20-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/tc358775.c | 37 +++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c index 35e66d1b6456..2c76331b251d 100644 --- a/drivers/gpu/drm/bridge/tc358775.c +++ b/drivers/gpu/drm/bridge/tc358775.c @@ -594,11 +594,26 @@ static int tc_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct tc_data *tc = bridge_to_tc(bridge); + + /* Attach the panel-bridge to the dsi bridge */ + return drm_bridge_attach(bridge->encoder, tc->panel_bridge, + &tc->bridge, flags); +} + +static const struct drm_bridge_funcs tc_bridge_funcs = { + .attach = tc_bridge_attach, + .pre_enable = tc_bridge_pre_enable, + .enable = tc_bridge_enable, + .mode_valid = tc_mode_valid, + .post_disable = tc_bridge_post_disable, +}; + +static int tc_attach_host(struct tc_data *tc) +{ struct device *dev = &tc->i2c->dev; struct mipi_dsi_host *host; struct mipi_dsi_device *dsi; int ret; - const struct mipi_dsi_device_info info = { .type = "tc358775", .channel = 0, .node = NULL, @@ -628,19 +643,9 @@ static int tc_bridge_attach(struct drm_bridge *bridge, return ret; } - /* Attach the panel-bridge to the dsi bridge */ - return drm_bridge_attach(bridge->encoder, tc->panel_bridge, - &tc->bridge, flags); + return 0; } -static const struct drm_bridge_funcs tc_bridge_funcs = { - .attach = tc_bridge_attach, - .pre_enable = tc_bridge_pre_enable, - .enable = tc_bridge_enable, - .mode_valid = tc_mode_valid, - .post_disable = tc_bridge_post_disable, -}; - static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct device *dev = &client->dev; @@ -704,7 +709,15 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) i2c_set_clientdata(client, tc); + ret = tc_attach_host(tc); + if (ret) + goto err_bridge_remove; + return 0; + +err_bridge_remove: + drm_bridge_remove(&tc->bridge); + return ret; } static int tc_remove(struct i2c_client *client) From patchwork Thu Oct 21 07:39:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 876BDC433FE for ; Thu, 21 Oct 2021 07:42:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F9F060EFE for ; Thu, 21 Oct 2021 07:42:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbhJUHoi (ORCPT ); Thu, 21 Oct 2021 03:44:38 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:44643 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbhJUHnm (ORCPT ); Thu, 21 Oct 2021 03:43:42 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 3FDAE2B0046A; Thu, 21 Oct 2021 03:41:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 21 Oct 2021 03:41:27 -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=fm1; bh=3aQjtC+OIX1dD SUs4abOhDu7UcQuzLgRDPAEOeXSI5o=; b=XmjkmpdKYLBYTdvxEy78AkuiGSYiA 146qEjXfHcrB3u+hM/kxxcPR6+L+EKwrFfWNXTDK7jiP8nvM7TrxAV+DdJTtGAgt jHkgiDXq5ANdBK3eHQaCghZLB/RFEj4lM8WSv8SCOvz7a06Fl5wmaY/k0o8NfE+3 c/TF6gb4JprZjWjlo3oB3A0DEucNz6TMW8I/dTn72IQEPKNKduDk72DG6eOUuOoO poFf3z2L694G0c7XjQmsd84csbstbhHiSavaJ4S/Zv1PquM2nKnjCjaCJ+1tdVIX M7Cfe3t83oF/0iq+pVTw7Zfc+jYFHi3AV+aiy1+V2MxzTHfafkxoavB5A== 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= fm1; bh=3aQjtC+OIX1dDSUs4abOhDu7UcQuzLgRDPAEOeXSI5o=; b=kwO5iryX GO9W54hNqi2TgLB/eMj3vG8fbe2X6+Q8KTYgOp3Kgf7ZnNAmoXMSPChYjiNxNiNs H7BAqmt+kgszPN8BqhaXl0BAX7tqxU0AcBqCZV7nUNbUK8YBCSifSUTa3NMrfgbO 1PuqNkm7pD6SC/Ji1kH7Sd74C0Sfo0ebNBXzr3CHIgEeWrJRtGi/OnfsAycDEXpH MCaZAh8Ue6LH4oZwsHhlbJtHtYQZOh5wNRoeynayiZdzpRfvDx9J2x5MbpZ77+ch 3+96yrtEa/lx8uX19efqqe+yhAgW5iqTMbcnGeuKebVdO2zXccwwZzSS/OkHrziu oN33cIwV+U48mw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:41:24 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 20/21] drm/kirin: dsi: Adjust probe order Date: Thu, 21 Oct 2021 09:39:46 +0200 Message-Id: <20211021073947.499373-21-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Without proper care and an agreement between how DSI hosts and devices drivers register their MIPI-DSI entities and potential components, we can end up in a situation where the drivers can never probe. Most drivers were taking evasive maneuvers to try to workaround this, but not all of them were following the same conventions, resulting in various incompatibilities between DSI hosts and devices. Now that we have a sequence agreed upon and documented, let's convert kirin to it. Tested-by: John Stultz Signed-off-by: Maxime Ripard --- drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 52 +++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c index 952cfdb1961d..1d556482bb46 100644 --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c @@ -81,7 +81,7 @@ struct dsi_hw_ctx { struct dw_dsi { struct drm_encoder encoder; - struct drm_bridge *bridge; + struct device *dev; struct mipi_dsi_host host; struct drm_display_mode cur_mode; struct dsi_hw_ctx *ctx; @@ -720,10 +720,13 @@ static int dw_drm_encoder_init(struct device *dev, return 0; } +static const struct component_ops dsi_ops; static int dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *mdsi) { struct dw_dsi *dsi = host_to_dsi(host); + struct device *dev = host->dev; + int ret; if (mdsi->lanes < 1 || mdsi->lanes > 4) { DRM_ERROR("dsi device params invalid\n"); @@ -734,13 +737,20 @@ static int dsi_host_attach(struct mipi_dsi_host *host, dsi->format = mdsi->format; dsi->mode_flags = mdsi->mode_flags; + ret = component_add(dev, &dsi_ops); + if (ret) + return ret; + return 0; } static int dsi_host_detach(struct mipi_dsi_host *host, struct mipi_dsi_device *mdsi) { - /* do nothing */ + struct device *dev = host->dev; + + component_del(dev, &dsi_ops); + return 0; } @@ -768,7 +778,17 @@ static int dsi_host_init(struct device *dev, struct dw_dsi *dsi) static int dsi_bridge_init(struct drm_device *dev, struct dw_dsi *dsi) { struct drm_encoder *encoder = &dsi->encoder; - struct drm_bridge *bridge = dsi->bridge; + struct drm_bridge *bridge; + struct device_node *np = dsi->dev->of_node; + int ret; + + /* + * Get the endpoint node. In our case, dsi has one output port1 + * to which the external HDMI bridge is connected. + */ + ret = drm_of_find_panel_or_bridge(np, 1, 0, NULL, &bridge); + if (ret) + return ret; /* associate the bridge to dsi encoder */ return drm_bridge_attach(encoder, bridge, NULL, 0); @@ -785,10 +805,6 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; - ret = dsi_host_init(dev, dsi); - if (ret) - return ret; - ret = dsi_bridge_init(drm_dev, dsi); if (ret) return ret; @@ -809,17 +825,7 @@ static const struct component_ops dsi_ops = { static int dsi_parse_dt(struct platform_device *pdev, struct dw_dsi *dsi) { struct dsi_hw_ctx *ctx = dsi->ctx; - struct device_node *np = pdev->dev.of_node; struct resource *res; - int ret; - - /* - * Get the endpoint node. In our case, dsi has one output port1 - * to which the external HDMI bridge is connected. - */ - ret = drm_of_find_panel_or_bridge(np, 1, 0, NULL, &dsi->bridge); - if (ret) - return ret; ctx->pclk = devm_clk_get(&pdev->dev, "pclk"); if (IS_ERR(ctx->pclk)) { @@ -852,6 +858,7 @@ static int dsi_probe(struct platform_device *pdev) dsi = &data->dsi; ctx = &data->ctx; dsi->ctx = ctx; + dsi->dev = &pdev->dev; ret = dsi_parse_dt(pdev, dsi); if (ret) @@ -859,12 +866,19 @@ static int dsi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); - return component_add(&pdev->dev, &dsi_ops); + ret = dsi_host_init(&pdev->dev, dsi); + if (ret) + return ret; + + return 0; } static int dsi_remove(struct platform_device *pdev) { - component_del(&pdev->dev, &dsi_ops); + struct dsi_data *data = platform_get_drvdata(pdev); + struct dw_dsi *dsi = &data->dsi; + + mipi_dsi_host_unregister(&dsi->host); return 0; } From patchwork Thu Oct 21 07:39:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1994C433EF for ; Thu, 21 Oct 2021 07:42:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D93FE6109F for ; Thu, 21 Oct 2021 07:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231228AbhJUHor (ORCPT ); Thu, 21 Oct 2021 03:44:47 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:51255 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbhJUHnr (ORCPT ); Thu, 21 Oct 2021 03:43:47 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id A34EE2B00475; Thu, 21 Oct 2021 03:41:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 21 Oct 2021 03:41:31 -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=fm1; bh=aukaaii7eMmjt ussZ47JHi84aYPnG7d4VwRuG6/sJ+I=; b=ZT7+Y8Q4tBaex/F9ouLOSHAfXIw+A EWV+MDbmOEcFzq3qH1H78fPn3qIjkpUoXK1wluxGE5H2Hram5miwS3l0muc11tTw /HjyBIvJ1DkB8tZWB13m59AGN6Rw2B52HlD+eaiQ1FWhzyHEMiHkTEqB50Wr/8t7 2dc2feMguqoyEuCzOS9cZYb3v/7sHIH264sYsOnC+1TH5gjmqa+rhhPgr6vJcC07 3pVaxWJ1q4KTxFQ3vmDrmir+Lp5DgtjthkpBhnfvu2C0yjHUNcJ1RlVX5TPudhJp n5NTFunhgkbuJZRR1pZKYS99mTVDWpln0Vu9iGy+rBVdMzvAQqMxTh84w== 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= fm1; bh=aukaaii7eMmjtussZ47JHi84aYPnG7d4VwRuG6/sJ+I=; b=hc7/UA67 xEO/PK6JKnVEJG4yrESn1ZLsFWZog2NxRAdQnbSRUmLCiWLB20rDDbMiAvG77bYf GH5oJrhqdyfoq7gLXqIbt5S6wNXsTW6dDbO3+1Md0UN/3bojVwpEcZr724VnVEe8 70NG3Sbl7RCXGBVnyBkpIVjCFnXu6n6QzRs/43ePa7qbTFLyvePJzgGh+Oeb02br D6tDK4g1DK5NFYZNAASOe/iDlgxDwXiPDe+tltJHuC8PxIAnzHShkIa5wltZdxcs Jdt3czsepdX1UOfTDxHn1UH8ph+nllR6Qv1tNDqIWDB9kBtW3h7P3ixu9Ge4ykql uBkkhBaPz1ZDQA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:41:28 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org, Rob Clark , Amit Pundir , Caleb Connolly Subject: [PATCH v5 21/21] drm/msm/dsi: Adjust probe order Date: Thu, 21 Oct 2021 09:39:47 +0200 Message-Id: <20211021073947.499373-22-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Switch to the documented order dsi-host vs bridge probe. Tested-by: Amit Pundir Tested-by: Caleb Connolly Tested-by: John Stultz Signed-off-by: Rob Clark Signed-off-by: Maxime Ripard --- drivers/gpu/drm/msm/dsi/dsi.c | 50 ++++++++++++++++----------- drivers/gpu/drm/msm/dsi/dsi.h | 2 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 22 ++++-------- drivers/gpu/drm/msm/dsi/dsi_manager.c | 6 ++-- drivers/gpu/drm/msm/msm_drv.h | 2 ++ 5 files changed, 43 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c index 614dc7f26f2c..ad73ebb84b2d 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -112,18 +112,7 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) { struct drm_device *drm = dev_get_drvdata(master); struct msm_drm_private *priv = drm->dev_private; - struct platform_device *pdev = to_platform_device(dev); - struct msm_dsi *msm_dsi; - - DBG(""); - msm_dsi = dsi_init(pdev); - if (IS_ERR(msm_dsi)) { - /* Don't fail the bind if the dsi port is not connected */ - if (PTR_ERR(msm_dsi) == -ENODEV) - return 0; - else - return PTR_ERR(msm_dsi); - } + struct msm_dsi *msm_dsi = dev_get_drvdata(dev); priv->dsi[msm_dsi->id] = msm_dsi; @@ -136,12 +125,8 @@ static void dsi_unbind(struct device *dev, struct device *master, struct drm_device *drm = dev_get_drvdata(master); struct msm_drm_private *priv = drm->dev_private; struct msm_dsi *msm_dsi = dev_get_drvdata(dev); - int id = msm_dsi->id; - if (priv->dsi[id]) { - dsi_destroy(msm_dsi); - priv->dsi[id] = NULL; - } + priv->dsi[msm_dsi->id] = NULL; } static const struct component_ops dsi_ops = { @@ -149,15 +134,40 @@ static const struct component_ops dsi_ops = { .unbind = dsi_unbind, }; -static int dsi_dev_probe(struct platform_device *pdev) +int dsi_dev_attach(struct platform_device *pdev) { return component_add(&pdev->dev, &dsi_ops); } -static int dsi_dev_remove(struct platform_device *pdev) +void dsi_dev_detach(struct platform_device *pdev) { - DBG(""); component_del(&pdev->dev, &dsi_ops); +} + +static int dsi_dev_probe(struct platform_device *pdev) +{ + struct msm_dsi *msm_dsi; + + DBG(""); + msm_dsi = dsi_init(pdev); + if (IS_ERR(msm_dsi)) { + /* Don't fail the bind if the dsi port is not connected */ + if (PTR_ERR(msm_dsi) == -ENODEV) + return 0; + else + return PTR_ERR(msm_dsi); + } + + return 0; +} + +static int dsi_dev_remove(struct platform_device *pdev) +{ + struct msm_dsi *msm_dsi = platform_get_drvdata(pdev); + + DBG(""); + dsi_destroy(msm_dsi); + return 0; } diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h index b50db91cb8a7..83787cbee419 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.h +++ b/drivers/gpu/drm/msm/dsi/dsi.h @@ -116,7 +116,7 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host, struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host); unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host); struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host); -int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer); +int msm_dsi_host_register(struct mipi_dsi_host *host); void msm_dsi_host_unregister(struct mipi_dsi_host *host); int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host, struct msm_dsi_phy *src_phy); diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index e269df285136..f741494b1bf6 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -1624,6 +1624,10 @@ static int dsi_host_attach(struct mipi_dsi_host *host, if (ret) return ret; + ret = dsi_dev_attach(msm_host->pdev); + if (ret) + return ret; + DBG("id=%d", msm_host->id); if (msm_host->dev) queue_work(msm_host->workqueue, &msm_host->hpd_work); @@ -1636,6 +1640,8 @@ static int dsi_host_detach(struct mipi_dsi_host *host, { struct msm_dsi_host *msm_host = to_msm_dsi_host(host); + dsi_dev_detach(msm_host->pdev); + msm_host->device_node = NULL; DBG("id=%d", msm_host->id); @@ -1970,7 +1976,7 @@ int msm_dsi_host_modeset_init(struct mipi_dsi_host *host, return 0; } -int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer) +int msm_dsi_host_register(struct mipi_dsi_host *host) { struct msm_dsi_host *msm_host = to_msm_dsi_host(host); int ret; @@ -1984,20 +1990,6 @@ int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer) return ret; msm_host->registered = true; - - /* If the panel driver has not been probed after host register, - * we should defer the host's probe. - * It makes sure panel is connected when fbcon detects - * connector status and gets the proper display mode to - * create framebuffer. - * Don't try to defer if there is nothing connected to the dsi - * output - */ - if (check_defer && msm_host->device_node) { - if (IS_ERR(of_drm_find_panel(msm_host->device_node))) - if (!of_drm_find_bridge(msm_host->device_node)) - return -EPROBE_DEFER; - } } return 0; diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c index c41d39f5b7cf..fc949a84cef6 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c @@ -72,7 +72,7 @@ static int dsi_mgr_setup_components(int id) int ret; if (!IS_BONDED_DSI()) { - ret = msm_dsi_host_register(msm_dsi->host, true); + ret = msm_dsi_host_register(msm_dsi->host); if (ret) return ret; @@ -92,10 +92,10 @@ static int dsi_mgr_setup_components(int id) * because only master DSI device adds the panel to global * panel list. The panel's device is the master DSI device. */ - ret = msm_dsi_host_register(slave_link_dsi->host, false); + ret = msm_dsi_host_register(slave_link_dsi->host); if (ret) return ret; - ret = msm_dsi_host_register(master_link_dsi->host, true); + ret = msm_dsi_host_register(master_link_dsi->host); if (ret) return ret; diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 8b005d1ac899..31d50e98a723 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -344,6 +344,8 @@ int msm_edp_modeset_init(struct msm_edp *edp, struct drm_device *dev, struct msm_dsi; #ifdef CONFIG_DRM_MSM_DSI +int dsi_dev_attach(struct platform_device *pdev); +void dsi_dev_detach(struct platform_device *pdev); void __init msm_dsi_register(void); void __exit msm_dsi_unregister(void); int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,