Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2619761ybk; Mon, 18 May 2020 03:53:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUCajaSSARWSxYO47A37l/IKnJ+An5jeItfarwmQ2FguBhOBja40bIgUKaS/KNxjY69grw X-Received: by 2002:a17:906:f108:: with SMTP id gv8mr14009179ejb.91.1589799193901; Mon, 18 May 2020 03:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589799193; cv=none; d=google.com; s=arc-20160816; b=YMQIUbtTuqPTqN5NNVCUUfdMSTK+nOx5FsJNZZ5fcEB4FdZriTzu/mKRGG+nATDUG4 FcZfYBH1Fdu2rqHNW5whZXjR64xWj5CbqGVMwiiuJyaIr5QkcaQXXfGdxFxijjHSAWZA w+D+sfhnvJ6za+8xaVaDEiLd/jnhbxsySeIvk6tCRnc2dW4w6wgiSBYFjTf1fQCbg00b dcXhN6XgtybIJZeT7Gherw8vPC8om3mEYx8WG0vyV2PuMgZMP9o33tVFMCvQZ0yA08sC mZN8nzix24R7fuqczLTJ22BxoKZKwpuYnceTFfvVgFJe6RMdqV/M3fANHDjQWBw1OSoI QD7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=lNMXSW+sgPzbz8sV3erf+BVgtCmbmji/K/QtFyrknmo=; b=RWQeifg6sqyI+xc2XfDuXSCrW8oxdAJtxsFDxvKisQY0u1fTBax1Aj0jNVwLzV0PnB ki1DRC1CzrFi7jqKEe8AnLBT3W32LFclbiBxYgPh9xHVStwwO1EWshi2hPPCagcHCIkb O7r43rNkwo0yASzNRPwTDn8NVoqLPYOUOdYsw21DqB+D3TtMSsj4bf0kS0uRZpsVMkdX wgfLbUHUKjffzhwvve6Chpqo/t0ITd1spetsw1w2FuARe+tK7Hz1TQGYORtxm4u827/A JDk1/ZsKTg/ryDrmTL9h3iQ8mUWbumCbhvcUkLiQkXyNL6pacT3dtr2B6TG6m4gxfxhP xENg== 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 d6si7350800edo.493.2020.05.18.03.52.50; Mon, 18 May 2020 03:53:13 -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 S1726399AbgERKv1 (ORCPT + 99 others); Mon, 18 May 2020 06:51:27 -0400 Received: from mail-oo1-f66.google.com ([209.85.161.66]:34032 "EHLO mail-oo1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgERKv1 (ORCPT ); Mon, 18 May 2020 06:51:27 -0400 Received: by mail-oo1-f66.google.com with SMTP id s139so1936141oos.1; Mon, 18 May 2020 03:51:26 -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=lNMXSW+sgPzbz8sV3erf+BVgtCmbmji/K/QtFyrknmo=; b=s1CfJ7uhVTqb5RMP+t++4sBVZFwoxJv9g4uee/6P6MjaiyD0euuv17fCPFm1NjsYP/ pmARXhuD0Cb4k169afAtx5woREgl1Ow0QcIz221jFyWto5mxFXRtaIefqPeoiRYiuRd4 +XH4Um2iGVuBpcXLM+G02trzec0eNTnA3OwQ4112QE7l/+T7pm8Z3AKHpL6yGLV+rTVY t3pBFs9U7/5i2E4R1vzGM4b879BzcDFQ6K0vseg3q3H1dUXvrVl4SGq3Ws+AYNgOCVTW 3ttenyx0RHvV4VrgZjSIJZTOye3HrRQdvXBg8fKzkg+psMQq8iz8ETbCezlL/BTCWhWg mgtg== X-Gm-Message-State: AOAM532LKdoA/52i+Kp9GUrjqtB/Ei+JEfyE+HMPKXar2tmtPpK6EsBg SHjc44vMSWh+f2yvQIvNjZ7HExnIWoThNu4p9ouqGQ== X-Received: by 2002:a4a:e0d1:: with SMTP id e17mr12336167oot.1.1589799085973; Mon, 18 May 2020 03:51:25 -0700 (PDT) MIME-Version: 1.0 References: <20200306124807.3596F80307C2@mail.baikalelectronics.ru> <20200518102415.k4c5qglodij5ac6h@vireshk-i7> <20200518103102.t3a3g4uxeeuwsnix@mobilestation> <5284478.EF2IWm2iUs@kreacher> <20200518104602.mjh2p5iltf2x4wmq@mobilestation> In-Reply-To: <20200518104602.mjh2p5iltf2x4wmq@mobilestation> From: "Rafael J. Wysocki" Date: Mon, 18 May 2020 12:51:15 +0200 Message-ID: Subject: Re: [PATCH v2 20/20] cpufreq: Return zero on success in boost sw setting To: Serge Semin Cc: "Rafael J. Wysocki" , Serge Semin , Viresh Kumar , "Rafael J. Wysocki" , Thomas Bogendoerfer , Ulf Hansson , Matthias Kaehlcke , Alexey Malahov , Paul Burton , Ralf Baechle , Arnd Bergmann , Rob Herring , linux-mips@vger.kernel.org, "devicetree@vger.kernel.org" , Stable , Frederic Weisbecker , Ingo Molnar , Yue Hu , Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 18, 2020 at 12:46 PM Serge Semin wrote: > > On Mon, May 18, 2020 at 12:41:19PM +0200, Rafael J. Wysocki wrote: > > On Monday, May 18, 2020 12:31:02 PM CEST Serge Semin wrote: > > > On Mon, May 18, 2020 at 03:54:15PM +0530, Viresh Kumar wrote: > > > > On 18-05-20, 12:22, Rafael J. Wysocki wrote: > > > > > On Monday, May 18, 2020 12:11:09 PM CEST Viresh Kumar wrote: > > > > > > On 18-05-20, 11:53, Rafael J. Wysocki wrote: > > > > > > > That said if you really only want it to return 0 on success, you may as well > > > > > > > add a ret = 0; statement (with a comment explaining why it is needed) after > > > > > > > the last break in the loop. > > > > > > > > > > > > That can be done as well, but will be a bit less efficient as the loop > > > > > > will execute once for each policy, and so the statement will run > > > > > > multiple times. Though it isn't going to add any significant latency > > > > > > in the code. > > > > > > > > > > Right. > > > > > > > > > > However, the logic in this entire function looks somewhat less than > > > > > straightforward to me, because it looks like it should return an > > > > > error on the first policy without a frequency table (having a frequency > > > > > table depends on the driver and that is the same for all policies, so it > > > > > is pointless to iterate any further in that case). > > > > > > > > > > Also, the error should not be -EINVAL, because that means "invalid > > > > > argument" which would be the state value. > > > > > > > > > > So I would do something like this: > > > > > > > > > > --- > > > > > drivers/cpufreq/cpufreq.c | 11 ++++++----- > > > > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > > > > > > > Index: linux-pm/drivers/cpufreq/cpufreq.c > > > > > =================================================================== > > > > > --- linux-pm.orig/drivers/cpufreq/cpufreq.c > > > > > +++ linux-pm/drivers/cpufreq/cpufreq.c > > > > > @@ -2535,26 +2535,27 @@ EXPORT_SYMBOL_GPL(cpufreq_update_limits) > > > > > static int cpufreq_boost_set_sw(int state) > > > > > { > > > > > struct cpufreq_policy *policy; > > > > > - int ret = -EINVAL; > > > > > > > > > > for_each_active_policy(policy) { > > > > > + int ret; > > > > > + > > > > > if (!policy->freq_table) > > > > > - continue; > > > > > + return -ENXIO; > > > > > > > > > > ret = cpufreq_frequency_table_cpuinfo(policy, > > > > > policy->freq_table); > > > > > if (ret) { > > > > > pr_err("%s: Policy frequency update failed\n", > > > > > __func__); > > > > > - break; > > > > > + return ret; > > > > > } > > > > > > > > > > ret = freq_qos_update_request(policy->max_freq_req, policy->max); > > > > > if (ret < 0) > > > > > - break; > > > > > + return ret; > > > > > } > > > > > > > > > > - return ret; > > > > > + return 0; > > > > > } > > > > > > > > > > int cpufreq_boost_trigger_state(int state) > > > > > > > > Acked-by: Viresh Kumar > > > > > > Ok. Thanks for the comments. Shall I resend the patch with update Rafael > > > suggests or you'll merge the Rafael's fix in yourself? > > > > I'll apply the fix directly, thanks! > > Great. Is it going to be available in the repo: > https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/ > ? Yes, it is. Please see the bleeding-edge branch in there, thanks!