Skip to contentSkip to conversation

Add support for GPU DDR BW scaling

PATCH Superseded Akhil P Oommen 3 participants 14 messages Jul 9, 2020 – Jul 10, 2020

Subsystems (8)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add support for GPU DDR BW scaling

This is mostly a rebase of Sharat's patches [1] on the tip of msm-next branch. Changes compared to v3:
1. Rebased on top of Jonathan's patch which adds support for changing gpu freq through hfi on newer targets. Created patch 1 to make this the generic approach of setting gpu freq on newer targets.
2. As suggested by Rob, left the icc_path intact for pre-a6xx GPUs.

As mentioned in [1], these patches have dependency on Georgi's series from opp/linux-next [2] and also Sibi's patch which adds a helper function to set and clear ddr bandwidth vote [2].

[1] https://patchwork.freedesktop.org/series/75291/
[2] https://kernel.googlesource.com/pub/scm/linux/kernel/git/vireshk/pm/+log/opp/linux-next/

Akhil P Oommen (1):
drm: msm: a6xx: set gpu freq through hfi

Sharat Masetty (6):
dt-bindings: drm/msm/gpu: Document gpu opp table
drm: msm: a6xx: send opp instead of a frequency
drm: msm: a6xx: use dev_pm_opp_set_bw to scale DDR
arm64: dts: qcom: SDM845: Enable GPU DDR bw scaling
arm64: dts: qcom: sc7180: Add interconnects property for GPU
arm64: dts: qcom: sc7180: Add opp-peak-kBps to GPU opp

 .../devicetree/bindings/display/msm/gpu.txt        |  28 ++++++
 arch/arm64/boot/dts/qcom/sc7180.dtsi               |   9 ++
 arch/arm64/boot/dts/qcom/sdm845.dtsi               |   9 ++
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c              | 105 +++++++++++----------
 drivers/gpu/drm/msm/adreno/a6xx_gpu.h              |   2 +-
 drivers/gpu/drm/msm/msm_gpu.c                      |   3 +-
 drivers/gpu/drm/msm/msm_gpu.h                      |   3 +-
 7 files changed, 106 insertions(+), 53 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v4 1/7 dt-bindings: drm/msm/gpu: Document gpu opp table

From: Sharat Masetty <[email protected]>

Update documentation to list the gpu opp table bindings including the newly added "opp-peak-kBps" needed for GPU-DDR bandwidth scaling.

---
 .../devicetree/bindings/display/msm/gpu.txt        | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
Documentation/devicetree/bindings/display/msm/gpu.txt +28 -0
index fd779cd..1af0ff1 100644
@@ -112,6 +112,34 @@ Example a6xx (with GMU):
 		interconnects = <&rsc_hlos MASTER_GFX3D &rsc_hlos SLAVE_EBI1>;
 		interconnect-names = "gfx-mem";
 
+		gpu_opp_table: opp-table {
+			compatible = "operating-points-v2";
+
+			opp-430000000 {
+				opp-hz = /bits/ 64 <430000000>;
+				opp-level = <RPMH_REGULATOR_LEVEL_SVS_L1>;
+				opp-peak-kBps = <5412000>;
+			};
+
+			opp-355000000 {
+				opp-hz = /bits/ 64 <355000000>;
+				opp-level = <RPMH_REGULATOR_LEVEL_SVS>;
+				opp-peak-kBps = <3072000>;
+			};
+
+			opp-267000000 {
+				opp-hz = /bits/ 64 <267000000>;
+				opp-level = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
+				opp-peak-kBps = <3072000>;
+			};
+
+			opp-180000000 {
+				opp-hz = /bits/ 64 <180000000>;
+				opp-level = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
+				opp-peak-kBps = <1804000>;
+			};
+		};
+
 		qcom,gmu = <&gmu>;
 
 		zap-shader {
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH v4 2/7 drm: msm: a6xx: send opp instead of a frequency

In reply to Akhil P Oommen

From: Sharat Masetty <[email protected]>

This patch changes the plumbing to send the devfreq recommended opp rather than the frequency. Also consolidate and rearrange the code in a6xx to set the GPU frequency and the icc vote in preparation for the upcoming changes for GPU->DDR scaling votes.

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 73 ++++++++++++++++-------------------
 drivers/gpu/drm/msm/adreno/a6xx_gpu.h |  2 +-
 drivers/gpu/drm/msm/msm_gpu.c         |  3 +-
 drivers/gpu/drm/msm/msm_gpu.h         |  3 +-
 4 files changed, 38 insertions(+), 43 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +34 -39
index 21e77d6..233afea 100644
@@ -103,17 +103,31 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu)
 		A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_CLK_OFF));
 }
 
-static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
+void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 {
-	struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
-	struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
-	struct msm_gpu *gpu = &adreno_gpu->base;
-	int ret;
+	struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
+	struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
+	struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
+	u32 perf_index;
+	unsigned long gpu_freq;
+	int ret = 0;
+
+	gpu_freq = dev_pm_opp_get_freq(opp);
+
+	if (gpu_freq == gmu->freq)
+		return;
+
+	for (perf_index = 0; perf_index < gmu->nr_gpu_freqs - 1; perf_index++)
+		if (gpu_freq == gmu->gpu_freqs[perf_index])
+			break;
+
+	gmu->current_perf_index = perf_index;
+	gmu->freq = gmu->gpu_freqs[perf_index];
 
 	gmu_write(gmu, REG_A6XX_GMU_DCVS_ACK_OPTION, 0);
 
 	gmu_write(gmu, REG_A6XX_GMU_DCVS_PERF_SETTING,
-		((3 & 0xf) << 28) | index);
+			((3 & 0xf) << 28) | perf_index);
 
 	/*
 	 * Send an invalid index as a vote for the bus bandwidth and let the
@@ -136,38 +150,6 @@ static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
 	icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
 }
 
-void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq)
-{
-	struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
-	struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
-	struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
-	u32 perf_index = 0;
-
-	if (freq == gmu->freq)
-		return;
-
-	for (perf_index = 0; perf_index < gmu->nr_gpu_freqs - 1; perf_index++)
-		if (freq == gmu->gpu_freqs[perf_index])
-			break;
-
-	gmu->current_perf_index = perf_index;
-	gmu->freq = gmu->gpu_freqs[perf_index];
-
-	/*
-	 * This can get called from devfreq while the hardware is idle. Don't
-	 * bring up the power if it isn't already active
-	 */
-	if (pm_runtime_get_if_in_use(gmu->dev) == 0)
-		return;
-
-	if (gmu->legacy)
-		__a6xx_gmu_set_freq(gmu, perf_index);
-	else
-		a6xx_hfi_set_freq(gmu, perf_index);
-
-	pm_runtime_put(gmu->dev);
-}
-
 unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
 {
 	struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
@@ -839,6 +821,19 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)
 	a6xx_gmu_rpmh_off(gmu);
 }
 
+static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
+{
+	struct dev_pm_opp *gpu_opp;
+	unsigned long gpu_freq = gmu->gpu_freqs[gmu->current_perf_index];
+
+	gpu_opp = dev_pm_opp_find_freq_exact(&gpu->pdev->dev, gpu_freq, true);
+	if (IS_ERR_OR_NULL(gpu_opp))
+		return;
+
+	a6xx_gmu_set_freq(gpu, gpu_opp);
+	dev_pm_opp_put(gpu_opp);
+}
+
 int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 {
 	struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
@@ -899,7 +894,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 
 	/* Set the GPU to the current freq */
 	if (gmu->legacy)
-		__a6xx_gmu_set_freq(gmu, gmu->current_perf_index);
+		a6xx_gmu_set_initial_freq(gpu, gmu);
 	else
 		a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
 
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +1 -1
index 7239b8b..03ba60d 100644
@@ -63,7 +63,7 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state);
 int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node);
 void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu);
 
-void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq);
+void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp);
 unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu);
 
 void a6xx_show(struct msm_gpu *gpu, struct msm_gpu_state *state,
drivers/gpu/drm/msm/msm_gpu.c +1 -2
index a22d306..82eb727 100644
@@ -13,7 +13,6 @@
 
 #include <generated/utsrelease.h>
 #include <linux/string_helpers.h>
-#include <linux/pm_opp.h>
 #include <linux/devfreq.h>
 #include <linux/devcoredump.h>
 #include <linux/sched/task.h>
@@ -34,7 +33,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
 		return PTR_ERR(opp);
 
 	if (gpu->funcs->gpu_set_freq)
-		gpu->funcs->gpu_set_freq(gpu, (u64)*freq);
+		gpu->funcs->gpu_set_freq(gpu, opp);
 	else
 		clk_set_rate(gpu->core_clk, *freq);
 
drivers/gpu/drm/msm/msm_gpu.h +2 -1
index 429cb40..0db117a 100644
@@ -9,6 +9,7 @@
 
 #include <linux/clk.h>
 #include <linux/interconnect.h>
+#include <linux/pm_opp.h>
 #include <linux/regulator/consumer.h>
 
 #include "msm_drv.h"
@@ -61,7 +62,7 @@ struct msm_gpu_funcs {
 	struct msm_gpu_state *(*gpu_state_get)(struct msm_gpu *gpu);
 	int (*gpu_state_put)(struct msm_gpu_state *state);
 	unsigned long (*gpu_get_freq)(struct msm_gpu *gpu);
-	void (*gpu_set_freq)(struct msm_gpu *gpu, unsigned long freq);
+	void (*gpu_set_freq)(struct msm_gpu *gpu, struct dev_pm_opp *opp);
 	struct msm_gem_address_space *(*create_address_space)
 		(struct msm_gpu *gpu, struct platform_device *pdev);
 };
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH v4 3/7 drm: msm: a6xx: set gpu freq through hfi

In reply to Akhil P Oommen

Newer targets support changing gpu frequency through HFI. So use that wherever supported instead of the legacy method.

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +7 -4
index 233afea..b547339 100644
@@ -121,6 +121,12 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 		if (gpu_freq == gmu->gpu_freqs[perf_index])
 			break;
 
+	if (!gmu->legacy) {
+		a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
+		icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+		return;
+	}
+
 	gmu->current_perf_index = perf_index;
 	gmu->freq = gmu->gpu_freqs[perf_index];
 
@@ -893,10 +899,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 	enable_irq(gmu->hfi_irq);
 
 	/* Set the GPU to the current freq */
-	if (gmu->legacy)
-		a6xx_gmu_set_initial_freq(gpu, gmu);
-	else
-		a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
+	a6xx_gmu_set_initial_freq(gpu, gmu);
 
 	/*
 	 * "enable" the GX power domain which won't actually do anything but it
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH v4 3/7] drm: msm: a6xx: set gpu freq through hfi

Quoted 3 lines · Akhil P Oommen

Newer targets support changing gpu frequency through HFI. So use that wherever supported instead of the legacy method.

It was already using HFI on newer targets. Don't break it in one commit then fix it in the next.

Quoted 35 lines
---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 11 +++++++----
  1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +7 -4
index 233afea..b547339 100644
@@ -121,6 +121,12 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
  		if (gpu_freq == gmu->gpu_freqs[perf_index])
  			break;
 
+	if (!gmu->legacy) {
+		a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
+		icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+		return;
+	}
+
  	gmu->current_perf_index = perf_index;
  	gmu->freq = gmu->gpu_freqs[perf_index];
 
@@ -893,10 +899,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
  	enable_irq(gmu->hfi_irq);
 
  	/* Set the GPU to the current freq */
-	if (gmu->legacy)
-		a6xx_gmu_set_initial_freq(gpu, gmu);
-	else
-		a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
+	a6xx_gmu_set_initial_freq(gpu, gmu);
 
  	/*
  	 * "enable" the GX power domain which won't actually do anything but it
#5 lore raw

Re: [PATCH v4 3/7] drm: msm: a6xx: set gpu freq through hfi

Quoted 6 lines · Jonathan Marek
Quoted 3 lines · Akhil P Oommen

Newer targets support changing gpu frequency through HFI. So use that wherever supported instead of the legacy method.

It was already using HFI on newer targets. Don't break it in one commit then fix it in the next.

Oops. I somehow got confused. Will fix and resend.

-Akhil

Quoted 29 lines
Quoted 29 lines

---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 11 +++++++----

  1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +5 -0
index 233afea..b547339 100644
@@ -121,6 +121,12 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, 
 struct dev_pm_opp *opp)
           if (gpu_freq == gmu->gpu_freqs[perf_index])
               break;
   +    if (!gmu->legacy) {
+        a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
+        icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+        return;
+    }
+
       gmu->current_perf_index = perf_index;
       gmu->freq = gmu->gpu_freqs[perf_index];

  @@ -893,10 +899,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu) enable_irq(gmu->hfi_irq);
        /* Set the GPU to the current freq */
-    if (gmu->legacy)
-        a6xx_gmu_set_initial_freq(gpu, gmu);
-    else
-        a6xx_hfi_set_freq(gmu, gmu->current_perf_index);

Quoted 8 lines
Quoted 4 lines

+    a6xx_gmu_set_initial_freq(gpu, gmu);
        /*
       * "enable" the GX power domain which won't actually do anything but it

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH v4 3/7] drm: msm: a6xx: set gpu freq through hfi

Quoted 7 lines · Akhil P Oommen
Quoted 5 lines · Jonathan Marek
Quoted 3 lines · Akhil P Oommen

Newer targets support changing gpu frequency through HFI. So use that wherever supported instead of the legacy method.

Quoted 5 lines
Quoted 1 line

It was already using HFI on newer targets. Don't break it in one commit then fix it in the next.

Oops. I somehow got confused. Will fix and resend.

-Akhil

I broke the pm_runtime_get_if_in_use() check too. Other than that, just squashing this patch with the previous one should be enough.

-Akhil.

Quoted 42 lines
Quoted 30 lines
Quoted 30 lines

---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 11 +++++++----

  1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +5 -0
index 233afea..b547339 100644
@@ -121,6 +121,12 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, 
 struct dev_pm_opp *opp)
           if (gpu_freq == gmu->gpu_freqs[perf_index])
               break;
   +    if (!gmu->legacy) {
+        a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
+        icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+        return;
+    }
+
       gmu->current_perf_index = perf_index;
       gmu->freq = gmu->gpu_freqs[perf_index];

  @@ -893,10 +899,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu) enable_irq(gmu->hfi_irq);
        /* Set the GPU to the current freq */
-    if (gmu->legacy)
-        a6xx_gmu_set_initial_freq(gpu, gmu);
-    else
-        a6xx_hfi_set_freq(gmu, gmu->current_perf_index);

Quoted 8 lines
Quoted 4 lines

+    a6xx_gmu_set_initial_freq(gpu, gmu);
        /*
       * "enable" the GX power domain which won't actually do anything but it

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

PATCH v4 4/7 drm: msm: a6xx: use dev_pm_opp_set_bw to scale DDR

In reply to Akhil P Oommen

From: Sharat Masetty <[email protected]>

This patches replaces the previously used static DDR vote and uses dev_pm_opp_set_bw() to scale GPU->DDR bandwidth along with scaling GPU frequency. Also since the icc path voting is handled completely in the opp driver, remove the icc_path handle and its usage in the drm driver.

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +17 -8
index b547339..6fbfd7d 100644
@@ -123,7 +123,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 
 	if (!gmu->legacy) {
 		a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
-		icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+		dev_pm_opp_set_bw(&gpu->pdev->dev, opp);
 		return;
 	}
 
@@ -149,11 +149,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 	if (ret)
 		dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
 
-	/*
-	 * Eventually we will want to scale the path vote with the frequency but
-	 * for now leave it at max so that the performance is nominal.
-	 */
-	icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+	dev_pm_opp_set_bw(&gpu->pdev->dev, opp);
 }
 
 unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
@@ -840,6 +836,19 @@ static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
 	dev_pm_opp_put(gpu_opp);
 }
 
+static void a6xx_gmu_set_initial_bw(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
+{
+	struct dev_pm_opp *gpu_opp;
+	unsigned long gpu_freq = gmu->gpu_freqs[gmu->current_perf_index];
+
+	gpu_opp = dev_pm_opp_find_freq_exact(&gpu->pdev->dev, gpu_freq, true);
+	if (IS_ERR_OR_NULL(gpu_opp))
+		return;
+
+	dev_pm_opp_set_bw(&gpu->pdev->dev, gpu_opp);
+	dev_pm_opp_put(gpu_opp);
+}
+
 int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 {
 	struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
@@ -864,7 +873,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 	}
 
 	/* Set the bus quota to a reasonable value for boot */
-	icc_set_bw(gpu->icc_path, 0, MBps_to_icc(3072));
+	a6xx_gmu_set_initial_bw(gpu, gmu);
 
 	/* Enable the GMU interrupt */
 	gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_CLR, ~0);
@@ -1040,7 +1049,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
 		a6xx_gmu_shutdown(gmu);
 
 	/* Remove the bus vote */
-	icc_set_bw(gpu->icc_path, 0, 0);
+	dev_pm_opp_set_bw(&gpu->pdev->dev, NULL);
 
 	/*
 	 * Make sure the GX domain is off before turning off the GMU (CX)
Signature · 1 line
2.7.4
#8 lore raw

Re: [Freedreno] [PATCH v4 4/7] drm: msm: a6xx: use dev_pm_opp_set_bw to scale DDR

Quoted 20 lines · Akhil P Oommen

From: Sharat Masetty <[email protected]>

This patches replaces the previously used static DDR vote and uses dev_pm_opp_set_bw() to scale GPU->DDR bandwidth along with scaling GPU frequency. Also since the icc path voting is handled completely in the opp driver, remove the icc_path handle and its usage in the drm driver.

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0 -0
index b547339..6fbfd7d 100644

drivers/gpu/drm/msm/adreno/a6xx_gmu.c void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp) · line 126

Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1 -1
@@ -123,7 +123,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 
        if (!gmu->legacy) {
                a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
-               icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+               dev_pm_opp_set_bw(&gpu->pdev->dev, opp);

What is the status of the patch to add dev_pm_opp_set_bw()? If it is ready to go, and I get an ack-by from the OPP maintainer, I suppose I could merge it via drm/msm.

Otherwise should we consider pulling in a private copy of it into drm/msm (and then drop it to use the helper in, hopefully, the next cycle)?

I'm pulling the patches preceding this one into msm-next-staging to do some testing. And the dt patches following this one would normally get merged via Bjorn. At the moment, I'm not sure what to do with this one.

BR,
-R

Quoted 57 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +16 -8
                return;
        }
 
@@ -149,11 +149,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
        if (ret)
                dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
 
-       /*
-        * Eventually we will want to scale the path vote with the frequency but
-        * for now leave it at max so that the performance is nominal.
-        */
-       icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+       dev_pm_opp_set_bw(&gpu->pdev->dev, opp);
 }
 
 unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
@@ -840,6 +836,19 @@ static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
        dev_pm_opp_put(gpu_opp);
 }
 
+static void a6xx_gmu_set_initial_bw(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
+{
+       struct dev_pm_opp *gpu_opp;
+       unsigned long gpu_freq = gmu->gpu_freqs[gmu->current_perf_index];
+
+       gpu_opp = dev_pm_opp_find_freq_exact(&gpu->pdev->dev, gpu_freq, true);
+       if (IS_ERR_OR_NULL(gpu_opp))
+               return;
+
+       dev_pm_opp_set_bw(&gpu->pdev->dev, gpu_opp);
+       dev_pm_opp_put(gpu_opp);
+}
+
 int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 {
        struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
@@ -864,7 +873,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
        }
 
        /* Set the bus quota to a reasonable value for boot */
-       icc_set_bw(gpu->icc_path, 0, MBps_to_icc(3072));
+       a6xx_gmu_set_initial_bw(gpu, gmu);
 
        /* Enable the GMU interrupt */
        gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_CLR, ~0);
@@ -1040,7 +1049,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
                a6xx_gmu_shutdown(gmu);
 
        /* Remove the bus vote */
-       icc_set_bw(gpu->icc_path, 0, 0);
+       dev_pm_opp_set_bw(&gpu->pdev->dev, NULL);
 
        /*
         * Make sure the GX domain is off before turning off the GMU (CX)
--

2.7.4

Quoted 4 lines

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

Re: [Freedreno] [PATCH v4 4/7] drm: msm: a6xx: use dev_pm_opp_set_bw to scale DDR

Quoted 33 lines · Rob Clark
Quoted 19 lines · Akhil P Oommen

From: Sharat Masetty <[email protected]>

This patches replaces the previously used static DDR vote and uses dev_pm_opp_set_bw() to scale GPU->DDR bandwidth along with scaling GPU frequency. Also since the icc path voting is handled completely in the opp driver, remove the icc_path handle and its usage in the drm driver.

---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 25 +++++++++++++++++--------
  1 file changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0 -0
index b547339..6fbfd7d 100644

drivers/gpu/drm/msm/adreno/a6xx_gmu.c void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp) · line 126

Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1 -1
@@ -123,7 +123,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 
         if (!gmu->legacy) {
                 a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
-               icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+               dev_pm_opp_set_bw(&gpu->pdev->dev, opp);

What is the status of the patch to add dev_pm_opp_set_bw()? If it is ready to go, and I get an ack-by from the OPP maintainer, I suppose I could merge it via drm/msm.

Otherwise should we consider pulling in a private copy of it into drm/msm (and then drop it to use the helper in, hopefully, the next cycle)?

Quoted 7 lines

I'm pulling the patches preceding this one into msm-next-staging to do some testing. And the dt patches following this one would normally get merged via Bjorn. At the moment, I'm not sure what to do with this one.

BR,
-R

I see Sibi's patch is already picked in opp/linux-next branch.
https://kernel.googlesource.com/pub/scm/linux/kernel/git/vireshk/pm/+/b466542f331e221a3628c1cfe5ccff307d7d787f

Thanks,
-Akhil

Quoted 57 lines
Quoted 57 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +16 -8
                 return;
         }
 
@@ -149,11 +149,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
         if (ret)
                 dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
 
-       /*
-        * Eventually we will want to scale the path vote with the frequency but
-        * for now leave it at max so that the performance is nominal.
-        */
-       icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+       dev_pm_opp_set_bw(&gpu->pdev->dev, opp);
  }
 
  unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
@@ -840,6 +836,19 @@ static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
         dev_pm_opp_put(gpu_opp);
  }
 
+static void a6xx_gmu_set_initial_bw(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
+{
+       struct dev_pm_opp *gpu_opp;
+       unsigned long gpu_freq = gmu->gpu_freqs[gmu->current_perf_index];
+
+       gpu_opp = dev_pm_opp_find_freq_exact(&gpu->pdev->dev, gpu_freq, true);
+       if (IS_ERR_OR_NULL(gpu_opp))
+               return;
+
+       dev_pm_opp_set_bw(&gpu->pdev->dev, gpu_opp);
+       dev_pm_opp_put(gpu_opp);
+}
+
  int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
  {
         struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
@@ -864,7 +873,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
         }
 
         /* Set the bus quota to a reasonable value for boot */
-       icc_set_bw(gpu->icc_path, 0, MBps_to_icc(3072));
+       a6xx_gmu_set_initial_bw(gpu, gmu);
 
         /* Enable the GMU interrupt */
         gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_CLR, ~0);
@@ -1040,7 +1049,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
                 a6xx_gmu_shutdown(gmu);
 
         /* Remove the bus vote */
-       icc_set_bw(gpu->icc_path, 0, 0);
+       dev_pm_opp_set_bw(&gpu->pdev->dev, NULL);
 
         /*
          * Make sure the GX domain is off before turning off the GMU (CX)
--

2.7.4

Quoted 4 lines
Quoted 4 lines

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

Re: [Freedreno] [PATCH v4 4/7] drm: msm: a6xx: use dev_pm_opp_set_bw to scale DDR

Quoted 41 lines · Akhil P Oommen
Quoted 38 lines · Rob Clark
Quoted 19 lines · Akhil P Oommen

From: Sharat Masetty <[email protected]>

This patches replaces the previously used static DDR vote and uses dev_pm_opp_set_bw() to scale GPU->DDR bandwidth along with scaling GPU frequency. Also since the icc path voting is handled completely in the opp driver, remove the icc_path handle and its usage in the drm driver.

---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 25 +++++++++++++++++--------
  1 file changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0 -0
index b547339..6fbfd7d 100644

drivers/gpu/drm/msm/adreno/a6xx_gmu.c void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp) · line 126

Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1 -1
@@ -123,7 +123,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 
         if (!gmu->legacy) {
                 a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
-               icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+               dev_pm_opp_set_bw(&gpu->pdev->dev, opp);

What is the status of the patch to add dev_pm_opp_set_bw()? If it is ready to go, and I get an ack-by from the OPP maintainer, I suppose I could merge it via drm/msm.

Otherwise should we consider pulling in a private copy of it into drm/msm (and then drop it to use the helper in, hopefully, the next cycle)?

I'm pulling the patches preceding this one into msm-next-staging to do some testing. And the dt patches following this one would normally get merged via Bjorn. At the moment, I'm not sure what to do with this one.

Quoted 5 lines
Quoted 2 lines

BR,
-R

I see Sibi's patch is already picked in opp/linux-next branch.
https://kernel.googlesource.com/pub/scm/linux/kernel/git/vireshk/pm/+/b466542f331e221a3628c1cfe5ccff307d7d787f

ok, I guess we can try and do a 2nd late pull-req for msm-next, after the opp pull-req lands..

BR,
-R

Quoted 65 lines

Thanks,
-Akhil

Quoted 61 lines
Quoted 61 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +16 -8
                 return;
         }
 
@@ -149,11 +149,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
         if (ret)
                 dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
 
-       /*
-        * Eventually we will want to scale the path vote with the frequency but
-        * for now leave it at max so that the performance is nominal.
-        */
-       icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+       dev_pm_opp_set_bw(&gpu->pdev->dev, opp);
  }
 
  unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
@@ -840,6 +836,19 @@ static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
         dev_pm_opp_put(gpu_opp);
  }
 
+static void a6xx_gmu_set_initial_bw(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
+{
+       struct dev_pm_opp *gpu_opp;
+       unsigned long gpu_freq = gmu->gpu_freqs[gmu->current_perf_index];
+
+       gpu_opp = dev_pm_opp_find_freq_exact(&gpu->pdev->dev, gpu_freq, true);
+       if (IS_ERR_OR_NULL(gpu_opp))
+               return;
+
+       dev_pm_opp_set_bw(&gpu->pdev->dev, gpu_opp);
+       dev_pm_opp_put(gpu_opp);
+}
+
  int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
  {
         struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
@@ -864,7 +873,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
         }
 
         /* Set the bus quota to a reasonable value for boot */
-       icc_set_bw(gpu->icc_path, 0, MBps_to_icc(3072));
+       a6xx_gmu_set_initial_bw(gpu, gmu);
 
         /* Enable the GMU interrupt */
         gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_CLR, ~0);
@@ -1040,7 +1049,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
                 a6xx_gmu_shutdown(gmu);
 
         /* Remove the bus vote */
-       icc_set_bw(gpu->icc_path, 0, 0);
+       dev_pm_opp_set_bw(&gpu->pdev->dev, NULL);
 
         /*
          * Make sure the GX domain is off before turning off the GMU (CX)
--

2.7.4

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

#11 lore raw

PATCH v4 5/7 arm64: dts: qcom: SDM845: Enable GPU DDR bw scaling

In reply to Akhil P Oommen

From: Sharat Masetty <[email protected]>

This patch adds the interconnects property for the gpu node and the opp-peak-kBps property to the opps of the gpu opp table. This should help enable DDR bandwidth scaling dynamically and proportionally to the GPU frequency.

---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/qcom/sdm845.dtsi +9 -0
index 8eb5a31..5e9561a 100644
@@ -3515,42 +3515,51 @@
 
 			qcom,gmu = <&gmu>;
 
+			interconnects = <&mem_noc MASTER_GFX3D &mem_noc SLAVE_EBI1>;
+
 			gpu_opp_table: opp-table {
 				compatible = "operating-points-v2";
 
 				opp-710000000 {
 					opp-hz = /bits/ 64 <710000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
+					opp-peak-kBps = <7216000>;
 				};
 
 				opp-675000000 {
 					opp-hz = /bits/ 64 <675000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_TURBO>;
+					opp-peak-kBps = <7216000>;
 				};
 
 				opp-596000000 {
 					opp-hz = /bits/ 64 <596000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_NOM_L1>;
+					opp-peak-kBps = <6220000>;
 				};
 
 				opp-520000000 {
 					opp-hz = /bits/ 64 <520000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_NOM>;
+					opp-peak-kBps = <6220000>;
 				};
 
 				opp-414000000 {
 					opp-hz = /bits/ 64 <414000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_SVS_L1>;
+					opp-peak-kBps = <4068000>;
 				};
 
 				opp-342000000 {
 					opp-hz = /bits/ 64 <342000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_SVS>;
+					opp-peak-kBps = <2724000>;
 				};
 
 				opp-257000000 {
 					opp-hz = /bits/ 64 <257000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
+					opp-peak-kBps = <1648000>;
 				};
 			};
 		};
Signature · 1 line
2.7.4
#12 lore raw

PATCH v4 6/7 arm64: dts: qcom: sc7180: Add interconnects property for GPU

In reply to Akhil P Oommen

From: Sharat Masetty <[email protected]>

This patch adds the interconnects property to the GPU node. This enables the GPU->DDR path bandwidth voting.

---
 arch/arm64/boot/dts/qcom/sc7180.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sc7180.dtsi +2 -0
index 31b9217..a567297 100644
@@ -1470,6 +1470,8 @@
 			operating-points-v2 = <&gpu_opp_table>;
 			qcom,gmu = <&gmu>;
 
+			interconnects = <&gem_noc MASTER_GFX3D &mc_virt SLAVE_EBI1>;
+
 			gpu_opp_table: opp-table {
 				compatible = "operating-points-v2";
 
Signature · 1 line
2.7.4
#13 lore raw

PATCH v4 7/7 arm64: dts: qcom: sc7180: Add opp-peak-kBps to GPU opp

In reply to Akhil P Oommen

From: Sharat Masetty <[email protected]>

Add opp-peak-kBps bindings to the GPU opp table, listing the peak GPU -> DDR bandwidth requirement for each opp level. This will be used to scale the DDR bandwidth along with the GPU frequency dynamically.

---
 arch/arm64/boot/dts/qcom/sc7180.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/qcom/sc7180.dtsi +7 -0
index a567297..8567e9e 100644
@@ -1478,36 +1478,43 @@
 				opp-800000000 {
 					opp-hz = /bits/ 64 <800000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_TURBO>;
+					opp-peak-kBps = <8532000>;
 				};
 
 				opp-650000000 {
 					opp-hz = /bits/ 64 <650000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_NOM_L1>;
+					opp-peak-kBps = <7216000>;
 				};
 
 				opp-565000000 {
 					opp-hz = /bits/ 64 <565000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_NOM>;
+					opp-peak-kBps = <5412000>;
 				};
 
 				opp-430000000 {
 					opp-hz = /bits/ 64 <430000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_SVS_L1>;
+					opp-peak-kBps = <5412000>;
 				};
 
 				opp-355000000 {
 					opp-hz = /bits/ 64 <355000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_SVS>;
+					opp-peak-kBps = <3072000>;
 				};
 
 				opp-267000000 {
 					opp-hz = /bits/ 64 <267000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
+					opp-peak-kBps = <3072000>;
 				};
 
 				opp-180000000 {
 					opp-hz = /bits/ 64 <180000000>;
 					opp-level = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
+					opp-peak-kBps = <1804000>;
 				};
 			};
 		};
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel