Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3126596ybk; Mon, 18 May 2020 18:55:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycmfxIizivJioW9BzZms293VrfWcUP4xLh4PXQqB9LxjU55IGD48uDViiMGaXGnp62KVF/ X-Received: by 2002:a17:906:b08c:: with SMTP id x12mr15699343ejy.154.1589853320413; Mon, 18 May 2020 18:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589853320; cv=none; d=google.com; s=arc-20160816; b=qqg1ujF+vLIRpgPMbK8og0KmczSoPiOAnXDuHxtCXykybGsFZjF6U9TLp+iLJ2+Xsv D48S8Tx5mEa1DpaBzAPFRRZYtwEvbpIkEmzwG88YxoZEqYYfyGdwZq7Kx5T9Y3LR+GlJ ZZzZD1A/wvV32gD4vH+5ej7PhB2R89RaYvguL16RdncKdjg76ev6AlnFj7TjUNgiOkGp UwIlG6/KG/fsr3JNsbkginhor5t8mULRkgaVgRvJK7vJkEdHGUxVEAuyALKBJLeuwF1j H2c1bTc3I32YPOplvTCZKpYR+P3Hx1UvdB25D7f6jqEPggn8XBeIYH/0VVgrfNC2iTpk iJqQ== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=XSyVEQFAwLqAWjGAiJ75ET3sFUn5FlysVVOZvl0MJ0I=; b=WEf+6yd9pnlFuBCTHe0KRLsGV8Ur6fZbVS/EFxo1MgHEhnipwdsrtkBylgbHI7VBKl CrjZXBXx0oPoHlUF4viln5YHDXGxMyuFxx6CvG9UOqgyP0KCHY0Z+VutB8JwuUIuv8F5 ernVoRJorgAmIya3GU73/HLhxsUOWLIHevD160zsL8eoAMH3S0VDWB03XSnNts+ckW7N G/emmMfPx/7c0wYOicEpDL6JH1AUgWSJldPs4e28m5YrG3GHV+YbuE6mczReSDYUuXvi QyTUweJ9gw0/gydER2Z42DQy+sujYw/IZcu1WRJlXWvU/jL0l9+OXjpa/8JmDzYKg5Bg kAjA== 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 e21si6462396edv.87.2020.05.18.18.54.43; Mon, 18 May 2020 18:55:20 -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 S1726724AbgESBuM (ORCPT + 99 others); Mon, 18 May 2020 21:50:12 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:49988 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726285AbgESBuL (ORCPT ); Mon, 18 May 2020 21:50:11 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 8ECD523AA1AC6E274294; Tue, 19 May 2020 09:50:08 +0800 (CST) Received: from [127.0.0.1] (10.166.215.101) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Tue, 19 May 2020 09:50:04 +0800 Subject: Re: [PATCH v2 20/20] cpufreq: Return zero on success in boost sw setting To: "Rafael J. Wysocki" , Serge Semin CC: Serge Semin , "Rafael J. Wysocki" , Viresh Kumar , "Rafael J. Wysocki" , Thomas Bogendoerfer , Ulf Hansson , "Matthias Kaehlcke" , Alexey Malahov , Paul Burton , Ralf Baechle , Arnd Bergmann , "Rob Herring" , , "devicetree@vger.kernel.org" , Stable , Frederic Weisbecker , "Ingo Molnar" , Yue Hu , Linux PM , Linux Kernel Mailing List References: <20200306124807.3596F80307C2@mail.baikalelectronics.ru> <20200518102415.k4c5qglodij5ac6h@vireshk-i7> <20200518103102.t3a3g4uxeeuwsnix@mobilestation> <5284478.EF2IWm2iUs@kreacher> <20200518104602.mjh2p5iltf2x4wmq@mobilestation> <20200518105649.gcv22l253lsuje7y@mobilestation> From: Xiongfeng Wang Message-ID: Date: Tue, 19 May 2020 09:50:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.166.215.101] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rafael, On 2020/5/18 19:05, Rafael J. Wysocki wrote: > On Mon, May 18, 2020 at 12:56 PM Serge Semin > wrote: >> >> On Mon, May 18, 2020 at 12:51:15PM +0200, Rafael J. Wysocki wrote: >>> 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! Thanks for CCing me. I will write my next version based on this branch. Thanks, Xiongfeng >> >> No credits with at least Reported-by tag? That's sad.( > > OK, done now, but you are not the only reported of it, so I've added > the other reporter too. > > Thanks! > > . >