summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-06-08 12:24:17 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-06-21 20:35:00 -0400
commit234835b9d1b74b318a8d976cd5284697cf99fff1 (patch)
tree0655cc659eba93636e4f588937589154bd5ca286 /drivers/gpu/nvgpu
parent974379ebb7e7acddc143923f094c58becf3067f1 (diff)
gpu: nvgpu: Move devfreq field to os_linux
Move devfreq field from struct gk20a to os_linux. It's a Linux specific framework. JIRA NVGPU-38 Change-Id: I1e00f5a80e31deb4aaba379274c3a7a7b04d963b Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1505176 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_linux.h2
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h2
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_scale.c30
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.c7
4 files changed, 25 insertions, 16 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/os_linux.h b/drivers/gpu/nvgpu/common/linux/os_linux.h
index a61d07e6..e39d3c4d 100644
--- a/drivers/gpu/nvgpu/common/linux/os_linux.h
+++ b/drivers/gpu/nvgpu/common/linux/os_linux.h
@@ -65,6 +65,8 @@ struct nvgpu_os_linux {
65 65
66 dev_t cdev_region; 66 dev_t cdev_region;
67 67
68 struct devfreq *devfreq;
69
68 struct device_dma_parameters dma_parms; 70 struct device_dma_parameters dma_parms;
69}; 71};
70 72
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index c53e83dd..c1898d2c 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -1186,8 +1186,6 @@ struct gk20a {
1186 struct nvgpu_spinlock items_lock; 1186 struct nvgpu_spinlock items_lock;
1187 } channel_worker; 1187 } channel_worker;
1188 1188
1189 struct devfreq *devfreq;
1190
1191 struct gk20a_scale_profile *scale_profile; 1189 struct gk20a_scale_profile *scale_profile;
1192 unsigned long last_freq; 1190 unsigned long last_freq;
1193 1191
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_scale.c b/drivers/gpu/nvgpu/gk20a/gk20a_scale.c
index 160776bc..df4e4996 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a_scale.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a_scale.c
@@ -28,8 +28,8 @@
28 28
29#include "gk20a.h" 29#include "gk20a.h"
30#include "platform_gk20a.h" 30#include "platform_gk20a.h"
31#include "clk_gk20a.h"
32#include "gk20a_scale.h" 31#include "gk20a_scale.h"
32#include "common/linux/os_linux.h"
33 33
34/* 34/*
35 * gk20a_scale_qos_notify() 35 * gk20a_scale_qos_notify()
@@ -46,7 +46,8 @@ int gk20a_scale_qos_notify(struct notifier_block *nb,
46 container_of(nb, struct gk20a_scale_profile, 46 container_of(nb, struct gk20a_scale_profile,
47 qos_notify_block); 47 qos_notify_block);
48 struct gk20a *g = get_gk20a(profile->dev); 48 struct gk20a *g = get_gk20a(profile->dev);
49 struct devfreq *devfreq = g->devfreq; 49 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
50 struct devfreq *devfreq = l->devfreq;
50 51
51 if (!devfreq) 52 if (!devfreq)
52 return NOTIFY_OK; 53 return NOTIFY_OK;
@@ -79,6 +80,7 @@ int gk20a_scale_qos_notify(struct notifier_block *nb,
79 qos_notify_block); 80 qos_notify_block);
80 struct gk20a_platform *platform = dev_get_drvdata(profile->dev); 81 struct gk20a_platform *platform = dev_get_drvdata(profile->dev);
81 struct gk20a *g = get_gk20a(profile->dev); 82 struct gk20a *g = get_gk20a(profile->dev);
83 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
82 unsigned long freq; 84 unsigned long freq;
83 85
84 if (!platform->postscale) 86 if (!platform->postscale)
@@ -88,8 +90,8 @@ int gk20a_scale_qos_notify(struct notifier_block *nb,
88 * has higher demand than qos */ 90 * has higher demand than qos */
89 freq = platform->clk_round_rate(profile->dev, 91 freq = platform->clk_round_rate(profile->dev,
90 (u32)pm_qos_read_min_bound(PM_QOS_GPU_FREQ_BOUNDS)); 92 (u32)pm_qos_read_min_bound(PM_QOS_GPU_FREQ_BOUNDS));
91 if (g->devfreq) 93 if (l->devfreq)
92 freq = max(g->devfreq->previous_freq, freq); 94 freq = max(l->devfreq->previous_freq, freq);
93 95
94 /* Update gpu load because we may scale the emc target 96 /* Update gpu load because we may scale the emc target
95 * if the gpu load changed. */ 97 * if the gpu load changed. */
@@ -138,8 +140,9 @@ static int gk20a_scale_target(struct device *dev, unsigned long *freq,
138{ 140{
139 struct gk20a_platform *platform = dev_get_drvdata(dev); 141 struct gk20a_platform *platform = dev_get_drvdata(dev);
140 struct gk20a *g = platform->g; 142 struct gk20a *g = platform->g;
143 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
141 struct gk20a_scale_profile *profile = g->scale_profile; 144 struct gk20a_scale_profile *profile = g->scale_profile;
142 struct devfreq *devfreq = g->devfreq; 145 struct devfreq *devfreq = l->devfreq;
143 unsigned long local_freq = *freq; 146 unsigned long local_freq = *freq;
144 unsigned long rounded_rate; 147 unsigned long rounded_rate;
145 unsigned long min_freq = 0, max_freq = 0; 148 unsigned long min_freq = 0, max_freq = 0;
@@ -236,7 +239,8 @@ static void update_load_estimate_gpmu(struct device *dev)
236void gk20a_scale_suspend(struct device *dev) 239void gk20a_scale_suspend(struct device *dev)
237{ 240{
238 struct gk20a *g = get_gk20a(dev); 241 struct gk20a *g = get_gk20a(dev);
239 struct devfreq *devfreq = g->devfreq; 242 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
243 struct devfreq *devfreq = l->devfreq;
240 244
241 if (!devfreq) 245 if (!devfreq)
242 return; 246 return;
@@ -253,7 +257,8 @@ void gk20a_scale_suspend(struct device *dev)
253void gk20a_scale_resume(struct device *dev) 257void gk20a_scale_resume(struct device *dev)
254{ 258{
255 struct gk20a *g = get_gk20a(dev); 259 struct gk20a *g = get_gk20a(dev);
256 struct devfreq *devfreq = g->devfreq; 260 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
261 struct devfreq *devfreq = l->devfreq;
257 262
258 if (!devfreq) 263 if (!devfreq)
259 return; 264 return;
@@ -272,8 +277,9 @@ void gk20a_scale_resume(struct device *dev)
272static void gk20a_scale_notify(struct device *dev, bool busy) 277static void gk20a_scale_notify(struct device *dev, bool busy)
273{ 278{
274 struct gk20a *g = get_gk20a(dev); 279 struct gk20a *g = get_gk20a(dev);
280 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
275 struct gk20a_scale_profile *profile = g->scale_profile; 281 struct gk20a_scale_profile *profile = g->scale_profile;
276 struct devfreq *devfreq = g->devfreq; 282 struct devfreq *devfreq = l->devfreq;
277 283
278 /* Is the device profile initialised? */ 284 /* Is the device profile initialised? */
279 if (!(profile && devfreq)) 285 if (!(profile && devfreq))
@@ -355,6 +361,7 @@ void gk20a_scale_init(struct device *dev)
355{ 361{
356 struct gk20a_platform *platform = dev_get_drvdata(dev); 362 struct gk20a_platform *platform = dev_get_drvdata(dev);
357 struct gk20a *g = platform->g; 363 struct gk20a *g = platform->g;
364 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
358 struct gk20a_scale_profile *profile; 365 struct gk20a_scale_profile *profile;
359 int err; 366 int err;
360 367
@@ -398,7 +405,7 @@ void gk20a_scale_init(struct device *dev)
398 if (IS_ERR(devfreq)) 405 if (IS_ERR(devfreq))
399 devfreq = NULL; 406 devfreq = NULL;
400 407
401 g->devfreq = devfreq; 408 l->devfreq = devfreq;
402 } 409 }
403 410
404 /* Should we register QoS callback for this device? */ 411 /* Should we register QoS callback for this device? */
@@ -422,6 +429,7 @@ void gk20a_scale_exit(struct device *dev)
422{ 429{
423 struct gk20a_platform *platform = dev_get_drvdata(dev); 430 struct gk20a_platform *platform = dev_get_drvdata(dev);
424 struct gk20a *g = platform->g; 431 struct gk20a *g = platform->g;
432 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
425 int err; 433 int err;
426 434
427 if (platform->qos_notify) { 435 if (platform->qos_notify) {
@@ -432,8 +440,8 @@ void gk20a_scale_exit(struct device *dev)
432 } 440 }
433 441
434 if (platform->devfreq_governor) { 442 if (platform->devfreq_governor) {
435 err = devfreq_remove_device(g->devfreq); 443 err = devfreq_remove_device(l->devfreq);
436 g->devfreq = NULL; 444 l->devfreq = NULL;
437 } 445 }
438 446
439 nvgpu_kfree(g, g->scale_profile); 447 nvgpu_kfree(g, g->scale_profile);
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index f2abb76b..559ba4ea 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -568,6 +568,7 @@ static void vgpu_pm_qos_remove(struct device *dev)
568static int vgpu_pm_init(struct device *dev) 568static int vgpu_pm_init(struct device *dev)
569{ 569{
570 struct gk20a *g = get_gk20a(dev); 570 struct gk20a *g = get_gk20a(dev);
571 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
571 unsigned long *freqs; 572 unsigned long *freqs;
572 int num_freqs; 573 int num_freqs;
573 int err = 0; 574 int err = 0;
@@ -579,7 +580,7 @@ static int vgpu_pm_init(struct device *dev)
579 if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) 580 if (IS_ENABLED(CONFIG_GK20A_DEVFREQ))
580 gk20a_scale_init(dev); 581 gk20a_scale_init(dev);
581 582
582 if (g->devfreq) { 583 if (l->devfreq) {
583 /* set min/max frequency based on frequency table */ 584 /* set min/max frequency based on frequency table */
584 err = vgpu_clk_get_freqs(dev, &freqs, &num_freqs); 585 err = vgpu_clk_get_freqs(dev, &freqs, &num_freqs);
585 if (err) 586 if (err)
@@ -588,8 +589,8 @@ static int vgpu_pm_init(struct device *dev)
588 if (num_freqs < 1) 589 if (num_freqs < 1)
589 return -EINVAL; 590 return -EINVAL;
590 591
591 g->devfreq->min_freq = freqs[0]; 592 l->devfreq->min_freq = freqs[0];
592 g->devfreq->max_freq = freqs[num_freqs - 1]; 593 l->devfreq->max_freq = freqs[num_freqs - 1];
593 } 594 }
594 595
595 err = vgpu_pm_qos_init(dev); 596 err = vgpu_pm_qos_init(dev);