Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2615924ybk; Mon, 18 May 2020 03:45:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ0vDJzhadL7/4fHZTcT0JdaAb17A8oDm5tlwjgDQk23z57/P/TnBo40w7Rs3XdSsK3L9y X-Received: by 2002:a17:906:cd18:: with SMTP id oz24mr15013053ejb.179.1589798737459; Mon, 18 May 2020 03:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589798737; cv=none; d=google.com; s=arc-20160816; b=ZnVuuYyWc4YvKSo6m2nFxWDJ1llzNNDWwgmyd9mHkeC/tOGAcYrATmd89LrucNfD4h AvJIuofTr5V5bUamms+RCBm4Eg6wNtXK7gUQU56ewB9iUxHWQu2MoD5z+bQXd1OaLZyH IASxSL0zIbtK8m0ukNyBs0zshgNGXxi0n9AzVl3pmD5Fow1QIY8Rfc6RtzQLZJl/IL2J kq7eW3mGzQ+VMttuTYve1MQQvUAE8HQkEf70oX3d/3wNukATRnfPSBcFGHbKEyoaxyEt N4i1oBtSMNVM9RNXqiSdQkrt3xcj6j1p5WzoZRgPkXswig8X8cUDdSuZZEealAlP8JqY W+EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1pZuewlvuO97djGvGPtlNa7WVhHpkBd6gaEirIXqQxM=; b=hBE2gOZ8wMqzcjhR1X37UnsAP1uaC3LXse74nKB74M0PPXSFtKqeiIuD9CnKSad7mm 9F5ZMKgAMhqg7bChm5k42JITWsGesLP5BNK5TaOaTCLuyQa9yCcw86DjK/6k9Sb5EXQq gYdpJHg4FqzhgW5QDPgEcGQpzQWhT7AUC5cSL1HlfYiIlq3jO0KbTFWsqi1a7HpQrgYp hbmZH/MnrYl2qhGnijyOUABdp44pmaiwiU6uHBesOm8UfQdcHnDIiektPUj+VU+FXYDV ALWxiJxRq3h5TGQaPkPGrYU0PoRhhDegztZx+BW9lXsfMUBTr6E4/4DGUTMLzyUHVJD1 zRgw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id si3si6101209ejb.5.2020.05.18.03.45.14; Mon, 18 May 2020 03:45:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbgERKlZ (ORCPT + 99 others); Mon, 18 May 2020 06:41:25 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:43030 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726274AbgERKlZ (ORCPT ); Mon, 18 May 2020 06:41:25 -0400 Received: from 89-64-86-21.dynamic.chello.pl (89.64.86.21) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.415) id 850b1f41962055eb; Mon, 18 May 2020 12:41:21 +0200 From: "Rafael J. Wysocki" To: Serge Semin Cc: Viresh Kumar , Serge Semin , "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@vger.kernel.org, Frederic Weisbecker , Ingo Molnar , Yue Hu , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 20/20] cpufreq: Return zero on success in boost sw setting Date: Mon, 18 May 2020 12:41:19 +0200 Message-ID: <5284478.EF2IWm2iUs@kreacher> In-Reply-To: <20200518103102.t3a3g4uxeeuwsnix@mobilestation> References: <20200306124807.3596F80307C2@mail.baikalelectronics.ru> <20200518102415.k4c5qglodij5ac6h@vireshk-i7> <20200518103102.t3a3g4uxeeuwsnix@mobilestation> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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!