Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp642106rda; Sun, 22 Oct 2023 03:50:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHL2ETEPyrg+gkp6bJA2eXVpjcy+wRV0vAFctuF/GvlmaccqVOT0Q/NFKB+pQpgX/d4yp0h X-Received: by 2002:a05:6a21:35c8:b0:17b:77d3:207c with SMTP id ba8-20020a056a2135c800b0017b77d3207cmr6697370pzc.17.1697971810879; Sun, 22 Oct 2023 03:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697971810; cv=none; d=google.com; s=arc-20160816; b=T2pdkEIMaA+UeYSvRKqgdr1EBVBB+QWHjRVDA9lPlMSAbFxC6VAHysVtCifUsSyVGH EliFWgPW/jz0oB59BeZVW8aL1RxurD52zuVlhfLaYr44jaZVNbR/5HQ5ibF7xL3Fj2gR VqKUoheKYwZDEDfyP9VkNnWY7Hi+MJvFkBV4JyPd453gxFOOldSBCL4Gtg0e0ri3tPAg 9R8oBdcx6b9wRgwPrjTVqM9CMiLehRuSoxcRGhi+brqEZoTca3qETxsEzHsmupoRZ/ER 4VNmlyrE0nXzvKSGiA6KpQ24ZGm73Fvc02GEZzITys56cIG2XHHc2w+6yMJnA/jrjy6o d+gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zsyTofoiJdTaMgzaZy88bV2Z5IwkB35oaVbzN5yV92E=; fh=TWvUNSILGPUIfXqqi1KM0HkZnrDM0WNHXD62wje5o7I=; b=vmXO9/cCa4sAiabLq65BzcEqKXUv3RCXlVKbfvU1xb8QDZAf2hjK2sejJ0pC0Bb1bJ PO/Dnm4IeWFppvykdPWqMt1BzJomQe422yBQ13Sa7Xt04sGBY08LVltJ4pU6Y3qfSgyX WLwqqIrmlL8s+HyvVF0d8ljFRJcx5Fxbd+RZVZ/Qc3Y5tL7zY9l3wDYS7OOWGWSkdp7K 4SskAB7DJArB8D2NIZUEuuzyUYvuivt5SMLL8MMUFX+pTu4sqlbfFji1W/rXskw78P3V zv+/oKxH+RUg9CRMcE7y9+h2XuT3zONboHLcGyg5oF0pzFeXzVUcYg+2HiDSNR5Aq8Xw GdbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e+5NQoDI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id a6-20020a654186000000b00578a56baebesi4521447pgq.674.2023.10.22.03.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 03:50:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e+5NQoDI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id AE880804AD93; Sun, 22 Oct 2023 03:50:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231481AbjJVKt4 (ORCPT + 99 others); Sun, 22 Oct 2023 06:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjJVKtz (ORCPT ); Sun, 22 Oct 2023 06:49:55 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04981B4 for ; Sun, 22 Oct 2023 03:49:53 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3b2f4a5ccebso1671273b6e.3 for ; Sun, 22 Oct 2023 03:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697971792; x=1698576592; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zsyTofoiJdTaMgzaZy88bV2Z5IwkB35oaVbzN5yV92E=; b=e+5NQoDI87tL3cK8fQ9EEfMXDdzYf68v0TMMxSL9lPl2FkWAbqNwk2lWluI8GiivRF dRPlTXhqtBBa8hnkVNVNaU0ad8hh08yfQs+HIiVC/vHho/N+YCRUhqqvBhJ0+KI9GimB HkrGDzCPPpdJuqnSEgPOo4Zj4+ZeyNXKz/01vcFA0eVHKy3zlEnH/15GmZtzY2XrLfjc TI7xD7ULwdTp4VaK68XS0oZpHEkOp0hLbVJuQnYpq1fRBUHeiM0pD+0txqBK1l8fcb4Z MAf6c+JfN0aQowUzK2BEIF4UpsyYrXnyDJkFa375GO0mDda8S3ft2cbpp5zDhsub8vIn lT8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697971792; x=1698576592; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zsyTofoiJdTaMgzaZy88bV2Z5IwkB35oaVbzN5yV92E=; b=DdIROMlWYW0sg9EQlY93HC2APQpd5yIzGf15TuJZZeIqgUE9gB3RYIidkOnsRPBfcv e7oySM6WZSGSOsrHdpP/JeFAxzUi6eHCwrG1UFxVwNpkS+b9GnUZT0yM9m1mYqaYuUKr 9oOeIEZDfq5MiqVS725xS2a3htf4CbNvnwYtxzFdHM7jov9nArcspDfV5M+b0LbC+nRR eS+f/s2DAEyINsqdYw3Nz4EysumyPeZ6EU24wH5+ji/6fdHg398orvaYa1leWvjO/PxY /vPwLKZVjOLfaHXPEhkl+VXxSLVRMy9iSoY8kEol+GUlv4azulwu0mr21/rDNb/oKS18 ZrPA== X-Gm-Message-State: AOJu0YxnBP+GFy/sN+WIgAnx4IH7os9KhwBOUGmkiWptdNe6b2qQjYsu 7/Gss0aGshdIJQ6JZ9MwhhWgeJzQRKho4hpWwmjDsw== X-Received: by 2002:a05:6808:c3:b0:3ae:251f:923f with SMTP id t3-20020a05680800c300b003ae251f923fmr6825013oic.28.1697971792253; Sun, 22 Oct 2023 03:49:52 -0700 (PDT) MIME-Version: 1.0 References: <20231016165355.1327217-1-dmitry.baryshkov@linaro.org> <7e4ak4e77fp5dat2aopyq3g4wnqu3tt7di7ytdr3dvgjviyhrd@vqiqx6iso6vg> <1907377.IobQ9Gjlxr@steina-w> In-Reply-To: <1907377.IobQ9Gjlxr@steina-w> From: Dmitry Baryshkov Date: Sun, 22 Oct 2023 13:49:41 +0300 Message-ID: Subject: Re: [RFC PATCH 03/10] drm/mipi-dsi: add API for manual control over the DSI link power state To: Alexander Stein Cc: Maxime Ripard , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Laurent Pinchart , Andrzej Hajda , Marijn Suijten , Marek Vasut , Robert Foss , Dave Stevenson , Jernej Skrabec , Jessica Zhang , Jonas Karlman , linux-arm-msm@vger.kernel.org, Abhinav Kumar , Sean Paul , Neil Armstrong , Douglas Anderson , Konrad Dybcio , Thomas Zimmermann , freedreno@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 22 Oct 2023 03:50:07 -0700 (PDT) On Thu, 19 Oct 2023 at 14:42, Alexander Stein wrote: > > Hi, > > Am Donnerstag, 19. Oktober 2023, 13:19:51 CEST schrieb Dmitry Baryshkov: > > On Thu, 19 Oct 2023 at 12:26, Maxime Ripard wrote: > > > 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. > > > > > > Explaining why would help > > > > A kind of explanation comes afterwards, but probably I should change > > the order of the phrases and expand it: > > > > 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. > > > > 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. 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). > > > > 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. 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. > > There are also bridges (e.g. tc358767) which require DSI-LP11 upon bridge > reset. And additionally this DSI-(e)DP bridge requires LP11 while accessi= ng > DP-AUX channel, e.g. reading EDID. So bridges need at least some control = over > DSI line state. For sending commands in LP11 it is typical to toggle the MIPI_DSI_MODE_LPM flag, for example see panel-=3Djdi-lt070me05000.c or some other drives. It might be a good idea to make that more explicit. All suggestions here would be appreciated. > > > 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]. > > > > 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. > > I want to use this series to support tc358767 properly, because > pre_enable_prev_first is not enough, see AUX channel above. I hope I'll f= ind > any time soon. > > Best regards, > Alexander > > > > > > > The drm_bridge_funcs abstraction. > > > > > > Is there a typo or missing words? > > > > missing comma in front of The > > > > > > Instead of having just two states (off and on) the DSI hosts have > > > > separate LP-11 state. In this state the host is on, but the video > > > > stream is not yet enabled. > > > > > > > > Introduce API that allows DSI bridges / panels to control the DSI h= ost > > > > power up state. > > > > [1] > > https://lore.kernel.org/dri-devel/6c0dd9fd-5d8e-537c-804f-7a03d5899a07@= lina > > ro.org/ > > > > Signed-off-by: Dmitry Baryshkov > > > > --- > > > > > > > > drivers/gpu/drm/drm_mipi_dsi.c | 31 ++++++++++++++++++++++++++++++= + > > > > include/drm/drm_mipi_dsi.h | 29 +++++++++++++++++++++++++---- > > > > 2 files changed, 56 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c > > > > b/drivers/gpu/drm/drm_mipi_dsi.c index 14201f73aab1..c467162cb7d8 > > > > 100644 > > > > --- a/drivers/gpu/drm/drm_mipi_dsi.c > > > > +++ b/drivers/gpu/drm/drm_mipi_dsi.c > > > > @@ -428,6 +428,37 @@ int devm_mipi_dsi_attach(struct device *dev, > > > > > > > > } > > > > EXPORT_SYMBOL_GPL(devm_mipi_dsi_attach); > > > > > > > > +bool mipi_dsi_host_power_control_available(struct mipi_dsi_host *h= ost) > > > > +{ > > > > + const struct mipi_dsi_host_ops *ops =3D host->ops; > > > > + > > > > + return ops && ops->power_up; > > > > +} > > > > +EXPORT_SYMBOL_GPL(mipi_dsi_host_power_control_available); > > > > + > > > > +int mipi_dsi_host_power_up(struct mipi_dsi_host *host) > > > > +{ > > > > + const struct mipi_dsi_host_ops *ops =3D host->ops; > > > > + > > > > + if (!mipi_dsi_host_power_control_available(host)) > > > > + return -EOPNOTSUPP; > > > > + > > > > + return ops->power_up ? ops->power_up(host) : 0; > > > > +} > > > > +EXPORT_SYMBOL_GPL(mipi_dsi_host_power_up); > > > > + > > > > +void mipi_dsi_host_power_down(struct mipi_dsi_host *host) > > > > +{ > > > > + const struct mipi_dsi_host_ops *ops =3D host->ops; > > > > + > > > > + if (!mipi_dsi_host_power_control_available(host)) > > > > + return; > > > > + > > > > + if (ops->power_down) > > > > + ops->power_down(host); > > > > +} > > > > +EXPORT_SYMBOL_GPL(mipi_dsi_host_power_down); > > > > + > > > > > > If this API is supposed to be used by DSI devices, it should probably > > > take a mipi_dsi_device pointer as a parameter? > > > > Ack. > > > > > We should probably make sure it hasn't been powered on already too? > > > > Ack, I can add an atomic count there and a WARN_ON. However I don't > > think that it is a real problem. > > > > > Maxime > > > > -- > > With best wishes > > > > Dmitry > > > -- > TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Ge= rmany > Amtsgericht M=C3=BCnchen, HRB 105018 > Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan S= chneider > http://www.tq-group.com/ > > --=20 With best wishes Dmitry