From patchwork Thu Mar 28 15:28:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875193 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 DA08B14DE for ; Thu, 28 Mar 2019 15:28:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C697D28671 for ; Thu, 28 Mar 2019 15:28:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA8F228B5F; Thu, 28 Mar 2019 15:28:50 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 5736B28671 for ; Thu, 28 Mar 2019 15:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726430AbfC1P2t (ORCPT ); Thu, 28 Mar 2019 11:28:49 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51342 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbfC1P2t (ORCPT ); Thu, 28 Mar 2019 11:28:49 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BF8D1618CD; Thu, 28 Mar 2019 15:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786928; bh=saxFG01wr/WqbM/6BscCUxiM8aweZyEy5YEKycoCjMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAXyzuVAOxL8T+ybzcWarUiea2mlQ9l13ZM/RilnX315+itbSfynnfmVQg/AfyROP S+3xozMRUki3LZQzjImZBk1s3lo6O/H5HuPlsbkX11RqCC9zy9pj3AbSc2g/frEUdu 1l1qrgg3GZ/s2QC+IL5JjEiMpEVQJq0z9znFsVOA= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 62FC961639; Thu, 28 Mar 2019 15:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786924; bh=saxFG01wr/WqbM/6BscCUxiM8aweZyEy5YEKycoCjMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hFLHCZf6b5lYFYNZa24m735IZbqzEQsbbciSxM09DA7Qhp1wNKZUCCeIBvg5EO14r XWkC2/ImhlT8/HFy1fbgu4qkPTagi4egdTCNoBlIQ6x+zbrs39KmaqduuOwobeejOx t1p1QNEovdIM0BmNREG0mWu643wcFiJgpoSHv7xM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 62FC961639 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Sibi Sankar Subject: [PATCH RFC 1/9] OPP: Add and export helpers to get avg/peak bw Date: Thu, 28 Mar 2019 20:58:14 +0530 Message-Id: <20190328152822.532-2-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 Add and export helpers 'dev_pm_opp_get_avg_bw()' and 'dev_pm_opp_get_peak_bw()' that can be used to get the average and peak bandwidth values read from device tree when present. Signed-off-by: Sibi Sankar --- drivers/opp/core.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 12 ++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 4fcc2b9259c5..addaf7aae9ae 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -149,6 +149,44 @@ unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_level); +/** + * dev_pm_opp_get_avg_bw() - Gets the average bandwidth corresponding to an + * available opp + * @opp: opp for which average bandwidth has to be returned for + * + * Return: average bandwidth read from device tree corresponding to the + * opp, else return 0. + */ +unsigned int dev_pm_opp_get_avg_bw(struct dev_pm_opp *opp) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->bandwidth->avg; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_avg_bw); + +/** + * dev_pm_opp_get_peak_bw() - Gets the peak bandwidth corresponding to an + * available opp + * @opp: opp for which peak bandwidth has to be returned for + * + * Return: peak bandwidth read from device tree corresponding to the + * opp, else return 0. + */ +unsigned int dev_pm_opp_get_peak_bw(struct dev_pm_opp *opp) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->bandwidth->peak; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_peak_bw); + /** * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not * @opp: opp for which turbo mode is being verified diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 80a49d1fa9a8..82ff8e2e1ff7 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -99,6 +99,8 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); +unsigned int dev_pm_opp_get_avg_bw(struct dev_pm_opp *opp); +unsigned int dev_pm_opp_get_peak_bw(struct dev_pm_opp *opp); bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); @@ -179,6 +181,16 @@ static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) return 0; } +static inline unsigned int dev_pm_opp_get_avg_bw(struct dev_pm_opp *opp) +{ + return 0; +} + +static inline unsigned int dev_pm_opp_get_peak_bw(struct dev_pm_opp *opp) +{ + return 0; +} + static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) { return false; From patchwork Thu Mar 28 15:28:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875199 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 ADFAF1708 for ; Thu, 28 Mar 2019 15:29:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 988C828685 for ; Thu, 28 Mar 2019 15:29:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 899B92876D; Thu, 28 Mar 2019 15:29:16 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 212B128685 for ; Thu, 28 Mar 2019 15:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726949AbfC1P27 (ORCPT ); Thu, 28 Mar 2019 11:28:59 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51632 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbfC1P25 (ORCPT ); Thu, 28 Mar 2019 11:28:57 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5559E6194E; Thu, 28 Mar 2019 15:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786935; bh=B9hm3m4js6tRmQZKwTll7Uw3VE0CDlgLZj4xvLuVkYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TbcXk2fi2es4Ppg/D3jo8oLFvVguHs4EvouYX9fX5mZ7IrRvCFodQekhyhB1Icn3f o6QFgPlNLYMkBX7VVYiL/sL77BOBsu7MjAVe4IWbZ449jOLbC4p0yzQVN03YgnmHxR Hkzy9cam/CPd8sHxOxfFea0u0m3EXiEjOdSWooXQ= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 31B2F618DC; Thu, 28 Mar 2019 15:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786931; bh=B9hm3m4js6tRmQZKwTll7Uw3VE0CDlgLZj4xvLuVkYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfA3yBor9su7O5UZqeivHo5AA2L9zSjoElFd/FXy9TimegOQjkhUute2Qx+mqM5md leHKmX8KSaehjADvplyAy97rloNdg+xfGbdjsOYKlBwlvGrYBTcZ3miYqF2m/AAzfO b3G6oA1VtRbBzK5fEGJ8RiJr/O29QAhCje6hNW5I= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 31B2F618DC Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Sibi Sankar Subject: [PATCH RFC 2/9] OPP: Export a number of helpers to prevent code duplication Date: Thu, 28 Mar 2019 20:58:15 +0530 Message-Id: <20190328152822.532-3-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 Export 'dev_pm_opp_find_opp_of_np' and 'of_parse_required_nodes' as it will be used by passive governor to parse and auto-populate mapping specified using the required-opps property. Signed-off-by: Sibi Sankar --- drivers/opp/of.c | 13 +++++++++++-- include/linux/pm_opp.h | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 539f3d013a59..d9d8875eca05 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -98,8 +98,8 @@ static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table, return NULL; } -static struct device_node *of_parse_required_opp(struct device_node *np, - int index) +struct device_node *of_parse_required_opp(struct device_node *np, + int index) { struct device_node *required_np; @@ -111,6 +111,15 @@ static struct device_node *of_parse_required_opp(struct device_node *np, return required_np; } +EXPORT_SYMBOL_GPL(of_parse_required_opp); + +/* The caller must call dev_pm_opp_put() after the OPP is used */ +struct dev_pm_opp *dev_pm_opp_find_opp_of_np(struct opp_table *opp_table, + struct device_node *opp_np) +{ + return _find_opp_of_np(opp_table, opp_np); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_find_opp_of_np); /* The caller must call dev_pm_opp_put_opp_table() after the table is used */ static struct opp_table *_find_table_of_opp_np(struct device_node *opp_np) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 82ff8e2e1ff7..d7cb0e65c4f0 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -359,8 +359,11 @@ void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); +struct device_node *of_parse_required_opp(struct device_node *np, int index); int of_get_required_opp_performance_state(struct device_node *np, int index); void dev_pm_opp_of_register_em(struct cpumask *cpus); +struct dev_pm_opp *dev_pm_opp_find_opp_of_np(struct opp_table *opp_table, + struct device_node *opp_np); #else static inline int dev_pm_opp_of_add_table(struct device *dev) { @@ -390,6 +393,11 @@ static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct return -ENOTSUPP; } +static inline struct dev_pm_opp *dev_pm_opp_find_opp_of_np(struct opp_table *opp_table, struct device_node *opp_np) +{ + return ERR_PTR(-ENOTSUPP); +} + static inline struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev) { return NULL; @@ -408,6 +416,11 @@ static inline int of_get_required_opp_performance_state(struct device_node *np, { return -ENOTSUPP; } + +static inline struct device_node *of_parse_required_opp(struct device_node *np, int index) +{ + return NULL; +} #endif #endif /* __LINUX_OPP_H__ */ From patchwork Thu Mar 28 15:28:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875195 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 790051390 for ; Thu, 28 Mar 2019 15:29:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F38528B78 for ; Thu, 28 Mar 2019 15:29:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 526D128CDA; Thu, 28 Mar 2019 15:29:05 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 3C29D28B78 for ; Thu, 28 Mar 2019 15:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727251AbfC1P3D (ORCPT ); Thu, 28 Mar 2019 11:29:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51814 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbfC1P3C (ORCPT ); Thu, 28 Mar 2019 11:29:02 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id F2CDA619C6; Thu, 28 Mar 2019 15:29:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786941; bh=CXIkHPKNCSxKMJ9BxS5wFSnViYneB1z5X+9DDurq+Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JMyHQH/CuYqOmssDB6CKi2xrfYEtXH2kOu/CpsRZjIgxX9Rm2Cwb6trnCJiowNIMQ Jxt6bE320Xu5kHqyM4CL45K98jhfCMNP3HfDyQP6lmF7xET0O+6htLTGHum0sEaTdf t3E5rrAYIl+EGcglM/rqLW93v9EqNnELhw2mm66M= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B70EA6192C; Thu, 28 Mar 2019 15:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786938; bh=CXIkHPKNCSxKMJ9BxS5wFSnViYneB1z5X+9DDurq+Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ljjaUzVgNkRM9wTQPIYoVKpZciQM9kT+GqvFhoM2XwW67mWlWzhdfsQo4IhW8II0h jQFTMeMEqwO0lHI8Nn8QFrdG2ZaX1AsKCEyEWSj3dcM90+DZ7MfLU3dp9jsSReQut4 oCNRiUxUgdotsJDAJFsJXm+Cj4DE1Id55ICMRAzY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B70EA6192C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Saravana Kannan , Sibi Sankar Subject: [PATCH RFC 3/9] PM / devfreq: Add cpu based scaling support to passive_governor Date: Thu, 28 Mar 2019 20:58:16 +0530 Message-Id: <20190328152822.532-4-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 From: Saravana Kannan Many CPU architectures have caches that can scale independent of the CPUs. Frequency scaling of the caches is necessary to make sure the cache is not a performance bottleneck that leads to poor performance and power. The same idea applies for RAM/DDR. To achieve this, this patch add support for cpu based scaling to the passive governor. This is accomplished by taking the current frequency of each CPU frequency domain and then adjusts the frequency of the cache (or any devfreq device) based on the frequency of the CPUs. It listens to CPU frequency transition notifiers to keep itself up to date on the current CPU frequency. To decide the frequency of the device, the governor does one of the following: * Constructs a CPU frequency to device frequency mapping table from required-opps property of the devfreq device's opp_table * Scales the device frequency in proportion to the CPU frequency. So, if the CPUs are running at their max frequency, the device runs at its max frequency. If the CPUs are running at their min frequency, the device runs at its min frequency. It is interpolated for frequencies in between. Signed-off-by: Saravana Kannan [Sibi: Integrated cpu-freqmap governor into passive_governor] Signed-off-by: Sibi Sankar --- drivers/devfreq/Kconfig | 4 + drivers/devfreq/governor_passive.c | 276 ++++++++++++++++++++++++++++- include/linux/devfreq.h | 43 ++++- 3 files changed, 315 insertions(+), 8 deletions(-) diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig index 6a172d338f6d..9a45f464a56b 100644 --- a/drivers/devfreq/Kconfig +++ b/drivers/devfreq/Kconfig @@ -72,6 +72,10 @@ config DEVFREQ_GOV_PASSIVE device. This governor does not change the frequency by itself through sysfs entries. The passive governor recommends that devfreq device uses the OPP table to get the frequency/voltage. + Alternatively the governor can also be chosen to scale based on + the online CPUs current frequency. A CPU frequency to device + frequency mapping table(s) is auto-populated by the governor + for this purpose. comment "DEVFREQ Drivers" diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 3bc29acbd54e..2506682b233b 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -11,10 +11,63 @@ */ #include +#include +#include +#include #include #include +#include +#include #include "governor.h" +static unsigned int xlate_cpufreq_to_devfreq(struct devfreq_passive_data *data, + unsigned int cpu) +{ + unsigned int cpu_min, cpu_max; + struct devfreq *devfreq = (struct devfreq *)data->this; + unsigned int dev_min, dev_max, cpu_percent, cpu_freq = 0, freq = 0; + unsigned long *freq_table = devfreq->profile->freq_table; + struct device *dev = devfreq->dev.parent; + struct devfreq_map *map; + int opp_cnt, i; + + if (!data->state[cpu] || data->state[cpu]->first_cpu != cpu) { + freq = 0; + goto out; + } + + /* Use Interpolation if map is not available */ + cpu_freq = data->state[cpu]->freq; + if (!data->map) { + cpu_min = data->state[cpu]->min_freq; + cpu_max = data->state[cpu]->max_freq; + if (freq_table) { + dev_min = freq_table[0]; + dev_max = freq_table[devfreq->profile->max_state - 1]; + } else { + if (devfreq->max_freq <= devfreq->min_freq) + return 0; + dev_min = devfreq->min_freq; + dev_max = devfreq->max_freq; + } + + cpu_percent = ((cpu_freq - cpu_min) * 100) / cpu_max - cpu_min; + freq = dev_min + mult_frac(dev_max - dev_min, cpu_percent, 100); + goto out; + } + + map = data->map[cpu]; + opp_cnt = dev_pm_opp_get_opp_count(dev); + for (i = 0; i < opp_cnt; i++) { + freq = max(freq, map[i].dev_hz); + if (map[i].cpu_khz >= cpu_freq) + break; + } +out: + dev_dbg(dev, "CPU%u: %d -> dev: %u\n", cpu, cpu_freq, freq); + return freq; +} + static int devfreq_passive_get_target_freq(struct devfreq *devfreq, unsigned long *freq) { @@ -23,6 +76,7 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, struct devfreq *parent_devfreq = (struct devfreq *)p_data->parent; unsigned long child_freq = ULONG_MAX; struct dev_pm_opp *opp; + unsigned int cpu, tgt_freq = 0; int i, count, ret = 0; /* @@ -35,6 +89,14 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, goto out; } + if (p_data->cpufreq_type) { + for_each_possible_cpu(cpu) + tgt_freq = max(tgt_freq, + xlate_cpufreq_to_devfreq(p_data, cpu)); + *freq = tgt_freq; + goto out; + } + /* * If the parent and passive devfreq device uses the OPP table, * get the next frequency by using the OPP table. @@ -149,6 +211,200 @@ static int devfreq_passive_notifier_call(struct notifier_block *nb, return NOTIFY_DONE; } +static int cpufreq_passive_notifier_call(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct devfreq_passive_data *data = + container_of(nb, struct devfreq_passive_data, nb); + struct devfreq *devfreq = (struct devfreq *)data->this; + struct cpufreq_freqs *freq = ptr; + struct devfreq_cpu_state *state; + int ret = 0; + + if (event != CPUFREQ_POSTCHANGE) + goto out; + + state = data->state[freq->cpu]; + if (!state) + goto out; + + if (state->freq != freq->new) { + state->freq = freq->new; + mutex_lock(&devfreq->lock); + ret = update_devfreq(devfreq); + mutex_unlock(&devfreq->lock); + if (ret) + dev_err(&devfreq->dev, "Frequency update failed.\n"); + } +out: + return ret; +} + +static int cpufreq_passive_register(struct devfreq_passive_data **p_data) +{ + unsigned int cpu; + struct devfreq_map **cpu_map; + struct devfreq_map *map, *per_cpu_map; + struct devfreq_passive_data *data = *p_data; + struct devfreq *devfreq = (struct devfreq *)data->this; + int i, count = 0, opp_cnt = 0, ret = 0, iter_val = 0; + struct device_node *np, *opp_table_np, *cpu_np; + struct opp_table *opp_table, *cpu_opp_tbl; + struct device *dev = devfreq->dev.parent; + struct devfreq_cpu_state *state; + struct dev_pm_opp *opp, *cpu_opp; + struct cpufreq_policy *policy; + struct device *cpu_dev; + u64 cpu_khz, dev_hz; + + get_online_cpus(); + data->nb.notifier_call = cpufreq_passive_notifier_call; + ret = cpufreq_register_notifier(&data->nb, + CPUFREQ_TRANSITION_NOTIFIER); + if (ret) + return ret; + + /* Populate devfreq_cpu_state */ + for_each_online_cpu(cpu) { + if (data->state[cpu]) + continue; + + policy = cpufreq_cpu_get(cpu); + if (policy) { + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + state->first_cpu = cpumask_first(policy->related_cpus); + state->freq = policy->cur; + state->min_freq = policy->cpuinfo.min_freq; + state->max_freq = policy->cpuinfo.max_freq; + data->state[cpu] = state; + cpufreq_cpu_put(policy); + } else { + return -EPROBE_DEFER; + } + } + + opp_table_np = dev_pm_opp_of_get_opp_desc_node(dev); + if (!opp_table_np) + goto out; + + opp_cnt = dev_pm_opp_get_opp_count(dev); + if (opp_cnt <= 0) + goto put_opp_table; + + /* Allocate memory for devfreq_map*/ + cpu_map = kcalloc(num_possible_cpus(), sizeof(*cpu_map), GFP_KERNEL); + if (!cpu_map) + return -ENOMEM; + + for_each_possible_cpu(cpu) { + per_cpu_map = kcalloc(opp_cnt, sizeof(*per_cpu_map), + GFP_KERNEL); + if (!per_cpu_map) + return -ENOMEM; + cpu_map[cpu] = per_cpu_map; + } + data->map = cpu_map; + + /* Populate devfreq_map */ + opp_table = dev_pm_opp_get_opp_table(dev); + if (!opp_table) + return -ENOMEM; + + for_each_available_child_of_node(opp_table_np, np) { + opp = dev_pm_opp_find_opp_of_np(opp_table, np); + if (IS_ERR(opp)) + continue; + + dev_hz = dev_pm_opp_get_freq(opp); + dev_pm_opp_put(opp); + + count = of_count_phandle_with_args(np, "required-opps", NULL); + for (i = 0; i < count; i++) { + for_each_possible_cpu(cpu) { + cpu_dev = get_cpu_device(cpu); + if (!cpu_dev) { + dev_err(dev, "CPU get device failed.\n"); + continue; + } + + cpu_np = of_parse_required_opp(np, i); + if (!cpu_np) { + dev_err(dev, "Parsing required opp failed.\n"); + continue; + } + + /* Get cpu opp-table */ + cpu_opp_tbl = dev_pm_opp_get_opp_table(cpu_dev); + if (!cpu_opp_tbl) { + dev_err(dev, "CPU opp table get failed.\n"); + goto put_cpu_node; + } + + /* Match the cpu opp node from required-opp with + * the cpu-opp table */ + cpu_opp = dev_pm_opp_find_opp_of_np(cpu_opp_tbl, + cpu_np); + if (!cpu_opp) { + dev_dbg(dev, "CPU opp get failed.\n"); + goto put_cpu_opp_table; + } + + cpu_khz = dev_pm_opp_get_freq(cpu_opp); + if (cpu_opp && cpu_khz) { + /* Update freq-map if not already set */ + map = cpu_map[cpu]; + map[iter_val].cpu_khz = cpu_khz / 1000; + map[iter_val].dev_hz = dev_hz; + } + dev_pm_opp_put(cpu_opp); +put_cpu_opp_table: + dev_pm_opp_put_opp_table(cpu_opp_tbl); +put_cpu_node: + of_node_put(cpu_np); + } + } + iter_val++; + } + dev_pm_opp_put_opp_table(opp_table); +put_opp_table: + of_node_put(opp_table_np); +out: + put_online_cpus(); + + /* Update devfreq */ + mutex_lock(&devfreq->lock); + ret = update_devfreq(devfreq); + mutex_unlock(&devfreq->lock); + if (ret) + dev_err(dev, "Frequency update failed.\n"); + + return ret; +} + +static int cpufreq_passive_unregister(struct devfreq_passive_data **p_data) +{ + int cpu; + struct devfreq_passive_data *data = *p_data; + + cpufreq_unregister_notifier(&data->nb, + CPUFREQ_TRANSITION_NOTIFIER); + + for_each_possible_cpu(cpu) { + kfree(data->state[cpu]); + kfree(data->map[cpu]); + data->state[cpu] = NULL; + data->map[cpu] = NULL; + } + + kfree(data->map); + data->map = NULL; + + return 0; +} + static int devfreq_passive_event_handler(struct devfreq *devfreq, unsigned int event, void *data) { @@ -159,7 +415,7 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq, struct notifier_block *nb = &p_data->nb; int ret = 0; - if (!parent) + if (!parent && !p_data->cpufreq_type) return -EPROBE_DEFER; switch (event) { @@ -167,13 +423,21 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq, if (!p_data->this) p_data->this = devfreq; - nb->notifier_call = devfreq_passive_notifier_call; - ret = devm_devfreq_register_notifier(dev, parent, nb, - DEVFREQ_TRANSITION_NOTIFIER); + if (p_data->cpufreq_type) { + ret = cpufreq_passive_register(&p_data); + } else { + nb->notifier_call = devfreq_passive_notifier_call; + ret = devm_devfreq_register_notifier(dev, parent, nb, + DEVFREQ_TRANSITION_NOTIFIER); + } break; case DEVFREQ_GOV_STOP: - devm_devfreq_unregister_notifier(dev, parent, nb, - DEVFREQ_TRANSITION_NOTIFIER); + if (p_data->cpufreq_type) { + cpufreq_passive_unregister(&p_data); + } else { + devm_devfreq_unregister_notifier(dev, parent, nb, + DEVFREQ_TRANSITION_NOTIFIER); + } break; default: break; diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index fbffa74bfc1b..e8235fbe49e6 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -265,6 +265,38 @@ struct devfreq_simple_ondemand_data { #endif #if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) +/** + * struct devfreq_cpu_state - holds the per-cpu state + * @freq: holds the current frequency of the cpu. + * @min_freq: holds the min frequency of the cpu. + * @max_freq: holds the max frequency of the cpu. + * @first_cpu: holds the cpumask of the first cpu of a policy. + * + * This structure stores the required cpu_state of a cpu. + * This is auto-populated by the governor. + */ +struct devfreq_cpu_state { + unsigned int freq; + unsigned int min_freq; + unsigned int max_freq; + unsigned int first_cpu; +}; + +/** + * struct devfreq_map - holds mapping from cpu frequency + * to devfreq frequency + * @cpu_khz: holds the cpu frequency in Khz + * @dev_hz: holds the devfreq device frequency in Hz + * + * This structure stores the lookup table between cpu + * and the devfreq device. This is auto-populated by the + * governor. + */ +struct devfreq_map { + unsigned int cpu_khz; + unsigned int dev_hz; +}; + /** * struct devfreq_passive_data - void *data fed to struct devfreq * and devfreq_add_device @@ -278,11 +310,13 @@ struct devfreq_simple_ondemand_data { * the next frequency, should use this callback. * @this: the devfreq instance of own device. * @nb: the notifier block for DEVFREQ_TRANSITION_NOTIFIER list + * @state: holds the state min/max/current frequency of all online cpu's + * @map: holds the maps between cpu frequency and device frequency * * The devfreq_passive_data have to set the devfreq instance of parent * device with governors except for the passive governor. But, don't need to - * initialize the 'this' and 'nb' field because the devfreq core will handle - * them. + * initialize the 'this', 'nb', 'state' and 'map' field because the devfreq + * core will handle them. */ struct devfreq_passive_data { /* Should set the devfreq instance of parent device */ @@ -291,9 +325,14 @@ struct devfreq_passive_data { /* Optional callback to decide the next frequency of passvice device */ int (*get_target_freq)(struct devfreq *this, unsigned long *freq); + /* Should be set if the devfreq device wants to be scaled with cpu*/ + u8 cpufreq_type; + /* For passive governor's internal use. Don't need to set them */ struct devfreq *this; struct notifier_block nb; + struct devfreq_cpu_state *state[NR_CPUS]; + struct devfreq_map **map; }; #endif From patchwork Thu Mar 28 15:28:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875197 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 5A6ED1390 for ; Thu, 28 Mar 2019 15:29:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4207628685 for ; Thu, 28 Mar 2019 15:29:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 335092876D; Thu, 28 Mar 2019 15:29:15 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 A614828685 for ; Thu, 28 Mar 2019 15:29:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727416AbfC1P3J (ORCPT ); Thu, 28 Mar 2019 11:29:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52038 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727385AbfC1P3I (ORCPT ); Thu, 28 Mar 2019 11:29:08 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AD5CD619CE; Thu, 28 Mar 2019 15:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786946; bh=Mmp1jfuc1zu5FoGaNthCHKPchoSMms/QsUzlv8N/jIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cfEoOfwsYynhQfsEiy1myFmiDEt+AS3cPH09T5HblP27Qzm55ZRggS8IhLrCQbj9G SNf8kI7a3iJVtkftpcZIT8jeSb9HmYrkL2U3uGln7kx9qcDL0gNT98OSJADpVOCGw/ gXL/pdtMN3PGzoEC1fKB9jvI6x3VmssPdrUF6jWg= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7361B619AE; Thu, 28 Mar 2019 15:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786945; bh=Mmp1jfuc1zu5FoGaNthCHKPchoSMms/QsUzlv8N/jIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nHOC/vZWKi8b/zp3WzqXoVjFp+aI1KvtlJlDuJ4KQ5SIvB9vM0N4zc8n2C5BCnrvp F9csCUKiUnQgJHhGVG8WNihFiUy7vRuYozHzFvZPM+8VgPPg2Sd2wXScAFhDHh7W3B IJNHku7Xw1liBrL5WMT0JArkNKcZlCfzi5UhzEHA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7361B619AE Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Sibi Sankar Subject: [PATCH RFC 4/9] dt-bindings: devfreq: Add bindings for devfreq dev-icbw driver Date: Thu, 28 Mar 2019 20:58:17 +0530 Message-Id: <20190328152822.532-5-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 Add dt-bindings support for a generic interconnect bandwidth voting devfreq driver. Signed-off-by: Sibi Sankar --- .../devicetree/bindings/devfreq/icbw.txt | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 Documentation/devicetree/bindings/devfreq/icbw.txt diff --git a/Documentation/devicetree/bindings/devfreq/icbw.txt b/Documentation/devicetree/bindings/devfreq/icbw.txt new file mode 100644 index 000000000000..389aa77a2363 --- /dev/null +++ b/Documentation/devicetree/bindings/devfreq/icbw.txt @@ -0,0 +1,146 @@ +Interconnect bandwidth device + +icbw is a device that represents an interconnect path that connects two +devices. This device is typically used to vote for BW requirements between +two devices. Eg: CPU to DDR, GPU to DDR, etc. This device is expected to +use passive govenor by default. + +Required properties: +- compatible: Must be "devfreq-icbw" +- interconnects: Pairs of phandles and interconnect provider specifier + to denote the edge source and destination ports of + the interconnect path. See also: + Documentation/devicetree/bindings/interconnect/interconnect.txt +- operating-points-v2: A phandle to an OPP v2 table that holds frequency, + bandwidth values (in MB/s) and required-opp's populated + with phandles pointing to the required per cpu opp. The + bandwidth (in MB/s) values depend on multiple properties + of the interconnect path like frequency, interconnect + width, etc. + +Example: + +cpus { + ... + + CPU0: cpu@0 { + ... + operating-points-v2 = <&cpu0_opp_table>; + ... + }; + + CPU1: cpu@100 { + ... + operating-points-v2 = <&cpu0_opp_table>; + ... + }; + + CPU2: cpu@200 { + ... + operating-points-v2 = <&cpu0_opp_table>; + ... + }; + + CPU3: cpu@300 { + ... + operating-points-v2 = <&cpu0_opp_table>; + ... + }; + + CPU4: cpu@400 { + ... + operating-points-v2 = <&cpu4_opp_table>; + ... + }; + + CPU5: cpu@500 { + ... + operating-points-v2 = <&cpu4_opp_table>; + ... + }; + + CPU6: cpu@600 { + ... + operating-points-v2 = <&cpu4_opp_table>; + ... + }; + + CPU7: cpu@700 { + ... + operating-points-v2 = <&cpu4_opp_table>; + ... + }; +}; + +cpu0_opp_table: cpu0_opp_table { + compatible = "operating-points-v2"; + opp-shared; + + cpu0_opp1: opp-300000000 { + opp-hz = /bits/ 64 <300000000>; + }; + + ... + + cpu0_opp16: opp-1612800000 { + opp-hz = /bits/ 64 <1612800000>; + }; + + ... +}; + +cpu4_opp_table: cpu4_opp_table { + compatible = "operating-points-v2"; + opp-shared; + + ... + + cpu4_opp4: opp-1056000000 { + opp-hz = /bits/ 64 <1056000000>; + }; + + cpu4_opp5: opp-1209600000 { + opp-hz = /bits/ 64 <1209600000>; + }; + + ... +}; + +bw_opp_table: bw-opp-table { + compatible = "operating-points-v2"; + + opp-200 { + opp-hz = /bits/ 64 < 200000000 >; /* 200 MHz */ + required-opps = <&cpu0_opp1>; + /* 0 MB/s average and 762 MB/s peak bandwidth */ + opp-bw-MBs = <0 762>; + }; + + opp-300 { + opp-hz = /bits/ 64 < 300000000 >; /* 300 MHz */ + /* 0 MB/s average and 1144 MB/s peak bandwidth */ + opp-bw-MBs = <0 1144>; + }; + + ... + + opp-768 { + opp-hz = /bits/ 64 < 768000000 >; /* 768 MHz */ + /* 0 MB/s average and 2929 MB/s peak bandwidth */ + opp-bw-MBs = <0 2929>; + required-opps = <&cpu4_opp4>; + }; + + opp-1017 { + opp-hz = /bits/ 64 < 1017000000 >; /* 1017 MHz */ + /* 0 MB/s average and 3879 MB/s peak bandwidth */ + opp-bw-MBs = <0 3879>; + required-opps = <&cpu0_opp16>, <&cpu4_opp5>; + }; +}; + +cpubw { + compatible = "devfreq-icbw"; + interconnects = <&snoc MASTER_APSS_1 &bimc SLAVE_EBI_CH0>; + operating-points-v2 = <&bw_opp_table>; +}; From patchwork Thu Mar 28 15:28:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875201 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 BB9EB1390 for ; Thu, 28 Mar 2019 15:29:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A35A928685 for ; Thu, 28 Mar 2019 15:29:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96BB32876D; Thu, 28 Mar 2019 15:29:23 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 F1DAB28685 for ; Thu, 28 Mar 2019 15:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfC1P3R (ORCPT ); Thu, 28 Mar 2019 11:29:17 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52352 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726348AbfC1P3Q (ORCPT ); Thu, 28 Mar 2019 11:29:16 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E370761F56; Thu, 28 Mar 2019 15:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786954; bh=7BMY4QJoj1T/gCui5d+gGvi++TgL+G+x0BzCC+M750c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jNDLmX8X+pxV6QKpENBt5P+pMGUT+qHHzXp70jzENQ9HAD2/GDbMLypu0IiZB/N42 /jwpfivh6oV2nOhmpk5/80ltbL2eI7GLcrHf5Dxy61gc9QeO74Y07bUpJXH06Mv06p DJ9+lUlWV4kDfemSqkk8kU5t2jW4Q14dd+glz3jI= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C099A61778; Thu, 28 Mar 2019 15:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786951; bh=7BMY4QJoj1T/gCui5d+gGvi++TgL+G+x0BzCC+M750c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OI24v2THZqLCEEz3/r+th5BwKuLftsiALnWXCaeJbL8U4LRcp8O0opVneH/QCpgSb 3BCguZRB2uxpZ0dBQhdRUZh1Ssa4e9TNEpyn2d0OhiI7Wr1qQdoCYsH8UaChgT4i+W gg2hd7rNUOBo/fICiAkITzqykWZMzj0/gGzm6ngM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C099A61778 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Saravana Kannan , Sibi Sankar Subject: [PATCH RFC 5/9] PM / devfreq: Add devfreq driver for interconnect bandwidth voting Date: Thu, 28 Mar 2019 20:58:18 +0530 Message-Id: <20190328152822.532-6-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 From: Saravana Kannan This driver registers itself as a devfreq device that allows devfreq governors to make bandwidth votes for an interconnect path. This allows applying various policies for different interconnect paths using devfreq governors. Example uses: * Use the devfreq performance governor to set the CPU to DDR interconnect path for maximum performance. * Use the devfreq powersave governor to set the GPU to DDR interconnect path for minimum performance. * Use the Passive governor to scale the DDR frequency based on the needs of the CPUs' current frequency Signed-off-by: Saravana Kannan [Sibi: cleanup and added passive governor support] Signed-off-by: Sibi Sankar --- drivers/devfreq/Kconfig | 15 ++++ drivers/devfreq/Makefile | 1 + drivers/devfreq/devfreq_icbw.c | 132 +++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 drivers/devfreq/devfreq_icbw.c diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig index 9a45f464a56b..0df5b65f157a 100644 --- a/drivers/devfreq/Kconfig +++ b/drivers/devfreq/Kconfig @@ -117,6 +117,21 @@ config ARM_RK3399_DMC_DEVFREQ It sets the frequency for the memory controller and reads the usage counts from hardware. +config DEVFREQ_ICBW + tristate "Driver for making bandwidth votes on interconnect paths" + select DEVFREQ_GOV_PASSIVE + select DEVFREQ_GOV_PERFORMANCE + select DEVFREQ_GOV_POWERSAVE + select DEVFREQ_GOV_USERSPACE + depends on INTERCONNECT + default n + help + Different devfreq governors use this devfreq device to make + bandwidth votes for interconnect paths between different devices + (Eg: CPU to DDR, GPU to DDR, etc). This driver provides a generic + interface so that the devfreq governors can be shared across SoCs + and architectures. + source "drivers/devfreq/event/Kconfig" endif # PM_DEVFREQ diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile index 32b8d4d3f12c..66591b0e5259 100644 --- a/drivers/devfreq/Makefile +++ b/drivers/devfreq/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_DEVFREQ_GOV_PASSIVE) += governor_passive.o obj-$(CONFIG_ARM_EXYNOS_BUS_DEVFREQ) += exynos-bus.o obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ) += rk3399_dmc.o obj-$(CONFIG_ARM_TEGRA_DEVFREQ) += tegra-devfreq.o +obj-$(CONFIG_DEVFREQ_ICBW) += devfreq_icbw.o # DEVFREQ Event Drivers obj-$(CONFIG_PM_DEVFREQ_EVENT) += event/ diff --git a/drivers/devfreq/devfreq_icbw.c b/drivers/devfreq/devfreq_icbw.c new file mode 100644 index 000000000000..c552cf4218c8 --- /dev/null +++ b/drivers/devfreq/devfreq_icbw.c @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +struct icbw_data { + struct devfreq *df; + struct icc_path *path; + u32 cur_ab; + u32 cur_pb; +}; + +static int icbw_target(struct device *dev, unsigned long *freq, u32 flags) +{ + struct dev_pm_opp *opp; + struct icbw_data *data = dev_get_drvdata(dev); + u32 new_pb, new_ab; + int ret; + + opp = devfreq_recommended_opp(dev, freq, flags); + if (IS_ERR(opp)) + return PTR_ERR(opp); + + /* Get avg and peak bandwidth */ + new_ab = dev_pm_opp_get_avg_bw(opp); + new_pb = dev_pm_opp_get_peak_bw(opp); + dev_pm_opp_put(opp); + + if (data->cur_pb == new_pb && data->cur_ab == new_ab) + return 0; + + dev_dbg(dev, "BW icc: AB: %u PB: %u\n", new_ab, new_pb); + + ret = icc_set_bw(data->path, new_ab, new_pb); + if (ret) { + dev_err(dev, "bandwidth request failed (%d)\n", ret); + } else { + data->cur_pb = new_pb; + data->cur_ab = new_ab; + } + + return ret; +} + +static int devfreq_icbw_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct devfreq_dev_profile *profile; + struct devfreq_passive_data *passive_data; + struct icbw_data *data; + int ret; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + dev_set_drvdata(dev, data); + + passive_data = devm_kzalloc(dev, sizeof(*passive_data), GFP_KERNEL); + if (!passive_data) + return -ENOMEM; + + passive_data->cpufreq_type = true; + + profile = devm_kzalloc(dev, sizeof(*profile), GFP_KERNEL); + if (!profile) + return -ENOMEM; + + profile->target = icbw_target; + + data->path = of_icc_get(dev, NULL); + if (IS_ERR(data->path)) { + dev_err(dev, "Unable to register interconnect path\n"); + return PTR_ERR(data->path); + } + + ret = dev_pm_opp_of_add_table(dev); + if (ret) { + dev_err(dev, "Couldn't find OPP table\n"); + goto err_icc; + } + + data->df = devfreq_add_device(dev, profile, + DEVFREQ_GOV_PASSIVE, passive_data); + if (IS_ERR(data->df)) { + ret = PTR_ERR(data->df); + goto err_opp_table; + } + + return 0; + +err_opp_table: + dev_pm_opp_of_remove_table(dev); +err_icc: + icc_put(data->path); + return ret; +} + +static int devfreq_icbw_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct icbw_data *data = dev_get_drvdata(dev); + + devfreq_remove_device(data->df); + icc_put(data->path); + return 0; +} + +static const struct of_device_id icbw_match_table[] = { + { .compatible = "devfreq-icbw" }, + {} +}; +MODULE_DEVICE_TABLE(of, icbw_match_table); + +static struct platform_driver icbw_driver = { + .probe = devfreq_icbw_probe, + .remove = devfreq_icbw_remove, + .driver = { + .name = "devfreq-icbw", + .of_match_table = icbw_match_table, + }, +}; +module_platform_driver(icbw_driver); + +MODULE_DESCRIPTION("Interconnect bandwidth voting driver"); +MODULE_LICENSE("GPL v2"); From patchwork Thu Mar 28 15:28:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875203 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 578401390 for ; Thu, 28 Mar 2019 15:29:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41EF828685 for ; Thu, 28 Mar 2019 15:29:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 360432876D; Thu, 28 Mar 2019 15:29:29 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 DF15428685 for ; Thu, 28 Mar 2019 15:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726525AbfC1P3W (ORCPT ); Thu, 28 Mar 2019 11:29:22 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52600 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726311AbfC1P3V (ORCPT ); Thu, 28 Mar 2019 11:29:21 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E772861F81; Thu, 28 Mar 2019 15:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786960; bh=BVhb2m6ms/9S31/QcRfv2NsjtFeog5ga38D1sOsl8s4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajRp/hqnN0P01hUdBqT5KjCdvywBmmpdSuX7hFJxvVkOlgHGbc2j4dZtST3Amg5VC bzDGZNg9B4i8LhX2TvM81qeutg4mxyuVqQIsJwGYOQ/d0+MjXyu6i7wYKypITxe0Kk Po23jrzVi4bmLgqhtArcM26kknDeunx2wsT86rOM= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7F83C614DB; Thu, 28 Mar 2019 15:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786958; bh=BVhb2m6ms/9S31/QcRfv2NsjtFeog5ga38D1sOsl8s4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bPWlLHhGI/cQfhltDx6TqCvNa2NXxl1KGnAJYx0d+8U0z/i+xJf+nyLkpJWjiTTbY BsLkwOpSC4W7a6FvQvZ51eJ2zc8bSId8bxJiAbg3oIkmlC3Frt95HdImGXQURS1jV7 h0wM/A4c7nX/NsbNmAZhED9TdDTdI93PCP6x3stc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7F83C614DB Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Sibi Sankar Subject: [PATCH RFC 6/9] OPP: Add and export helper to update voltage Date: Thu, 28 Mar 2019 20:58:19 +0530 Message-Id: <20190328152822.532-7-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 Add and export 'dev_pm_opp_update_voltage' to find and update voltage of an opp for a given frequency. This will be useful to update the opps with voltages read back from firmware. Signed-off-by: Sibi Sankar --- drivers/opp/core.c | 62 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 10 +++++++ 2 files changed, 72 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index addaf7aae9ae..c066cd120a33 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2090,6 +2090,68 @@ int dev_pm_opp_disable(struct device *dev, unsigned long freq) } EXPORT_SYMBOL_GPL(dev_pm_opp_disable); +static int _opp_update_voltage(struct device *dev, unsigned long freq, + unsigned long u_volt) +{ + struct opp_table *opp_table; + struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV); + int r = 0; + + /* Find the opp_table */ + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) { + r = PTR_ERR(opp_table); + dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); + return r; + } + + mutex_lock(&opp_table->lock); + + /* Do we have the frequency? */ + list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { + if (tmp_opp->rate == freq) { + opp = tmp_opp; + break; + } + } + + if (IS_ERR(opp)) { + r = PTR_ERR(opp); + goto unlock; + } + + /* update only if the opp is disabled */ + if (opp->available) + goto unlock; + + opp->supplies[0].u_volt = u_volt; + +unlock: + mutex_unlock(&opp_table->lock); + dev_pm_opp_put_opp_table(opp_table); + return r; +} + +/** + * dev_pm_opp_update_voltage() - find and update voltage of an opp + * for a given frequency + * @dev: device for which we do this operation + * @freq: OPP frequency to update voltage + * @u_volt: voltage requested for this opp + * + * This is useful only for devices with single power supply. + * + * Return: -EINVAL for bad pointers, -ENOMEM if no memory available for the + * copy operation, returns 0 if no modification was done OR modification was + * successful. + */ +int dev_pm_opp_update_voltage(struct device *dev, unsigned long freq, + unsigned long u_volt) +{ + return _opp_update_voltage(dev, freq, u_volt); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_update_voltage); + /** * dev_pm_opp_register_notifier() - Register OPP notifier for the device * @dev: Device for which notifier needs to be registered diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index d7cb0e65c4f0..58490f6839ce 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -130,6 +130,9 @@ int dev_pm_opp_enable(struct device *dev, unsigned long freq); int dev_pm_opp_disable(struct device *dev, unsigned long freq); +int dev_pm_opp_update_voltage(struct device *dev, unsigned long freq, + unsigned long u_volt); + int dev_pm_opp_register_notifier(struct device *dev, struct notifier_block *nb); int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nb); @@ -265,6 +268,13 @@ static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq) return 0; } +static inline int dev_pm_opp_update_voltage(struct device *dev, + unsigned long freq, + unsigned long u_volt) +{ + return 0; +} + static inline int dev_pm_opp_register_notifier(struct device *dev, struct notifier_block *nb) { return -ENOTSUPP; From patchwork Thu Mar 28 15:28:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875205 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 E4EFE14DE for ; Thu, 28 Mar 2019 15:29:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE4AF28685 for ; Thu, 28 Mar 2019 15:29:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0DC52876D; Thu, 28 Mar 2019 15:29:31 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 5C05328685 for ; Thu, 28 Mar 2019 15:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbfC1P3a (ORCPT ); Thu, 28 Mar 2019 11:29:30 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52890 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbfC1P3a (ORCPT ); Thu, 28 Mar 2019 11:29:30 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B649161A1E; Thu, 28 Mar 2019 15:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786969; bh=sGwRr0RI3MC9asNopdI7X8k7yKvKf+lSlw/YZ3i/d7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Moii8SyQICIcvS/PBec3YSDM7L3MkrZiroTLJ/rmDf5i/0DhrRffYN+Yj9sl1pPTh HvrWrXRtQEf1L3Gf9iHfYoet4frpJnakhgBToNbUfpCr8JrBz3btDeU6GEJshLKOnP H7oDlrb2SE7vkleHck+/B5T9/EdYse78X2zX+upw= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D998961F65; Thu, 28 Mar 2019 15:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786964; bh=sGwRr0RI3MC9asNopdI7X8k7yKvKf+lSlw/YZ3i/d7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkDRvx3QjRLfw65XIPgMy37i7XLbDo2m1hWSl95uoACd66gVBkeA0SqdGjpBWqG0c M5k2+TEKoDyIymBT1x/nh7zHehXEk5X5/Cj5qqn/hGBAbn8fXk774e/XPO9oSQlbdV 0XUSuENMIrZZzaRxObvDvldGyVr+TswE2Z4ufj1E= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D998961F65 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Sibi Sankar Subject: [PATCH RFC 7/9] cpufreq: qcom: Add support to update cpu node's OPP tables Date: Thu, 28 Mar 2019 20:58:20 +0530 Message-Id: <20190328152822.532-8-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 Add support to parse and update OPP tables attached to the cpu nodes. Signed-off-by: Sibi Sankar --- drivers/cpufreq/qcom-cpufreq-hw.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 4b0b50403901..5c268dd2346c 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -73,6 +73,25 @@ static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy, return policy->freq_table[index].frequency; } +static int qcom_find_update_opp(struct device *cpu_dev, unsigned long freq, + unsigned long volt) +{ + int ret; + struct dev_pm_opp *opp; + + opp = dev_pm_opp_find_freq_exact(cpu_dev, freq, true); + if (IS_ERR(opp)) { + ret = dev_pm_opp_add(cpu_dev, freq, volt); + } else { + dev_pm_opp_disable(cpu_dev, freq); + ret = dev_pm_opp_update_voltage(cpu_dev, freq, volt); + dev_pm_opp_enable(cpu_dev, freq); + dev_pm_opp_put(opp); + } + + return ret; +} + static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, struct cpufreq_policy *policy, void __iomem *base) @@ -81,11 +100,16 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, u32 volt; unsigned int max_cores = cpumask_weight(policy->cpus); struct cpufreq_frequency_table *table; + int ret; table = kcalloc(LUT_MAX_ENTRIES + 1, sizeof(*table), GFP_KERNEL); if (!table) return -ENOMEM; + ret = dev_pm_opp_of_add_table(cpu_dev); + if (ret) + dev_dbg(cpu_dev, "Couldn't add OPP table\n"); + for (i = 0; i < LUT_MAX_ENTRIES; i++) { data = readl_relaxed(base + REG_FREQ_LUT + i * LUT_ROW_SIZE); @@ -104,7 +128,7 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, if (freq != prev_freq && core_count == max_cores) { table[i].frequency = freq; - dev_pm_opp_add(cpu_dev, freq * 1000, volt); + qcom_find_update_opp(cpu_dev, freq * 1000, volt); dev_dbg(cpu_dev, "index=%d freq=%d, core_count %d\n", i, freq, core_count); } else { @@ -125,7 +149,8 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, if (prev_cc != max_cores) { prev->frequency = prev_freq; prev->flags = CPUFREQ_BOOST_FREQ; - dev_pm_opp_add(cpu_dev, prev_freq * 1000, volt); + qcom_find_update_opp(cpu_dev, prev_freq * 1000, + volt); } break; From patchwork Thu Mar 28 15:28:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875207 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 2C51A14DE for ; Thu, 28 Mar 2019 15:29:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1534728685 for ; Thu, 28 Mar 2019 15:29:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 070D12876D; Thu, 28 Mar 2019 15:29:39 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 67B8C28685 for ; Thu, 28 Mar 2019 15:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727606AbfC1P3h (ORCPT ); Thu, 28 Mar 2019 11:29:37 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53114 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbfC1P3h (ORCPT ); Thu, 28 Mar 2019 11:29:37 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 40D3761FC6; Thu, 28 Mar 2019 15:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786975; bh=M5vRPc1j1QGqoN/9ointK/z71vnWK0PC4gDDE9TDln8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nL8BdOItsibzwuI648IH8CzG2Fr4OQ/nMoXvtUAUyx2oUYidmknxyCbYRKmzyAQss uYBOJYt5W5vuHzTzxt7maCeVP42aAJrQ0DntCuzKjqos6zIzf0xantLN8J7zbT1QUo w+F1dfR7C8KMUFLgy1uSDDPVxjmNEVEm3agdW00E= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 305E061846; Thu, 28 Mar 2019 15:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786971; bh=M5vRPc1j1QGqoN/9ointK/z71vnWK0PC4gDDE9TDln8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oBPjBVXG5rqcBePRlVQ1WCmOut5XwsuvBHFiCmbFr4gxhUuQIwKvurSS57u1vTKeP 8AfkqizAAhHsCHc0W1kthawb99UVR4NMb32ZeB16H9rRmt1M5xTCn12GugJpQ4c3MG dE3srM90LHo5r6PxuOMlK1IkZFdWkhrxkRiNn1BM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 305E061846 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Sibi Sankar Subject: [PATCH RFC 8/9] arm64: dts: qcom: sdm845: Add cpu OPP tables Date: Thu, 28 Mar 2019 20:58:21 +0530 Message-Id: <20190328152822.532-9-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 Add a OPP tables for the cpu nodes. Signed-off-by: Sibi Sankar --- arch/arm64/boot/dts/qcom/sdm845.dtsi | 182 +++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi index cd8ac481381b..072563f6b6cb 100644 --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi @@ -193,6 +193,7 @@ qcom,freq-domain = <&cpufreq_hw 0>; #cooling-cells = <2>; next-level-cache = <&L2_0>; + operating-points-v2 = <&cpu0_opp_table>; L2_0: l2-cache { compatible = "cache"; next-level-cache = <&L3_0>; @@ -210,6 +211,7 @@ qcom,freq-domain = <&cpufreq_hw 0>; #cooling-cells = <2>; next-level-cache = <&L2_100>; + operating-points-v2 = <&cpu0_opp_table>; L2_100: l2-cache { compatible = "cache"; next-level-cache = <&L3_0>; @@ -224,6 +226,7 @@ qcom,freq-domain = <&cpufreq_hw 0>; #cooling-cells = <2>; next-level-cache = <&L2_200>; + operating-points-v2 = <&cpu0_opp_table>; L2_200: l2-cache { compatible = "cache"; next-level-cache = <&L3_0>; @@ -238,6 +241,7 @@ qcom,freq-domain = <&cpufreq_hw 0>; #cooling-cells = <2>; next-level-cache = <&L2_300>; + operating-points-v2 = <&cpu0_opp_table>; L2_300: l2-cache { compatible = "cache"; next-level-cache = <&L3_0>; @@ -252,6 +256,7 @@ qcom,freq-domain = <&cpufreq_hw 1>; #cooling-cells = <2>; next-level-cache = <&L2_400>; + operating-points-v2 = <&cpu4_opp_table>; L2_400: l2-cache { compatible = "cache"; next-level-cache = <&L3_0>; @@ -266,6 +271,7 @@ qcom,freq-domain = <&cpufreq_hw 1>; #cooling-cells = <2>; next-level-cache = <&L2_500>; + operating-points-v2 = <&cpu4_opp_table>; L2_500: l2-cache { compatible = "cache"; next-level-cache = <&L3_0>; @@ -280,6 +286,7 @@ qcom,freq-domain = <&cpufreq_hw 1>; #cooling-cells = <2>; next-level-cache = <&L2_600>; + operating-points-v2 = <&cpu4_opp_table>; L2_600: l2-cache { compatible = "cache"; next-level-cache = <&L3_0>; @@ -294,6 +301,7 @@ qcom,freq-domain = <&cpufreq_hw 1>; #cooling-cells = <2>; next-level-cache = <&L2_700>; + operating-points-v2 = <&cpu4_opp_table>; L2_700: l2-cache { compatible = "cache"; next-level-cache = <&L3_0>; @@ -301,6 +309,180 @@ }; }; + cpu0_opp_table: cpu0_opp_table { + compatible = "operating-points-v2"; + opp-shared; + + cpu0_opp1: opp-300000000 { + opp-hz = /bits/ 64 <300000000>; + }; + + cpu0_opp2: opp-403200000 { + opp-hz = /bits/ 64 <403200000>; + }; + + cpu0_opp3: opp-480000000 { + opp-hz = /bits/ 64 <480000000>; + }; + + cpu0_opp4: opp-576000000 { + opp-hz = /bits/ 64 <576000000>; + }; + + cpu0_opp5: opp-652800000 { + opp-hz = /bits/ 64 <652800000>; + }; + + cpu0_opp6: opp-748800000 { + opp-hz = /bits/ 64 <748800000>; + }; + + cpu0_opp7: opp-825600000 { + opp-hz = /bits/ 64 <825600000>; + }; + + cpu0_opp8: opp-902400000 { + opp-hz = /bits/ 64 <902400000>; + }; + + cpu0_opp9: opp-979200000 { + opp-hz = /bits/ 64 <979200000>; + }; + + cpu0_opp10: opp-1056000000 { + opp-hz = /bits/ 64 <1056000000>; + }; + + cpu0_opp11: opp-1132800000 { + opp-hz = /bits/ 64 <1132800000>; + }; + + cpu0_opp12: opp-1228800000 { + opp-hz = /bits/ 64 <1228800000>; + }; + + cpu0_opp13: opp-1324800000 { + opp-hz = /bits/ 64 <1324800000>; + }; + + cpu0_opp14: opp-1420800000 { + opp-hz = /bits/ 64 <1420800000>; + }; + + cpu0_opp15: opp-1516800000 { + opp-hz = /bits/ 64 <1516800000>; + }; + + cpu0_opp16: opp-1612800000 { + opp-hz = /bits/ 64 <1612800000>; + }; + + cpu0_opp17: opp-1689600000 { + opp-hz = /bits/ 64 <1689600000>; + }; + + cpu0_opp18: opp-1766400000 { + opp-hz = /bits/ 64 <1766400000>; + }; + }; + + cpu4_opp_table: cpu4_opp_table { + compatible = "operating-points-v2"; + opp-shared; + + cpu4_opp1: opp-825600000 { + opp-hz = /bits/ 64 <825600000>; + }; + + cpu4_opp2: opp-902400000 { + opp-hz = /bits/ 64 <902400000>; + }; + + cpu4_opp3: opp-979200000 { + opp-hz = /bits/ 64 <979200000>; + }; + + cpu4_opp4: opp-1056000000 { + opp-hz = /bits/ 64 <1056000000>; + }; + + cpu4_opp5: opp-1209600000 { + opp-hz = /bits/ 64 <1209600000>; + }; + + cpu4_opp6: opp-1286400000 { + opp-hz = /bits/ 64 <1286400000>; + }; + + cpu4_opp7: opp-1363200000 { + opp-hz = /bits/ 64 <1363200000>; + }; + + cpu4_opp8: opp-1459200000 { + opp-hz = /bits/ 64 <1459200000>; + }; + + cpu4_opp9: opp-1536000000 { + opp-hz = /bits/ 64 <1536000000>; + }; + + cpu4_opp10: opp-1612800000 { + opp-hz = /bits/ 64 <1612800000>; + }; + + cpu4_opp11: opp-1689600000 { + opp-hz = /bits/ 64 <1689600000>; + }; + + cpu4_opp12: opp-1766400000 { + opp-hz = /bits/ 64 <1766400000>; + }; + + cpu4_opp13: opp-1843200000 { + opp-hz = /bits/ 64 <1843200000>; + }; + + cpu4_opp14: opp-1920000000 { + opp-hz = /bits/ 64 <1920000000>; + }; + + cpu4_opp15: opp-1996800000 { + opp-hz = /bits/ 64 <1996800000>; + }; + + cpu4_opp16: opp-2092800000 { + opp-hz = /bits/ 64 <2092800000>; + }; + + cpu4_opp17: opp-2169600000 { + opp-hz = /bits/ 64 <2169600000>; + }; + + cpu4_opp18: opp-2246400000 { + opp-hz = /bits/ 64 <2246400000>; + }; + + cpu4_opp19: opp-2323200000 { + opp-hz = /bits/ 64 <2323200000>; + }; + + cpu4_opp20: opp-2400000000 { + opp-hz = /bits/ 64 <2400000000>; + }; + + cpu4_opp21: opp-2476800000 { + opp-hz = /bits/ 64 <2476800000>; + }; + + cpu4_opp22: opp-2553600000 { + opp-hz = /bits/ 64 <2553600000>; + }; + + cpu4_opp23: opp-2649600000 { + opp-hz = /bits/ 64 <2649600000>; + }; + }; + pmu { compatible = "arm,armv8-pmuv3"; interrupts = ; From patchwork Thu Mar 28 15:28:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10875209 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 32F121390 for ; Thu, 28 Mar 2019 15:29:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19F3128671 for ; Thu, 28 Mar 2019 15:29:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C03628AFA; Thu, 28 Mar 2019 15:29:50 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 86A3D28671 for ; Thu, 28 Mar 2019 15:29:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727647AbfC1P3n (ORCPT ); Thu, 28 Mar 2019 11:29:43 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53374 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbfC1P3n (ORCPT ); Thu, 28 Mar 2019 11:29:43 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8194961FF2; Thu, 28 Mar 2019 15:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786981; bh=cA8kJQLv8KrqVZVWqb2sBxN1Ktr/DIfvjvs5gwiJB1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dq5HhCqsMXE6QILy/iZMa/Dh6bXRqBDhgoQx479DbsLkavzwNJxVacYXzWrATnHOp +xpvPzzX134v71rRMqIw+bH86BCl3CSvuLwkPXSlI4kPG2lIYzpOhXnWcrGNLwQRvt qTp8UsMM1E/rNoY6PdjqV10YQIcRzv1yMANAPgrA= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B83CA61F8B; Thu, 28 Mar 2019 15:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553786977; bh=cA8kJQLv8KrqVZVWqb2sBxN1Ktr/DIfvjvs5gwiJB1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UIXDYPzvwu83gby5WhIopopq0df8QGffGJ4rx6zdMrsR/o6XJhD5Hwq3OjIOLB3A/ 9ZEiNukj6gGhLf8LnAKKrwpTnYHJwl3erTYPsRcJziPwZDe/5rPK2m/pXP6hr9fEeO ip50kJcbSwG7NmxQ7sh956mXaS7KbOdKjLXR/PYs= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B83CA61F8B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: robh+dt@kernel.org, andy.gross@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, georgi.djakov@linaro.org Cc: bjorn.andersson@linaro.org, david.brown@linaro.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org, devicetree@vger.kernel.org, rnayak@codeaurora.org, cw00.choi@samsung.com, linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, dianders@chromium.org, Sibi Sankar Subject: [PATCH RFC 9/9] arm64: dts: qcom: sdm845: Add nodes for icbw driver and opp tables Date: Thu, 28 Mar 2019 20:58:22 +0530 Message-Id: <20190328152822.532-10-sibis@codeaurora.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328152822.532-1-sibis@codeaurora.org> References: <20190328152822.532-1-sibis@codeaurora.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 Add nodes to enable DDR devfreq driver on SDM845 SoC. Signed-off-by: Sibi Sankar --- arch/arm64/boot/dts/qcom/sdm845.dtsi | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi index 072563f6b6cb..21a0068855e8 100644 --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -488,6 +489,85 @@ interrupts = ; }; + cpubw: cpu-icbw { + compatible = "devfreq-icbw"; + interconnects = <&rsc_hlos MASTER_APPSS_PROC &rsc_hlos SLAVE_EBI1>; + operating-points-v2 = <&bw_opp_table>; + }; + + bw_opp_table: bw-opp-table { + compatible = "operating-points-v2"; + + opp-200 { + opp-hz = /bits/ 64 < 200000000 >; /* 200 MHz */ + required-opps = <&cpu0_opp1>; + /* 0 MB/s average and 762 MB/s peak bandwidth */ + opp-bw-MBs = <0 762>; + }; + + opp-300 { + opp-hz = /bits/ 64 < 300000000 >; /* 300 MHz */ + /* 0 MB/s average and 1144 MB/s peak bandwidth */ + opp-bw-MBs = <0 1144>; + }; + + opp-451 { + opp-hz = /bits/ 64 < 451000000 >; /* 451 MHz */ + /* 0 MB/s average and 1720 MB/s peak bandwidth */ + opp-bw-MBs = <0 1720>; + required-opps = <&cpu0_opp6>; + }; + + opp-547 { + opp-hz = /bits/ 64 < 547000000 >; /* 547 MHz */ + /* 0 MB/s average and 2086 MB/s peak bandwidth */ + opp-bw-MBs = <0 2086>; + required-opps = <&cpu0_opp11>; + }; + + opp-681 { + opp-hz = /bits/ 64 < 681000000 >; /* 681 MHz */ + /* 0 MB/s average and 2597 MB/s peak bandwidth */ + opp-bw-MBs = <0 2597>; + required-opps = <&cpu0_opp15>; + }; + + opp-768 { + opp-hz = /bits/ 64 < 768000000 >; /* 768 MHz */ + /* 0 MB/s average and 2929 MB/s peak bandwidth */ + opp-bw-MBs = <0 2929>; + required-opps = <&cpu4_opp4>; + }; + + opp-1017 { + opp-hz = /bits/ 64 < 1017000000 >; /* 1017 MHz */ + /* 0 MB/s average and 3879 MB/s peak bandwidth */ + opp-bw-MBs = <0 3879>; + required-opps = <&cpu0_opp16>, <&cpu4_opp5>; + }; + + opp-1296 { + opp-hz = /bits/ 64 < 1296000000 >; /* 1296 MHz */ + /* 0 MB/s average and 4943 MB/s peak bandwidth */ + opp-bw-MBs = <0 4943>; + required-opps = <&cpu4_opp10>; + }; + + opp-1555 { + opp-hz = /bits/ 64 < 1555000000 >; /* 1555 MHz */ + /* 0 MB/s average and 5931 MB/s peak bandwidth */ + opp-bw-MBs = <0 5931>; + required-opps = <&cpu4_opp12>; + }; + + opp-1804 { + opp-hz = /bits/ 64 < 1804000000 >; /* 1804 MHz */ + /* 0 MB/s average and 6881 MB/s peak bandwidth */ + opp-bw-MBs = <0 6881>; + required-opps = <&cpu4_opp15>; + }; + }; + timer { compatible = "arm,armv8-timer"; interrupts = ,