From patchwork Wed Sep 19 22:20:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 147050 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1232864ljw; Wed, 19 Sep 2018 15:20:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbMTwcG/PBRSmnDp18y2oY2S58WvHVROiO+momREDsVk4EdRNbANLY25COh2xaCaWznlSkJ X-Received: by 2002:a17:902:3041:: with SMTP id u59-v6mr35465614plb.99.1537395649053; Wed, 19 Sep 2018 15:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537395649; cv=none; d=google.com; s=arc-20160816; b=TJitA8lEIzSW/g1dCCY+0cnIpLx4rahXa3xIcW+YH2DQMT2mVZ2k37lpBduQWGoQG3 bGjcSR2/hfHCufHI1RKugtI/tgTcFSDnWdh06vTTENdcKFUk+ID/sQGvXXpKMqeaNYiY 6EIRGZjOjgF5hbWNsuaNsiG495wzpgpuKx6Gtg6qeLnNZ41WK8BYJDBGIJhaMrpCxjhv PQNCraONE/YMud/vm56cWtMLUluTtUBpmSgfO0jPMYZv3qeUEdncrEhWWicj4cSNX4+O oEPtXU3mTS1Fe0a7HZQLx/vGYkjt3HhCtggTL+szI1rrvtUtsfJtAXfKB7hlH/lV7DPK HlYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=eozK+qk21bu6C0o4GTQGviL35NBsR1qUdySDKI0vP2I=; b=arAXk7nsyn8tUYDwNNONbk0t5Dq9clCEoYjNBETeWMxS84VThhbYDAcCbz8NSSz469 /0ZVlCPRC7oT6RANtopd6SCOlKbyYo+CM4sUVXPI+Uwi+QRoVm1Ttx/8XeNlqG7e+ckl hqBQTa/5jmgMPUf/f+4JkRyV4RPLBhdNbZzYSI7U7xZlk/Nn4mx4F1T/ImUrCfor2Jrj TE+R1z9VvdgXWRd1+8ig4Q7htYY/2L7LJYebvQFDqjgNV40OvQb8L/4OUfO4I2AQAiPl CS47rqz7Keg++NIE5GWWV4EU8f9UVa2DB9n47XME79g29AYPcH8scrjK1gotQUmdAz1G GX2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SwuaU0eM; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 b30-v6si22112844pgm.389.2018.09.19.15.20.48; Wed, 19 Sep 2018 15:20:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=SwuaU0eM; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1725784AbeITEAr (ORCPT + 10 others); Thu, 20 Sep 2018 00:00:47 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34051 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbeITEAr (ORCPT ); Thu, 20 Sep 2018 00:00:47 -0400 Received: by mail-pg1-f195.google.com with SMTP id d19-v6so3409722pgv.1 for ; Wed, 19 Sep 2018 15:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=eozK+qk21bu6C0o4GTQGviL35NBsR1qUdySDKI0vP2I=; b=SwuaU0eMFXWnHwJhPlvOyv1Ga8JLS7+7VSsRo3kxfYuFSx+xD06mKbdqANxh0D6aTu yLH7qygik4fIlLze/wJlcC5Jp2Y8uuYOFSS9qnG2Ec1Z4KM/QmhRNrRZfrZjs0N9C6oK mghgYTt71zKhka1NiY4O/UJ9fQUBja1hRVG7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=eozK+qk21bu6C0o4GTQGviL35NBsR1qUdySDKI0vP2I=; b=VcWnfvTb1SaGAwHT9VBOmjXBJA5iCqEGAiaywL6af0u7uw8qLJ+mSj5o4eKO+l1p0l 5EqFNVtXWOIXpXlOBQoQ0M3TkoInquCNYfXSfmCzmX1IRSatCY2xr1KdpjVrvq8KfQIf RNaKWL8g7fgwqwH1IeIjOCfgpmGV1vsaMSxqkbUF74c2h9Z5jbpv9bKqCMf+V7Cgn72b RADyrBPgVlM8v3MHyp/q9U3o3I/2ZkCdtfQBURwfU+ix63kjcOEyN8d8qTYkSyrHXqVT widCQ958LGSMStPz6V+nMoNh7aONe/fxHBB/LAJIaCi0V9K8L/rY7EA80xsEBAh+PaHX ZRlA== X-Gm-Message-State: APzg51CLz9Gmcx+gbKOuZpu2omTjEuI53dEi6DwNXEmGageRmeWxW0nb t9jWgsmUEfAIAAXUW99vkMthnw== X-Received: by 2002:a62:6690:: with SMTP id s16-v6mr38022974pfj.152.1537395645964; Wed, 19 Sep 2018 15:20:45 -0700 (PDT) Received: from localhost ([209.121.128.187]) by smtp.gmail.com with ESMTPSA id e190-v6sm45557047pfc.81.2018.09.19.15.20.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Sep 2018 15:20:45 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , Rafael Wysocki , linux-pm@vger.kernel.org, Vincent Guittot , Niklas Cassel , linux-kernel@vger.kernel.org Subject: [PATCH V2 02/12] OPP: Don't try to remove all OPP tables on failure Date: Wed, 19 Sep 2018 15:20:21 -0700 Message-Id: <404b1369ea26f598b96ae4d3183262a879703cfe.1537394233.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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-and-tested-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(-) -- 2.14.1 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