Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1955051lql; Wed, 13 Mar 2024 12:58:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVxTlBmCWFqnHM/ihXCqEmNvNw2oJeYUImVmPEW3CAV9PrLhuei4FzaE/RFL5ULki16B82Q1PudOAy6eQrExJvJ6faFPAYk3syKS0lkEQ== X-Google-Smtp-Source: AGHT+IEY+Bt3KBdL3EQlsDc96dBMPcBJI7+3HRuUkFNSgndqMRbrL1QtNu58s6ED1GyDu9BdfFrY X-Received: by 2002:a17:902:c403:b0:1db:d826:45a1 with SMTP id k3-20020a170902c40300b001dbd82645a1mr4750652plk.9.1710359908234; Wed, 13 Mar 2024 12:58:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710359908; cv=pass; d=google.com; s=arc-20160816; b=KiD3qTq3ivfv4/puNq6yFYaFZ5xLcu6ikGNc7uBmtLBbMol26pV2i4kMIbTCc0LwqV TfzeLXiF9h4/8aSysN3cGFF63AFFObhmxvwIwjXo+GNchRythdB6HeEIc9b05EHEth1r A2tMfTo5S8xbEM1392zwfjRLptP6gFYIHLBNxanUmQwkljNqnXHIMM5wMWqPrDgGw4XO eJ9e2mEjHY6hT2k/eM5zj2C1tmKABoZcWjsXdorKhxJegaeqSSgnrwmCeyqeLhhFcm6s /7oMDfttF9jx9icpkh7j34SAxn3M3Ls6REiFlt9Bhk0+jcZzXbTuF68u+jM8Uze8a7Hs 2w6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=NdP8F+x5j1lSl9Kjac5VCWtp2OKa5wXezFE2irQlxPY=; fh=AnWXIpT3m/DrTs0wnKouJtQD0BOBIzp3rbRn4Qc2DGE=; b=Ya2XmcF5mHgVeAJvoILuFy59CX3goMwRXJwiV7+3fGTYPXDrxQ+ZtUcZudibvAD2JI cHlNf006cYFIvarAOzadploBPGkEdrffh1Kxa3U4p86bVBD5qdUBBlyvp0+RCduan2M/ QtoSXEmwoOQ0KO2/DGpzPLK6bBkLUj0LxJTfW89BK4pyqm0Qn+xhZDdqjNFmW9lRCqj1 NGMSaSwS2cXYlWDDThTL1lMLW24btqjiol5+ubWqOEDbtm0bq4XYNYhFYxmjFSjE7BS1 HyIBmMOCLOQwbLVGiPauVtr85hYeP6e3Ag9qvwx4FJEkbXwOfUaTbOpA+bU0GrRUW2xK 56rQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-102458-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x7-20020a656aa7000000b005e46720db84si53862pgu.117.2024.03.13.12.58.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 12:58:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102458-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-102458-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B1E6328A279 for ; Wed, 13 Mar 2024 19:58:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C36304CE11; Wed, 13 Mar 2024 19:58:18 +0000 (UTC) Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 326AA20DDB; Wed, 13 Mar 2024 19:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710359898; cv=none; b=ImeV9DvLjNvLogHLRbtuM7rC4SodVDX5svar8zu9BUVC6R6bVBaeivJxAH4SSnAhs4xlm9Y+piUG4PyuYFmtx6c8dzjXyr4vl9CDZj6K4l0NH/Ux3URsBaLq2bYp3sNZRwMJSihLFp2spVWTIs1Nd2dbXbyPYkSEARhiGcKmGUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710359898; c=relaxed/simple; bh=hhFq5IpzNKqt3vASlinqD/E0HbWm7PiMwUPQBESAj5I=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=TCwFzEsWezUjZH8fv04mi0bJZBH6+tuzneg2tUh/d9TyV63k2DOr3bljkaDqkByp17tATkVqlzrzLVRxisB6dFboc/TNdYJxoPuNVRuk+C1jrVxEtITX8GRAJKRJmsO+Rf5OoVdTi0oYB2QBuyO81qja0QHlhcHenGrbeeta6iY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-2219edd959dso74895fac.0; Wed, 13 Mar 2024 12:58:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710359895; x=1710964695; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NdP8F+x5j1lSl9Kjac5VCWtp2OKa5wXezFE2irQlxPY=; b=a0Z04Dna8Gtl25EDeNATVlB59ubX0/tiAtYJlvgryvdokzvYz+eWuu+Z9AX4maeHoK jOIQpFnt/SAADin7E6OCoqIzxTlwJ2vKMZUfcTeyUhbQc2UNv4sKPiQbIjYRhwRkf+Iq pImL6fA8hCJkeInpdxDF+kq/Of+7MyvmC4rDAAleU/4teFrM9I/jhx+YmVUZ1Ov0uPWZ OTkxVbL5o1AFBDm5vW5rM3V6MaCbb68z8ZWMDpqt8/bh+QzF6RVJv3FAq02mRqbmoQAi gUcnhlL/5wZY6imdqWV4Zmz+nieWoBfYdTzwfk+5X2K9BrFb//AkSzOcg3uObKM+USwk oHLg== X-Forwarded-Encrypted: i=1; AJvYcCVJZEg3ArUTE8aNv3QGGlmHEXzhlSuQQLiZ+3SZLyn8QoCs099nrjdYacb7++GoQJGzRlV4QwYEsXa1BU3ZPKM+Bdf5tR76AXu4Qo4aDJF8bkxs40D2QLu1unVCdxTU+lPpobspiwSJ/qAajyCcXbFV34wd/XsAcQBWKWaWgMXu0PFLuwmy X-Gm-Message-State: AOJu0Yx0LO+PUL8p6GQBHCHiWemX9Dni2XD+cDFgBaGbgaVPmNFVYaI4 c+6loQSWCa6RUZKrxT+Ds7TSuFF/bYOfigKdBRa2JCJ631axKYFExYNUVnLT2k1YdsF3MbCgzlo vjI8rMg0NY/Aa2Xwt9+rM9UvWMl8= X-Received: by 2002:a05:6871:3325:b0:221:cb1b:cc05 with SMTP id nf37-20020a056871332500b00221cb1bcc05mr3047428oac.0.1710359895299; Wed, 13 Mar 2024 12:58:15 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240312103723.3469762-1-quic_sibis@quicinc.com> In-Reply-To: <20240312103723.3469762-1-quic_sibis@quicinc.com> From: "Rafael J. Wysocki" Date: Wed, 13 Mar 2024 20:58:04 +0100 Message-ID: Subject: Re: [PATCH V3] cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw To: Sibi Sankar Cc: dietmar.eggemann@arm.com, rafael@kernel.org, viresh.kumar@linaro.org, xuwei5@hisilicon.com, zhanjie9@hisilicon.com, sudeep.holla@arm.com, cristian.marussi@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, quic_rgottimu@quicinc.com, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, d-gole@ti.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 12, 2024 at 11:37=E2=80=AFAM Sibi Sankar wrote: > > In the existing code, per-policy flags doesn't have any impact i.e. > if cpufreq_driver boost is enabled and one or more of the per-policy > boost is disabled, the cpufreq driver will behave as if boost is > enabled. Fix this by incorporating per-policy boost flag in the policy->m= ax > calculus used in cpufreq_frequency_table_cpuinfo and setting the default > per-policy boost to mirror the cpufreq_driver boost flag. > > Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost") > Reported-by: Dietmar Eggemann > Reviewed-by: Viresh Kumar > Reviewed-by: Dhruva Gole > Signed-off-by: Sibi Sankar > --- > > v3: > * Pickup Rbs. > * Simplify per-policy boost setting. [Viresh] > > v2: > * Enable per-policy boost flag in the core instead. [Viresh] > * Add more details regarding the bug. [Viresh] > * Drop cover-letter and patch 2. > > Logs reported-by Dietmar Eggemann: > https://lore.kernel.org/lkml/265e5f2c-9b45-420f-89b1-44369aeb8418@arm.com= / > > drivers/cpufreq/cpufreq.c | 18 ++++++++++++------ > drivers/cpufreq/freq_table.c | 2 +- > 2 files changed, 13 insertions(+), 7 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index f6f8d7f450e7..66e10a19d76a 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -653,14 +653,16 @@ static ssize_t store_local_boost(struct cpufreq_pol= icy *policy, > if (policy->boost_enabled =3D=3D enable) > return count; > > + policy->boost_enabled =3D enable; > + > cpus_read_lock(); > ret =3D cpufreq_driver->set_boost(policy, enable); > cpus_read_unlock(); > > - if (ret) > + if (ret) { > + policy->boost_enabled =3D !policy->boost_enabled; > return ret; > - > - policy->boost_enabled =3D enable; > + } > > return count; > } > @@ -1428,6 +1430,9 @@ static int cpufreq_online(unsigned int cpu) > goto out_free_policy; > } > > + /* Let the per-policy boost flag mirror the cpufreq_drive= r boost during init */ > + policy->boost_enabled =3D cpufreq_boost_enabled() && poli= cy_has_boost_freq(policy); > + > /* > * The initialization has succeeded and the policy is onl= ine. > * If there is a problem with its frequency table, take i= t > @@ -2769,11 +2774,12 @@ int cpufreq_boost_trigger_state(int state) > > cpus_read_lock(); > for_each_active_policy(policy) { > + policy->boost_enabled =3D state; > ret =3D cpufreq_driver->set_boost(policy, state); > - if (ret) > + if (ret) { > + policy->boost_enabled =3D !policy->boost_enabled; > goto err_reset_state; > - > - policy->boost_enabled =3D state; > + } > } > cpus_read_unlock(); > > diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c > index c4d4643b6ca6..c17dc51a5a02 100644 > --- a/drivers/cpufreq/freq_table.c > +++ b/drivers/cpufreq/freq_table.c > @@ -40,7 +40,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_poli= cy *policy, > cpufreq_for_each_valid_entry(pos, table) { > freq =3D pos->frequency; > > - if (!cpufreq_boost_enabled() > + if ((!cpufreq_boost_enabled() || !policy->boost_enabled) > && (pos->flags & CPUFREQ_BOOST_FREQ)) > continue; > > -- Applied as 6.9-rc material, thanks!