Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2630824ybk; Mon, 18 May 2020 04:10:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnvfIs3VtcSCBHG2X3oePA18rv2RQexeQTVJN18K64aUdJEL3y+FTUtErYzLmatlAdoaOe X-Received: by 2002:aa7:db0b:: with SMTP id t11mr12382490eds.304.1589800230653; Mon, 18 May 2020 04:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589800230; cv=none; d=google.com; s=arc-20160816; b=Mw0US/mWWAgvD0+ruRILmUPwAw+61t7yph2NuYooPr2QMVNrFix6rQ5JbR6fcUQcg1 gBCFGdOsBFTcIKrcqBJ+OFvpR83fPOzzkJ5nHlnRdjXfD1JnaBYqWaIRaetKlsvJiWdd jir3J0uVqVDkrYXsyuf6JQgHZgg4QJs3I9p//EhiKSN+JGc+CaAyCwwDIdx2VM/HG2A/ ABlSOFldkSv7oCcamuUXy2z2Rt1SVNFDQPL7fZM11SaJWvhuxdKePvV/WoqU2P0IcftM IN1wbhhSU6Xv6uSg/xVHF/163UYV58kJCkYhtifLG4hDqDUekCtFb+5ZPHv7uL88wH5f F+Vw== 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=wmpjxGQuy4tiYJkt2jocarW0R5KqJW68O4d9EnN2j3I=; b=VqT/Cub68m/62zVDZOs3gaIXk2nR6741XatyT161YPg0BJ7Fs7DoKDnPC2ZSZp83/S 19/MCKuKNOnL1DbkHJdo7nmXeS+BZ9kQ3KPzOoZO/DQMNsWjt84C6DBOufZTz4XzgbtQ bV6zls5kHLDVGigGaLtXVImLJ7nl1Fe55joPOBHAh3nx4ayl+Zt9+SPq9o7pjQeaKAVh FuE860NLOAsjIM9Q636TMPpOzVxduauYLpHRe9CRlIMhI4Kf53S/sxUDRiOYz5Ok2tow I7+00Tb5ZIvCKeUfpGTJTA2wO1xFTn5axWRM3F5dk39x2xxcqaJsTxW7lQT76F/m/C/K QyzA== 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 dm8si7864213ejc.453.2020.05.18.04.10.07; Mon, 18 May 2020 04:10:30 -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 S1726726AbgERLGE (ORCPT + 99 others); Mon, 18 May 2020 07:06:04 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:40711 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbgERLGE (ORCPT ); Mon, 18 May 2020 07:06:04 -0400 Received: by mail-oi1-f196.google.com with SMTP id v128so8596347oia.7; Mon, 18 May 2020 04:06:03 -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=wmpjxGQuy4tiYJkt2jocarW0R5KqJW68O4d9EnN2j3I=; b=G55yI1py8Mr9nC3KibGyzpC56Rbsg4jJEvADlhXYQyZdwyF0KwBFrJmtatKh9Si4AF 0cVgt8yJ/S3Of/m1aNZkqaPcYnBCTFVkIpxeUT/q2hP+u3ieTGcGmPySnAi5c3FsKOaD BmQJWdN8eeztomd9Vs6KbVKnr5Cj/RTxIVaFrsXTbq/YdOLLweG3PRw3ohhdcuMDKR2H k/1FjJ2NNb1bxSLVpCM3RMx1dSogTAGqzTanoDMHATl4U0SG6YLPhkVvwI7yUk0S8Qrd //306H5r92Yv/rP+9/N6ScakqdHV1uDE1PgTw/HGoxpDs6xeKkMfnlbuivqCCGRtqC59 YsTg== X-Gm-Message-State: AOAM530vz9dquQzhLJngEQxGCQ4D9Rt7vs2aP2WjkErptqhDJryNhZrp 6icsRbGpK2/QqWZjBoyLTtz9ybto/8+xBV+7i/sEbA== X-Received: by 2002:a05:6808:486:: with SMTP id z6mr573511oid.103.1589799962685; Mon, 18 May 2020 04:06:02 -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> <20200518105649.gcv22l253lsuje7y@mobilestation> In-Reply-To: <20200518105649.gcv22l253lsuje7y@mobilestation> From: "Rafael J. Wysocki" Date: Mon, 18 May 2020 13:05:51 +0200 Message-ID: Subject: Re: [PATCH v2 20/20] cpufreq: Return zero on success in boost sw setting To: 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 , linux-mips@vger.kernel.org, "devicetree@vger.kernel.org" , Stable , Frederic Weisbecker , Ingo Molnar , Yue Hu , Linux PM , Linux Kernel Mailing List , Xiongfeng Wang 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: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! > > 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!