Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp260520rdh; Thu, 26 Oct 2023 01:05:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/KhABCTdI1XcK1AMw58E0CMNT/umOBRQihrRL20ooWLZmdzFEt+mSNLFK0wutbiXuHFeb X-Received: by 2002:a05:6870:8a27:b0:1e9:8a35:8635 with SMTP id p39-20020a0568708a2700b001e98a358635mr19140318oaq.21.1698307524119; Thu, 26 Oct 2023 01:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698307524; cv=none; d=google.com; s=arc-20160816; b=oA791MPej+a/UuhU3ucY5Y0EtIvEAxeIsRhK8LEyM6xlzf9FgJUcvasvolYiD0JgLW 2alTag5S+jlsE43nOUbDJfS63YPDoHJpFPsxUGmPmspxTF4UWYInA6hTDGODvuQCN8sX aK8xqPcVPLxGSsZmoQfIe5HhZ1jw0vab/eGL23a0sX9qtQz82hcoTVicM3ZYcoSabOvj 1qdIFyyq0qw9bdXyh4ff1Aphk2r09tFQrk0bD1ZZH0YC7H9ObRevuV8Kotvhi+I+VtIC wiM1uViyRH7Yt61FC00j843r3zhhMCyE37dbR1uF7LjWmGtzl+u/Fgd6g32uC6bbUi4F 1nCQ== 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=EAQ7g0hX/FrxSMaglusDeCTnn471+1/pfyILaNojVhU=; fh=UQMESVpC62xRFvSH1+uDf1FFPPoGfmiJd3O8oCYromw=; b=VVcAD2SQjNqRT5nTK9Az4+Uh0LRkcJscPk29gZKR49AQB2N3qFtOGBO5i/OFkCKcRR ZvIpqBzt4jv95rZYmGQNPwGFZ7e/DzYRrY8Qe7c5N40MVYjJp4YqheOJ6aC6LNRmwrKv IRnsBXdatUAcRIBUo+kNGdoMaj2f0x+y/h7rR3gMLHG5cYYYaHrWxYrefn49kqYsgtb5 hBRqQTy/5fia322mF4UuZf/5WgIXC1l/flxmkSY0Otw4F0bliJSHImMcDc1P8LaZgf6p B6mQxtWtNGjLAg2x+HZ8eC6xPEG8KzrR1pW90q+WvkvLS7HsYKWzRATZXijcjSkabHg9 +Y8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fgekZGHe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k77-20020a252450000000b00d8660484dd7si13719980ybk.328.2023.10.26.01.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 01:05:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fgekZGHe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 9F87B82696FF; Thu, 26 Oct 2023 01:05:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjJZIE5 (ORCPT + 99 others); Thu, 26 Oct 2023 04:04:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjJZIE4 (ORCPT ); Thu, 26 Oct 2023 04:04:56 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82EC7B8; Thu, 26 Oct 2023 01:04:52 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D14AC433C8; Thu, 26 Oct 2023 08:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698307492; bh=EAQ7g0hX/FrxSMaglusDeCTnn471+1/pfyILaNojVhU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fgekZGHe9w5dxxPKuk6zn5H1uJjUgh68Hyyq0hVSmesw81fAlMk4TVQuV+fG/Ifi1 bi/OMcbGSszHDTuVCfHrQcOiYv3LTv20fvoU1SpywODggvG/p4HrkVYhfgA8G/qA1K hq13Qi/F68Tl8sEwYkUI/j7oUhxsyaodVcl4/HP7yzK7y4t2wRZwYwoTFSM79ueRYJ t1gpgTbHagm39EF4326A8/n1Bjl28LzBwLUXBy4K6CFtS7RkxG0Hs4hxI6M4heugEC rmhGrFUtI9Er0T2HPvwVxaNJz1ohb/CzatsuXO6zXUA8YxRIjNRkVZhOVjkzn/xjKi l94O/mMwJ6K+Q== Date: Thu, 26 Oct 2023 10:04:48 +0200 From: Maxime Ripard To: Dmitry Baryshkov Cc: Dave Stevenson , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Douglas Anderson , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Konrad Dybcio , Jessica Zhang , Marek Vasut , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org Subject: Re: [RFC PATCH 03/10] drm/mipi-dsi: add API for manual control over the DSI link power state Message-ID: References: <20231016165355.1327217-1-dmitry.baryshkov@linaro.org> <20231016165355.1327217-4-dmitry.baryshkov@linaro.org> <7e4ak4e77fp5dat2aopyq3g4wnqu3tt7di7ytdr3dvgjviyhrd@vqiqx6iso6vg> <1696f131-83fb-4d0c-b4d7-0bdb61e4ae65@linaro.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="t5jjjcy33i2jy7lt" Content-Disposition: inline In-Reply-To: <1696f131-83fb-4d0c-b4d7-0bdb61e4ae65@linaro.org> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Thu, 26 Oct 2023 01:05:20 -0700 (PDT) --t5jjjcy33i2jy7lt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 25, 2023 at 06:16:14PM +0300, Dmitry Baryshkov wrote: > On 25/10/2023 15:44, Maxime Ripard wrote: > > On Thu, Oct 19, 2023 at 02:19:51PM +0300, Dmitry Baryshkov wrote: > > > On Thu, 19 Oct 2023 at 12:26, Maxime Ripard wrot= e: > > > >=20 > > > > On Mon, Oct 16, 2023 at 07:53:48PM +0300, Dmitry Baryshkov wrote: > > > > > The MIPI DSI links do not fully fall into the DRM callbacks model. > > > >=20 > > > > Explaining why would help > > >=20 > > > A kind of explanation comes afterwards, but probably I should change > > > the order of the phrases and expand it: > > >=20 > > > The atomic_pre_enable / atomic_enable and correspondingly > > > atomic_disable / atomic_post_disable expect that the bridge links > > > follow a simple paradigm: either it is off, or it is on and streaming > > > video. Thus, it is fine to just enable the link at the enable time, > > > doing some preparations during the pre_enable. > > >=20 > > > But then it causes several issues with DSI. First, some of the DSI > > > bridges and most of the DSI panels would like to send commands over > > > the DSI link to setup the device. > >=20 > > What prevent them from doing it in enable when the link is enabled? > >=20 > > > Next, some of the DSI hosts have limitations on sending the commands. > > > The proverbial sunxi DSI host can not send DSI commands after the > > > video stream has started. Thus most of the panels have opted to send > > > all DSI commands from pre_enable (or prepare) callback (before the > > > video stream has started). > >=20 > > I'm not sure we should account for a single driver when designing a > > framework. We should focus on designing something sound, and then making > > that driver work with whatever we designed, but not the other way > > around. And if we can't, we should get rid of that driver because it's > > de-facto unmaintainable. And I'm saying that as the author of that > > driver. >=20 > That's not the only driver with strange peculiarities. For example, see > commit 8a4b2fc9c91a ("drm/bridge: tc358762: Split register programming fr= om > pre-enable to enable"), which was one of the issues that actually prompted > me to send this this patchset (after my previous version of this patch be= ing > rejected because of sunxi). The datasheet for that bridge is available so at least we can try to fix it (and bridges are much simpler than controllers anyway). It's not something we can do with the sunxi driver. > > > However this leaves no good place for the DSI host to power up the DSI > > > link. By default the host's pre_enable callback is called after the > > > DSI bridge's pre_enable. For quite some time we were powering up the > > > DSI link from mode_set. This doesn't look fully correct. > >=20 > > Yeah, it's not. > >=20 > > > And also we got into the issue with ps8640 bridge, which requires for > > > the DSI link to be quiet / unpowered at the bridge's reset time. > > >=20 > > > Dave has come with the idea of pre_enable_prev_first / > > > prepare_prev_first flags, which attempt to solve the issue by > > > reversing the order of pre_enable callbacks. This mostly solves the > > > issue. However during this cycle it became obvious that this approach > > > is not ideal too. There is no way for the DSI host to know whether the > > > DSI panel / bridge has been updated to use this flag or not, see the > > > discussion at [1]. > >=20 > > Yeah. Well, that happens. I kind of disagree with Neil here though when > > he says that "A panel driver should not depend on features of a DSI > > controller". Panels definitely rely on particular features, like the > > number of lanes, the modes supported, etc. >=20 > In the mentioned discussion it was more about 'DSI host should not assume > panel driver features', like the panel sending commands in pre_enable or > not, or having pre_enable_prev_first. >=20 > So the pre_enable_prev_first clearly lacks feature negotiation. >=20 > > Panels shouldn't depend on a particular driver *behaviour*. But the > > features are fine. > >=20 > > For our particular discussion, I think that that kind of discussion is a > > dead-end, and we just shouldn't worry about it. Yes, some panels have > > not yet been updated to take the new flags into account. However, the > > proper thing to do is to update them if we see a problem with that (and > > thus move forward to the ideal solution), not revert the beginning of > > that feature enablement (thus moving away from where we want to end up > > in). > >=20 > > > Thus comes this proposal. It allows for the panels to explicitly bring > > > the link up and down at the correct time, it supports automatic use > > > case, where no special handling is required. And last, but not least, > > > it allows the DSI host to note that the bridge / panel were not > > > updated to follow new protocol and thus the link should be powered on > > > at the mode_set time. This leaves us with the possibility of dropping > > > support for this workaround once all in-kernel drivers are updated. > >=20 > > I'm kind of skeptical for these kind of claims that everything will be > > automatic and will be handled fine. What if we have conflicting > > requirements, for example two bridges drivers that would request the > > power up at different times? >=20 > Well, we do not support DSI sublinks, do we? No, but we start to consider adding support for muxes for example. A DSI mux + a DSI bridge behind it might trigger that behaviour, even if we don't support sublinks. > > Also, we would still need to update every single panel driver, which is > > going to create a lot of boilerplate that people might get wrong. >=20 > Yes, quite unfortunately. Another approach that I have in mind is to add = two > callbacks to mipi_dsi_device. This way the DSI host will call into the > device to initialise it once the link has been powered up and just before > tearing it down. We solve a lot of problems this way, no boilerplate and = the > panel / bridge are in control of the initialisation procedure. WDYT? >=20 > > I have the feeling that we should lay out the problem without talking > > about any existing code base first. So, what does the MIPI-DSI spec > > requires and what does panels and bridges expect? >=20 > There is not that much in the DSI spec (or maybe I do not understand the > question). The spec is more about the power states and the commands. Our > problem is that this doesn't fully match kernel expectations. You're explicitly asking for comments on that series. How can we provide any comment if you're dead-set on a particular implementation and not explain what the problem you are trying to solve is? Thinking more about it, I'm even more skeptical about the general approach that this should be implemented at the bridge level (or in KMS). It looks to me that this is very much a bus problem. USB device drivers also require the bus to be powered and generally available to send data to their device, and you don't fix that up in the HID or storage drivers, you make the bus behave that way. What prevents us from fixing it at the bus level? Maxime --t5jjjcy33i2jy7lt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZTodoAAKCRDj7w1vZxhR xXxfAP9VCXaQR2cQ7p55Qlz1ohFIbsH/qdui1vb3BqtSku+upgEAjT4JPOz2oULJ J5eoQVTdscVpioLNgkJXMKMNMAd0+A0= =lsQF -----END PGP SIGNATURE----- --t5jjjcy33i2jy7lt--