aboutsummaryrefslogtreecommitdiffstats
path: root/include/os/linux/scale.c
diff options
context:
space:
mode:
Diffstat (limited to 'include/os/linux/scale.c')
-rw-r--r--include/os/linux/scale.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/include/os/linux/scale.c b/include/os/linux/scale.c
index 388e168..f8f0ef9 100644
--- a/include/os/linux/scale.c
+++ b/include/os/linux/scale.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * gk20a clock scaling profile 2 * gk20a clock scaling profile
3 * 3 *
4 * Copyright (c) 2013-2020, NVIDIA Corporation. All rights reserved. 4 * Copyright (c) 2013-2023, NVIDIA Corporation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -148,32 +148,24 @@ static int gk20a_scale_target(struct device *dev, unsigned long *freq,
148{ 148{
149 struct gk20a_platform *platform = dev_get_drvdata(dev); 149 struct gk20a_platform *platform = dev_get_drvdata(dev);
150 struct gk20a *g = platform->g; 150 struct gk20a *g = platform->g;
151 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
152 struct gk20a_scale_profile *profile = g->scale_profile; 151 struct gk20a_scale_profile *profile = g->scale_profile;
153 struct devfreq *devfreq = l->devfreq;
154 unsigned long local_freq = *freq; 152 unsigned long local_freq = *freq;
155 unsigned long rounded_rate; 153 unsigned long rounded_rate;
154#ifdef CONFIG_GK20A_PM_QOS
156 unsigned long min_freq = 0, max_freq = 0; 155 unsigned long min_freq = 0, max_freq = 0;
156#endif
157 157
158 if (nvgpu_clk_arb_has_active_req(g)) 158 if (nvgpu_clk_arb_has_active_req(g))
159 return 0; 159 return 0;
160
161#ifdef CONFIG_GK20A_PM_QOS
160 /* 162 /*
161 * Calculate floor and cap frequency values 163 * devfreq takes care of min/max freq clipping in update_devfreq() then
162 * 164 * invoked devfreq->profile->target(), thus we only need to do freq
163 * Policy : 165 * clipping based on pm_qos constraint
164 * We have two APIs to clip the frequency
165 * 1. devfreq
166 * 2. pm_qos
167 *
168 * To calculate floor (min) freq, we select MAX of floor frequencies
169 * requested from both APIs
170 * To get cap (max) freq, we select MIN of max frequencies
171 *
172 * In case we have conflict (min_freq > max_freq) after above
173 * steps, we ensure that max_freq wins over min_freq
174 */ 166 */
175 min_freq = max_t(u32, devfreq->min_freq, profile->qos_min_freq); 167 min_freq = profile->qos_min_freq;
176 max_freq = min_t(u32, devfreq->max_freq, profile->qos_max_freq); 168 max_freq = profile->qos_max_freq;
177 169
178 if (min_freq > max_freq) 170 if (min_freq > max_freq)
179 min_freq = max_freq; 171 min_freq = max_freq;
@@ -184,6 +176,7 @@ static int gk20a_scale_target(struct device *dev, unsigned long *freq,
184 176
185 if (local_freq > max_freq) 177 if (local_freq > max_freq)
186 local_freq = max_freq; 178 local_freq = max_freq;
179#endif
187 180
188 /* set the final frequency */ 181 /* set the final frequency */
189 rounded_rate = platform->clk_round_rate(dev, local_freq); 182 rounded_rate = platform->clk_round_rate(dev, local_freq);