From b3a7c2b305ec6f895dc236f0c5f163bd4cbeb248 Mon Sep 17 00:00:00 2001 From: Sachit Kadle Date: Tue, 24 Jan 2017 10:22:13 -0800 Subject: gpu: nvgpu: vgpu: add devfreq support Add devfreq governor support in order to allow frequency scaling in virtualization config. GPU clock frequency operations are re-directed to the server over RPC. Bug 200237433 Change-Id: I1c8e565a4fff36d3456dc72ebb20795b7822650e Signed-off-by: Sachit Kadle Reviewed-on: http://git-master/r/1295542 (cherry picked from commit d5c956fc06697eda3829c67cb22987e538213b29) Reviewed-on: http://git-master/r/1280968 (cherry picked from commit 25e2b3cf7cb5559a6849c0024d42c157564a9be2) Reviewed-on: http://git-master/r/1321835 (cherry picked from commit f871b52fd3f553d6b6375a3c848fbca272ed8e29) Reviewed-on: http://git-master/r/1313468 Tested-by: Aparna Das Reviewed-by: Terje Bergstrom Reviewed-by: Richard Zhao GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/vgpu/vgpu.c | 49 ++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 12 deletions(-) (limited to 'drivers/gpu/nvgpu/vgpu/vgpu.c') diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index 2b1c93dd..e8a778f5 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c @@ -26,6 +26,7 @@ #include "vgpu/vgpu.h" #include "vgpu/fecs_trace_vgpu.h" +#include "vgpu/clk_vgpu.h" #include "gk20a/hal_gk20a.h" #include "gk20a/ctxsw_trace_gk20a.h" #include "gk20a/tsg_gk20a.h" @@ -538,18 +539,22 @@ static int vgpu_qos_notify(struct notifier_block *nb, static int vgpu_pm_qos_init(struct device *dev) { struct gk20a *g = get_gk20a(dev); - struct gk20a_scale_profile *profile; + struct gk20a_scale_profile *profile = g->scale_profile; - profile = nvgpu_kzalloc(g, sizeof(*profile)); - if (!profile) - return -ENOMEM; + if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) { + if (!profile) + return -EINVAL; + } else { + profile = nvgpu_kzalloc(g, sizeof(*profile)); + if (!profile) + return -ENOMEM; + g->scale_profile = profile; + } profile->dev = dev; profile->qos_notify_block.notifier_call = vgpu_qos_notify; - g->scale_profile = profile; pm_qos_add_max_notifier(PM_QOS_GPU_FREQ_BOUNDS, &profile->qos_notify_block); - return 0; } @@ -565,11 +570,31 @@ static void vgpu_pm_qos_remove(struct device *dev) static int vgpu_pm_init(struct device *dev) { + struct gk20a *g = get_gk20a(dev); + unsigned long *freqs; + int num_freqs; int err = 0; gk20a_dbg_fn(""); __pm_runtime_disable(dev, false); + + if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) + gk20a_scale_init(dev); + + if (g->devfreq) { + /* set min/max frequency based on frequency table */ + err = vgpu_clk_get_freqs(dev, &freqs, &num_freqs); + if (err) + return err; + + if (num_freqs < 1) + return -EINVAL; + + g->devfreq->min_freq = freqs[0]; + g->devfreq->max_freq = freqs[num_freqs - 1]; + } + err = vgpu_pm_qos_init(dev); if (err) return err; @@ -675,12 +700,6 @@ int vgpu_probe(struct platform_device *pdev) return err; } - err = vgpu_pm_init(dev); - if (err) { - dev_err(dev, "pm init failed"); - return err; - } - if (platform->late_probe) { err = platform->late_probe(dev); if (err) { @@ -708,6 +727,12 @@ int vgpu_probe(struct platform_device *pdev) return err; } + err = vgpu_pm_init(dev); + if (err) { + dev_err(dev, "pm init failed"); + return err; + } + err = nvgpu_thread_create(&priv->intr_handler, gk20a, vgpu_intr_thread, "gk20a"); if (err) -- cgit v1.2.2