Skip to content

Commit 1f60d11

Browse files
Sharat Masettyrobclark
authored andcommitted
drm: msm: a6xx: send opp instead of a frequency
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. Signed-off-by: Sharat Masetty <[email protected]> Signed-off-by: Akhil P Oommen <[email protected]> Signed-off-by: Rob Clark <[email protected]>
1 parent 369c4ef commit 1f60d11

File tree

4 files changed

+52
-45
lines changed

4 files changed

+52
-45
lines changed

drivers/gpu/drm/msm/adreno/a6xx_gmu.c

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,45 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu)
103103
A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_CLK_OFF));
104104
}
105105

106-
static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
106+
void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
107107
{
108-
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
109-
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
110-
struct msm_gpu *gpu = &adreno_gpu->base;
111-
int ret;
108+
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
109+
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
110+
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
111+
u32 perf_index;
112+
unsigned long gpu_freq;
113+
int ret = 0;
114+
115+
gpu_freq = dev_pm_opp_get_freq(opp);
116+
117+
if (gpu_freq == gmu->freq)
118+
return;
119+
120+
for (perf_index = 0; perf_index < gmu->nr_gpu_freqs - 1; perf_index++)
121+
if (gpu_freq == gmu->gpu_freqs[perf_index])
122+
break;
123+
124+
gmu->current_perf_index = perf_index;
125+
gmu->freq = gmu->gpu_freqs[perf_index];
126+
127+
/*
128+
* This can get called from devfreq while the hardware is idle. Don't
129+
* bring up the power if it isn't already active
130+
*/
131+
if (pm_runtime_get_if_in_use(gmu->dev) == 0)
132+
return;
133+
134+
if (!gmu->legacy) {
135+
a6xx_hfi_set_freq(gmu, perf_index);
136+
icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
137+
pm_runtime_put(gmu->dev);
138+
return;
139+
}
112140

113141
gmu_write(gmu, REG_A6XX_GMU_DCVS_ACK_OPTION, 0);
114142

115143
gmu_write(gmu, REG_A6XX_GMU_DCVS_PERF_SETTING,
116-
((3 & 0xf) << 28) | index);
144+
((3 & 0xf) << 28) | perf_index);
117145

118146
/*
119147
* Send an invalid index as a vote for the bus bandwidth and let the
@@ -134,37 +162,6 @@ static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
134162
* for now leave it at max so that the performance is nominal.
135163
*/
136164
icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
137-
}
138-
139-
void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq)
140-
{
141-
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
142-
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
143-
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
144-
u32 perf_index = 0;
145-
146-
if (freq == gmu->freq)
147-
return;
148-
149-
for (perf_index = 0; perf_index < gmu->nr_gpu_freqs - 1; perf_index++)
150-
if (freq == gmu->gpu_freqs[perf_index])
151-
break;
152-
153-
gmu->current_perf_index = perf_index;
154-
gmu->freq = gmu->gpu_freqs[perf_index];
155-
156-
/*
157-
* This can get called from devfreq while the hardware is idle. Don't
158-
* bring up the power if it isn't already active
159-
*/
160-
if (pm_runtime_get_if_in_use(gmu->dev) == 0)
161-
return;
162-
163-
if (gmu->legacy)
164-
__a6xx_gmu_set_freq(gmu, perf_index);
165-
else
166-
a6xx_hfi_set_freq(gmu, perf_index);
167-
168165
pm_runtime_put(gmu->dev);
169166
}
170167

@@ -839,6 +836,19 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)
839836
a6xx_gmu_rpmh_off(gmu);
840837
}
841838

839+
static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
840+
{
841+
struct dev_pm_opp *gpu_opp;
842+
unsigned long gpu_freq = gmu->gpu_freqs[gmu->current_perf_index];
843+
844+
gpu_opp = dev_pm_opp_find_freq_exact(&gpu->pdev->dev, gpu_freq, true);
845+
if (IS_ERR_OR_NULL(gpu_opp))
846+
return;
847+
848+
a6xx_gmu_set_freq(gpu, gpu_opp);
849+
dev_pm_opp_put(gpu_opp);
850+
}
851+
842852
int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
843853
{
844854
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
@@ -898,10 +908,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
898908
enable_irq(gmu->hfi_irq);
899909

900910
/* Set the GPU to the current freq */
901-
if (gmu->legacy)
902-
__a6xx_gmu_set_freq(gmu, gmu->current_perf_index);
903-
else
904-
a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
911+
a6xx_gmu_set_initial_freq(gpu, gmu);
905912

906913
/*
907914
* "enable" the GX power domain which won't actually do anything but it

drivers/gpu/drm/msm/adreno/a6xx_gpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state);
6363
int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node);
6464
void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu);
6565

66-
void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq);
66+
void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp);
6767
unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu);
6868

6969
void a6xx_show(struct msm_gpu *gpu, struct msm_gpu_state *state,

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include <generated/utsrelease.h>
1515
#include <linux/string_helpers.h>
16-
#include <linux/pm_opp.h>
1716
#include <linux/devfreq.h>
1817
#include <linux/devcoredump.h>
1918
#include <linux/sched/task.h>
@@ -34,7 +33,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
3433
return PTR_ERR(opp);
3534

3635
if (gpu->funcs->gpu_set_freq)
37-
gpu->funcs->gpu_set_freq(gpu, (u64)*freq);
36+
gpu->funcs->gpu_set_freq(gpu, opp);
3837
else
3938
clk_set_rate(gpu->core_clk, *freq);
4039

drivers/gpu/drm/msm/msm_gpu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/clk.h>
1111
#include <linux/interconnect.h>
12+
#include <linux/pm_opp.h>
1213
#include <linux/regulator/consumer.h>
1314

1415
#include "msm_drv.h"
@@ -61,7 +62,7 @@ struct msm_gpu_funcs {
6162
struct msm_gpu_state *(*gpu_state_get)(struct msm_gpu *gpu);
6263
int (*gpu_state_put)(struct msm_gpu_state *state);
6364
unsigned long (*gpu_get_freq)(struct msm_gpu *gpu);
64-
void (*gpu_set_freq)(struct msm_gpu *gpu, unsigned long freq);
65+
void (*gpu_set_freq)(struct msm_gpu *gpu, struct dev_pm_opp *opp);
6566
struct msm_gem_address_space *(*create_address_space)
6667
(struct msm_gpu *gpu, struct platform_device *pdev);
6768
};

0 commit comments

Comments
 (0)