From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BBE9C433F5 for ; Tue, 14 Sep 2021 19:00:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0222D61164 for ; Tue, 14 Sep 2021 19:00:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232113AbhINTBw (ORCPT ); Tue, 14 Sep 2021 15:01:52 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:40965 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232269AbhINTBu (ORCPT ); Tue, 14 Sep 2021 15:01:50 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20210914190031euoutp0252a3f0c65b54a254acad7d078254053b~kxWurLt5o2848928489euoutp02B for ; Tue, 14 Sep 2021 19:00:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20210914190031euoutp0252a3f0c65b54a254acad7d078254053b~kxWurLt5o2848928489euoutp02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1631646031; bh=xm1zaqXeyvV2esoGirppTvrBf0GA4uTS8Yww/fX/oqc=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=M7QKMNs/1PdJgacqnxuCPAjPZkqsMt6XVUrOQw00rGQakWaUY3cQ6Gx3ewjGE21FY 0FsF0CPLhD5ffAn3GSvNbDCvm2/tS20dZsnAJpiJr+Dr2ivnTt98EVZ1OsPimCjXaa s4iM+KuiGWh4SjD/GXJnKzuEsAX+dn5MWb+STUXc= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20210914190030eucas1p175b756fbaec2a0c514695fcec70152f1~kxWuLC4EH2248322483eucas1p1c; Tue, 14 Sep 2021 19:00:30 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id BD.1E.45756.E41F0416; Tue, 14 Sep 2021 20:00:30 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20210914190030eucas1p25f2fca6b8abc3f09e9c3eec15ef95675~kxWtnXQVj3156731567eucas1p2f; Tue, 14 Sep 2021 19:00:30 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210914190030eusmtrp2a4b24888128433c0437039bb0067ea99~kxWtmOi7o2400724007eusmtrp22; Tue, 14 Sep 2021 19:00:30 +0000 (GMT) X-AuditID: cbfec7f2-7d5ff7000002b2bc-55-6140f14e43a7 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 68.FE.20981.D41F0416; Tue, 14 Sep 2021 20:00:29 +0100 (BST) Received: from [106.210.131.79] (unknown [106.210.131.79]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210914190028eusmtip236a1fe4ead5a72d804ca1ce148a75845~kxWsHqeHR2441624416eusmtip2j; Tue, 14 Sep 2021 19:00:28 +0000 (GMT) Message-ID: Date: Tue, 14 Sep 2021 21:00:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Thunderbird/93.0 Subject: Re: [PATCH v4 02/24] drm/bridge: Document the probe issue with MIPI-DSI bridges Content-Language: pl To: Maxime Ripard Cc: Sam Ravnborg , Daniel Vetter , David Airlie , Jonas Karlman , Laurent Pinchart , Thierry Reding , Maarten Lankhorst , Thomas Zimmermann , Neil Armstrong , Robert Foss , Jernej Skrabec , Sean Paul , freedreno@lists.freedesktop.org, Kyungmin Park , linux-kernel@vger.kernel.org, Xinliang Liu , Seung-Woo Kim , Tian Tao , Inki Dae , linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, Rob Clark , dri-devel@lists.freedesktop.org, John Stultz , Chen Feng , Xinwei Kong , Joonyoung Shim From: Andrzej Hajda In-Reply-To: <20210914143541.433ucx2kvz36tw42@gilmour> Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA01Sf0wTZxj2u7veHTVlR6n2i4PhMJrpBDQj5osKgUWXW7IZN2MCnRMPuCFZ +bFWnJNECTjtMLgCpkKrIFOEgGMCLY5GIIFhbaCADkz5ZZkQfpPyeyCDDXqY8d/zPu/7PM/7 fvloXFpNbqNj48/xqnhO6UuKiaqni61+x6ZCuH35y9tRRosVQ0XNZThqn3OS6PaQDaAsh5ZA Q/llADUv+SHreAeBhl89J9DCcq0I2VLHKfRT5n0KZdbZKPSn+TaJclprMVQwZSJQzsIKQPU3 vkIOnX7Vo2ABR9P6v3BUvGgCqDf7D4ByskdItGjOI1DpWC2FjOOZItRYVyIK8WKd9h8ptqel lWSr9b0U23+nnGINmlwRe+/JCMY+077A2J6XT0j28XyfiM2zfsE6rlsw1mLuotj7ug6SvWEs AWxlUzI7U/HecUYhPhzNK2PP86qA4DPisy9Su6nEXwMuPGxGKaBmZzpwoyETCDsrJ7B0IKal TDGAhddLSaGYBTB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: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20210910101246eucas1p17191a80c37b0e1784d6d9b8bf6fbcd60 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210910101246eucas1p17191a80c37b0e1784d6d9b8bf6fbcd60 References: <20210910101218.1632297-1-maxime@cerno.tech> <20210910101218.1632297-3-maxime@cerno.tech> <7ad18d53-3ad6-a614-a8e1-cce6505f90a8@samsung.com> <20210914143541.433ucx2kvz36tw42@gilmour> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org W dniu 14.09.2021 o 16:35, Maxime Ripard pisze: > Hi, > > On Mon, Sep 13, 2021 at 08:29:37AM +0200, Andrzej Hajda wrote: >> W dniu 10.09.2021 o 12:11, Maxime Ripard pisze: >>> Interactions between bridges, panels, MIPI-DSI host and the component >>> framework are not trivial and can lead to probing issues when >>> implementing a display driver. Let's document the various cases we need >>> too consider, and the solution to support all the cases. >>> >>> Signed-off-by: Maxime Ripard >>> --- >>> Documentation/gpu/drm-kms-helpers.rst | 6 +++ >>> drivers/gpu/drm/drm_bridge.c | 57 +++++++++++++++++++++++++++ >>> 2 files changed, 63 insertions(+) >>> >>> diff --git a/Documentation/gpu/drm-kms-helpers.rst b/Documentation/gpu/drm-kms-helpers.rst >>> index 10f8df7aecc0..ec2f65b31930 100644 >>> --- a/Documentation/gpu/drm-kms-helpers.rst >>> +++ b/Documentation/gpu/drm-kms-helpers.rst >>> @@ -157,6 +157,12 @@ Display Driver Integration >>> .. kernel-doc:: drivers/gpu/drm/drm_bridge.c >>> :doc: display driver integration >>> >>> +Special Care with MIPI-DSI bridges >>> +---------------------------------- >>> + >>> +.. kernel-doc:: drivers/gpu/drm/drm_bridge.c >>> + :doc: special care dsi >>> + >>> Bridge Operations >>> ----------------- >>> >>> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c >>> index baff74ea4a33..7cc2d2f94ae3 100644 >>> --- a/drivers/gpu/drm/drm_bridge.c >>> +++ b/drivers/gpu/drm/drm_bridge.c >>> @@ -96,6 +96,63 @@ >>> * documentation of bridge operations for more details). >>> */ >>> >>> +/** >>> + * DOC: special care dsi >>> + * >>> + * The interaction between the bridges and other frameworks involved in >>> + * the probing of the upstream driver and the bridge driver can be >>> + * challenging. Indeed, there's multiple cases that needs to be >>> + * considered: >>> + * >>> + * - The upstream driver doesn't use the component framework and isn't a >>> + * MIPI-DSI host. In this case, the bridge driver will probe at some >>> + * point and the upstream driver should try to probe again by returning >>> + * EPROBE_DEFER as long as the bridge driver hasn't probed. >>> + * >>> + * - The upstream driver doesn't use the component framework, but is a >>> + * MIPI-DSI host. The bridge device uses the MIPI-DCS commands to be >>> + * controlled. In this case, the bridge device is a child of the >>> + * display device and when it will probe it's assured that the display >>> + * device (and MIPI-DSI host) is present. The upstream driver will be >>> + * assured that the bridge driver is connected between the >>> + * &mipi_dsi_host_ops.attach and &mipi_dsi_host_ops.detach operations. >>> + * Therefore, it must run mipi_dsi_host_register() in its probe >>> + * function, and then run drm_bridge_attach() in its >>> + * &mipi_dsi_host_ops.attach hook. >>> + * >>> + * - The upstream driver uses the component framework and is a MIPI-DSI >>> + * host. The bridge device uses the MIPI-DCS commands to be >>> + * controlled. This is the same situation than above, and can run >>> + * mipi_dsi_host_register() in either its probe or bind hooks. >>> + * >>> + * - The upstream driver uses the component framework and is a MIPI-DSI >>> + * host. The bridge device uses a separate bus (such as I2C) to be >>> + * controlled. In this case, there's no correlation between the probe >>> + * of the bridge and upstream drivers, so care must be taken to avoid >>> + * an endless EPROBE_DEFER loop, with each driver waiting for the >>> + * other to probe. >>> + * >>> + * The ideal pattern to cover the last item (and all the others in the >>> + * MIPI-DSI host driver case) is to split the operations like this: >>> + * >>> + * - The MIPI-DSI host driver must run mipi_dsi_host_register() in its >>> + * probe hook. It will make sure that the MIPI-DSI host sticks around, >>> + * and that the driver's bind can be called. >>> + * >>> + * - In its probe hook, the bridge driver must try to find its MIPI-DSI >>> + * host, register as a MIPI-DSI device and attach the MIPI-DSI device >>> + * to its host. The bridge driver is now functional. >>> + * >>> + * - In its &struct mipi_dsi_host_ops.attach hook, the MIPI-DSI host can >>> + * now add its component. Its bind hook will now be called and since >>> + * the bridge driver is attached and registered, we can now look for >>> + * and attach it. >>> + * >>> + * At this point, we're now certain that both the upstream driver and >>> + * the bridge driver are functional and we can't have a deadlock-like >>> + * situation when probing. >>> + */ >>> + >>> static DEFINE_MUTEX(bridge_lock); >>> static LIST_HEAD(bridge_list); >> >> Nice work with documenting this initialization dance. It clearly shows >> that bridge API lacks better mechanism - usage of mipi dsi callbacks to >> get notifications about bridge appearance is ugly. > Yeah, there's so many moving parts it's definitely not great. > >> It remains me my resource tracking patches which I have posted long >> time ago [1] - they would solve the issue in much more elegant way, >> described here [2]. Apparently I was not stubborn enough in promoting >> this solution. > Wow, that sounds like a massive change indeed :/ > >> Anyway: >> >> Reviewed-by: Andrzej Hajda > I assume you'll want me to hold off that patch before someone reviews > the rest? The last exynos patch should be dropped, kirin patch should be tested/reviewed/acked by kirin maintaner. I am not sure about bridge patches, which ones have been tested by you, and which one have other users. If yes it would be good to test them as well - changes in initialization flow can beat sometimes :) I think patches 1-4 can be merged earlier, if you like, as they are on the list for long time. Regards Andrzej > > Thanks! > Maxime