Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1677738pxb; Mon, 23 Aug 2021 01:48:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4NBo57FNHjcEEoZuuziOWDzFP3KTbXp2Gz+4IvnRgWRUxtQIKoq/Q6V7wLGFD3ZMXuqhy X-Received: by 2002:a6b:6319:: with SMTP id p25mr26146950iog.100.1629708518838; Mon, 23 Aug 2021 01:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629708518; cv=none; d=google.com; s=arc-20160816; b=BKPd6bhSlQPwaI0TSraf3zRS4DzHMwGGJI5NTn4t07uI+1q3ujZfPQYnnh2vyHv4xs CsuYlHpG2l7xdsHAoB7fef8vQHRbyclC5C6UXkhxwBIFhm+WuLs8ADPV7+wsyipJ/vIS zFAEcEVwtGBlaz+JByCQ88+YXTOysw9bxQlHPASGZe3iorThzDOlRtq94/2HFkaps2eo C4X4TBYNijNqdcMEes4/VMxybLaTXAEoPRQs9pppjHNyvR3VNgQxm4BjpBNP2o2lJhZR mHvy+hUUeg+5X5/ZMnpJXjNZG0sJYR39RTKC7FvwQcF/tQ+bYzMA4u2IQNWHhll090pQ kBCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=AAA162HvOKjssXLDsIaF5gFDavpFUxRYx2PLty6HBAo=; b=wPh0NOFq0rqGpe3AA4xi7kO3s1pfOEaOXcvC3kSMqthrHdZKHgrjPoQjUyDUju2ZOT kdsm001UZnYvwJtJ2yTadp9t8BrDrSLyEaqvrV23N2TxVg6On5tLmt5MPaAvRYndO7oH k3NAPzaYVN+Cd4PaLuN++2veRZzu6wz/W6R7ubNFnzcXkarDeGxLhz6VAW0F9pIQ/IWI QU7z5MKVqAFsUJkW0vq8o3WXBHUslNzBeuNpKMPKGpq7AZFWInVQzSroaEbGjTSZKGxd W5BuD6BAOHJP64j9rMRte3ewtnUTeFHsdy1XJY4MexI/RWmquHptvpxtfxTd7YB+raCG fqYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=k8WfRqGC; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=bINKokqf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si16679631ilu.22.2021.08.23.01.48.28; Mon, 23 Aug 2021 01:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=k8WfRqGC; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=bINKokqf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235672AbhHWIsZ (ORCPT + 99 others); Mon, 23 Aug 2021 04:48:25 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:35411 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235661AbhHWIsU (ORCPT ); Mon, 23 Aug 2021 04:48:20 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 15741580C67; Mon, 23 Aug 2021 04:47:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 23 Aug 2021 04:47:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=AAA162HvOKjss XLDsIaF5gFDavpFUxRYx2PLty6HBAo=; b=k8WfRqGCOYP1zoGF6B9uPl4bXnJyE gwLFHybQubwOCpHrgOvS/vG8yBpuUc9KV5NK8eMoOCh6eN8dIaovpToltv+Gx46t FT3GU9BUJqWoTzW7TaIqjMYY9awidgymAKw0hP48ZmO0LzhquYE80gqnKHGiPEi+ TzMpZ7qsJpH/VmK2y8GTj8D5us1ONilw916kZLI+YxbcgO995N6xBkd9fO+xvrDn jbQeENukgi6+cZZjWum61F1rwj+FfnkXIAkTKCXvIrSHSuTrxWnLoDBwXfDlgEr+ 9ciZj/gsXk8GhMxpkGh49hcPrNyFO/Wq3d0791O1HPV9awmBec2L5UONQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=AAA162HvOKjssXLDsIaF5gFDavpFUxRYx2PLty6HBAo=; b=bINKokqf feK4LXTUdS34YYNSYXvye6yBBDBQukfXO2+spBvgOPrTNPOqifrNjmaigUWozyK7 2zujyBRbYBtKrDZd0fLRNHD6QgubyfUzcW267qg59qQGA8heR8sdq3AncscsmrUE 48+2JW9ab2Hn477x1iISq0+EZtlliIIau7oKKUZiuMTZKwFVNWDULAd2HCXEIP7z I3i29Y4gPfpZ+HnsKHVF4HKkghvvqP4lV4o0wx8WnY1jF7HrWV6ooedxCl0hY7TM s28lvdy3q+6zfDnLDLCG4zaI32pkY06eK+fQjBPjcdXU+fhMnGcc5J5zx2xjQ0nc wJnNGfZUnzak0w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddthedgtdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Aug 2021 04:47:36 -0400 (EDT) From: Maxime Ripard To: Jonas Karlman , Sam Ravnborg , Jernej Skrabec , Thierry Reding , Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Neil Armstrong , Laurent Pinchart , Robert Foss , Andrzej Hajda Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v3 2/8] drm/bridge: Document the probe issue with MIPI-DSI bridges Date: Mon, 23 Aug 2021 10:47:17 +0200 Message-Id: <20210823084723.1493908-3-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823084723.1493908-1-maxime@cerno.tech> References: <20210823084723.1493908-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 58 +++++++++++++++++++++++++++ 2 files changed, 64 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..794654233cf5 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -96,6 +96,64 @@ * documentation of bridge operations for more details). */ +/** + * DOC: special care dsi + * + * The interaction between the bridges and other frameworks involved in + * the probing of the display driver and the bridge driver can be + * challenging. Indeed, there's multiple cases that needs to be + * considered: + * + * - The display driver doesn't use the component framework and isn't a + * MIPI-DSI host. In this case, the bridge driver will probe at some + * point and the display driver should try to probe again by returning + * EPROBE_DEFER as long as the bridge driver hasn't probed. + * + * - The display driver doesn't use the component framework, but is a + * MIPI-DSI host. The bridge device uses the MIPI-DCS commands to be + * controlled. In this case, the bridge device is a child of the + * display device and when it will probe it's assured that the display + * device (and MIPI-DSI host) is present. The display driver will be + * assured that the bridge driver is connected between the + * &mipi_dsi_host_ops.attach and &mipi_dsi_host_ops.detach operations. + * Therefore, it must run mipi_dsi_host_register() in its probe + * function, and then run drm_bridge_attach() in its + * &mipi_dsi_host_ops.attach hook. + * + * - The display driver uses the component framework and is a MIPI-DSI + * host. The bridge device uses the MIPI-DCS commands to be + * controlled. This is the same situation than above, and can run + * mipi_dsi_host_register() in either its probe or bind hooks. + * + * - The display driver uses the component framework and is a MIPI-DSI + * host. The bridge device uses a separate bus (such as I2C) to be + * controlled. In this case, there's no correlation between the probe + * of the bridge and display drivers, so care must be taken to avoid + * an endless EPROBE_DEFER loop, with each driver waiting for the + * other to probe. + * + * The ideal pattern to cover the last item (and all the others in the + * display driver case) is to split the operations like this: + * + * - In the display driver must run mipi_dsi_host_register() and + * component_add in its probe hook. It will make sure that the + * MIPI-DSI host sticks around, and that the driver's bind can be + * called. + * + * - In its probe hook, the bridge driver must 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 display driver + * 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 display driver and the + * bridge driver are functional and we can't have a deadlock-like + * situation when probing. + */ + static DEFINE_MUTEX(bridge_lock); static LIST_HEAD(bridge_list); -- 2.31.1