From patchwork Wed Jul 17 10:19:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11047587 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9222A14DB for ; Wed, 17 Jul 2019 10:19:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8071C28712 for ; Wed, 17 Jul 2019 10:19:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7455B28724; Wed, 17 Jul 2019 10:19:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6682628720 for ; Wed, 17 Jul 2019 10:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725993AbfGQKTz (ORCPT ); Wed, 17 Jul 2019 06:19:55 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41016 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbfGQKTy (ORCPT ); Wed, 17 Jul 2019 06:19:54 -0400 Received: by mail-pg1-f196.google.com with SMTP id x15so592475pgg.8 for ; Wed, 17 Jul 2019 03:19:54 -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:mime-version :content-transfer-encoding; bh=47h7mNoqO2yjIf+Awl5RozvneGnjTx6MR3XFMeu6eY4=; b=fciAn2pTVnVyE5s5FVXbRgH1XKNS9xOCpqD5H9fswkBPYdyiTkKHfBJv0kncocpENV MpYMoIyUn616Kd5L0p3GFB1WFSkm02dI2a2n7BPn0+/fr6xw/nLGhzLkOwC7DDtBweQr PEOBXwF9y9dJwMvqwMmxHtrcAoeomRVRjy9MEObaBEaGLJuPTROHEt125DzEZvuBTbA3 pWjsGu2/Z8V4O+eFtVYpdoihmo6+1nT/yu1Jtw84lTURE63k2Pu591ftFL94w9iJgfGf QWzrJCuMwAwa+s/dZhiBNO+ZH40XA44CqyoP26vGQNoSSXVo9HkRa5mXIXtin7KOj19v TttA== 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:mime-version :content-transfer-encoding; bh=47h7mNoqO2yjIf+Awl5RozvneGnjTx6MR3XFMeu6eY4=; b=W4ErAXhtDoK4F5PpIg2YCStUERVUNFG9dFOeXubJthLB/50g8sGf8bWrcoyx1STBis Xh4V2TWVFEAxcncYXg0GuzWuZRaMGZWknEeFIHJE73KCXS05IIXdeaHPMp6H+zf55B0+ /eZapl//PwCHjQwJZTvtrlBc91pmAHPf4rgfDQzdFMgq/Ltac2EoKgmQ/m+pkwHArlWZ kiOODGyqp84k7WL86Wt5wkoP9cjef8hWWxrUX7ifL9SRe9dVPPmmOFqtrJfy0KufJBKn fyqy+3Sv4nUORrLRk3GxnxVg4GKOzm0MqW7Y6fFykkRbFGKpjtgF5F/pgPzgoghwM1Su G7IQ== X-Gm-Message-State: APjAAAXXotBVmvkm99BXiK5y3YzLCBt1zf+tcTAtrIPhV9mZSidqD1mF cxw5Ily2vjenSQfc4zHfxuPqSA== X-Google-Smtp-Source: APXvYqx99DGNvMjwQ9E+nXYfGa8Bpdx3n8eMr1L+9m55nCd8gA3oMk/ssQiH9ob9gKOnQmAxabFGiQ== X-Received: by 2002:a17:90a:2506:: with SMTP id j6mr7362792pje.129.1563358794014; Wed, 17 Jul 2019 03:19:54 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id i126sm23884866pfb.32.2019.07.17.03.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 03:19:53 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , niklas.cassel@linaro.org, Rajendra Nayak , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] opp: Not all power-domains are scalable Date: Wed, 17 Jul 2019 15:49:46 +0530 Message-Id: <90ba3941b56e50ea5548dd1e90bf3bcd8c9da4fe.1563358721.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A device may have multiple power-domains and not all of them may be scalable (i.e. support performance states). But dev_pm_opp_attach_genpd() doesn't take that into account currently. Fix that by not verifying the names argument with "power-domain-names" DT property and finding the index into the required-opps array. The names argument will anyway get verified later on when we call dev_pm_domain_attach_by_name(). Fixes: 6319aee10e53 ("opp: Attach genpds to devices from within OPP core") Reported-by: Rajendra Nayak Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 2958cc7bbb58..4e2a81698cd2 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1788,12 +1788,15 @@ static void _opp_detach_genpd(struct opp_table *opp_table) * * This helper needs to be called once with a list of all genpd to attach. * Otherwise the original device structure will be used instead by the OPP core. + * + * The order of entries in the names array must match the order in which + * "required-opps" are added in DT. */ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names) { struct opp_table *opp_table; struct device *virt_dev; - int index, ret = -EINVAL; + int index = 0, ret = -EINVAL; const char **name = names; opp_table = dev_pm_opp_get_opp_table(dev); @@ -1819,14 +1822,6 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names goto unlock; while (*name) { - index = of_property_match_string(dev->of_node, - "power-domain-names", *name); - if (index < 0) { - dev_err(dev, "Failed to find power domain: %s (%d)\n", - *name, index); - goto err; - } - if (index >= opp_table->required_opp_count) { dev_err(dev, "Index can't be greater than required-opp-count - 1, %s (%d : %d)\n", *name, opp_table->required_opp_count, index); @@ -1847,6 +1842,7 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names } opp_table->genpd_virt_devs[index] = virt_dev; + index++; name++; } From patchwork Wed Jul 17 10:19:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11047589 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A83D514DB for ; Wed, 17 Jul 2019 10:20:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9437728712 for ; Wed, 17 Jul 2019 10:20:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84F7928724; Wed, 17 Jul 2019 10:20:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D1FC28712 for ; Wed, 17 Jul 2019 10:20:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbfGQKT6 (ORCPT ); Wed, 17 Jul 2019 06:19:58 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34508 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726519AbfGQKT5 (ORCPT ); Wed, 17 Jul 2019 06:19:57 -0400 Received: by mail-pg1-f194.google.com with SMTP id n9so4716929pgc.1 for ; Wed, 17 Jul 2019 03:19:57 -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 :mime-version:content-transfer-encoding; bh=VK4VAAKwmD6vCOcxsuweQdA7aImoD6BI1bwtOEYy7Ec=; b=AJQ2aUxdLzlHM27/CtHDPhhfUR2r74bNE+Fqr8namI4DMjtm0Ji7+gNHpxvvqiRDFx bS/TqlbQ6J90Uxwy03MVOU1uUp0BxIa1DOVdxUbaoshON5cRSy5QWQOcrDfOaIEIPcdP Gj2ufs3wvpr0tw0Iq50TgspWBICEBWEol53OGPNkl8cZtKwGcqeS38ztPFf5v/Wd+nLa kX3Mi6+0hE6FPSjCsz+vronqX1BzubKEO3WPstJw0glwlOgwWZqVOv/G7bW0m2LHVVGK zPjPsD7GYAXYfav8ZhSf5kMBqYM5zQNLyMN2FfN9Agg5SVevn8e/U2FH1BycN/4I9raM ejMA== 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:mime-version:content-transfer-encoding; bh=VK4VAAKwmD6vCOcxsuweQdA7aImoD6BI1bwtOEYy7Ec=; b=aWMNDQdLhy/p9JTWn5oDa5TwyNGyu8lSdTZXYItOck4mKPpxnZBhtCjLJLbIQVFpLU L9vB3Jo38sX+bImFbTnSm3dmCh3P0b9O/QrKW78ZodYpVLd9+yJL5L6XUduVKHERhVxd BXclfG+3ZwCgwfIxbj7CGPz1QxtULmCc2e6BDxrsbqGFXnE1k/jtu4cSNImgBpMTpEqf 3i/KgaM4t/G/RlX+j82TtC0pyd5nSLWdCalkHNJ0UAlLOs3hEVRtdHA4XRHsISSw9JSa G0tMk+yPC8QGJ/2jdf7K0g4XsyzEggnmbpK3xqCU6VJPEpnjgEkPUN850ZRJ+Q6GSgWH RSnw== X-Gm-Message-State: APjAAAVK+Fn1DRLEqIuTk1tT9jaUmpWvI9Ox39NEGFPTry9iqzVg4Lzh Yqf+T17e1LaE1d8FzbefwAc/fg== X-Google-Smtp-Source: APXvYqyHlVMuMahTL4YiiobGoIz/ikKUUA807jg2o7LAg2+WQ8WsgPVx+k4SS6QyIEowyz5oHtjfGA== X-Received: by 2002:a63:9318:: with SMTP id b24mr30127568pge.31.1563358796826; Wed, 17 Jul 2019 03:19:56 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id r1sm27721976pfq.100.2019.07.17.03.19.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 03:19:56 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , niklas.cassel@linaro.org, Rajendra Nayak , linux-kernel@vger.kernel.org Subject: [PATCH V2 2/2] opp: Return genpd virtual devices from dev_pm_opp_attach_genpd() Date: Wed, 17 Jul 2019 15:49:47 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: <90ba3941b56e50ea5548dd1e90bf3bcd8c9da4fe.1563358721.git.viresh.kumar@linaro.org> References: <90ba3941b56e50ea5548dd1e90bf3bcd8c9da4fe.1563358721.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The cpufreq drivers don't need to do runtime PM operations on the virtual devices returned by dev_pm_domain_attach_by_name() and so the virtual devices weren't shared with the callers of dev_pm_opp_attach_genpd() earlier. But the IO device drivers would want to do that. This patch updates the prototype of dev_pm_opp_attach_genpd() to accept another argument to return the pointer to the array of genpd virtual devices. Reported-by: Rajendra Nayak Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- V1->V2: - Check virt_devs pointer before assigning. drivers/opp/core.c | 6 +++++- include/linux/pm_opp.h | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 4e2a81698cd2..1f11f8c92337 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1775,6 +1775,7 @@ static void _opp_detach_genpd(struct opp_table *opp_table) * dev_pm_opp_attach_genpd - Attach genpd(s) for the device and save virtual device pointer * @dev: Consumer device for which the genpd is getting attached. * @names: Null terminated array of pointers containing names of genpd to attach. + * @virt_devs: Pointer to return the array of virtual devices. * * Multiple generic power domains for a device are supported with the help of * virtual genpd devices, which are created for each consumer device - genpd @@ -1792,7 +1793,8 @@ static void _opp_detach_genpd(struct opp_table *opp_table) * The order of entries in the names array must match the order in which * "required-opps" are added in DT. */ -struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names) +struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, + const char **names, struct device ***virt_devs) { struct opp_table *opp_table; struct device *virt_dev; @@ -1846,6 +1848,8 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names name++; } + if (virt_devs) + *virt_devs = opp_table->genpd_virt_devs; mutex_unlock(&opp_table->genpd_virt_dev_lock); return opp_table; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index be570761b77a..7c2fe2952f40 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -131,7 +131,7 @@ struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char * name); void dev_pm_opp_put_clkname(struct opp_table *opp_table); struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); -struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names); +struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); void dev_pm_opp_detach_genpd(struct opp_table *opp_table); int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); @@ -295,7 +295,7 @@ static inline struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const static inline void dev_pm_opp_put_clkname(struct opp_table *opp_table) {} -static inline struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names) +static inline struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs) { return ERR_PTR(-ENOTSUPP); }