Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1242080imm; Wed, 19 Sep 2018 14:51:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbXtk0h3qhetKSeH0bb7QxWsI0iCsj7NQX/IddMYucrJxw4pLSNLaaklF859Lus7Rgp/lHB X-Received: by 2002:a62:e813:: with SMTP id c19-v6mr38118596pfi.124.1537393888212; Wed, 19 Sep 2018 14:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537393888; cv=none; d=google.com; s=arc-20160816; b=0KzyMq/dRf0/MzyNf2UkqZLBwwJ6Y7nDj3VgEMS0/YAt0VRWdnXRt7tZF/P2Ii+al7 DmPeSOh9KWCvj2MydBkLZSs1O/JVDoWJN0b9GaesVAFzts/uovfARTWbD67ZjUVKWGKY TFmX+adB6pEXfaXqpvEjk+GqapWbuZmG66rpm7ejWSYRj9bbJ3K7V0D6tZXoHs4R7A9P hLARZBnk0qHSa+MEcKGrz+MZh0KJwUu02jXPSEc3lJEP6x+d5e0RGF8j7JJYUJ/xEBg5 BBXP2qXP3lJCveKOGwLijbEYi9Q6C3ood4eWDWmDpg4dc+f10lsI2rDYTI5efFsoyjkL cq8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iTchldsYhyDPFCiRic9iRa2/5REzN2/e/p1pgEkEsDM=; b=hhhYacQ7jbvQUUaDSUJPzLs4zXyTN2crIpXtJ3kDvIB8Zw6nx6SmycfSNc7gIcwgv5 O+Xp4dOZSXGuKVawFgxZpHa5E7t9EhUosUJjNBWKd8bw2nLtTWatxJnaeQd7lqEEec0b R6Y/Rsf82Y0RZ2eCxF6uh3IBlWARR7h0gvZnuEnICp0iyFTa0LPzmYpq3ANjyOeCe+fO swH6wSEzKu1AMJy1S3dZKYIbKMkhJpC2aXY2epGN+qqIcch3tg95NgI0Q1nVhGvzBbnY 8/xC4ZHTcUM8XC/Qey6zRHMjj2ooOSDaMD3Cny7goVF6qK5Km9Y0CXkYtb7D5yhulri+ 8sDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YERew+MC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u37-v6si19964662pgl.78.2018.09.19.14.51.12; Wed, 19 Sep 2018 14:51:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YERew+MC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732979AbeITDSG (ORCPT + 99 others); Wed, 19 Sep 2018 23:18:06 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38045 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732724AbeITDSF (ORCPT ); Wed, 19 Sep 2018 23:18:05 -0400 Received: by mail-pg1-f193.google.com with SMTP id t84-v6so3350246pgb.5 for ; Wed, 19 Sep 2018 14:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=iTchldsYhyDPFCiRic9iRa2/5REzN2/e/p1pgEkEsDM=; b=YERew+MCnEqT2eHkPRi61n7+ps0GuWzCkBxiU6RO9BJVrVlImcjE4bScvtFMuNlpwd J7zmMw7MkyMKnXiaJ95FZOz4ud6IHfsOpuYkveDIHT+VZR0oENa3njR/0knUqYKIw0cP 9NTnkPNyUq9AxO5zGX0wI2MjSjA2x6Nvnw7RI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=iTchldsYhyDPFCiRic9iRa2/5REzN2/e/p1pgEkEsDM=; b=Hh41xtk08lRFP/0JVOlyzsdtptEj+ieQOvBYo8W83pEVv4kxTKtRYHo07McJWfsbFJ jffK5caYEQkwao9UqUBowwuua6IDaiOM8HthLuwQo9AzhXObb8ZjpO2Ok8B6HrE0Mcam PmDTr4t1mkjRxrb5NblcFkzUEhlZKc5QN1W0Kv22IcFZEVYSpf7q/QU4574u8fiqrlJE 5Akofn1LrN2Go9cgNH+9v0RTlkppZKY5WvnLpfLr4q7cK6dHz/Kqo4ovG7pPIyhCpZ9/ y8ykl6pnnUw7GfjpMhJdhg+iiHJFaa4Vp379YYeTyFMbKOSKXFAaDqPKlOksuc4NtVEY kziA== X-Gm-Message-State: APzg51BGGKuQJnJrQLfhUQzqh9ifa5JX8Qpt35LnxnCks8gr51M5msYQ Z3otUD8Z+eUYaJOo1D7jt5rHxw== X-Received: by 2002:a63:4e4e:: with SMTP id o14-v6mr137181pgl.181.1537393095065; Wed, 19 Sep 2018 14:38:15 -0700 (PDT) Received: from localhost ([209.121.128.187]) by smtp.gmail.com with ESMTPSA id s23-v6sm29826267pgo.44.2018.09.19.14.38.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Sep 2018 14:38:14 -0700 (PDT) Date: Wed, 19 Sep 2018 14:38:13 -0700 From: Viresh Kumar To: Niklas Cassel Cc: Andrew Lunn , Gregory Clement , Jason Cooper , Nishanth Menon , "Rafael J. Wysocki" , Sebastian Hesselbarth , Stephen Boyd , Viresh Kumar , "linux-pm@vger.kernel.org" , Vincent Guittot , "4.18" , "linux-arm-kernel@lists.infradead.org" , Linux Kernel Mailing List Subject: Re: [PATCH 00/11] OPP: Don't create multiple OPP tables for devices sharing OPP table Message-ID: <20180919213813.cd2q6ciyuhpwgdqe@vireshk-mac-ubuntu> References: <20180912135537.GA9985@centauri.ideon.se> <20180913102113.GA25222@centauri.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180913102113.GA25222@centauri.lan> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13-09-18, 12:21, Niklas Cassel wrote: > You confused me here, since you did hide the fix for this old bug in the > middle of your new patch series :) Actually I had to place the fix at the beginning of the series and that caused git rebase to have some conflicts. And so never posted the diff. > I think that it would have been more obvious to simply paste the fix/diff > in your reply directly, since that is the most common way to post a > potential fix. Or, if you are really confident in your fix, post a V2 > directly. I will post the v2 now. > However, your branch works like a charm, so feel free to add: > Tested-by: Niklas Cassel > when sending out your branch as a V2. Thanks. Here is the new commit though which I added to this series: -------------------------8<------------------------- From: Viresh Kumar Date: Thu, 13 Sep 2018 13:09:27 +0530 Subject: [PATCH] OPP: Don't try to remove all OPP tables on failure dev_pm_opp_of_cpumask_add_table() creates the OPP table for all CPUs present in the cpumask and on errors it should revert all changes it has done. It actually is doing a bit more than that. On errors, it tries to free all the OPP tables, even the one it hasn't created yet. This may also end up freeing the OPP tables which were created from separate path, like dev_pm_opp_set_supported_hw(). Reported-by: Niklas Cassel Signed-off-by: Viresh Kumar --- drivers/opp/cpu.c | 8 ++++++-- drivers/opp/of.c | 4 ++-- drivers/opp/opp.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/opp/cpu.c b/drivers/opp/cpu.c index 0c0910709435..2eb5e2e7ff66 100644 --- a/drivers/opp/cpu.c +++ b/drivers/opp/cpu.c @@ -108,7 +108,8 @@ void dev_pm_opp_free_cpufreq_table(struct device *dev, EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); #endif /* CONFIG_CPU_FREQ */ -void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of) +void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of, + int last_cpu) { struct device *cpu_dev; int cpu; @@ -116,6 +117,9 @@ void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of) WARN_ON(cpumask_empty(cpumask)); for_each_cpu(cpu, cpumask) { + if (cpu == last_cpu) + break; + cpu_dev = get_cpu_device(cpu); if (!cpu_dev) { pr_err("%s: failed to get cpu%d device\n", __func__, @@ -140,7 +144,7 @@ void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of) */ void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask) { - _dev_pm_opp_cpumask_remove_table(cpumask, false); + _dev_pm_opp_cpumask_remove_table(cpumask, false, -1); } EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table); diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 20988c426650..86222586f27b 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -592,7 +592,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_indexed); */ void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask) { - _dev_pm_opp_cpumask_remove_table(cpumask, true); + _dev_pm_opp_cpumask_remove_table(cpumask, true, -1); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table); @@ -627,7 +627,7 @@ int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask) __func__, cpu, ret); /* Free all other OPPs */ - dev_pm_opp_of_cpumask_remove_table(cpumask); + _dev_pm_opp_cpumask_remove_table(cpumask, true, cpu); break; } } diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 7c540fd063b2..a9d22aa534c3 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -196,7 +196,7 @@ struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table); void _opp_free(struct dev_pm_opp *opp); int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table, bool rate_not_available); int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic); -void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of); +void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of, int last_cpu); struct opp_table *_add_opp_table(struct device *dev); #ifdef CONFIG_OF -- viresh