Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp952708rdb; Wed, 6 Dec 2023 04:59:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGde8jlQTXMl5LYJSamiFM6nG79+fn+bKQADzd+nEQjOE+2fhCJmf7mvW7z26mVmBbRvlWJ X-Received: by 2002:a05:6a20:9706:b0:18f:97c:3851 with SMTP id hr6-20020a056a20970600b0018f097c3851mr788030pzc.43.1701867581314; Wed, 06 Dec 2023 04:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701867581; cv=none; d=google.com; s=arc-20160816; b=DL7qOrOSMj6xEgaJaifqe8gBLVhAdbOr3rRi6mK1n9uGiL7GGtTPf4mMcZvjleqtU7 OKA5pKgH7aCIomXL0uBZjyUS4BpM2w/dKxb4/YOB8CqAJvd8jTPnG8jiYkI4C1LNBSJi J7LGz2xQhEXttf0xXHf6gIsYlNKsf2glJsTRoaibskXfm09a3tEJmq1Fg3cFrRQMkitf y1IOIzEkG5sB7Zy01ePc48NnparFl2xKhl1TSONue6GTj7n3Yyn6j2RXahkscpoOtHrq +K6W4U77h0xaGJ9Y+VTCpYyEeLRjomfi39uyF0jIr1SL0BsMWN9UYMwcGTcuz32L+oFv dOlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lvar08RZ4ORslbEb1luF1/IJqQVEnF3URQJLMAYkhoY=; fh=atJ50RBzWWzFASvZZbMdUFdbyG/eveVCm7mkS+2G1ns=; b=LVCGxiI8v+G45qrEtt8NJVCaWju4Tu7u9VAr1BarLkGVpD97aaAGknhcJIK1spm/6A qdEX2UJyOfoOpJ4XfVxZdpd5tjGRa3L8BNJiadroM6D8UQbOjnbsHv9njx+Bcf+LwvSY 4xE6soOsFduss6WFcLh8cJ+IxXediBSJRZSGksi/j7BT7v4EDkHFgFqqpsGBTQOGqZ2t qM1eIGBwC9HUPuIa/vNjJVrWMyHVW7QRiBQ+OGoS9nUCVylH23aEH57m3k2rfwBj7oxR 4KGA4M2ZE/Q/B+2AP+bh82ixyMQoumOri1u7vuVuzXiVkiOU78QiegrfO6qzAtsn5asY TywQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i1pB5nV1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q5-20020a056a00150500b006cd8db94631si11542977pfu.365.2023.12.06.04.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i1pB5nV1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1DAF7802A731; Wed, 6 Dec 2023 04:59:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378372AbjLFM7Y (ORCPT + 99 others); Wed, 6 Dec 2023 07:59:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378112AbjLFM7X (ORCPT ); Wed, 6 Dec 2023 07:59:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 985971A2 for ; Wed, 6 Dec 2023 04:59:29 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0104C433C9; Wed, 6 Dec 2023 12:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701867569; bh=lvar08RZ4ORslbEb1luF1/IJqQVEnF3URQJLMAYkhoY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i1pB5nV18CuS2PHe3L+ATKsQxhSiOiP+u92khN6+OwRfquc8/6aNV+xmKwIMvjtYl 4wfnynO7HAaGTKQY9Sj+2t6iF9PwPbSZFtabUaueRekoWVedimFrbVwoo7SU+XNnWd AcBkffwJ59POnly2CwLOJFE44jtHmcM8BjjJHCu+jpWhx5i7HfA8Htbs9VEamSp68V lOzdEXvTvbdq3TRIHhLhiap3hCD1hk+/Hjeh3vV1umfjcWFvDNA2Nro1nM+/8IgcRR uM+BFpWIsf8Hc/xlKZctAzNuJ5FI8V6mMI7R+HFd7xCrzY9IjGil78gavXK3aF+cGb v4UjG+vStQdMg== Date: Wed, 6 Dec 2023 13:59:26 +0100 From: Maxime Ripard To: Tomi Valkeinen Cc: "H. Nikolaus Schaller" , Tony Lindgren , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Andrzej Hajda , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Laurent Pinchart Subject: Re: [PATCH] drm/mipi-dsi: Fix detach call without attach Message-ID: References: <20230921-dsi-detach-fix-v1-1-d0de2d1621d9@ideasonboard.com> <17b43cb8-1543-48d2-830a-b9f6dd50fc15@ideasonboard.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5ru2mkl7w2cdikn2" Content-Disposition: inline In-Reply-To: <17b43cb8-1543-48d2-830a-b9f6dd50fc15@ideasonboard.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 04:59:40 -0800 (PST) --5ru2mkl7w2cdikn2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Wed, Dec 06, 2023 at 02:48:58PM +0200, Tomi Valkeinen wrote: > Hi mipi dsi maintainers (I'm not sure who that is =3D), >=20 > On 21/09/2023 13:50, Tomi Valkeinen wrote: > > It's been reported that DSI host driver's detach can be called without > > the attach ever happening: > >=20 > > https://lore.kernel.org/all/20230412073954.20601-1-tony@atomide.com/ > >=20 > > After reading the code, I think this is what happens: > >=20 > > We have a DSI host defined in the device tree and a DSI peripheral under > > that host (i.e. an i2c device using the DSI as data bus doesn't exhibit > > this behavior). > >=20 > > The host driver calls mipi_dsi_host_register(), which causes (via a few > > functions) mipi_dsi_device_add() to be called for the DSI peripheral. So > > now we have a DSI device under the host, but attach hasn't been called. > >=20 > > Normally the probing of the devices continues, and eventually the DSI > > peripheral's driver will call mipi_dsi_attach(), attaching the > > peripheral. > >=20 > > However, if the host driver's probe encounters an error after calling > > mipi_dsi_host_register(), and before the peripheral has called > > mipi_dsi_attach(), the host driver will do cleanups and return an error > > from its probe function. The cleanups include calling > > mipi_dsi_host_unregister(). > >=20 > > mipi_dsi_host_unregister() will call two functions for all its DSI > > peripheral devices: mipi_dsi_detach() and mipi_dsi_device_unregister(). > > The latter makes sense, as the device exists, but the former may be > > wrong as attach has not necessarily been done. > >=20 > > To fix this, track the attached state of the peripheral, and only detach > > from mipi_dsi_host_unregister() if the peripheral was attached. > >=20 > > Note that I have only tested this with a board with an i2c DSI > > peripheral, not with a "pure" DSI peripheral. > >=20 > > However, slightly related, the unregister machinery still seems broken. > > E.g. if the DSI host driver is unbound, it'll detach and unregister the > > DSI peripherals. After that, when the DSI peripheral driver unbound > > it'll call detach either directly or using the devm variant, leading to > > a crash. And probably the driver will crash if it happens, for some > > reason, to try to send a message via the DSI bus. > >=20 > > But that's another topic. > >=20 > > Signed-off-by: Tomi Valkeinen > > --- >=20 > Any comments? I can push this via drm-misc, but I'd like an ack. An ack is a requirement, it's not optional. Acked-by: Maxime Ripard Maxime --5ru2mkl7w2cdikn2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZXBwLgAKCRDj7w1vZxhR xVm2AP4lzzMS9AIxLfwi+DBan5rF0+9sRuEawKmLVG5Dhlr8pgEA5aQqW0Jxatak kWZMCHxy4Rne5nN91Y54zMv2CT24UQY= =1mwD -----END PGP SIGNATURE----- --5ru2mkl7w2cdikn2--