From patchwork Fri Apr 16 22:39:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 12209187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D43FC43600 for ; Fri, 16 Apr 2021 22:41:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B326613C3 for ; Fri, 16 Apr 2021 22:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235058AbhDPWlg (ORCPT ); Fri, 16 Apr 2021 18:41:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235073AbhDPWlb (ORCPT ); Fri, 16 Apr 2021 18:41:31 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C1D1C06175F for ; Fri, 16 Apr 2021 15:41:01 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id w8so15798269pfn.9 for ; Fri, 16 Apr 2021 15:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4INPsktRh63MYznTPEEwmqN4qH+4+y6bOootcCGCpqs=; b=kgDbFvpoaiTtEYJP/SI4i/wU3eREZ10ugre9Kjus0KuOlxxFF0adtLiKAcm1gyzJ+c naAccRw1h9kCrgHQJeNZw/jlAkUmX2FqzN4eR1zv/AqYXgRpFpNDhd9szX6PzibqbUq6 syf8bF1GO3vgBLnpBUqPPL0vI72391UvUDl5U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4INPsktRh63MYznTPEEwmqN4qH+4+y6bOootcCGCpqs=; b=mVXoyi16Rbp9E8FAq5TlugFedE0+lKcURq3iCkHcsAlWD2qgvv3fbJt8X9r3SfBNyp UufrI0wAfbfzMq8kknpBo6pjZ6XHvfKbAuUhkBN3yAeqCMsYMS5V4R8hwcuxEoD8VMMw LLqnyBJoFfg+gw1Jy+3e4F/9Pd5lwaQWNBy3jnugaziuJgq8riFRfjtKiXa3WisjfVOV Lh4vKqilTGi2GafeaxSuY4BAfI4YwRq+v4KDq8QgPwBvvBJb3bMetOND5y2cA9GALFlX mUIaKbbOUjjcTr3Y2YPWtXz6IfTY/lFjiVEk4MUUa4NaJuRgoQOgrqj+WqvOOCS41qnq 7aPA== X-Gm-Message-State: AOAM531k1vnf95zRqxzCsCVVaUexfk3yuOc28de22E5W4FxbgkLL7hLu tSzdswSWTT4u1csUo2889fAUiA== X-Google-Smtp-Source: ABdhPJxdxpzcVYaUk0y3l3qc/9b9JdCgkaUw8QkdRQqUWBnzRKxRKV4SFk9rcOynna/BuiRHtzXx8Q== X-Received: by 2002:aa7:8d5a:0:b029:227:7b07:7d8b with SMTP id s26-20020aa78d5a0000b02902277b077d8bmr9605907pfe.26.1618612860869; Fri, 16 Apr 2021 15:41:00 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:dc8a:c9d0:aa5b:5386]) by smtp.gmail.com with ESMTPSA id r6sm5633659pgp.64.2021.04.16.15.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Apr 2021 15:41:00 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: Stephen Boyd , robdclark@chromium.org, Maarten Lankhorst , Stanislav Lisovskiy , Steev Klimaszewski , Bjorn Andersson , linux-arm-msm@vger.kernel.org, Linus W , Douglas Anderson , Laurent Pinchart , Daniel Vetter , David Airlie , Thierry Reding , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 07/27] drm/panel: panel-simple: Use runtime pm to avoid excessive unprepare / prepare Date: Fri, 16 Apr 2021 15:39:30 -0700 Message-Id: <20210416153909.v4.7.I9e8bd33b49c496745bfac58ea9ab418bd3b6f5ce@changeid> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210416223950.3586967-1-dianders@chromium.org> References: <20210416223950.3586967-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Unpreparing and re-preparing a panel can be a really heavy operation. Panels datasheets often specify something on the order of 500ms as the delay you should insert after turning off the panel before turning it on again. In addition, turning on a panel can have delays on the order of 100ms - 200ms before the panel will assert HPD (AKA "panel ready"). The above means that we should avoid turning a panel off if we're going to turn it on again shortly. The above becomes a problem when we want to read the EDID of a panel. The way that ordering works is that userspace wants to read the EDID of the panel _before_ fully enabling it so that it can set the initial mode correctly. However, we can't read the EDID until we power it up. This leads to code that does this dance (like ps8640_bridge_get_edid()): 1. When userspace requests EDID / the panel modes (through an ioctl), we power on the panel just enough to read the EDID and then power it off. 2. Userspace then turns the panel on. There's likely not much time between step #1 and #2 and so we want to avoid powering the panel off and on again between those two steps. Let's use Runtime PM to help us. We'll move the existing prepare() and unprepare() to be runtime resume() and runtime suspend(). Now when we want to prepare() or unprepare() we just increment or decrement the refcount. We'll default to a 1 second autosuspend delay which seems sane given the typical delays we see for panels. A few notes: - It seems the existing unprepare() and prepare() are defined to be no-ops if called extra times. We'll preserve that behavior but may try to remove it in a future patch. - This is a slight change in the ABI of simple panel. If something was absolutely relying on the unprepare() to happen instantly that simply won't be the case anymore. I'm not aware of anyone relying on that behavior, but if there is someone then we'll need to figure out how to enable (or disable) this new delayed behavior selectively. - In order for this to work we now have a hard dependency on "PM". From memory this is a legit thing to assume these days and we don't have to find some fallback to keep working if someone wants to build their system without "PM". Signed-off-by: Douglas Anderson Link: https://lore.kernel.org/r/20210402152701.v3.12.I9e8bd33b49c496745bfac58ea9ab418bd3b6f5ce@changeid Reviewed-by: Laurent Pinchart --- Laurent pointed out that perhaps we don't need to make unprepare() and prepare() no-ops if called extra times [1]. Since I worry that will break someone out there, I have left it as a separate change at the end of this series. See ("drm/panel: panel-simple: Prepare/unprepare are refcounted, not forced") [1] https://lore.kernel.org/r/YHePsQgqOau1V5lD@pendragon.ideasonboard.com/ (no changes since v1) drivers/gpu/drm/panel/Kconfig | 1 + drivers/gpu/drm/panel/panel-simple.c | 93 +++++++++++++++++++++------- 2 files changed, 73 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index 4894913936e9..ef87d92cdf49 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -80,6 +80,7 @@ config DRM_PANEL_SIMPLE tristate "support for simple panels" depends on OF depends on BACKLIGHT_CLASS_DEVICE + depends on PM select VIDEOMODE_HELPERS help DRM panel driver for dumb panels that need at most a regulator and diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index be312b5c04dd..6b22872b3281 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include