diff options
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/vgpu.c')
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/vgpu.c | 49 |
1 files changed, 37 insertions, 12 deletions
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 @@ | |||
26 | 26 | ||
27 | #include "vgpu/vgpu.h" | 27 | #include "vgpu/vgpu.h" |
28 | #include "vgpu/fecs_trace_vgpu.h" | 28 | #include "vgpu/fecs_trace_vgpu.h" |
29 | #include "vgpu/clk_vgpu.h" | ||
29 | #include "gk20a/hal_gk20a.h" | 30 | #include "gk20a/hal_gk20a.h" |
30 | #include "gk20a/ctxsw_trace_gk20a.h" | 31 | #include "gk20a/ctxsw_trace_gk20a.h" |
31 | #include "gk20a/tsg_gk20a.h" | 32 | #include "gk20a/tsg_gk20a.h" |
@@ -538,18 +539,22 @@ static int vgpu_qos_notify(struct notifier_block *nb, | |||
538 | static int vgpu_pm_qos_init(struct device *dev) | 539 | static int vgpu_pm_qos_init(struct device *dev) |
539 | { | 540 | { |
540 | struct gk20a *g = get_gk20a(dev); | 541 | struct gk20a *g = get_gk20a(dev); |
541 | struct gk20a_scale_profile *profile; | 542 | struct gk20a_scale_profile *profile = g->scale_profile; |
542 | 543 | ||
543 | profile = nvgpu_kzalloc(g, sizeof(*profile)); | 544 | if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) { |
544 | if (!profile) | 545 | if (!profile) |
545 | return -ENOMEM; | 546 | return -EINVAL; |
547 | } else { | ||
548 | profile = nvgpu_kzalloc(g, sizeof(*profile)); | ||
549 | if (!profile) | ||
550 | return -ENOMEM; | ||
551 | g->scale_profile = profile; | ||
552 | } | ||
546 | 553 | ||
547 | profile->dev = dev; | 554 | profile->dev = dev; |
548 | profile->qos_notify_block.notifier_call = vgpu_qos_notify; | 555 | profile->qos_notify_block.notifier_call = vgpu_qos_notify; |
549 | g->scale_profile = profile; | ||
550 | pm_qos_add_max_notifier(PM_QOS_GPU_FREQ_BOUNDS, | 556 | pm_qos_add_max_notifier(PM_QOS_GPU_FREQ_BOUNDS, |
551 | &profile->qos_notify_block); | 557 | &profile->qos_notify_block); |
552 | |||
553 | return 0; | 558 | return 0; |
554 | } | 559 | } |
555 | 560 | ||
@@ -565,11 +570,31 @@ static void vgpu_pm_qos_remove(struct device *dev) | |||
565 | 570 | ||
566 | static int vgpu_pm_init(struct device *dev) | 571 | static int vgpu_pm_init(struct device *dev) |
567 | { | 572 | { |
573 | struct gk20a *g = get_gk20a(dev); | ||
574 | unsigned long *freqs; | ||
575 | int num_freqs; | ||
568 | int err = 0; | 576 | int err = 0; |
569 | 577 | ||
570 | gk20a_dbg_fn(""); | 578 | gk20a_dbg_fn(""); |
571 | 579 | ||
572 | __pm_runtime_disable(dev, false); | 580 | __pm_runtime_disable(dev, false); |
581 | |||
582 | if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) | ||
583 | gk20a_scale_init(dev); | ||
584 | |||
585 | if (g->devfreq) { | ||
586 | /* set min/max frequency based on frequency table */ | ||
587 | err = vgpu_clk_get_freqs(dev, &freqs, &num_freqs); | ||
588 | if (err) | ||
589 | return err; | ||
590 | |||
591 | if (num_freqs < 1) | ||
592 | return -EINVAL; | ||
593 | |||
594 | g->devfreq->min_freq = freqs[0]; | ||
595 | g->devfreq->max_freq = freqs[num_freqs - 1]; | ||
596 | } | ||
597 | |||
573 | err = vgpu_pm_qos_init(dev); | 598 | err = vgpu_pm_qos_init(dev); |
574 | if (err) | 599 | if (err) |
575 | return err; | 600 | return err; |
@@ -675,12 +700,6 @@ int vgpu_probe(struct platform_device *pdev) | |||
675 | return err; | 700 | return err; |
676 | } | 701 | } |
677 | 702 | ||
678 | err = vgpu_pm_init(dev); | ||
679 | if (err) { | ||
680 | dev_err(dev, "pm init failed"); | ||
681 | return err; | ||
682 | } | ||
683 | |||
684 | if (platform->late_probe) { | 703 | if (platform->late_probe) { |
685 | err = platform->late_probe(dev); | 704 | err = platform->late_probe(dev); |
686 | if (err) { | 705 | if (err) { |
@@ -708,6 +727,12 @@ int vgpu_probe(struct platform_device *pdev) | |||
708 | return err; | 727 | return err; |
709 | } | 728 | } |
710 | 729 | ||
730 | err = vgpu_pm_init(dev); | ||
731 | if (err) { | ||
732 | dev_err(dev, "pm init failed"); | ||
733 | return err; | ||
734 | } | ||
735 | |||
711 | err = nvgpu_thread_create(&priv->intr_handler, gk20a, | 736 | err = nvgpu_thread_create(&priv->intr_handler, gk20a, |
712 | vgpu_intr_thread, "gk20a"); | 737 | vgpu_intr_thread, "gk20a"); |
713 | if (err) | 738 | if (err) |