Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp520313lqp; Wed, 12 Jun 2024 08:22:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUp5j7jKQvyIvSfHuvceisymTUNQSYsqdcorGMr2mfFLH217z4L4ROJXqlCQuxwrxndSnEkphlhb0hXIXx+WvuMPv/gGdht219H7fJzA== X-Google-Smtp-Source: AGHT+IHqBZumCKb99COQISCeTJNjPfYIDOPDmRrEH7L2scGHZKOXEBbDejIhecuGJha8CYpNjKQ0 X-Received: by 2002:a17:90b:3c86:b0:2c1:a9d5:9b58 with SMTP id 98e67ed59e1d1-2c4a7601d99mr2136324a91.1.1718205725910; Wed, 12 Jun 2024 08:22:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718205725; cv=pass; d=google.com; s=arc-20160816; b=EffiXO5j1lA8TOR72kq/0fng1DSE5GJdCgn23p+QC50dPzVrc2U/C2qLDiKzbGwqGO YWalVj4kyWgo9uKj0xJXF25QgVr5iXTihjRUqdWYrqa/OMjloqnoKoVbeC3CezIRDd9v XUs5lI9jxNbjPelLYvqEpOA1T0L1uhCUJi0sqi0ap9HyWt8yoUZIbNcwLZ2LRcj1Y0vy lRgsscpCY8V3xzRRDgqbxM+u4EsmoHMgYthmsys9zqemUFy8EGNrDx7GO6bX7iB2y/tg s4Yb+qhpaoXX3m32o0aZWpgplgt4K3qtdBMByiqSIeAbHCNvE3wHeOOjDQnXcnjt61Ak 7bzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qdGEOzvxfhfIOFzZL64lYkKwSW3OPH+zys3vEXflbfg=; fh=/zz2vb9BVs68/mCOZJvvUv+SjKfMjAoZVtvivX/VVz0=; b=iW9k/zoSC8qU2TKYjcmfgMSP9CQ89x5BSlhYy600UGNvJgpCgxCOl9LUaFRzsq2BU7 u8IgUrnzFy9xfAe0UtHmswMJPRbqtf0JtDLRvyTlKZk2t1YtPFs8zjf5iFqy3Txtnv9P 9dOdhQFbtzLTBTya8PptqucPeal09gYb+IFUd0ZfWpMb3yn/LT0l/HNnP4xlXtq8NgUN c2dJQx40qT1K3Yd3lq5btPEDKaM5RAdiS5jBNUxZwMp9AmP8zYSmC1CpIgq3LM1PzZP+ TpxKfh+kbNE2AlIibEhVmq3Xwp8K6OsYzYNTYEycxfYXcD9d7dPc8U3WrSwbF171mR24 kX9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eGFxis70; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-211737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211737-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a76a5fa7si1714220a91.113.2024.06.12.08.22.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 08:22:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eGFxis70; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-211737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211737-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 60B23B221F1 for ; Wed, 12 Jun 2024 15:03:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1924F17FAA4; Wed, 12 Jun 2024 15:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eGFxis70" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2235317E90A for ; Wed, 12 Jun 2024 15:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204619; cv=none; b=I7So89EIwRAaraYFb2j8cKrq8/i3iAmMaRxaJBwp64asIaHTv6HDG61JQrSiBcmUk/sTD3j02/1F/3PVhTvmOkyg6/y/1yrc+BfAWRbuICCZiA6gx7OOrqbR76i57XFbwhqfck4a4sK4fNU1j8DVz/zOP/vCC7ZLf/hHcYjK+zc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204619; c=relaxed/simple; bh=706WUpcGbq+NDKSXOY/snfZFRh0zufY4LPNdKjpG+NA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=keNuHTKpuozJSUnxqbLdxC+4EyiiesIGLbzjE+JbX2yRSc0VhGnK4gRSb0RC+aaRV6Vt2SiLO9WThnWUMhH4DPk0qXpHpvOVbw/cy/jNf3Vz1sSheXvhu8Eg2Ef2yYPa4Botx/+tcMcBfmjXWwPGYvBaUWPk3MZBQ2c+gPooO9c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eGFxis70; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E32EC3277B; Wed, 12 Jun 2024 15:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718204618; bh=706WUpcGbq+NDKSXOY/snfZFRh0zufY4LPNdKjpG+NA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eGFxis70Mun2y8XB/lI8sWhk6hZyARQ21lXe3kGBkJx8uU6G9AfYakGRVKzAsO/Dr S8AQ84rVedE+4JUcsLy7ja5o42ECjsyFTqEsifadHO833jekYfbQNwDhmtVOHKXIpm L4vJWvdNwobNw3SuN41cgFsxwTptYpnZx3Dw4oS7RZFt8/C/oWWzJ3OXsXHaokTzzj QXyYwsFO1LTW5QwAKbt+dZKM94mgL2ocOf98z7dwmOTU9FodfvzFxArK2JLchaRK/P 0Hor4su3LMhL92z2CfZUUKkpNlxYA+uezHBRQIa9HHnN6L5wuh9XfwtVIdzFPuxbtk A9NTkuKoGi5Dg== Date: Wed, 12 Jun 2024 17:03:34 +0200 From: Maxime Ripard To: Doug Anderson Cc: dri-devel@lists.freedesktop.org, Neil Armstrong , Linus Walleij , Yuran Pereira , Chris Morgan , David Airlie , Jessica Zhang , Maarten Lankhorst , Thomas Zimmermann , linux-kernel@vger.kernel.org, Daniel Vetter Subject: Re: [PATCH] drm/panel: Avoid warnings w/ panel-simple/panel-edp at shutdown Message-ID: <20240612-lean-intrepid-sponge-bb30e6@houat> References: <20240611074846.1.Ieb287c2c3ee3f6d3b0d5f49b29f746b93621749c@changeid> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fib2hj3isyom324o" Content-Disposition: inline In-Reply-To: --fib2hj3isyom324o Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 12, 2024 at 07:49:31AM GMT, Doug Anderson wrote: > Hi, >=20 > On Wed, Jun 12, 2024 at 1:58=E2=80=AFAM Daniel Vetter w= rote: > > > > On Tue, Jun 11, 2024 at 07:48:51AM -0700, Douglas Anderson wrote: > > > At shutdown if you've got a _properly_ coded DRM modeset driver then > > > you'll get these two warnings at shutdown time: > > > > > > Skipping disable of already disabled panel > > > Skipping unprepare of already unprepared panel > > > > > > These warnings are ugly and sound concerning, but they're actually a > > > sign of a properly working system. That's not great. > > > > > > It's not easy to get rid of these warnings. Until we know that all DRM > > > modeset drivers used with panel-simple and panel-edp are properly > > > calling drm_atomic_helper_shutdown() or drm_helper_force_disable_all() > > > then the panel drivers _need_ to disable/unprepare themselves in order > > > to power off the panel cleanly. However, there are lots of DRM modeset > > > drivers used with panel-edp and panel-simple and it's hard to know > > > when we've got them all. Since the warning happens only on the drivers > > > that _are_ updated there's nothing to encourage broken DRM modeset > > > drivers to get fixed. > > > > > > In order to flip the warning to the proper place, we need to know > > > which modeset drivers are going to shutdown properly. Though ugly, do > > > this by creating a list of everyone that shuts down properly. This > > > allows us to generate a warning for the correct case and also lets us > > > get rid of the warning for drivers that are shutting down properly. > > > > > > Maintaining this list is ugly, but the idea is that it's only short > > > term. Once everyone is converted we can delete the list and call it > > > done. The list is ugly enough and adding to it is annoying enough that > > > people should push to make this happen. > > > > > > Implement this all in a shared "header" file included by the two panel > > > drivers that need it. This avoids us adding an new exports while still > > > allowing the panel drivers to be modules. The code waste should be > > > small and, as per above, the whole solution is temporary. > > > > > > Signed-off-by: Douglas Anderson > > > --- > > > I came up with this idea to help us move forward since otherwise I > > > couldn't see how we were ever going to fix panel-simple and panel-edp > > > since they're used by so many DRM Modeset drivers. It's a bit ugly but > > > I don't hate it. What do others think? > > > > I think it's terrible :-) >=20 > Well, we're in agreement. It is terrible. However, in my opinion it's > still a reasonable way to move forward. >=20 >=20 > > Why does something like this now work? > > > > drm_panel_shutdown_fixup(panel) > > { > > /* if you get warnings here, fix your main drm driver to call > > * drm_atomic_helper_shutdown() > > */ > > if (WARN_ON(panel->enabled)) > > drm_panel_disable(panel); > > > > if (WARN_ON(panel->prepared)) > > drm_panel_unprepare(panel); > > } > > > > And then call that little helper in the relevant panel drivers? Also fe= el > > free to bikeshed the name and maybe put a more lengthly explainer into = the > > kerneldoc for that ... > > > > Or am I completely missing the point here? >=20 > The problem is that the ordering is wrong, I think. Even if the OS was > calling driver shutdown functions in the perfect order (which I'm not > convinced about since panels aren't always child "struct device"s of > the DRM device), the OS should be calling panel shutdown _before_ > shutting down the DRM device. That means that with your suggestion: >=20 > 1. Shutdown starts and panel is on. >=20 > 2. OS calls panel shutdown call, which prints warnings because panel > is still on. >=20 > 3. OS calls DRM driver shutdown call, which prints warnings because > someone else turned the panel off. >=20 > :-P >=20 > Certainly if I goofed and the above is wrong then let me know--I did > my experiments on this many months ago and didn't try repeating them > again now. >=20 > In any case, the only way I could figure out around this was some sort > of list. As mentioned in the commit message, it's super ugly and > intended to be temporary. Once we solve all the current in-tree > drivers, I'd imagine that long term for new DRM drivers this kind of > thing would be discovered during bringup of new boards. Usually during > bringup of new boards EEs measure timing signals and complain if > they're not right. If some EE cared and said we weren't disabling the > panel correctly at shutdown time then we'd know there was a problem. Based on a discussion we had today With Sima on IRC, I think there's another way forward. We were actually discussing refcount'ing the panels to avoid lifetime issues. It would require some API overhaul to have a function to allocate the drm_panel structure and init'ing the refcount, plus some to get / put the references. Having this refcount would mean that we also get a release function now, called when the panel is free'd. Could we warn if the panel is still prepared/enabled and is about to be freed? It would require to switch panel-simple and panel-edp to that new API, but it should be easy enough. Maxime --fib2hj3isyom324o Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZmm4xgAKCRDj7w1vZxhR xV9DAP97um/MW9/cNpVyoRNyslgtaVeJw0pCd1ceNf4lsZolEgD/drvM2ZaMe2h0 86o1GqmQAJE1yfQ5yawsYLcaptlDIgY= =Clr1 -----END PGP SIGNATURE----- --fib2hj3isyom324o--