Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp517617pxv; Wed, 30 Jun 2021 10:48:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUkeczqf0FtMFM7SC7Gdou8oAJ4iTvZR1TR92qJS/Wzdnh8FRXM4tXgT610IJzZwKsaZgo X-Received: by 2002:a05:6402:12d4:: with SMTP id k20mr48990484edx.344.1625075332886; Wed, 30 Jun 2021 10:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625075332; cv=none; d=google.com; s=arc-20160816; b=ohTHmwfRvNwoPmhP9mWRVIaKEyyqmkl1B3LayWUJ/NhyyRY1inx+zJL+pbjJd7+7RM F3YP5x9va7MyvKvT+xPXUGJzkfHbcw6wwY5xKLjpyYRISea3Z5xyFKUJsh86Jr56d3fQ 8nEwqmVIAiMq0Re95tkq0g7geAgUB8MhPEI2ynQIyW/SFJJ2qYNpuRXhMarkvU6H5WBo BJL/zxcczCwJJ334eO94cYCTif6fnnBMsrZ6RsIQpx7vFDkNFIVjsbk37de7sgbCNUAi tmhgTW9W4WX3QXytC0sEs2YcFCA3h3Qi8/UbLcQnt1olm4HCdN4xhI9u3Giv3CUw4iPF yc+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=r0XgWyFZDrmT/H0aoUSBhg+ke5B0GhsrurcaFTIWJWQ=; b=XR5a9c92U+Falq9+7vvx72j0ssRrCIqX56mvtLO+1bvdpTZlVY1x0fleyv2/47Thk+ RAQndNmSz6mE1yd/Cz2z4IFkYIvGiQUPCsVQnZ2AOcS8zlSaj9oHYMVZTCXQvQ1KxTBV FXFv4sKAvnvACHel9lr6QLdaLn50RMIlyrmJ5i5MEUwZVjsGcdd7u1YTUAMhvgLp97/o jsXrI77bZKn8xxIImppnPAJxyzwBh+8V3FMrJsMxYKi8ebzuddtymSTI4mdqAx8vSVMw kHv23wUzFbOZLv7HGG20nnlFTuMyRANJBhn5xJnqUo8ih2DuWeB2Zv2V9Yic2+8qKAkw KK0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si24133766eje.489.2021.06.30.10.48.26; Wed, 30 Jun 2021 10:48:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232806AbhF3Rtx (ORCPT + 99 others); Wed, 30 Jun 2021 13:49:53 -0400 Received: from mail-ot1-f41.google.com ([209.85.210.41]:35535 "EHLO mail-ot1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbhF3Rtw (ORCPT ); Wed, 30 Jun 2021 13:49:52 -0400 Received: by mail-ot1-f41.google.com with SMTP id 7-20020a9d0d070000b0290439abcef697so3596275oti.2; Wed, 30 Jun 2021 10:47:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=r0XgWyFZDrmT/H0aoUSBhg+ke5B0GhsrurcaFTIWJWQ=; b=DIj/s5WKke38+rGSrav7A+0xNRsurLT0qPjU19wmOEhStqT3u7ajm0acmQs/kScNYO HgHegaIEz0DmAXwe6bt+x19RcutPhKBYsyjuroR4yF0HO0vzgUH4xW9110RL681gCEh3 N2FdCxxCWRlv1s1oq1qiG8YyLK4IZPpHbTyvUfVY6paji0cmsUSeXg3GehXUgPzvek6Z mAbzA3+SkBQb2omOcciNfYrJ2+IerrTYPurrvwIo9cGBGTu7UJO8sjG7gedaABgThpE6 NK+KTkM/T2n9ztZX8eZGUkMfm/EQ3UZ2OPtd7Ya3oepUTrtL39uZbAbXWLk+Q6MbK7xR ML3A== X-Gm-Message-State: AOAM533k7ql6a7mv3ZwqALyVXiU1ueTOooU8MCsZQaDxT+w4O+KvDMxK CmkYrUU8dHytKjqKXTPJZv9Y90/7hKU4ZejxjPc= X-Received: by 2002:a9d:674b:: with SMTP id w11mr10076387otm.260.1625075241865; Wed, 30 Jun 2021 10:47:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 30 Jun 2021 19:47:11 +0200 Message-ID: Subject: Re: [PATCH 1/2] cpufreq: Reuse cpufreq_driver_resolve_freq() in __cpufreq_driver_target() To: Viresh Kumar Cc: Rafael Wysocki , Linux PM , Vincent Guittot , TungChen Shih , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 29, 2021 at 8:27 AM Viresh Kumar wrote: > > __cpufreq_driver_target() open codes cpufreq_driver_resolve_freq(), lets > make the former reuse the later. > > Separate out __resolve_freq() to accept relation as well as an argument > and use it at both the locations. > > Signed-off-by: Viresh Kumar > --- > drivers/cpufreq/cpufreq.c | 42 ++++++++++++++++++++------------------- > 1 file changed, 22 insertions(+), 20 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 802abc925b2a..d691c6c97c79 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -524,19 +524,8 @@ void cpufreq_disable_fast_switch(struct cpufreq_policy *policy) > } > EXPORT_SYMBOL_GPL(cpufreq_disable_fast_switch); > > -/** > - * cpufreq_driver_resolve_freq - Map a target frequency to a driver-supported > - * one. > - * @policy: associated policy to interrogate > - * @target_freq: target frequency to resolve. > - * > - * The target to driver frequency mapping is cached in the policy. > - * > - * Return: Lowest driver-supported frequency greater than or equal to the > - * given target_freq, subject to policy (min/max) and driver limitations. > - */ > -unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, > - unsigned int target_freq) > +static unsigned int __resolve_freq(struct cpufreq_policy *policy, > + unsigned int target_freq, unsigned int relation) > { > target_freq = clamp_val(target_freq, policy->min, policy->max); > policy->cached_target_freq = target_freq; > @@ -545,7 +534,7 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, > unsigned int idx; > > idx = cpufreq_frequency_table_target(policy, target_freq, > - CPUFREQ_RELATION_L); > + relation); > policy->cached_resolved_idx = idx; > return policy->freq_table[idx].frequency; > } > @@ -555,6 +544,23 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, > > return target_freq; > } > + > +/** > + * cpufreq_driver_resolve_freq - Map a target frequency to a driver-supported > + * one. > + * @policy: associated policy to interrogate > + * @target_freq: target frequency to resolve. > + * > + * The target to driver frequency mapping is cached in the policy. > + * > + * Return: Lowest driver-supported frequency greater than or equal to the > + * given target_freq, subject to policy (min/max) and driver limitations. > + */ > +unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, > + unsigned int target_freq) > +{ > + return __resolve_freq(policy, target_freq, CPUFREQ_RELATION_L); > +} > EXPORT_SYMBOL_GPL(cpufreq_driver_resolve_freq); > > unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy) > @@ -2225,13 +2231,11 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, > unsigned int relation) > { > unsigned int old_target_freq = target_freq; > - int index; > > if (cpufreq_disabled()) > return -ENODEV; > > - /* Make sure that target_freq is within supported range */ > - target_freq = clamp_val(target_freq, policy->min, policy->max); > + target_freq = __resolve_freq(policy, target_freq, relation); > > pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", > policy->cpu, target_freq, relation, old_target_freq); > @@ -2252,9 +2256,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, > if (!cpufreq_driver->target_index) > return -EINVAL; > > - index = cpufreq_frequency_table_target(policy, target_freq, relation); > - > - return __target_index(policy, index); > + return __target_index(policy, policy->cached_resolved_idx); > } > EXPORT_SYMBOL_GPL(__cpufreq_driver_target); > > -- Applied as 5.14-rc1 material along with the [2/2], thanks!