aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel_ips.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86/intel_ips.c')
-rw-r--r--drivers/platform/x86/intel_ips.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index c44a5e8b8b82..f0b3ad13c273 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -75,6 +75,7 @@
75#include <drm/i915_drm.h> 75#include <drm/i915_drm.h>
76#include <asm/msr.h> 76#include <asm/msr.h>
77#include <asm/processor.h> 77#include <asm/processor.h>
78#include "intel_ips.h"
78 79
79#define PCI_DEVICE_ID_INTEL_THERMAL_SENSOR 0x3b32 80#define PCI_DEVICE_ID_INTEL_THERMAL_SENSOR 0x3b32
80 81
@@ -245,6 +246,7 @@
245#define thm_writel(off, val) writel((val), ips->regmap + (off)) 246#define thm_writel(off, val) writel((val), ips->regmap + (off))
246 247
247static const int IPS_ADJUST_PERIOD = 5000; /* ms */ 248static const int IPS_ADJUST_PERIOD = 5000; /* ms */
249static bool late_i915_load = false;
248 250
249/* For initial average collection */ 251/* For initial average collection */
250static const int IPS_SAMPLE_PERIOD = 200; /* ms */ 252static const int IPS_SAMPLE_PERIOD = 200; /* ms */
@@ -339,6 +341,9 @@ struct ips_driver {
339 u64 orig_turbo_ratios; 341 u64 orig_turbo_ratios;
340}; 342};
341 343
344static bool
345ips_gpu_turbo_enabled(struct ips_driver *ips);
346
342/** 347/**
343 * ips_cpu_busy - is CPU busy? 348 * ips_cpu_busy - is CPU busy?
344 * @ips: IPS driver struct 349 * @ips: IPS driver struct
@@ -517,7 +522,7 @@ static void ips_disable_cpu_turbo(struct ips_driver *ips)
517 */ 522 */
518static bool ips_gpu_busy(struct ips_driver *ips) 523static bool ips_gpu_busy(struct ips_driver *ips)
519{ 524{
520 if (!ips->gpu_turbo_enabled) 525 if (!ips_gpu_turbo_enabled(ips))
521 return false; 526 return false;
522 527
523 return ips->gpu_busy(); 528 return ips->gpu_busy();
@@ -532,7 +537,7 @@ static bool ips_gpu_busy(struct ips_driver *ips)
532 */ 537 */
533static void ips_gpu_raise(struct ips_driver *ips) 538static void ips_gpu_raise(struct ips_driver *ips)
534{ 539{
535 if (!ips->gpu_turbo_enabled) 540 if (!ips_gpu_turbo_enabled(ips))
536 return; 541 return;
537 542
538 if (!ips->gpu_raise()) 543 if (!ips->gpu_raise())
@@ -549,7 +554,7 @@ static void ips_gpu_raise(struct ips_driver *ips)
549 */ 554 */
550static void ips_gpu_lower(struct ips_driver *ips) 555static void ips_gpu_lower(struct ips_driver *ips)
551{ 556{
552 if (!ips->gpu_turbo_enabled) 557 if (!ips_gpu_turbo_enabled(ips))
553 return; 558 return;
554 559
555 if (!ips->gpu_lower()) 560 if (!ips->gpu_lower())
@@ -1454,6 +1459,31 @@ out_err:
1454 return false; 1459 return false;
1455} 1460}
1456 1461
1462static bool
1463ips_gpu_turbo_enabled(struct ips_driver *ips)
1464{
1465 if (!ips->gpu_busy && late_i915_load) {
1466 if (ips_get_i915_syms(ips)) {
1467 dev_info(&ips->dev->dev,
1468 "i915 driver attached, reenabling gpu turbo\n");
1469 ips->gpu_turbo_enabled = !(thm_readl(THM_HTS) & HTS_GTD_DIS);
1470 }
1471 }
1472
1473 return ips->gpu_turbo_enabled;
1474}
1475
1476void
1477ips_link_to_i915_driver()
1478{
1479 /* We can't cleanly get at the various ips_driver structs from
1480 * this caller (the i915 driver), so just set a flag saying
1481 * that it's time to try getting the symbols again.
1482 */
1483 late_i915_load = true;
1484}
1485EXPORT_SYMBOL_GPL(ips_link_to_i915_driver);
1486
1457static DEFINE_PCI_DEVICE_TABLE(ips_id_table) = { 1487static DEFINE_PCI_DEVICE_TABLE(ips_id_table) = {
1458 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 1488 { PCI_DEVICE(PCI_VENDOR_ID_INTEL,
1459 PCI_DEVICE_ID_INTEL_THERMAL_SENSOR), }, 1489 PCI_DEVICE_ID_INTEL_THERMAL_SENSOR), },