Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp945074rdb; Fri, 1 Sep 2023 08:22:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMHsUliGrySYF6MbiYqvGtJ8vqzeMR+4Fr3ReT71Cs3JPyLwA+kcFsfxVDB4S8/VTWAu6N X-Received: by 2002:a17:907:77d3:b0:9a1:fbfb:4d11 with SMTP id kz19-20020a17090777d300b009a1fbfb4d11mr2186607ejc.73.1693581763601; Fri, 01 Sep 2023 08:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693581763; cv=none; d=google.com; s=arc-20160816; b=Gl1SDzGVWB+fcFZLLLtSdiuYF+fZl6ngGzz0Iw+vaAv+AKOgpo/VDTkdncxSFTcbfl 1s5Ad4SbFdQJyzvF0mKjcTZU6X7fgU5izL8KXelXDVtw5YhyUV8ch8jZ1mYD2tLmlwes Ka/naJY6+4gUQMK7ZC3NsL1vkyMoaVNuja5G1GWqtfvTrXykfGeTy061dwC05hr9f0kt rDeyQzuO1KmqDUSKnIzg+gM0jzSBb2tKdnkhOh/FBKDWgI3Hi7Kxi2o+dMFTW4Ets0Zt sFUXNmfyzdSNaec+8abL78YhsJa2RSK0N2AUKFgAPsCkFK01Uqhlnd8oJTiHdvIjCDjf +gSg== 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=0xWWxQ1wnsRGr2NxhIuXiGw5f1zLQdlYjm7eA1DDvEs=; fh=GkaHvC1hcueeMsWD1eEyL8PgTf7zKZ7NUy+EoZl0FP8=; b=GwY/ASaL/p73zed3ykue0RnqYoDBwa8Oipfdx3b64FUxlnzYlOeRvZ3lKpmANkvWvN tFK5iJPjYRorukhAzgxKtchz3PxNPwRVUf/iukW6+IgrS8hmJ49ryuqlXp4n1sIw07Pb TX9Y5Xld+7CXubBK90YLuBRZjlYSid2u0w4uYmcqMoj+a9kWqKTSZIhdUzONpnY2Pq/X O75eOCCUH6eOUSmo0V8qSjKNEoL5jjjdApvTKJ2Mrf0Yk1wfB6V00bTCjUvXGch9NbXQ kjD4gWSqz82HhvypCO0glIJZeoESUPgetovhISfoRWmx3uXY1WzypEN7D+Z71K4yhlEo 3t5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NeaTE4bw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a170906830500b0099bca0c5445si2421160ejx.363.2023.09.01.08.22.08; Fri, 01 Sep 2023 08:22:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NeaTE4bw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbjIAIPl (ORCPT + 99 others); Fri, 1 Sep 2023 04:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjIAIPk (ORCPT ); Fri, 1 Sep 2023 04:15:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 685BD8F for ; Fri, 1 Sep 2023 01:15:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 081A8B8215C for ; Fri, 1 Sep 2023 08:15:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ACBAC433C8; Fri, 1 Sep 2023 08:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693556134; bh=2wB7L2T/6gucMGBa8qwYTbhct0FtefKhC6NitCO5nSU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NeaTE4bwRfJq2L/Udjecu/an4nn0RHJ/41pv7GjnoPHueOWcGZ8Ai8srAevHqwCPC pYwNzAiCPL37qwBoxFyb0TV5ee50TMe/8nkaDfHhjQtrlsad+a4EAgn/92eegbLIAc aFhUgjtftnM7Lm4sn+5y4LlfoRdoFBOQO9RRN7vtNkM45D7dg056iCbVXKCPmagKdF QvPnxr5tNfvjKEdv1kS768E2jsGZccLNuir9Uv5XIvZzj9lma2v1biVG0nuqANG/f8 XQe6l/2utAmUgGV6eChzWYHeWhXzuMox6EaLIjJQ8JyMtPpL5RwGlPLu8Az5DhZKif bY5x7lRhTjfmQ== Date: Fri, 1 Sep 2023 10:15:31 +0200 From: Maxime Ripard To: Doug Anderson Cc: dri-devel@lists.freedesktop.org, Linus Walleij , Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 04/10] drm/panel_helper: Introduce drm_panel_helper Message-ID: References: <20230804210644.1862287-1-dianders@chromium.org> <20230804140605.RFC.4.I930069a32baab6faf46d6b234f89613b5cec0f14@changeid> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yow5sxzddb743r2y" Content-Disposition: inline In-Reply-To: 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 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 --yow5sxzddb743r2y Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 31, 2023 at 11:18:49AM -0700, Doug Anderson wrote: > Hi, >=20 > On Thu, Aug 31, 2023 at 12:38=E2=80=AFAM Maxime Ripard wrote: > > > > If so, then I think we can implement everything by doing something like: > > > > - Implement enable and disable refcounting in panels. > > drm_panel_prepare and drm_panel_enable would increase it, > > drm_panel_unprepare and drm_panel_disable would decrease it. > > > > - Only actually call the disable and unprepare functions when that > > refcount goes to 0 in the normal case. >=20 > Just to be clear: by refcounting do you mean switching this to actual > refcount? Yes > Today this is explicitly _not_ refcounting, right? It is simply > treating double-enables as no-ops and double-disables as no-ops. With > our current understanding, the only thing we actually need to guard > against is double-disable but at the moment we do guard against both. > Specifically we believe the cases that are issues: >=20 > a) At shutdown/remove time we want to disable the panel, but only if > it was enabled (we wouldn't want to call disable if the panel was > already off because userspace turned it off). Yeah, and that's doable with refcounting too. > b) At shutdown time we want to disable the panel but then we don't > want to double-disable if the main DRM driver also causes us to get > disabled. That's what I want to prevent though. Eventually, I don't want to see panels call drm_panel_unprepare/disable themselves. There's no need to if all drivers implement the shutdown sequence properly. > I'd rather keep it the way it is (prevent double-disable) and not > switch it to a refcount. > > I'll also note that drm_panel currently already keeps track of the > enabled/prepared state, so there's no "implement" step here, right? > That's what landed in commit d2aacaf07395 ("drm/panel: Check for > already prepared/enabled in drm_panel"). Just to remind ourselves of > the history: >=20 > 1. I needed to keep track of the "prepared" state anyway to make the > "panel follower" API work properly. See drm_panel_add_follower() where > we immediately power on a follower if the panel they're following was > already prepared. >=20 > 2. Since I was keeping track of the "prepared" state in the core > anyway, it seemed like a good idea to prevent > double-prepare/unprepare/enable/disable in the drm_panel core so that > we could remove it from individual panels since that was always a > point of contention in individual panels. It was asserted that, even > in the core, we shouldn't need code to prevent > double-prepare/unprepare/enable/disable but that as a first step > moving this to the core and out of drivers made sense. Anyone relying > on the core would get a warning printed out indicating that they were > doing something wrong and this would eventually move to a WARN_ON. >=20 > 3. While trying to remove this from the drivers we ended up realizing > some of the issues with panels wanting to power them off at shutdown / > remove time. Yes, I'm aware. It's not clear to me what you're confused about though. Is there anything I said that would conflict with that? > > - In drm_panel_remove, if we still have a refcount > 0, then we WARN > > and force unprepare/disable the panel. >=20 > I think the net-net of this is that you're saying I should fold the > code from this patch straight into drm_panel_remove() and add a WARN > if it ever triggers, right? Aside from the refcounting-or-not discussion, yes. > In this patch series I'd remove the calls to > drm_panel_helper_shutdown() and rely on drm_panel_remove() to do the > power off at remove time. Yep > This might give a warning but, as discussed, removing a panel like > this isn't likely to work well and at least we'd power sequence it > properly. In some cases, I might have to move the call to > drm_panel_remove() around a little bit but I think it'll work. Yep > The above solves the problem with panels wanting to power sequence > themselves at remove() time, but not at shutdown() time. Thus we'd > still have a dependency on having all drivers use > drm_atomic_helper_shutdown() so that work becomes a dependency. Does it? I think it can be done in parallel? Maxime --yow5sxzddb743r2y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZPGdowAKCRDj7w1vZxhR xemMAQCjvWUe0LrT48END3QeEh8MVtJxWru6mnbP2BMN7WfgJwEA2BWDtuKGI3wD fMqBPs+WoAgCGBEDFeSAav5VDruM8QE= =3BUN -----END PGP SIGNATURE----- --yow5sxzddb743r2y--