Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp927274rdb; Wed, 1 Nov 2023 06:54:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1H8HU/NDdEfrBAuj6IxDHmOCaxoiZVrHy6G2jIcPjlInDQXqcVg3IsBlZ3CZpyENxdxZw X-Received: by 2002:a17:903:18b:b0:1cc:665d:f818 with SMTP id z11-20020a170903018b00b001cc665df818mr5376883plg.68.1698846869433; Wed, 01 Nov 2023 06:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698846869; cv=none; d=google.com; s=arc-20160816; b=x8mDTXuq5hznQfJRY7hykZe1zCuicnrhIqwUWP/TZQT/G5CUw8Ikym8Hx9bnf1wyVN dqe0j7NCfJlJzwyT5uCT7Dn1vmswcRjvRt6z7TfCMFUoWUwMOwN7/CwpEOK6jGi2ooND nF0IQ4TMlnZYuaW6f1alCwUTktEALDtdTGIqmwCzOembThkQjt5xLKxEFUpxqPF7ajlZ UvzaFlUkIN9HXjQVuJOKa9DWbgTRcxWhO+I9Gae8B1CgYJimuZvvDlSHWt54UA655daB 2hfsO0vZuKn8Vuc/6lVMBp94rLosEjrNQiJOr+S3LvcAttTcW94e3ALwHOOWPjkoMWSx venA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XM3X2Sk+gBL4Q9FjN2GvwLjG4n0AaLMaoLO8KQzdOEE=; fh=5C3CAkIfBsG8EK8jEaBmpiwV3a9azH+DT0pG9NOmIu4=; b=LJ/DfsKaSDy2YPVz3B4Y5cQqZv+5xaIOT63/UR3h1Xj26H5IwwtX9YyKM5vK9jt9Gn 0KgYPMHfpGo3+dfp5jPwDetqW+FjbQQVIgNZ+JcxrPtu0KiCgW+dsnSUUrO6tKwsDAGQ lu8GF0K3RQPZmO1qJExBeFIc7LqJVvpKH20sSn6PgT7891XsD2bp6SZRrQ30YOFf0yX1 B/WdH/tnZwjEKPxeQ6q6m5f1gV4eRQQojQW/ZtnoLZUJS1PKS6p4ddvARJRKWR7p9Ql+ wye3jGkSzykbdFo2IwRRXq0fPhmUD0Nrt7HwljCxaCa72UtwgODG/1k6r4w4nitvFc1a HJbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=V1KOm7VV; 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 z15-20020a170903018f00b001ca4ad86363si3168315plg.390.2023.11.01.06.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 06:54:29 -0700 (PDT) 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=V1KOm7VV; 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 B0CEE80423BA; Wed, 1 Nov 2023 06:54:23 -0700 (PDT) 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 S234120AbjKANyJ (ORCPT + 99 others); Wed, 1 Nov 2023 09:54:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231924AbjKANyH (ORCPT ); Wed, 1 Nov 2023 09:54:07 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3939883 for ; Wed, 1 Nov 2023 06:54:01 -0700 (PDT) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D953D8D; Wed, 1 Nov 2023 14:53:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698846823; bh=umd36ZH9/8B0MzVnTORCG6HOMVV7hcOEiqUo9JtmjcM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V1KOm7VV3uZjtjNlXMR4pg1tx0mUa8ziTZ8aXVn4dCHc+FqmR3wzmkrOc/reHG2Zy Ep72AygN+Ez+WGmY6Tth0UMsvO2klG60j8uUF53lf1Z0+vUS2hpkR9h7IDVogWAVyp xmBWW4X6TuRDwzW+uCf3C0XtyBqOhUNks7BHVt8U= Date: Wed, 1 Nov 2023 15:54:06 +0200 From: Laurent Pinchart To: Tomi Valkeinen 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 Subject: Re: [PATCH 02/10] drm/tidss: Use PM autosuspend Message-ID: <20231101135406.GR12764@pendragon.ideasonboard.com> References: <20231101-tidss-probe-v1-0-45149e0f9415@ideasonboard.com> <20231101-tidss-probe-v1-2-45149e0f9415@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231101-tidss-probe-v1-2-45149e0f9415@ideasonboard.com> 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,URIBL_BLOCKED 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]); Wed, 01 Nov 2023 06:54:23 -0700 (PDT) Hi Tomi, Thank you for the patch. 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); Then, in the error path, pm_runtime_dont_use_autosuspend(dev); pm_runtime_disable(dev); pm_runtime_put_noidle(dev); dispc_runtime_suspend(tidss->dispc); And in remove: pm_runtime_dont_use_autosuspend(dev); pm_runtime_disable(dev); if (!pm_runtime_status_suspended(dev)) dispc_runtime_suspend(tidss->dispc); pm_runtime_set_suspended(dev); And yes, runtime PM is a horrible API. > @@ -215,6 +220,7 @@ static void tidss_remove(struct platform_device *pdev) > /* If we don't have PM, we need to call suspend manually */ > dispc_runtime_suspend(tidss->dispc); > #endif > + pm_runtime_dont_use_autosuspend(dev); This also needs to be done in the probe error path. > pm_runtime_disable(dev); > > /* devm allocated dispc goes away with the dev so mark it NULL */ > -- Regards, Laurent Pinchart