Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp835416rdd; Wed, 10 Jan 2024 00:25:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1yUIVM80vZnc2Vx+HMSfYhagG2uxSZUCmm0u6QeW22yD0K2gXppLP7f4tmX6yq//0JW/6 X-Received: by 2002:a17:906:5a:b0:a2b:c70e:c194 with SMTP id 26-20020a170906005a00b00a2bc70ec194mr311374ejg.95.1704875120822; Wed, 10 Jan 2024 00:25:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704875120; cv=none; d=google.com; s=arc-20160816; b=zdQ9Fm+9rnvhu1vFEg859eQAuLQHDUYn104CwTEoOasowWK5qeihFOgw6ax4dqb4/R MT4C49RXs6bAnzEki5GEhhAuC218FuIpMYeD4RQ24PVMtghbVVyVnor7YpQZw46ujwml JYm+oV86ncB3RUIio4uGVDkcmOa8U5AO5W0mQuMCN7g6O0jxmXadt7APJ92rTIq+Qg1g BjwKopW9Toiqd3Xtn7Ag8oAYPRIJeZePn/946QMApTGmK3PBycNjqlJuwUxdM2ONrdd5 3huAvFxy7Xjmytnxh5a7fL+x0YNX/M6AzW2sT7Z069p/eF9PJsMrtCIjLeGlB+wjvUte 2Jsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=+rwsu4ehR1Zm4z9JScOZHH0okyzmjxBMudjcIY09/L0=; fh=s5LTG57xrKYvBy8x3cAOBO7cBEkCfcPJR73y6QQBMoo=; b=Js7Ddv7paTH1Mz0T6FFJRIhaOWf7y80O8LAAqXgz/tPqeABrmJy15HDANRAAGeseDJ 4VSUZnwp6qJDeb9h7Lw7nOe6WnqezC3267LQSRGifG+NiHDDTaDyP74aTlXuqv/1HsoL IMOt9naqiNbXDlskEPPqlyxp9I0ajObbRHFmDHDcEMjY23jJ+WtnsIylaZqp08DhvSCP GNRvRHOHIkjldENmGuPISLojE76URt0poO2geA3aGZLERh7WoNea+Wzg6sbKJuf+qfwT OT3qsVp+xVkpmbIbgYRaAE3XlbWFH+6HAjqolhq0u0I53UBA1pLMuF7AwIBYo/sZXMrd TFbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-21831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21831-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id cw26-20020a170906c79a00b00a26e29352b9si1555288ejb.301.2024.01.10.00.25.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 00:25:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-21831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21831-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 80AB91F26D4B for ; Wed, 10 Jan 2024 08:25:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADD923E47B; Wed, 10 Jan 2024 08:25:09 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68CCD3C461; Wed, 10 Jan 2024 08:25:06 +0000 (UTC) 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 CBF482F4; Wed, 10 Jan 2024 00:25:50 -0800 (PST) Received: from [10.57.87.179] (unknown [10.57.87.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 38B753F73F; Wed, 10 Jan 2024 00:25:03 -0800 (PST) Message-ID: <94aad654-4f20-4b82-b978-77f1f9376dab@arm.com> Date: Wed, 10 Jan 2024 08:26:25 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] cpufreq: scmi: Register for limit change notifications Content-Language: en-US To: Sibi Sankar Cc: linux-arm-kernel@lists.infradead.org, viresh.kumar@linaro.org, rafael@kernel.org, cristian.marussi@arm.com, sudeep.holla@arm.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_mdtipton@quicinc.com, linux-arm-msm@vger.kernel.org, Morten Rasmussen , Dietmar Eggemann References: <20240108140118.1596-1-quic_sibis@quicinc.com> <20240108140118.1596-4-quic_sibis@quicinc.com> From: Lukasz Luba In-Reply-To: <20240108140118.1596-4-quic_sibis@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Sibi, + Morten and Dietmar on CC On 1/8/24 14:01, Sibi Sankar wrote: > Register for limit change notifications if supported with the help of > perf_notify_support interface and determine the throttled frequency > using the perf_opp_xlate to apply HW pressure. > > Signed-off-by: Sibi Sankar > --- > drivers/cpufreq/scmi-cpufreq.c | 42 +++++++++++++++++++++++++++++++++- > 1 file changed, 41 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c > index 4ee23f4ebf4a..53bc8868455d 100644 > --- a/drivers/cpufreq/scmi-cpufreq.c > +++ b/drivers/cpufreq/scmi-cpufreq.c > @@ -25,9 +25,13 @@ struct scmi_data { > int domain_id; > int nr_opp; > struct device *cpu_dev; > + struct cpufreq_policy *policy; > cpumask_var_t opp_shared_cpus; > + struct notifier_block limit_notify_nb; > }; > > +const struct scmi_handle *handle; > +static struct scmi_device *scmi_dev; > static struct scmi_protocol_handle *ph; > static const struct scmi_perf_proto_ops *perf_ops; > > @@ -144,6 +148,22 @@ scmi_get_cpu_power(struct device *cpu_dev, unsigned long *power, > return 0; > } > > +static int scmi_limit_notify_cb(struct notifier_block *nb, unsigned long event, void *data) > +{ > + unsigned long freq_hz; > + struct scmi_perf_limits_report *limit_notify = data; > + struct scmi_data *priv = container_of(nb, struct scmi_data, limit_notify_nb); > + struct cpufreq_policy *policy = priv->policy; > + > + if (perf_ops->perf_opp_xlate(ph, priv->domain_id, limit_notify->range_max, &freq_hz)) > + return NOTIFY_OK; > + > + /* Update HW pressure (the boost frequencies are accepted) */ > + arch_update_hw_pressure(policy->related_cpus, (freq_hz / HZ_PER_KHZ)); This is wrong. The whole idea of the new HW pressure was that I wanted to get rid of the 'signal smoothing' mechanism in order to get instantaneous value from FW to task scheduler. Vincent created 2 interfaces in that new HW pressure: 1. cpufreq_update_pressure(policy) - raw variable 2. arch_update_hw_pressure(policy->related_cpus, (freq_hz / HZ_PER_KHZ)) - smoothing PELT mechanism, good for raw IRQ in drivers In our SCMI cpufreq driver we need the 1st one: cpufreq_update_pressure(policy) The FW will do the 'signal smoothing or filtering' and won't flood the kernel with hundreds of notifications. So, please change that bit and add me, Morten and Dietmar on CC. I would like to review it. Regards, Lukasz