Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4570974pxf; Tue, 16 Mar 2021 17:52:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6gUjyFxrQbORg6k3GBrHHAZSHYh8lPpnb+xbdKZLvY4V4ea0C8+fSulUzcFk48C6WQasm X-Received: by 2002:a05:6402:5244:: with SMTP id t4mr39604952edd.87.1615942330558; Tue, 16 Mar 2021 17:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615942330; cv=none; d=google.com; s=arc-20160816; b=cslfqmwsJbExHw41YJkrnFHHrCycd22hSLLp2S3KRvxs+ZPb+MA7bRkXet378LxXyQ rUBRdZjBmdF/KPZkKKjJFXve2plxXX4ArJn+WtR0oprtvo13THSVlY7gXLoZ2VRidgsE H/8Xae+8CGRAhuIRfkyDy6OKbAAVug2ch5XaUnvlw/CyQ9LKMNGDkyPGLegi3Tz/xWzx Bf/2ZKssih18n8Noyq5abLh6umUhcwM757cPYUBsubzF0nmwKhfiM1uskICgDEvq0b80 kGMmiaEJ1ncQAu7B0aMd917WR614HgHFoUt82n9amnY5OPvf6OvpGL27O5RDnpr/1LI6 G1LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aO/OZ4zO5c+UReCZXfD9/ue3OlGDOu+K9xY/v16MWOM=; b=jqHFR2lfUWUB8L6pPFpUn74fS2T/OQjBwLB+mq6ynHZrAH4H7nquwHI2SdJ1vleQBb 7/YM+7PhaVThxVpNNue+iRG7564rwg0wWNqK7oWP3ID0CQUKZxmxM8DzYe2/U8kfCG6j zpv4ukCFHcvDaPhSNmEwIgDUpO8ft0gP+Y7/yuGZWOsspNcIk4hEb27KZz0vCNxnDwjk l6pLobSZmfiidFStYXuwY3N3ErE6V35IfcYqo/2MfW4Z+cGILngYq8RDLjN+1veuCaDp 3V3bvYDw/hIfWkg91rMNuXKBMTdxFcqquf7oJl+bOmsNYLP3li3igzeKhNEh6wB2UH67 tB6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Yjxx9s2k; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d16si5025366edc.45.2021.03.16.17.51.48; Tue, 16 Mar 2021 17:52:10 -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=@chromium.org header.s=google header.b=Yjxx9s2k; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229739AbhCQApp (ORCPT + 99 others); Tue, 16 Mar 2021 20:45:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbhCQApU (ORCPT ); Tue, 16 Mar 2021 20:45:20 -0400 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82EEAC06174A for ; Tue, 16 Mar 2021 17:45:20 -0700 (PDT) Received: by mail-qv1-xf34.google.com with SMTP id t16so602686qvr.12 for ; Tue, 16 Mar 2021 17:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aO/OZ4zO5c+UReCZXfD9/ue3OlGDOu+K9xY/v16MWOM=; b=Yjxx9s2kQ4DOhIjHj6+/pNSGqV161HlvXedt3ioyBFMJpaown9V/+E6jKZL9S8hlvD /g20NMV4xosL3HCIgWPtGpkvEXYezGYew1XCpu4lMFetz9DROLcwY0BqVdgEc/puWbj2 CSWigEl1OnH/gTE+ZVG39hnrhmWVqAbwq5ils= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aO/OZ4zO5c+UReCZXfD9/ue3OlGDOu+K9xY/v16MWOM=; b=tFkqu2ktiLd/QhZRy+UEFEtE4heasyerepZDtMuuhmCm7pus1RPsvbM9x17+712bTX 7NIC36/d/OTSy7VUJyubQdmqj1Ddw8K7HrLdStntYO2ydXcX6BYZqyljcerQw5d9s3R9 u/kPzfay7g/bBRp+syNQGSjKEZoBReKqVfpOYMRkisZQ/vAwO6fvBi/9x8aBfSdsnTrC l31GNl5oNy8xzsDaM5HWpmpiGVAftu3JJq7AqrkNtLcL+x48nWlyPfjgsQ5/ofARVJfE 2VY9WuW8vO1P67VHmT87EX/MFsdwKIz3AEE+wTb/MyhYLnFNS1luY/VpOx2dNolqHtte ZFFQ== X-Gm-Message-State: AOAM533dFISOiiDMFIIksP1qJwTdS38MZIehMcameBsxWwVnZAaYC9yT Jq0CnRDZFwFgVfo9zQbtAh+9BAgjMuSG2w== X-Received: by 2002:a05:6214:10c7:: with SMTP id r7mr2785614qvs.3.1615941914596; Tue, 16 Mar 2021 17:45:14 -0700 (PDT) Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com. [209.85.219.178]) by smtp.gmail.com with ESMTPSA id m25sm14320080qtq.59.2021.03.16.17.45.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Mar 2021 17:45:12 -0700 (PDT) Received: by mail-yb1-f178.google.com with SMTP id p186so38813706ybg.2 for ; Tue, 16 Mar 2021 17:45:12 -0700 (PDT) X-Received: by 2002:a25:1883:: with SMTP id 125mr1752626yby.465.1615941912101; Tue, 16 Mar 2021 17:45:12 -0700 (PDT) MIME-Version: 1.0 References: <20210304155144.1.Ic9c04f960190faad5290738b2a35d73661862735@changeid> <20210304155144.3.I60a7fb23ce4589006bc95c64ab8d15c74b876e68@changeid> In-Reply-To: From: Doug Anderson Date: Tue, 16 Mar 2021 17:44:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] drm/bridge: ti-sn65dsi86: Properly get the EDID, but only if refclk To: Laurent Pinchart Cc: Andrzej Hajda , Neil Armstrong , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Stephen Boyd , linux-arm-msm , Rob Clark , Daniel Vetter , David Airlie , dri-devel , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Mar 16, 2021 at 2:46 PM Laurent Pinchart wrote: > > Hi Doug, > > On Mon, Mar 15, 2021 at 09:25:37AM -0700, Doug Anderson wrote: > > On Sat, Mar 13, 2021 at 1:17 PM Laurent Pinchart wrote: > > > On Thu, Mar 04, 2021 at 03:52:01PM -0800, Douglas Anderson wrote: > > > > In commit 58074b08c04a ("drm/bridge: ti-sn65dsi86: Read EDID blob over > > > > DDC") we attempted to make the ti-sn65dsi86 bridge properly read the > > > > EDID from the panel. That commit kinda worked but it had some serious > > > > problems. > > > > > > > > The problems all stem from the fact that userspace wants to be able to > > > > read the EDID before it explicitly enables the panel. For eDP panels, > > > > though, we don't actually power the panel up until the pre-enable > > > > stage and the pre-enable call happens right before the enable call > > > > with no way to interject in-between. For eDP panels, you can't read > > > > the EDID until you power the panel. The result was that > > > > ti_sn_bridge_connector_get_modes() was always failing to read the EDID > > > > (falling back to what drm_panel_get_modes() returned) until _after_ > > > > the EDID was needed. > > > > > > > > To make it concrete, on my system I saw this happen: > > > > 1. We'd attach the bridge. > > > > 2. Userspace would ask for the EDID (several times). We'd try but fail > > > > to read the EDID over and over again and fall back to the hardcoded > > > > modes. > > > > 3. Userspace would decide on a mode based only on the hardcoded modes. > > > > 4. Userspace would ask to turn the panel on. > > > > 5. Userspace would (eventually) check the modes again (in Chrome OS > > > > this happens on the handoff from the boot splash screen to the > > > > browser). Now we'd read them properly and, if they were different, > > > > userspace would request to change the mode. > > > > > > > > The fact that userspace would always end up using the hardcoded modes > > > > at first significantly decreases the benefit of the EDID > > > > reading. Also: if the modes were even a tiny bit different we'd end up > > > > doing a wasteful modeset and at boot. > > > > > > s/and at/at/ ? > > > > Sure, I can correct if/when I respin or it can be corrected when landed. > > > > > > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > > > index 491c9c4f32d1..af3fb4657af6 100644 > > > > --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > > > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > > > @@ -16,6 +16,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > #include > > > > > > > > @@ -130,6 +131,12 @@ > > > > * @ln_assign: Value to program to the LN_ASSIGN register. > > > > * @ln_polrs: Value for the 4-bit LN_POLRS field of SN_ENH_FRAME_REG. > > > > * > > > > + * @pre_enabled_early: If true we did an early pre_enable at attach. > > > > + * @pre_enable_timeout_work: Delayed work to undo the pre_enable from attach > > > > + * if a normal pre_enable never came. > > > > > > Could we simplify this by using the runtime PM autosuspend feature ? The > > > configuration of the bridge would be moved from pre_enable to the PM > > > runtime resume handler, the clk_disable_unprepare() call moved from > > > post_disable to the runtime suspend handler, and the work queue replaced > > > by usage of pm_runtime_put_autosuspend(). > > > > It's an interesting idea but I don't think I can make it work, at > > least not in a generic enough way. Specifically we can also use this > > bridge chip as a generic GPIO provider in Linux. When someone asks us > > to read a GPIO then we have to power the bridge on > > (pm_runtime_get_sync()) and when someone asks us to configure a GPIO > > as an output then we actually leave the bridge powered until they stop > > requesting it as an output. At the moment the only user of this > > functionality (that I know of) is for the HPD pin on trogdor boards > > (long story about why we don't use the dedicated HPD) but the API > > supports using these GPIOs for anything and I've tested that it works. > > It wouldn't be great to have to keep the panel on in order to access > > the GPIOs. > > The issue you're trying to fix doesn't seem specific to this bridge, so > handling it in the bridge driver bothers me :-S Is there any way we > could handle this in the DRM core ? I don't want to see similar > implementations duplicated in all HDMI/DP bridges. Yes, it is true that this problem could affect other drivers. ...and in full disclosure I think there are other similar workarounds already present. I haven't personally worked on those chips, but in ps8640_bridge_get_edid() there is a somewhat similar workaround to chain a pre-enable (though maybe it's not quite as optimized?). I'm told that maybe something had to be handled for anx7625 (in anx7625_get_edid()?) but that definitely doesn't look at all like it's doing a pre-enable, so maybe things for that bridge just work differently. One thing that makes me hesitant about trying to moving this to the core is that even in sn65dsi86 there is a case where it won't work. As I mentioned in the patch I'm not aware of anyone using it in production, but if someone was using the MIPI clock as input to the bridge chip instead of a fixed "refclk" then trying to get the EDID after just "pre-enable" falls over. Said another way: I can say that with this particular bridge chip, if you're using a fixed refclk, you can read the EDID after the pre-enable. I don't know if that's always true with all other bridge chips. So I guess in summary: I think I could put my code in the core, but I don't _think_ I can just make it automatically enabled. * In sn65dsi I'd have to only enable it if we have a fixed refclk. * Maybe in ps8640 I could just always enable it and replace the existing code? I'd have to find someone to test. * In anx7625 things look totally different. Can you give me any advice on how you'd like me to proceed? -Doug