Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2962548rdh; Mon, 27 Nov 2023 03:34:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzLYVdJMTHQ6Le661qA9oWe/zrpC7rV7rrXy20ByujyisEPniRSnVfjmQolMV+VctyLUs6 X-Received: by 2002:a9d:7491:0:b0:6d5:11f6:eec7 with SMTP id t17-20020a9d7491000000b006d511f6eec7mr11944151otk.28.1701084857950; Mon, 27 Nov 2023 03:34:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701084857; cv=none; d=google.com; s=arc-20160816; b=QL6OCvb7kPWWoE1OieYQZiRr8Qk5dHll/s6LXScH3uzCwLs0gr9/6yizsHu9S+BbMr u10y2K2dT25+VdPu7VpnFPfcf3AYH5CSPCTNDZFWJkyBBnzAr/xQAbGxs6iz/p/DU6RD OjPz+BV6J6eFpVWGIw4GnVDF9SJ2Ho7cWMSpqHg59QpNB43daLoMNXKNsCdCK6ndXb1N jI83ZgJpW4U/2xd7RmGFZi7Oo4wMVeUJCN962gFyb4DEf00qjToR1wzrKENkFtWKOw9m p/iYN/AWkymTyEwnkY3fDHafSa627QSm1MQRrRL0ZoR1YOEmvULei2nWxb9oVIPSCmxU PGMA== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=/t5bNp3UE6dQpCuJtZ3yxplHTTDVQEfozj5+aWIRTS4=; fh=CQLHSdxSsgw76AL8bhWbNSzTGHnm3kswiGHOsfubpaU=; b=pWhdRwkGFnxj8DG+fEzeyc+BxZKdzYct1D8t2YDtGqzJhwGtaECn4yxH6LJ16aguKb 7nJnfdX/ABaqk5D1MFYehbAZ/+zXIAD1BUmPE5oBBtJhFvckFbzMZmczsRAeyRDkgaCr J9lwKpPImgbsWuXLeHAGuFlEi/WgDOga6T5YfvmThjmRkdgJqZJOyM2fFUcSxumwI1eb GJ+Hr9wGs6hcigzu0Qv4bJ+t1u/+zGxlBMANdMKhuEvu+8DQ5cthU/wflG3V1UN37mS/ 7ks6+za61IE/OrAkdNNSehCr2QnL0jJHNgne0zUNe2eXrmiFutihDh8Wn3So7YxpQxC8 y0BQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k5-20020a6568c5000000b005a0018ec786si9524278pgt.854.2023.11.27.03.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 03:34:17 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 500B3808D4AE; Mon, 27 Nov 2023 03:34:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233245AbjK0LeA (ORCPT + 99 others); Mon, 27 Nov 2023 06:34:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233236AbjK0Ld7 (ORCPT ); Mon, 27 Nov 2023 06:33:59 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AD8B4133 for ; Mon, 27 Nov 2023 03:34:05 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0A2042F4; Mon, 27 Nov 2023 03:34:53 -0800 (PST) Received: from [10.57.72.179] (unknown [10.57.72.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D90AE3F73F; Mon, 27 Nov 2023 03:34:02 -0800 (PST) Message-ID: Date: Mon, 27 Nov 2023 11:34:05 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] drm/panfrost: Fix incorrect updating of current device frequency Content-Language: en-GB To: =?UTF-8?Q?Adri=C3=A1n_Larumbe?= , Boris Brezillon , Rob Herring , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , AngeloGioacchino Del Regno Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com References: <20231125205438.375407-1-adrian.larumbe@collabora.com> <20231125205438.375407-3-adrian.larumbe@collabora.com> From: Steven Price In-Reply-To: <20231125205438.375407-3-adrian.larumbe@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=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]); Mon, 27 Nov 2023 03:34:15 -0800 (PST) On 25/11/2023 20:52, Adrián Larumbe wrote: > It was noticed when setting the Panfrost's DVFS device to the performant > governor, GPU frequency as reported by fdinfo had dropped to 0 permamently. > > There are two separate issues causing this behaviour: > - Not initialising the device's current_frequency variable to its original > value during device probe(). > - Updating said variable in Panfrost devfreq's get_dev_status() rather > than after the new OPP's frequency had been retrieved in target(), which > meant the old frequency would be assigned instead. Good catch - I'd not looked at the performance governor. I'd assumed that one was "too simple to be wrong" ;) Reviewed-by: Steven Price > > Signed-off-by: Adrián Larumbe > Fixes: f11b0417eec2 ("drm/panfrost: Add fdinfo support GPU load metrics") > --- > drivers/gpu/drm/panfrost/panfrost_devfreq.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > index f59c82ea8870..2d30da38c2c3 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > @@ -29,14 +29,20 @@ static void panfrost_devfreq_update_utilization(struct panfrost_devfreq *pfdevfr > static int panfrost_devfreq_target(struct device *dev, unsigned long *freq, > u32 flags) > { > + struct panfrost_device *ptdev = dev_get_drvdata(dev); > struct dev_pm_opp *opp; > + int err; > > opp = devfreq_recommended_opp(dev, freq, flags); > if (IS_ERR(opp)) > return PTR_ERR(opp); > dev_pm_opp_put(opp); > > - return dev_pm_opp_set_rate(dev, *freq); > + err = dev_pm_opp_set_rate(dev, *freq); > + if (!err) > + ptdev->pfdevfreq.current_frequency = *freq; > + > + return err; > } > > static void panfrost_devfreq_reset(struct panfrost_devfreq *pfdevfreq) > @@ -58,7 +64,6 @@ static int panfrost_devfreq_get_dev_status(struct device *dev, > spin_lock_irqsave(&pfdevfreq->lock, irqflags); > > panfrost_devfreq_update_utilization(pfdevfreq); > - pfdevfreq->current_frequency = status->current_frequency; > > status->total_time = ktime_to_ns(ktime_add(pfdevfreq->busy_time, > pfdevfreq->idle_time)); > @@ -164,6 +169,14 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) > > panfrost_devfreq_profile.initial_freq = cur_freq; > > + /* > + * We could wait until panfrost_devfreq_target() to set this value, but > + * since the simple_ondemand governor works asynchronously, there's a > + * chance by the time someone opens the device's fdinfo file, current > + * frequency hasn't been updated yet, so let's just do an early set. > + */ > + pfdevfreq->current_frequency = cur_freq; > + > /* > * Set the recommend OPP this will enable and configure the regulator > * if any and will avoid a switch off by regulator_late_cleanup()