Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1592429pxf; Fri, 2 Apr 2021 15:32:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8vy3jxYJSg8ZRjkyXd6ctEwoVSLeHAEscU6C/paZIjuK/ezH1zWj076/1t++eK/IkP9g5 X-Received: by 2002:a05:6e02:15c7:: with SMTP id q7mr12622251ilu.228.1617402775306; Fri, 02 Apr 2021 15:32:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617402775; cv=none; d=google.com; s=arc-20160816; b=NYsmyP9DijdxcQi3tno0iLPKRKvCaxyupGjH/+cUMVEoHi5CgbyWaQmdD7giOjqoh3 f2rqzEhRqQFHFXM9snFPAyufhSdywcnZzGyeJhpAvSFL8Qa/VhMJ2KIKY0gPSxmOdv3a iscKuJ+Zh8bSDJ+62ASAQP9RzmTmLu1eGERuEha9ffSOZMigzk/5W34ObX+GowhDg0sK 0f/zwTTYbuHLXWNVmC6XXXDCQTT67c2DnBoQyVIFfKLnYbWqWtHkwLE5hNuBlrXhZ9tZ c2iw+KLRBoFMQOm3Crlqp20VZUsD22s4N/N1U+58P9Df2DceJ5x8hbiji7yGUU7zkPD+ t2/Q== 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=Bd7ZOcdLbggTkWq/b11t2tsonPi+tFBvbqHGCQY6R64=; b=prK4V1agOCRzSjHWq1dB3I8zb6oB0U9QEhfBE5BqerctVq3iNYs2UVEiNQxawqo3sx DOdEoBTb3rppR8IyAin9FwjR+IwRFEJZjZeRxSkfs9qcx8BfY6jQGJ7y/DX3ug1qOyWk Qs5inU85P7Q3htg0gpTOAJbcB9hxKLqR0cv18lUZtvmlw87vSmyOMzVJvCpJJZTZycI/ 6TVq1THx89MJ666nJsEs+2KBxENiEyewhcaYpoPUQ5Ur4w9+fZhdxjnLXtzT051wOS/j gQkBnpwCgZzdLneK4k2/m2Sr8CkU+Syl+jGN4dY1aijeCoNZn2xxNT9ksOB3cn6v7W3Q eFYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y82Ifp58; 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 w15si8938857ilu.143.2021.04.02.15.32.41; Fri, 02 Apr 2021 15:32:55 -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=Y82Ifp58; 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 S236380AbhDBW36 (ORCPT + 99 others); Fri, 2 Apr 2021 18:29:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236056AbhDBW3m (ORCPT ); Fri, 2 Apr 2021 18:29:42 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62693C061794 for ; Fri, 2 Apr 2021 15:29:40 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id w8so3266303pjf.4 for ; Fri, 02 Apr 2021 15:29:40 -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=Bd7ZOcdLbggTkWq/b11t2tsonPi+tFBvbqHGCQY6R64=; b=Y82Ifp58mbKXik+k+22lEwNmBxDnbi4EdOcUxNE4tS1v8FtKxAXjDKfbiCg1WQ1fwo 9m5VHOYO2zt2rDjV9NpyYNB5AaUcnKTAozlTmgHodqHfwDOnGzuV6pogLfdcuiiaB8C+ GfUTEIrZj4D0dVJE4meMDZmr4ij2391fcpK9o= 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=Bd7ZOcdLbggTkWq/b11t2tsonPi+tFBvbqHGCQY6R64=; b=C2boyuuntRMKN1fIqVj4qMNFoMb7gJmTUjWVODN3R2QFkb0zQsmavOEV+9oRcojJa/ OpqZ8VVm9VXywp/X0kX/e5FyDLrP7zcOuMml+Nih/f+tGynmfHj6w4zdVjtNg4XYar1A ztOc9E88By2thEQYAjAfTcqtCp23SZWHJFYYRdadaF0+aGCYa10XLMJxlxqqDsBr2BVS F+Jfz3dhY3Aik7oxQLI8K+G+PR53n8C0sMXC3HzViAy6LCiEiYDZJnQdwWHv/HUtMH3S CVtb1AJXcDnSm8XOFbrnds9tSfm7ouPsjqrINV0IQeJrCdS1HxFsYfQxjNWrAANTX0+b VtzA== X-Gm-Message-State: AOAM531N3+dEUaOh16pq8DwXymevERGDxakOgP5Mfn9hl/+GSVVBSUMO vAIqgXTH4pV19bfvONo5wrAaXA== X-Received: by 2002:a17:902:e051:b029:e7:37d9:f32e with SMTP id x17-20020a170902e051b02900e737d9f32emr14488918plx.78.1617402579937; Fri, 02 Apr 2021 15:29:39 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6c58:fab2:c5e2:f2d7]) by smtp.gmail.com with ESMTPSA id t16sm9233094pfc.204.2021.04.02.15.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 15:29:39 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg Cc: Linus W , Bjorn Andersson , robdclark@chromium.org, Stephen Boyd , Steev Klimaszewski , Maarten Lankhorst , linux-arm-msm@vger.kernel.org, Stanislav Lisovskiy , Douglas Anderson , Daniel Vetter , David Airlie , Thierry Reding , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 12/12] drm/panel: panel-simple: Use runtime pm to avoid excessive unprepare / prepare Date: Fri, 2 Apr 2021 15:28:46 -0700 Message-Id: <20210402152701.v3.12.I9e8bd33b49c496745bfac58ea9ab418bd3b6f5ce@changeid> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210402222846.2461042-1-dianders@chromium.org> References: <20210402222846.2461042-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