From patchwork Tue Nov 29 05:11:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 84497 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1453853qgi; Mon, 28 Nov 2016 21:11:23 -0800 (PST) X-Received: by 10.99.116.25 with SMTP id p25mr46636611pgc.161.1480396282971; Mon, 28 Nov 2016 21:11:22 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142si58254551pgd.195.2016.11.28.21.11.22; Mon, 28 Nov 2016 21:11:22 -0800 (PST) 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=neutral (body hash did not verify) header.i=@linaro.org; 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=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754418AbcK2FLV (ORCPT + 13 others); Tue, 29 Nov 2016 00:11:21 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:33544 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751308AbcK2FLU (ORCPT ); Tue, 29 Nov 2016 00:11:20 -0500 Received: by mail-pf0-f179.google.com with SMTP id d2so29497090pfd.0 for ; Mon, 28 Nov 2016 21:11:19 -0800 (PST) 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=ROAxVSgGi6O4nZyflantrQ7t1hZ35JwVqjZ2PkVd1CA=; b=IV1cdFwqL3TYZQCZ9dU3Z+vqBToslAuGroTjFoc/Ql6dlYMWeqGoaf/4Jy5Y+riHSU B8Etl8HaVXD0vuauFpIq0gGGyhOf6GhsZHgs2pChlKmXl147KXEwrQDaDrcGoG8y8o4O QDNv6Q2zBF7usFUQ9pYQ2cqcl+Zdfxw3FseaY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ROAxVSgGi6O4nZyflantrQ7t1hZ35JwVqjZ2PkVd1CA=; b=l2xXEPDcPCCRq2zsiCpUcjITZy/PKFNjTPPFm93D+szTopInCejuWcgsn6Yy5U3x4S 3x7YIvEhjjcBM0DW4v9ftKGCFD+2hxt9OLgngbZz69whZyP/0oastAsEheJKJ0e9fZaW FoLziW/wGnQmeuq+yW9AJ9HBs8xcvyohlCIoQyKij0JKYtuN2KO1Dq9XZ4sMdu77AMfR Hb3HAbM13GsRsA0xXcfIbP5D7o3+EhQo7/4QoAyyfCDrNzB1XR/6JoZpm8goBRrOgD8N dK25D9/mK8dmrLWOlxiMP5AFIxsoQnRjAa6MfLERhISJ/jo4W6uvVxiYD8/9x4pDKrsj Y1sA== X-Gm-Message-State: AKaTC0033hsccXitzyTvHty3VcmoVuva7ZGx7DiyenuN2diPcMS3xVz3N1veIYEDpCZBNV3d X-Received: by 10.99.208.21 with SMTP id z21mr46349116pgf.79.1480396279411; Mon, 28 Nov 2016 21:11:19 -0800 (PST) Received: from localhost ([122.172.89.192]) by smtp.gmail.com with ESMTPSA id a22sm91034214pfg.7.2016.11.28.21.11.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 21:11:18 -0800 (PST) Date: Tue, 29 Nov 2016 10:41:15 +0530 From: Viresh Kumar To: Stephen Boyd Cc: Rafael Wysocki , jy0922.shim@samsung.com, Viresh Kumar , Nishanth Menon , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] PM / OPP: Allow inactive opp_device to be present in dev list Message-ID: <20161129051115.GE3288@vireshk-i7> References: <2fe61813c867c173ddfcb0b9cabc00a65997a935.1480056714.git.viresh.kumar@linaro.org> <20161129024647.GY6095@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161129024647.GY6095@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 28-11-16, 18:46, Stephen Boyd wrote: > Anyway, rant over, how about handing out the opp table pointer to > the caller so they can pass it back in when they call the put > side? That should fix the same problem if I understand correctly. Hmm, so the problem is that all below routines (and their callers) need to get updated: int dev_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, unsigned int count); void dev_pm_opp_put_supported_hw(struct device *dev); int dev_pm_opp_set_prop_name(struct device *dev, const char *name); void dev_pm_opp_put_prop_name(struct device *dev); struct opp_table *dev_pm_opp_set_regulator(struct device *dev, const char *name); void dev_pm_opp_put_regulator(struct opp_table *opp_table); And that will make it difficult to get it back to stable kernels, specially because they were all added in different kernel releases after 4.4. And we also need to fix them properly, with something like a cookie instead of a plain opp_table pointer. I suggest this patch for the time being, with a big FIXME in it, so that we can get it to stable kernels. -------------------------8<------------------------- -- viresh -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c index 8c3434bdb26d..2e96efdb10b2 100644 --- a/drivers/base/power/opp/cpu.c +++ b/drivers/base/power/opp/cpu.c @@ -118,26 +118,45 @@ void dev_pm_opp_free_cpufreq_table(struct device *dev, EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); #endif /* CONFIG_CPU_FREQ */ +void _cpu_remove_table(unsigned int cpu, bool of) +{ + struct device *cpu_dev = get_cpu_device(cpu); + + if (!cpu_dev) { + pr_err("%s: failed to get cpu%d device\n", __func__, cpu); + return; + } + + if (of) + dev_pm_opp_of_remove_table(cpu_dev); + else + dev_pm_opp_remove_table(cpu_dev); +} + void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of) { struct device *cpu_dev; - int cpu; + int cpu, first_cpu; WARN_ON(cpumask_empty(cpumask)); - for_each_cpu(cpu, cpumask) { - cpu_dev = get_cpu_device(cpu); - if (!cpu_dev) { - pr_err("%s: failed to get cpu%d device\n", __func__, - cpu); - continue; - } - - if (of) - dev_pm_opp_of_remove_table(cpu_dev); - else - dev_pm_opp_remove_table(cpu_dev); - } + /* + * The first cpu in the cpumask is important as that is used to create + * the opp-table initially and routines like dev_pm_opp_put_regulator() + * will expect the list-dev for the first CPU to be present while such + * routines are called, otherwise we will fail to find the opp-table for + * such devices. + * + * FIXME: Cleanup this mess and implement cookie based solutions instead + * of working on the device pointer. + */ + first_cpu = cpumask_first(cpumask); + cpumask_clear_cpu(first_cpu, cpumask); + + for_each_cpu(cpu, cpumask) + _cpu_remove_table(cpu, of); + + _cpu_remove_table(first_cpu, of); } /**