Message ID | 20230804140605.RFC.4.I930069a32baab6faf46d6b234f89613b5cec0f14@changeid |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp142154vqr; Fri, 4 Aug 2023 15:44:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKqrV7KeUQyrvzCMV8xL9dasbaomBWSCgoGZvMV7fVUhZ+z9SGqV5cJdZjQsuegcgD5vm/ X-Received: by 2002:aa7:c383:0:b0:522:219b:ce05 with SMTP id k3-20020aa7c383000000b00522219bce05mr2860697edq.7.1691189078306; Fri, 04 Aug 2023 15:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691189078; cv=none; d=google.com; s=arc-20160816; b=kTJjMaApqR8yXB+ZkfyIVbtRbIwUSln7qEAbI+17Um6w2msD8Xla7n29Qot9fFirYy iIZiugf1EzUMuyldlaUgWlRbay3kOhhLJl2PJ0FO4jz+DtlH/x8qpRdNGXzcfS6A5KNG 8/z63ZrP74UmzgrPP1n8iA+R2A7NrxDRwUSbkxDhEJYlqHOGgYUkuwXgPyIyE9p+W6Nj uLS4FeOhsFt6XQU3wF4BZt11x64D/8Ak5QCh1WsT7O+kwnCjTh+dyhIwb/hayfFpp+iw V3oW2S1K/JvE06cLgLHRFrznlScMi2kM1OT1s2c94x7CiEKR11Lz/rFbMKIBcR0ea+zq tx/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OgZd04X0Jnac/fFUkos5qfSoj7pVaTLYh5udS8UWgcQ=; fh=YQkvLGSH2rMOvm7jeVZBE4fYFAuT8AmzBDO5AKFTYyM=; b=k0leOn8ypgSppBBt8dhjZI/jz3DYO/2151iUM/E/Xy+AnaCaTYQ6YfP7X1hvd1vuvf jvkJdMj23smtTGJa1OaiYOwYYmHKeg6eHHBMOF8ZxrC0gJjzxwGpQgLTW0EfgSKn9UG6 eO69ZM2K8LPQL/giEM1wXE09KQnqN9DlU7XGynEqa24KTy+H6FOhC/8gLAG9c+24Q5oc uY9A/P+Ud0XgG84m1gZBS+xdyywRZy99a72bfwFlKeUxwNpiPlqoK3PZEXiir1M8bw3f JRZW8f6UxYe41exKiYt2Qkt/nYVwtzFAkjArEfhcsLj7yXHBDOQW2G0Pbk7c2Ml8f9np mAnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dWh3dGKd; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020aa7d6d0000000b0052231491597si2344198edr.677.2023.08.04.15.44.15; Fri, 04 Aug 2023 15:44:38 -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=@chromium.org header.s=google header.b=dWh3dGKd; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230464AbjHDVIc (ORCPT <rfc822;wenzhi022@gmail.com> + 99 others); Fri, 4 Aug 2023 17:08:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231172AbjHDVIK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 4 Aug 2023 17:08:10 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FFF6E46 for <linux-kernel@vger.kernel.org>; Fri, 4 Aug 2023 14:07:22 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-686be3cbea0so2475633b3a.0 for <linux-kernel@vger.kernel.org>; Fri, 04 Aug 2023 14:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691183241; x=1691788041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OgZd04X0Jnac/fFUkos5qfSoj7pVaTLYh5udS8UWgcQ=; b=dWh3dGKdYpdYdRJj8hocS/Jx852k0NaOXKh3si1et2/K0fsZUcbFeMkfTyTNYq5AhB cJNWWInbDx8vJsvS+phmgohWTE73bsjN/5Z80kAS0A//0yp2Xzm9tudwtnQygKNbWH95 K/Xrfpa2vyLkXmYwfbCkA4JEa0g85HOvBrD4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691183241; x=1691788041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OgZd04X0Jnac/fFUkos5qfSoj7pVaTLYh5udS8UWgcQ=; b=OmAmtqvNvR/XqDBsJY1n9rwemQ0Y00W9q2304Il+9wvyC+7dDRJk/fOtO6vrG8AnM+ DMYYyjY+tR04GDTVO58QAFiaJHTf4KXfkr8OeJ6F/9V7/sIo99WUZ/yQ9LYfZupdfBqR K9/g99zOHHpWFo158/M1AxUyQdJJD4999L/aVfENTvsTXBl1k8/361zU4qseakR4nZ9N V1YjaLWjtQclxlObTMRuHL/nM0aD4VK2EidnHLjb5Tz0Y1HfU8mTklrxKFTYft1dvXmJ siwKanZ0unGHQPeMRtE6fdK4YDsjSx9AcwGw+PZwF94kNai3Qq7gEaDUr2fMEOBGvPw3 Xv3g== X-Gm-Message-State: AOJu0Yy00rydpNfkHhlJEEaszQUYFbG9w7u0e/0spXj+n2jQOPVM+bKd 0tP3yHCl5lROQPuLboQ1M8OxrA== X-Received: by 2002:a05:6a20:548e:b0:127:72c3:6428 with SMTP id i14-20020a056a20548e00b0012772c36428mr1108268pzk.18.1691183240969; Fri, 04 Aug 2023 14:07:20 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:e186:e5d2:e60:bad3]) by smtp.gmail.com with ESMTPSA id n22-20020aa78a56000000b0068664ace38asm2037584pfa.19.2023.08.04.14.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 14:07:20 -0700 (PDT) From: Douglas Anderson <dianders@chromium.org> To: dri-devel@lists.freedesktop.org, Maxime Ripard <mripard@kernel.org> Cc: Linus Walleij <linus.walleij@linaro.org>, Douglas Anderson <dianders@chromium.org>, Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Thomas Zimmermann <tzimmermann@suse.de>, linux-kernel@vger.kernel.org Subject: [RFC PATCH 04/10] drm/panel_helper: Introduce drm_panel_helper Date: Fri, 4 Aug 2023 14:06:07 -0700 Message-ID: <20230804140605.RFC.4.I930069a32baab6faf46d6b234f89613b5cec0f14@changeid> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog In-Reply-To: <20230804210644.1862287-1-dianders@chromium.org> References: <20230804210644.1862287-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773340278766442691 X-GMAIL-MSGID: 1773340278766442691 |
Series |
drm/panel: Remove most store/double-check of prepared/enabled state
|
|
Commit Message
Doug Anderson
Aug. 4, 2023, 9:06 p.m. UTC
The goal of this file is to contain helper functions for panel drivers
to use. To start off with, let's add drm_panel_helper_shutdown() for
use by panels that want to make sure they're powered off at
shutdown/remove time if they happen to be powered on.
The main goal of introducting this function is so that panel drivers
don't need to track the enabled/prepared state themselves.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
If I've misunderstood and the drm_panel_helper_shutdown() should
belong in some other file and we don't need to introduce a "helper"
for this then please le me know.
drivers/gpu/drm/Makefile | 1 +
drivers/gpu/drm/drm_panel_helper.c | 37 ++++++++++++++++++++++++++++++
include/drm/drm_panel_helper.h | 13 +++++++++++
3 files changed, 51 insertions(+)
create mode 100644 drivers/gpu/drm/drm_panel_helper.c
create mode 100644 include/drm/drm_panel_helper.h
Comments
Hi Doug, Thanks for working on this :) On Fri, Aug 04, 2023 at 02:06:07PM -0700, Douglas Anderson wrote: > The goal of this file is to contain helper functions for panel drivers > to use. To start off with, let's add drm_panel_helper_shutdown() for > use by panels that want to make sure they're powered off at > shutdown/remove time if they happen to be powered on. > > The main goal of introducting this function is so that panel drivers > don't need to track the enabled/prepared state themselves. > > Signed-off-by: Douglas Anderson <dianders@chromium.org> It shouldn't be necessary at all: drivers should call drm_atomic_helper_shutdown at removal time which will disable the connector (which in turn should unprepare/disable its panel). If either the driver is missing drm_atomic_helper_shutdown, or if the connector doesn't properly disable the panel, then I would consider that a bug. Maxime
On Fri, Aug 25, 2023 at 02:58:02PM -0700, Doug Anderson wrote: > Maxime, > > On Sun, Aug 6, 2023 at 11:41 PM Maxime Ripard <mripard@kernel.org> wrote: > > > > Hi Doug, > > > > Thanks for working on this :) > > > > On Fri, Aug 04, 2023 at 02:06:07PM -0700, Douglas Anderson wrote: > > > The goal of this file is to contain helper functions for panel drivers > > > to use. To start off with, let's add drm_panel_helper_shutdown() for > > > use by panels that want to make sure they're powered off at > > > shutdown/remove time if they happen to be powered on. > > > > > > The main goal of introducting this function is so that panel drivers > > > don't need to track the enabled/prepared state themselves. > > > > > > Signed-off-by: Douglas Anderson <dianders@chromium.org> > > > > It shouldn't be necessary at all: drivers should call > > drm_atomic_helper_shutdown at removal time which will disable the > > connector (which in turn should unprepare/disable its panel). > > > > If either the driver is missing drm_atomic_helper_shutdown, or if the > > connector doesn't properly disable the panel, then I would consider that > > a bug. > > Hmmm. I'm a bit hesitant here. I guess I'm less worried about the > removal time and more worried about the shutdown time. > > For removal I'd be fine with just dropping the call and saying it's > the responsibility of the driver to call drm_atomic_helper_shutdown(), > as you suggest. I'd tend to believe that removal of DRM drivers is not > used anywhere in "production" code (or at least not common) and I > think it's super hard to get it right, to unregister and unbind all > the DRM components in the right order. It depends on the kind of devices. USB devices are very likely to be removed, platform devices very unlikely, and PCIe cards somewhere in the middle :) I'm not sure the likelyhood of the device getting removed has much to do with it though, and likely or not, it's definitely something we should address and fix if an issue is to be found. > Presumably anyone trying to remove a DRM panel in a generic case > supporting lots of different hardware is used to it being a bit > broken... It's not. Most drivers might be broken, but it's totally something we support and should strive for. > Not that it's a super great situation to be in for remove() not to > work reliably, but that's how I think it is right now. > > For shutdown, however, I'm not really OK with just blindly removing > the code that tries to power off the panel. I disagree with that statement. It's not "blindly removing the code", that code is still there, in the disable hook. > Shutdown is called any time you reboot a device. That means that if a > DRM driver is _not_ calling drm_atomic_helper_shutdown() on the > panel's behalf at shutdown time then the panel won't be powered off > properly. This feels to me like something that might actually matter. It does matter. What I disagree on is that you suggest working around that brokenness in the core framework. What I'm saying is driver is broken, we should keep the core framework sane and fix it in the driver. It should be fairly easy with a coccinelle script to figure out which panels are affected, and to add that call in remove. > Panels tend to be one of those things that really care about their > power sequencing and can even get damaged (or not turn on properly > next time) if sequencing is not done properly, so just removing this > code and putting the blame on the DRM driver seems scary to me. Sure, it's bad. But there's no difference compared to the approach you suggest in that patch: you created a helper, yes, but every driver will still have to call that helper and if they don't, the panel will still be called and it's a bug. And we would have to convert everything to that new helper. It's fundamentally the same discussion than what you were opposed to above. > Sure enough, a quick survey of DRM drivers shows that many don't call > drm_atomic_helper_shutdown() at .shutdown time. A _very_ quick skim of > callers to drm_atomic_helper_shutdown(): > > * omapdrm/omap_drv.c - calls at remove, not shutdown > * arm/hdlcd_drv.c - calls at unbind, not shutdown > * arm/malidp_drv.c - calls at unbind, not shutdown > * armada/armada_drv.c - calls at unbind, not shutdown > > ...huh, actually, there are probably too many to list that don't call > it at shutdown. There are some that do, but also quite a few that > don't. I'm not sure I really want to blindly add > drm_atomic_helper_shutdown() to all those DRM driver's shutdown > callbacks... That feels like asking for someone to flame me... No one will flame you, and if they do, we'll take care of it. And yes, those are bugs, so let's fix them instead of working around them? > ...but then, what's the way forward? I think normally the panel's > shutdown() callback would happen _before_ the DRM driver's shutdown() > callback, Is there such a guarantee? > so we can't easily write logic in the panel's shutdown like "if the > DRM panel didn't shut the panel down then print a warning and shut > down the panel". We'd have to somehow invent and register for a "late > shutdown" callback and have the panel use that to shut itself down if > the DRM driver didn't. That seems like a bad idea... > > Do you have any brilliant ideas here? I could keep the function as-is > but only have panels only call it at shutdown time if you want. I > could add to the comments and/or the commit message some summary of > the above and that the call is important for panels that absolutely > need to be powered off at shutdown time even if the DRM driver doesn't > do anything special at shutdown... Any other ideas? Brilliant ideas to do what exactly? I disagree that the solution to our problem is to disable the panel resources at shutdown time and we should only do it at disable time. Your helper does exactly that though, so I don't think the helper is a good idea. Maxime
Hi, On Thu, Sep 7, 2023 at 7:15 AM Maxime Ripard <mripard@kernel.org> wrote: > > > a) Block landing the change to "panel-tdo-tl070wsh30.c" until after > > all drivers properly call drm_atomic_helper_shutdown(). > > I don't think we care about all drivers here. Only the driver it's > enabled with would be a blocker. Like, let's say sun4i hasn't been > converted but that panel is only used with rockchip anyway, we don't > really care that sun4i shutdown patch hasn't been merged (yet). Yeah, I suppose that would work, though it would require a bit of research. Some other things have popped onto my plate recently, but for now I'm going to focus on seeing how much of the drivers can get their shutdown fixed. When that stalls out then we can see if we can unblock some of the panels by digging into which DRM drivers they're used with. Also, as my proposal in the cover letter [1], I'm leaving a breadcrumb here that I landed the first 3 patches in this series just to get them out of the way. Those 3 patches didn't depend on the resolution of the issues discussed here. [1] https://lore.kernel.org/lkml/CAD=FV=UFuUsrrZmkL8_RL5WLvkJryDwRSAy_PWTa-hX_p0dF+Q@mail.gmail.com/
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 215e78e79125..e811f3d68235 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -118,6 +118,7 @@ drm_kms_helper-y := \ drm_gem_framebuffer_helper.o \ drm_kms_helper_common.o \ drm_modeset_helper.o \ + drm_panel_helper.o \ drm_plane_helper.o \ drm_probe_helper.o \ drm_rect.o \ diff --git a/drivers/gpu/drm/drm_panel_helper.c b/drivers/gpu/drm/drm_panel_helper.c new file mode 100644 index 000000000000..85a55b5731cf --- /dev/null +++ b/drivers/gpu/drm/drm_panel_helper.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2023 Google Inc. + */ + +#include <linux/dev_printk.h> + +#include <drm/drm_panel.h> +#include <drm/drm_panel_helper.h> + +/** + * drm_panel_helper_shutdown - helper for panels to use at shutdown time + * @panel: DRM panel + * + * Panels may call this function unconditionally at shutdown time to ensure + * that they are disabled and unprepared if necessary. + * + * As part of this function: + * - The backlight will be turned off, if it was on. + * - Any panel followers will be power sequenced. + */ +void drm_panel_helper_shutdown(struct drm_panel *panel) +{ + int ret; + + if (panel->enabled) { + ret = drm_panel_disable(panel); + if (ret) + dev_warn(panel->dev, "Error disabling panel %d\n", ret); + } + if (panel->prepared) { + ret = drm_panel_unprepare(panel); + if (ret) + dev_warn(panel->dev, "Error unpreparing panel %d\n", ret); + } +} +EXPORT_SYMBOL_GPL(drm_panel_helper_shutdown); diff --git a/include/drm/drm_panel_helper.h b/include/drm/drm_panel_helper.h new file mode 100644 index 000000000000..5621482053a9 --- /dev/null +++ b/include/drm/drm_panel_helper.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2023 Google Inc. + */ + +#ifndef DRM_PANEL_HELPER_H +#define DRM_PANEL_HELPER_H + +struct drm_panel; + +void drm_panel_helper_shutdown(struct drm_panel *panel); + +#endif /* DRM_PANEL_HELPER_H */