Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1966738rdf; Sun, 5 Nov 2023 23:54:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuP+BXlw+mI1zx9T6kxKjUWh7wgSkYaCHum1GjOFDs6irdhPIdzfkCLQmH67tXTPb1VEyV X-Received: by 2002:a05:6808:f15:b0:3b2:e519:192c with SMTP id m21-20020a0568080f1500b003b2e519192cmr35140397oiw.9.1699257288224; Sun, 05 Nov 2023 23:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699257288; cv=none; d=google.com; s=arc-20160816; b=hmRHtVdPUG2qcwaWuIecWLrjp5ogKaILnFVUjEOJPKdgqS3m47IDCON4YjwPH0UK8N gNJB59QFliVO2cYBuMR//qJsu6ig3BhhZ7uHrqvzkA7uH+n1xPjZIt1aqRsnY+okSK8E dPmz2vlMaE2+lXr6bPYHTm9DwJkzsANdg+IQpsLT78cHAJ5xNHXIRntFdqSd+ssCf93h pCBXqqOiZdZZJxygWw1WZh7ocCwbtKA4ayiJCMO+JHn1llfP16FoYmdoWJk/xX0BAp4d SO3d1EOPKowAPNsXXpf0hpe875xpibAiJWJsiOwhrPYCEpci/jllYFUxrnD2Q8i7dlNh ywGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:content-language:references:cc:to:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=TvfZKLeg5rPlqP0UR4IDqfc/cx+bV1mPUTh8MDN0MGs=; fh=+idM9uzSEVtFG7eK9ucOQyp8EZZF0dcHHbdG+2gMIwQ=; b=S5QBmIawjquDyBUOMqL5SGJCIlhzOVhI42wMRA6OCB4yusSyMQ0gPf8xVX3uSKILkN 8yiO5FAkoz78OpAkybmUqsZXydD0+HHXlfqC36hdkUXoCdF12lp+QrMDQ4toPPfdyGcf GTzLrosUxWIKXWuqEua5xNIC1vTp5Sb2Ixlo2kZHMHwXzt5OsskIhypLqETHr0yhAPro mEVFNT20Yap7JP+eJfgZHHZdnz12/AtDHU2qCkx/tpfBv81oaFDaw9PMiHFdQyVes5wW 4NXIwAKkuSCXhDkvpAGxXClEwIwQqTD9p9So6DXJgh38ncS5mTChVaaXAw0KDBEJcyiu lSjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=bRNag+XL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id v202-20020a6361d3000000b005644a9be955si7526399pgb.179.2023.11.05.23.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 23:54:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=bRNag+XL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8DE1E8047515; Sun, 5 Nov 2023 23:54:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230173AbjKFHyd (ORCPT + 99 others); Mon, 6 Nov 2023 02:54:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbjKFHyb (ORCPT ); Mon, 6 Nov 2023 02:54:31 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22987B3 for ; Sun, 5 Nov 2023 23:54:27 -0800 (PST) Received: from [192.168.88.20] (91-158-149-209.elisa-laajakaista.fi [91.158.149.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 67CC3583; Mon, 6 Nov 2023 08:54:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699257245; bh=AWiS/+jyJMw7C0hLOtwr+kKJPUeb1haOClFxpULuZmQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=bRNag+XLKR94Pj/WFtofhAXLUJHlB2O/+yrJ6QbX7x5cwiseopn8n2tGmpv3VwOZm x/UFvnQ6lhi6XmhAGoiNgKYCU3yUT3P0xQX5TaLVmKQhcF+rn2qEdVRPiZ23c1Pagr jFgEfyEYQxD84TboUBKY+Mvsqg1wXCge3Xa//rag= Message-ID: Date: Mon, 6 Nov 2023 09:54:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/10] drm/tidss: Use PM autosuspend To: Laurent Pinchart Cc: Aradhya Bhatia , Devarsh Thakkar , Jyri Sarha , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sakari Ailus References: <20231101-tidss-probe-v1-0-45149e0f9415@ideasonboard.com> <20231101-tidss-probe-v1-2-45149e0f9415@ideasonboard.com> <20231101135406.GR12764@pendragon.ideasonboard.com> <7395880d-36ba-471c-ba7c-745a0ec8e5de@ideasonboard.com> <20231105225330.GA15635@pendragon.ideasonboard.com> Content-Language: en-US From: Tomi Valkeinen Autocrypt: addr=tomi.valkeinen@ideasonboard.com; keydata= xsFNBE6ms0cBEACyizowecZqXfMZtnBniOieTuFdErHAUyxVgtmr0f5ZfIi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jBbpP81h7QxWIfWtp+VnwNGc6nq5IQDESH mvQcsFS7d3eGVI6eyjCFdcAO8eMAEQEAAcLBXwQYAQIACQUCTqazRwIbDAAKCRD6PaqMvJYe 9fA7EACS6exUedsBKmt4pT7nqXBcRsqm6YzT6DeCM8PWMTeaVGHiR4TnNFiT3otD5UpYQI7S suYxoTdHrrrBzdlKe5rUWpzoZkVK6p0s9OIvGzLT0lrb0HC9iNDWT3JgpYDnk4Z2mFi6tTbq xKMtpVFRA6FjviGDRsfkfoURZI51nf2RSAk/A8BEDDZ7lgJHskYoklSpwyrXhkp9FHGMaYII m9EKuUTX9JPDG2FTthCBrdsgWYPdJQvM+zscq09vFMQ9Fykbx5N8z/oFEUy3ACyPqW2oyfvU CH5WDpWBG0s5BALp1gBJPytIAd/pY/5ZdNoi0Cx3+Z7jaBFEyYJdWy1hGddpkgnMjyOfLI7B CFrdecTZbR5upjNSDvQ7RG85SnpYJTIin+SAUazAeA2nS6gTZzumgtdw8XmVXZwdBfF+ICof 92UkbYcYNbzWO/GHgsNT1WnM4sa9lwCSWH8Fw1o/3bX1VVPEsnESOfxkNdu+gAF5S6+I6n3a ueeIlwJl5CpT5l8RpoZXEOVtXYn8zzOJ7oGZYINRV9Pf8qKGLf3Dft7zKBP832I3PQjeok7F yjt+9S+KgSFSHP3Pa4E7lsSdWhSlHYNdG/czhoUkSCN09C0rEK93wxACx3vtxPLjXu6RptBw 3dRq7n+mQChEB1am0BueV1JZaBboIL0AGlSJkm23kw== In-Reply-To: <20231105225330.GA15635@pendragon.ideasonboard.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 05 Nov 2023 23:54:45 -0800 (PST) On 06/11/2023 00:53, Laurent Pinchart wrote: > Hi Tomi, > > CC'ing Sakari for his expertise on runtime PM (I think he will soon > start wishing he would be ignorant in this area). > > On Thu, Nov 02, 2023 at 08:34:45AM +0200, Tomi Valkeinen wrote: >> On 01/11/2023 15:54, Laurent Pinchart wrote: >>> On Wed, Nov 01, 2023 at 11:17:39AM +0200, Tomi Valkeinen wrote: >>>> Use runtime PM autosuspend feature, with 1s timeout, to avoid >>>> unnecessary suspend-resume cycles when, e.g. the userspace temporarily >>>> turns off the crtcs when configuring the outputs. >>>> >>>> Signed-off-by: Tomi Valkeinen >>>> --- >>>> drivers/gpu/drm/tidss/tidss_drv.c | 8 +++++++- >>>> 1 file changed, 7 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c >>>> index f403db11b846..64914331715a 100644 >>>> --- a/drivers/gpu/drm/tidss/tidss_drv.c >>>> +++ b/drivers/gpu/drm/tidss/tidss_drv.c >>>> @@ -43,7 +43,9 @@ void tidss_runtime_put(struct tidss_device *tidss) >>>> >>>> dev_dbg(tidss->dev, "%s\n", __func__); >>>> >>>> - r = pm_runtime_put_sync(tidss->dev); >>>> + pm_runtime_mark_last_busy(tidss->dev); >>>> + >>>> + r = pm_runtime_put_autosuspend(tidss->dev); >>>> WARN_ON(r < 0); >>>> } >>>> >>>> @@ -144,6 +146,9 @@ static int tidss_probe(struct platform_device *pdev) >>>> >>>> pm_runtime_enable(dev); >>>> >>>> + pm_runtime_set_autosuspend_delay(dev, 1000); >>>> + pm_runtime_use_autosuspend(dev); >>>> + >>>> #ifndef CONFIG_PM >>>> /* If we don't have PM, we need to call resume manually */ >>>> dispc_runtime_resume(tidss->dispc); >>> >>> By the way, there's a way to handle this without any ifdef: >>> >>> dispc_runtime_resume(tidss->dispc); >>> >>> pm_runtime_set_active(dev); >>> pm_runtime_get_noresume(dev); >>> pm_runtime_enable(dev); >>> pm_runtime_set_autosuspend_delay(dev, 1000); >>> pm_runtime_use_autosuspend(dev); >> >> I'm not sure I follow what you are trying to do here. The call to >> dispc_runtime_resume() would crash if we have PM, as the HW would not be >> enabled at that point. > > Isn't dispc_runtime_resume() meant to enable the hardware ? > > The idea is to enable the hardware, then enable runtime PM, and tell the > runtime PM framework that the device is enabled. If CONFIG_PM is not > set, the RPM calls will be no-ops, and the device will stay enable. If > CONFIG_PM is set, the device will be enabled, and will get disabled at > end of probe by a call to pm_runtime_put_autosuspend(). (The text below is more about the end result of this series, rather than this specific patch): Hmm, no, I don't think that's how it works. My understanding is this: There are multiple parts "enabling the hardware", and I think they usually need to be done in this order: 1) enabling the parent devices, 2) system level HW module enable (this is possibly really part of the 1), 3) clk/regulator/register setup. 3) is handled by the driver, but 1) and 2) are handled via the runtime PM framework. Calling dispc_runtime_resume() as the first thing could mean that DSS's parents are not enabled or that the DSS HW module is not enabled at the system control level. That's why I first call pm_runtime_set_active(), which should handle 1) and 2). The only thing dispc_runtime_resume() does wrt. enabling the hardware is enabling the fclk. It does a lot more, but all the rest is just configuring the hardware to settings that we always want to use (e.g. fifo management). Now, if the bootloader had enabled the display, and the driver did: - pm_runtime_enable() - pm_runtime_get() - dispc_reset() it would cause dispc_runtime_resume() to be called before the reset. This would mean that the dispc_runtime_resume() would be changing settings that must not be changed while streaming is enabled. We could do a DSS reset always as the first thing in dispc_runtime_resume() (after enabling the fclk), but that feels a bit pointless as after the first reset the DSS is in a known state. Also, if we don't do a reset at probe time, there are things we need to take care of: at least we need to mask the IRQs (presuming we register the DSS interrupt at probe time). But generally speaking, I feel a bit uncomfortable leaving an IP possibly running in an unknown state after probe. I'd much rather just reset it at probe. Tomi