linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sharat Masetty <smasetty@codeaurora.org>
To: freedreno@lists.freedesktop.org, devicetree@vger.kernel.org
Cc: dri-devel@freedesktop.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, jcrouse@codeaurora.org,
	georgi.djakov@linaro.org, mka@chromium.org,
	Sibi Sankar <sibis@codeaurora.org>,
	Sharat Masetty <smasetty@codeaurora.org>
Subject: [PATCH 3/6] OPP: Add and export helper to set bandwidth
Date: Thu, 14 May 2020 16:24:16 +0530	[thread overview]
Message-ID: <1589453659-27581-4-git-send-email-smasetty@codeaurora.org> (raw)
In-Reply-To: <1589453659-27581-1-git-send-email-smasetty@codeaurora.org>

From: Sibi Sankar <sibis@codeaurora.org>

Add and export 'dev_pm_opp_set_bw' to set the bandwidth
levels associated with an OPP for a given frequency.

Signed-off-by: Sibi Sankar <sibis@codeaurora.org>
Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>
---
 drivers/opp/core.c     | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/pm_opp.h |  6 ++++++
 2 files changed, 49 insertions(+)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index f42b7c4..0f34077 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -828,6 +828,49 @@ static int _set_required_opps(struct device *dev,
 }

 /**
+ * dev_pm_opp_set_bw() - sets bandwidth levels corresponding to an available opp
+ * @dev:	device for which we do this operation
+ * @opp:	opp based on which the bandwidth levels are to be configured
+ *
+ * This configures the bandwidth to the levels specified
+ * by the OPP.
+ *
+ * Return: 0 on success or a negative error value.
+ */
+int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp)
+{
+	struct opp_table *opp_table;
+	int ret = -EINVAL;
+	int i;
+
+	if (IS_ERR_OR_NULL(opp) || !opp->available) {
+		dev_err(dev, "%s: Invalid parameters\n", __func__);
+		return -EINVAL;
+	}
+
+	opp_table = _find_opp_table(dev);
+	if (IS_ERR(opp_table)) {
+		dev_err(dev, "%s: device opp table doesn't exist\n", __func__);
+		return PTR_ERR(opp_table);
+	}
+
+	if (opp_table->paths) {
+		for (i = 0; i < opp_table->path_count; i++) {
+			ret = icc_set_bw(opp_table->paths[i],
+					 opp->bandwidth[i].avg,
+					 opp->bandwidth[i].peak);
+			if (ret)
+				dev_err(dev, "Failed to set bandwidth[%d]: %d\n",
+					i, ret);
+		}
+	}
+
+	dev_pm_opp_put_opp_table(opp_table);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw);
+
+/**
  * dev_pm_opp_set_rate() - Configure new OPP based on frequency
  * @dev:	 device for which we do this operation
  * @target_freq: frequency to achieve
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 76f8c6b..04f7fda 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -156,6 +156,7 @@ struct dev_pm_opp *dev_pm_opp_xlate_opp(struct opp_table *src_table,
 					struct opp_table *dst_table,
 					struct dev_pm_opp *src_opp);
 int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
+int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp);
 int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask);
 int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
 void dev_pm_opp_remove_table(struct device *dev);
@@ -354,6 +355,11 @@ static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_f
 	return -ENOTSUPP;
 }

+static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp)
+{
+	return -ENOTSUPP;
+}
+
 static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask)
 {
 	return -ENOTSUPP;
--
2.7.4

  parent reply	other threads:[~2020-05-14 10:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 10:54 [PATCH 0/6] Add support for GPU DDR BW scaling Sharat Masetty
2020-05-14 10:54 ` [PATCH 1/6] arm64: dts: qcom: sc7180: Add interconnect bindings for GPU Sharat Masetty
2020-05-14 23:37   ` Matthias Kaehlcke
2020-05-14 10:54 ` [PATCH 2/6] arm64: dts: qcom: sc7180: Add opp-peak-kBps to GPU opp Sharat Masetty
2020-05-14 23:45   ` Matthias Kaehlcke
2020-05-14 10:54 ` Sharat Masetty [this message]
2020-05-15  0:32   ` [PATCH 3/6] OPP: Add and export helper to set bandwidth Matthias Kaehlcke
2020-05-14 10:54 ` [PATCH 4/6] drm: msm: a6xx: send opp instead of a frequency Sharat Masetty
2020-05-15  0:39   ` Matthias Kaehlcke
2020-05-15  0:58     ` Matthias Kaehlcke
2020-05-14 10:54 ` [PATCH 5/6] drm: msm: a6xx: use dev_pm_opp_set_bw to set DDR bandwidth Sharat Masetty
2020-05-15  1:05   ` Matthias Kaehlcke
2020-05-18 14:23   ` Jordan Crouse
2020-05-18 16:25     ` [Freedreno] " Rob Clark
2020-05-27  8:47       ` Sharat Masetty
2020-05-27 15:38         ` Rob Clark
2020-05-27 17:31           ` Saravana Kannan
2020-05-27 20:41             ` Sibi Sankar
2020-05-27 20:51           ` Jordan Crouse
2020-05-28 11:02           ` Sharat Masetty
2020-05-14 10:54 ` [PATCH 6/6] dt-bindings: drm/msm/gpu: Document gpu opp table Sharat Masetty
2020-05-28 15:14   ` Rob Herring
2020-05-14 23:56 ` [PATCH 0/6] Add support for GPU DDR BW scaling Matthias Kaehlcke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1589453659-27581-4-git-send-email-smasetty@codeaurora.org \
    --to=smasetty@codeaurora.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=georgi.djakov@linaro.org \
    --cc=jcrouse@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mka@chromium.org \
    --cc=sibis@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).