Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4375370pxu; Wed, 9 Dec 2020 15:52:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKKo2qmvB3oHt0K3xEXvKBMyyeRD4j01i6JfSowKXUNn9VcJXnbP0L6JNeVqEp6nbM6jRK X-Received: by 2002:aa7:df91:: with SMTP id b17mr4380958edy.272.1607557924432; Wed, 09 Dec 2020 15:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607557924; cv=none; d=google.com; s=arc-20160816; b=hQfzVPIz2g/lpg3unncJRq9oiYKZeDjVu8pDqwxdyIebBIpgDCBWFsviR8wJWqlJQI yrzoc1eBurPRNd1n/igQXJFkcc2fwZFpwhrCM7ejlGvTBaFAuBr4UL6JexADlaRbqBt4 Xb8qlPF43Xl54xwQxV5Aq3j66TYLAHK/8dZyX5XeFoBRE8LQ7NMaZrxs2en5Qo5BGpQX AaZRFM3/9DW4lTDeEVt4JJhJlkf48h8RPgYZ8bK1NifGBra4+jonFJ511I0xcCf14BjH C2c1eNh87BV3kkpsvwmas/cprOri0oM0RUTN+fv1xtLoHJ5w5LbQzcRsN5k3nM0+CJNY tVkw== 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:to:from:date:dkim-signature; bh=a9oodgx96dNE52G7HAnQoVS4BjUM+0QDI3RZyqRo6JQ=; b=kTefvPa2lpohYv1VFktVkD1AFfPhz/XioaTarejUEEXmaGRKHkr2Vnx944qwWjsTmn aM9GTvG+ubUxdB6VBR2H/FATnost5XKMQ67stWDk/g4M89wsyfSH4WOBIQ5G/pRVmRdx WV19DPDC8+Q7G8eZh8Py2ST5Ul3617lZS1yKBKxR77OlGTY1cfOgUVdgaltTpOJM3pwf 4AW0IpojA8DNyQQk9oIjvpRi/LKBHk3P7MrHBPJdrYbtF5S2Z0vC7V+Fyu3pEum+chmy nAS7eYkX6Q9iT2wJC1adEzq3LMKOVZr0jHkS7gs4c5qkHREQXN1H+CKg+Qfg4LJZpXlo 1Wfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W187LOtE; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si1805612edv.359.2020.12.09.15.51.41; Wed, 09 Dec 2020 15:52:04 -0800 (PST) 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=@linaro.org header.s=google header.b=W187LOtE; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387764AbgLIU3c (ORCPT + 99 others); Wed, 9 Dec 2020 15:29:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387727AbgLIU3C (ORCPT ); Wed, 9 Dec 2020 15:29:02 -0500 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87255C061793 for ; Wed, 9 Dec 2020 12:28:22 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id a109so2713599otc.1 for ; Wed, 09 Dec 2020 12:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=a9oodgx96dNE52G7HAnQoVS4BjUM+0QDI3RZyqRo6JQ=; b=W187LOtE+RHCqwlNXiHpy3CdUMT0GCU02YuJP39fNyxI/tNje4TnbFUawd0jTYkIFp bvmiDH0g4Z1jTfGgO1/kDzoz4xo5kX1ihX+UkO4XXeM3i8uuvVBWJYEiQn5fu2gbv4vw tIBMKUE10LuxhfE66JpOXlBAgfjzdxnS+Ooc9+PgfQprLX0pxAO48amtyIsjatHaHhcg 7gHHR4Cf3bRnBtKeg9+XZlBJK0bmI9CBvl49EUvxStFBCeqtujaiNHbqLnEZ4ejexuac 7dBhOLXaKTbO5RsEMhpI+VjDoo2kTkuII3x9xN54G7gSd+inXFdI44wUQA+pE6GVTLPG aiGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=a9oodgx96dNE52G7HAnQoVS4BjUM+0QDI3RZyqRo6JQ=; b=AYLIy1dzJabX1OfBhw9665B22VnQplqBP003Z5nue+IJca7BtCjbsuhoEQYNumwp/d QIMTMkoVakzH1w1H1f5dC/AJS3Krl4FMUz7KnwBjwxSTgaAknXcZdcKQvwWUZjzrJNx9 QoHa/yQxfgi5GbB5EqYzVGG72N+4IIHGm2SP6ZeXAUDnclUE+dCFeA82MadcyMc3AM5C 1fJhVphD+qX3cF1D6MmwoNRnGdeehsdJ6rIpcha91MZUzPjfLsAOVGUhQzARMQ7pbJLP kaSdAOkCAfviD4sYQ6UDpMZVMUUiBDQX6S3QAG/3b47rvaiYcESEPiFHvyEYBLZQIukH IQ/A== X-Gm-Message-State: AOAM530ydkTMalkHrnY/QEAtt+hsPCgNvVOyIwvuCckWA75c9qKSoof2 mcTb8X7lF2q2hvQ1YKduVO4ECg== X-Received: by 2002:a05:6830:1c62:: with SMTP id s2mr3364351otg.177.1607545701571; Wed, 09 Dec 2020 12:28:21 -0800 (PST) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id y10sm601332ota.42.2020.12.09.12.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 12:28:20 -0800 (PST) Date: Wed, 9 Dec 2020 14:28:18 -0600 From: Bjorn Andersson To: Thierry Reding , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] drm/panel: Make backlight attachment lazy Message-ID: References: <20201208044446.973238-1-bjorn.andersson@linaro.org> <20201208235249.GD401619@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201208235249.GD401619@phenom.ffwll.local> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 08 Dec 17:52 CST 2020, Daniel Vetter wrote: > On Tue, Dec 08, 2020 at 04:02:16PM -0600, Bjorn Andersson wrote: > > On Tue 08 Dec 06:47 CST 2020, Thierry Reding wrote: > > > > > On Mon, Dec 07, 2020 at 10:44:46PM -0600, Bjorn Andersson wrote: > > > > Some bridge chips, such as the TI SN65DSI86 DSI/eDP bridge, provides > > > > means of generating a PWM signal for backlight control of the attached > > > > panel. The provided PWM chip is typically controlled by the > > > > pwm-backlight driver, which if tied to the panel will provide DPMS. > > > > > > > > But with the current implementation the panel will refuse to probe > > > > because the bridge driver has yet to probe and register the PWM chip, > > > > and the bridge driver will refuse to probe because it's unable to find > > > > the panel. > > > > > > What you're describing is basically a circular dependency. Can't we get > > > rid of that in some other way? Why exactly does the bridge driver refuse > > > to probe if the panel can't be found? > > > > > > In other words, I see how the bridge would /use/ the panel in that it > > > forward a video stream to it. But how does the panel /use/ the bridge? > > > > > > > Yes, this is indeed a circular dependency between the components. > > > > The involved parts are: > > * the bridge driver that implements the PWM chip probe defers on > > drm_of_find_panel_or_bridge() failing to find the panel. > > * the pwm-backlight driver that consumes the PWM channel probe defer > > because the pwm_chip was not registered by the bridge. > > * the panel that uses the backlight for DPMS purposes probe defer > > because drm_panel_of_backlight() fails to find the pwm-backlight. > > > > I looked at means of postponing drm_of_find_panel_or_bridge() to > > drm_bridge_funcs->attach(), but at that time "deferral" would be fatal. > > I looked at registering the pwm_chip earlier, but that would depend on a > > guarantee of the pwm-backlight and panel driver to probe concurrently. > > And the current solution of not tying the backlight to the panel means > > that when userspace decides to DPMS the display the backlight stays on. > > > > > > The proposed solution (hack?) means that DPMS operations happening > > before the pwm-backlight has probed will be missed, so it's not perfect. > > It does however allow the backlight on my laptop to turn off, which is a > > big improvement. > > > > But I'm certainly welcome to suggestions. > > Entirely hand-waving, why doesn't the following work: > > 1. driver for the platform device which is the bridge loads > 2. that platform driver registers the pwm > 3. it registers some magic for later on (more below) > 4. panel driver has deferred loading until step 2 happened > 5. panel driver registers drm_panel > 6. the magic from step 3 picks up (after having been deferred for a few > times probably) grabs the panel, and sets up the actual drm_bridge driver > > Everyone happy, or not? From the description it looks like the problem > that the pwm that we need for the backlight is tied to the same driver as > the drm_bridge, and always torn down too if the drm_bridge setup fails > somehow for a reason. And that reason is the circular dependency this > creates. > > Now for the magic in step 3, there's options: > - change DT to split out that pwm as a separate platform_device, that way > bridge and panel can load indepedently (hopefully) > This is an i2c device, so describing it multiple times would mean we have multiple devices with the same address... > - convert bridge to a multi-function device (mfd), essentially a way to > instantiate more devices with their drivers at runtime. Then the actual > pwm and drm_bridge parts of your bridge driver bind against those > sub-functions, and can defer indepedently > But, this sounds reasonable and would rely on the existing probe deferral logic and if there's ever any improvements in this area we would directly benefit from it. > - we could create a callback/wait function for "pls wait for any panel to > show up". Then your bridge driver could launch a work_struct with that > wait function, which will do the bridge setup once the panel has shown > up. The pwm will be registered right away. It's essentially hand-rolling > EPROBE_DEFERRED for work_struct in drm/panel. Maybe we might even have > that exported from the driver core, e.g. > > register_bridge_fn(struct work *) > { > do_wait_probe_defer(); > panel = drm_of_find_panel_or_bridge(); > if (!panel) { > schedule_work(); /* want to restart the work so it can be stopped on driver unload */ > return; > } > > /* we have the panel now, register drm_bridge */ > } > > - cobble something together with component.c, but that's more for > collecting unrelated struct device into a logical one than splitting it > up more. > > tldr; I think you can split this loop here at the bridge by untangling the > pwm from the drm_bridge part sufficiently. Yes, it seems like a reasonable path forward. But I wanted some input before refactoring the whole thing. Thank you, Bjorn