Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp348654lqm; Wed, 1 May 2024 02:27:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFFMEoKZ8nW/anSiHbeh5b93xjHx1QhPG+ACsEOYcPu9A06++L1qZE75dzxKDdvaiPxVf6pVnZxebnVi6muofuOYR8BmYPdyTH5dZNBg== X-Google-Smtp-Source: AGHT+IGsGJeFCy0acU34749Qm6AdGN/q5SiRLZzt+OKW0omRhJHBYNhX8JWjCzaS4TWMdo07XsUy X-Received: by 2002:aa7:de17:0:b0:572:ad86:d317 with SMTP id h23-20020aa7de17000000b00572ad86d317mr627288edv.11.1714555621206; Wed, 01 May 2024 02:27:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714555621; cv=pass; d=google.com; s=arc-20160816; b=xfDMCYkBue8N21mfqu4ehRIbRgR/S4r1gSr4SQVuDuusrg0kcD/FMyA5k0ZbAeYhxB HzEZ1sWNSuOYR9R6xZJfeD6iIsOIfo/FohGkqi1ThkcjdliijT/xYdH5bna7cyswraQG YOQw4ncRFVkwY6saqmxylEwRzSaYaouY3QameBfsPP6iLFeYBB0RD6S0hJO40vzLY4ZG SUIa8bLq8KjhLk1C50hZ6kZ7bcSEho1snRixy3TTK85k5H+kRwU4+AijhNZzVhXGACHl GBlUXwMx+6KwXd8bUiIazXll2Zf+9ZYT4I66HAPtYNKZkpZ27+lkqXlrhmZ+hA23AHKr Tfpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=qJbUfYnh/mFDrh/0JXK5ZwGFIojXwih7JY0vUjxqwTg=; fh=gO4xj6C/+5I1kPyBD/hI4WNmAF6RZSBQEV24sAT24xw=; b=CBCAA6otWbfEM9SltNLaspT171Mgb+obrQUc4kqakkXDUlohH5WeNQB7vh6zYZOJg/ LUs3eBYuwDrJDjaU8bJjurhGb/OsYMOBz8Pr+qx+jJS0GKdfRa81K/VmqJGDbw9NYgm2 v8ZzHwhwFiPuewCbTAyMIXZ7HTemMgP7f3b6zUYRPq1rHvysU3H6wu3cavHIQ6e0NxB5 tqC6dAF50Ga6Z+n/JiWyVUMsh4+h2DRsCfmUNdAWP0MEPy5LP4qwLxamh2up+yLRYhVX 48p5vxkmgG5CRyKFo6oIZnFGgyuuAsnxGZQrAOpqHB9QTiRtzXS3xh16My4e5wr8THxU f3Dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-165091-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k21-20020aa7d8d5000000b00572aefabf36si392439eds.445.2024.05.01.02.27.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 02:27:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165091-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-165091-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A38301F23846 for ; Wed, 1 May 2024 09:26:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33FE651034; Wed, 1 May 2024 09:26:51 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F9E51E498; Wed, 1 May 2024 09:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714555610; cv=none; b=JyY8Nbk55ddVVJDu7psMovBHfRgySHj+VWpaCSTVmml7RqvWcoCpkkF0ZvZJcEVHL0lE3VVCSHy56M1DjboBGnWUjJWhbuEakzMZ9fS4BUxgipHbSBpMuYtbqwzCljOS2hFdlFI8dlAIWwtwtCo2J6MwkGLW71J9JIV5kLPjYfE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714555610; c=relaxed/simple; bh=nzPyu2YiZD1yrE0VDN4oac8WQMHoMssmVIZQ+8dHAoQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KkYJxAt14sdV3+OJD5ykBfVMbnf9NCNWxhx5GhAg+lDewMglHsXKv7GblHmJVwPDo/x1j6CdIwjZw8/vUuIfOhtsZglf0MU+nRGvJs1UqvarYop6l6heNW6GkCB0+PFZyYUQk90xOgAzazlCyrMMyovqrq1xsKIx6hxWVSKcCmo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 79F022F4; Wed, 1 May 2024 02:27:13 -0700 (PDT) Received: from pluto (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DC4C73F793; Wed, 1 May 2024 02:26:45 -0700 (PDT) Date: Wed, 1 May 2024 10:26:43 +0100 From: Cristian Marussi To: Lukasz Luba Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dietmar.eggemann@arm.com, linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, linux-samsung-soc@vger.kernel.org, rafael@kernel.org, viresh.kumar@linaro.org, quic_sibis@quicinc.com Subject: Re: [PATCH 2/2] cpufreq: scmi: Update Energy Model with allowed performance limits Message-ID: References: <20240403162315.1458337-1-lukasz.luba@arm.com> <20240403162315.1458337-3-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240403162315.1458337-3-lukasz.luba@arm.com> On Wed, Apr 03, 2024 at 05:23:15PM +0100, Lukasz Luba wrote: > The Energy Model (EM) supports performance limits updates. Use the SCMI > notifications to get information from FW about allowed frequency scope for > the CPUs. > > Signed-off-by: Lukasz Luba > --- > drivers/cpufreq/scmi-cpufreq.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) > > diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c > index d946b7a082584..90c8448578cb1 100644 > --- a/drivers/cpufreq/scmi-cpufreq.c > +++ b/drivers/cpufreq/scmi-cpufreq.c > @@ -185,12 +185,25 @@ static int scmi_limit_notify_cb(struct notifier_block *nb, unsigned long event, > { > struct scmi_data *priv = container_of(nb, struct scmi_data, limit_notify_nb); > struct scmi_perf_limits_report *limit_notify = data; > + unsigned int limit_freq_max_khz, limit_freq_min_khz; > struct cpufreq_policy *policy = priv->policy; > - unsigned int limit_freq_khz; > + struct em_perf_domain *pd; > + int ret; > + > + limit_freq_max_khz = limit_notify->range_max_freq / HZ_PER_KHZ; > + limit_freq_min_khz = limit_notify->range_min_freq / HZ_PER_KHZ; Note that these values could be zeroed if the notification is good but the range_min/range_max values could NOT be mapped to a frequency equivalent (due to some FW errors). I would probably have to add a warn about this error in the core SCMI notification path (or drop the notif as a whole); if not here you could end-up just setting max/min to 0 if the fw has messed up the notification range_min/range_max. Or is it just that, especially max_feq = 0 is NOT plausible value and you will need anyway to check it here ? > > - limit_freq_khz = limit_notify->range_max_freq / HZ_PER_KHZ; > + pd = em_cpu_get(policy->cpu); > + if (pd) { > + ret = em_update_performance_limits(pd, limit_freq_min_khz, > + limit_freq_max_khz); > + if (ret) > + dev_warn(priv->cpu_dev, > + "EM perf limits update failed\n"); > + } > > - policy->max = clamp(limit_freq_khz, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); > + policy->max = clamp(limit_freq_max_khz, policy->cpuinfo.min_freq, > + policy->cpuinfo.max_freq); FWIW, regarding the SCMI bits. LGTM. Reviewed-by: Cristian Marussi Thanks, Cristian