Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4044886pxf; Mon, 29 Mar 2021 19:56:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTzcoMY5G5KCpCus1BMlc0kx94319JuoYyjCTIImzVm7LI9gc8odj6sjii4cceDWNnRnph X-Received: by 2002:a17:906:8408:: with SMTP id n8mr30155761ejx.152.1617073005103; Mon, 29 Mar 2021 19:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617073005; cv=none; d=google.com; s=arc-20160816; b=TlirIwTLzO90B3+oLKi9I2TvsLZ59c9+ReXk/R8MYutn1yOrlg6RHffpvnYcRj96Qr rTWMYqAxqvZmUJlnyp3UI4+3HvcfkEpfTtKRBt9eOngujcm+xV26HYL3Clpb7EsKjMc+ LNxAOOs+7k/c9WH9LTPvNv0FmiX+Wrw7juPZjENkRmidtmrIZ9NuNmLfWI/b64dWvVU3 YE6M8xzxvICarld7fYxCCn93RQXvko09jorD7FmiNY+wkDqktTxdD5qxXo/a+S5ct5HU vcGIEHmgHtPhGFYc4fW8aMDgpgcv8lMuhaA1e4eN+lWbfReVm56efX1rAZNU9xitgRuh IIXw== 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=Jys6treQLmtovHh8Q5PKz6NZS9rseP3crP7Ti/ybCsA=; b=dQwHoeFYIqG8ywuVlakfs8UhE9T+Rdu2vlbZYYDwogPat3ErTh73mzjJ2xSAh7Gud7 xjkZaqul8r1Uf6hT3GehuX4JJLOSvBrbRohdYKw6IlK1lNaucbfGm5ZCVvgQDJANd+Ce Z2mDO3SZdcWDe81WYr5fkbWquoiATLYZ0+97vXYKjUl+f8cyB+f4MUyZry6wMTpFAglb jTfw02rJNXr6RUF0wNYEnjsQYwoumaajgzMJYtFszDFwSm9dvkfgsN+nK8mubGqf9mKI +MRj4pm0A6vN3yBlU7mL+bnTWXuosunNwH+gke7wOSsneFj53ZMRAWS9Slvczec5DFAf UevQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=etvJfy76; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si13439421eds.454.2021.03.29.19.56.22; Mon, 29 Mar 2021 19:56:45 -0700 (PDT) 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=@chromium.org header.s=google header.b=etvJfy76; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbhC3CzG (ORCPT + 99 others); Mon, 29 Mar 2021 22:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231150AbhC3CyZ (ORCPT ); Mon, 29 Mar 2021 22:54:25 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB78C061762 for ; Mon, 29 Mar 2021 19:54:25 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id ha17so6994772pjb.2 for ; Mon, 29 Mar 2021 19:54:25 -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=Jys6treQLmtovHh8Q5PKz6NZS9rseP3crP7Ti/ybCsA=; b=etvJfy76jSeT8orrEcP21zK3SyGBHJ4mxUKIcAWBYkeAKj9R3EZgaRTrONfP7DVgYf 46ORMDHwSJu0PWv9KN3cGSkQGBp7Gc3S8z/V1F7xQ8NaY05TLvZ2vQ6IZR1hDGHMJ8WO sTuUPgt9knV7cvgKTDADChchQIs9AUiWeJ8fM= 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=Jys6treQLmtovHh8Q5PKz6NZS9rseP3crP7Ti/ybCsA=; b=uCpj0KXL/AOAwH3W1f0S2CUvXxEDq7izHmWxusVesZ9IrvdfQnOCCOvk/rgSzNOGuF softsRmt5DQBEr9hrH+jejZQVied0jsRzSE9mXnAPFmo8ZL4jY7KFNVVz2O2UvqpOKjK 36MfrJR1u0leRBsZIzY9fMPGxsABiN/FwEXmnp9zuzCdZhyNZzhz6x7bmcypxeGm+H0V 5tO4gx6vdUHVNryLdNx5x4nFRa64nEPo+aLrVHdpOnFgJlAvAHLs7/qCtDACATOv55E0 tTHCqzEOaUwwFGH8vKzMxBLRYeYM6z5Ms6OMm2YGW/lqrQhqeld6QxXh0Hyhzo3YJosW djNQ== X-Gm-Message-State: AOAM530kL0IsOmZ8f9HrzWZ0NigX6CrHk64H64Sw4sgKsgmfyP0SOsQP faLUnetldC8EayeRvVefRJRFrw== X-Received: by 2002:a17:902:ff01:b029:e7:147f:193 with SMTP id f1-20020a170902ff01b02900e7147f0193mr25884988plj.82.1617072864844; Mon, 29 Mar 2021 19:54:24 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f599:1ca7:742d:6b50]) by smtp.gmail.com with ESMTPSA id t17sm19152706pgk.25.2021.03.29.19.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 19:54:24 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg Cc: Bjorn Andersson , Stephen Boyd , Maarten Lankhorst , robdclark@chromium.org, Stanislav Lisovskiy , linux-arm-msm@vger.kernel.org, Steev Klimaszewski , Linus W , Douglas Anderson , Daniel Vetter , David Airlie , Thierry Reding , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 14/14] drm/panel: panel-simple: Use runtime pm to avoid excessive unprepare / prepare Date: Mon, 29 Mar 2021 19:53:45 -0700 Message-Id: <20210329195255.v2.14.I9e8bd33b49c496745bfac58ea9ab418bd3b6f5ce@changeid> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210330025345.3980086-1-dianders@chromium.org> References: <20210330025345.3980086-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. - 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 --- (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