Commit 5015817e authored by Timo Aaltonen's avatar Timo Aaltonen Committed by Tim Gardner

UBUNTU: SAUCE: i915_bpo: Add i915_bpo_*() calls for ubuntu/i915

BugLink: http://bugs.launchpad.net/bugs/1540390

Add i915_bpo_* functions for use with the ubuntu/i915 driver.

i915_gpu_turbo_disable => i915_bpo_gpu_turbo_disable
i915_gpu_busy => i915_bpo_gpu_busy
i915_gpu_lower => i915_bpo_gpu_lower
i915_gpu_raise => i915_bpo_gpu_raise
i915_read_mch_val => i915_bpo_read_mch_val
Signed-off-by: default avatarTimo Aaltonen <timo.aaltonen@canonical.com>
Signed-off-by: default avatarAndy Whitcroft <apw@canonical.com>
parent ef4409b0
......@@ -74,6 +74,7 @@
#include <linux/timer.h>
#include <linux/dmi.h>
#include <drm/i915_drm.h>
#include <drm/i915_drm_bpo.h>
#include <asm/msr.h>
#include <asm/processor.h>
#include "intel_ips.h"
......@@ -251,6 +252,9 @@
static const int IPS_ADJUST_PERIOD = 5000; /* ms */
static bool late_i915_load = false;
int i915_bpo_enabled = 0;
EXPORT_SYMBOL(i915_bpo_enabled);
/* For initial average collection */
static const int IPS_SAMPLE_PERIOD = 200; /* ms */
static const int IPS_SAMPLE_WINDOW = 5000; /* 5s moving window of samples */
......@@ -1421,8 +1425,43 @@ static struct ips_mcp_limits *ips_detect_cpu(struct ips_driver *ips)
* enable graphics turbo, otherwise we must disable it to avoid exceeding
* thermal and power limits in the MCP.
*/
static bool ips_get_i915_bpo_syms(struct ips_driver *ips)
{
ips->read_mch_val = symbol_get(i915_bpo_read_mch_val);
if (!ips->read_mch_val)
goto out_err;
ips->gpu_raise = symbol_get(i915_bpo_gpu_raise);
if (!ips->gpu_raise)
goto out_put_mch;
ips->gpu_lower = symbol_get(i915_bpo_gpu_lower);
if (!ips->gpu_lower)
goto out_put_raise;
ips->gpu_busy = symbol_get(i915_bpo_gpu_busy);
if (!ips->gpu_busy)
goto out_put_lower;
ips->gpu_turbo_disable = symbol_get(i915_bpo_gpu_turbo_disable);
if (!ips->gpu_turbo_disable)
goto out_put_busy;
return true;
out_put_busy:
symbol_put(i915_bpo_gpu_busy);
out_put_lower:
symbol_put(i915_bpo_gpu_lower);
out_put_raise:
symbol_put(i915_bpo_gpu_raise);
out_put_mch:
symbol_put(i915_bpo_read_mch_val);
out_err:
return false;
}
static bool ips_get_i915_syms(struct ips_driver *ips)
{
if (ips_get_i915_bpo_syms(ips) != false)
return true;
ips->read_mch_val = symbol_get(i915_read_mch_val);
if (!ips->read_mch_val)
goto out_err;
......
/*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef _I915_DRM_BPO_H_
#define _I915_DRM_BPO_H_
/* For use by IPS driver */
extern unsigned long i915_bpo_read_mch_val(void);
extern bool i915_bpo_gpu_raise(void);
extern bool i915_bpo_gpu_lower(void);
extern bool i915_bpo_gpu_busy(void);
extern bool i915_bpo_gpu_turbo_disable(void);
#endif /* _I915_DRM_BPO_H_ */
......@@ -45,6 +45,8 @@
static struct drm_driver driver;
extern int i915_bpo_enabled;
#define GEN_DEFAULT_PIPEOFFSETS \
.pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
......@@ -955,6 +957,7 @@ int i915_reset(struct drm_device *dev)
static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
int ret;
struct intel_device_info *intel_info =
(struct intel_device_info *) ent->driver_data;
......@@ -981,7 +984,11 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
!vga_switcheroo_handler_flags())
return -EPROBE_DEFER;
return drm_get_pci_dev(pdev, ent, &driver);
ret = drm_get_pci_dev(pdev, ent, &driver);
if (!ret)
i915_bpo_enabled = 1;
return ret;
}
static void
......
......@@ -5855,12 +5855,12 @@ unsigned long i915_gfx_val(struct drm_i915_private *dev_priv)
}
/**
* i915_read_mch_val - return value for IPS use
* i915_bpo_read_mch_val - return value for IPS use
*
* Calculate and return a value for the IPS driver to use when deciding whether
* we have thermal and power headroom to increase CPU or GPU power budget.
*/
unsigned long i915_read_mch_val(void)
unsigned long i915_bpo_read_mch_val(void)
{
struct drm_i915_private *dev_priv;
unsigned long chipset_val, graphics_val, ret = 0;
......@@ -5880,14 +5880,14 @@ unsigned long i915_read_mch_val(void)
return ret;
}
EXPORT_SYMBOL_GPL(i915_read_mch_val);
EXPORT_SYMBOL_GPL(i915_bpo_read_mch_val);
/**
* i915_gpu_raise - raise GPU frequency limit
* i915_bpo_gpu_raise - raise GPU frequency limit
*
* Raise the limit; IPS indicates we have thermal headroom.
*/
bool i915_gpu_raise(void)
bool i915_bpo_gpu_raise(void)
{
struct drm_i915_private *dev_priv;
bool ret = true;
......@@ -5907,15 +5907,15 @@ bool i915_gpu_raise(void)
return ret;
}
EXPORT_SYMBOL_GPL(i915_gpu_raise);
EXPORT_SYMBOL_GPL(i915_bpo_gpu_raise);
/**
* i915_gpu_lower - lower GPU frequency limit
* i915_bpo_gpu_lower - lower GPU frequency limit
*
* IPS indicates we're close to a thermal limit, so throttle back the GPU
* frequency maximum.
*/
bool i915_gpu_lower(void)
bool i915_bpo_gpu_lower(void)
{
struct drm_i915_private *dev_priv;
bool ret = true;
......@@ -5935,14 +5935,14 @@ bool i915_gpu_lower(void)
return ret;
}
EXPORT_SYMBOL_GPL(i915_gpu_lower);
EXPORT_SYMBOL_GPL(i915_bpo_gpu_lower);
/**
* i915_gpu_busy - indicate GPU business to IPS
* i915_bpo_gpu_busy - indicate GPU business to IPS
*
* Tell the IPS driver whether or not the GPU is busy.
*/
bool i915_gpu_busy(void)
bool i915_bpo_gpu_busy(void)
{
struct drm_i915_private *dev_priv;
struct intel_engine_cs *ring;
......@@ -5962,15 +5962,15 @@ bool i915_gpu_busy(void)
return ret;
}
EXPORT_SYMBOL_GPL(i915_gpu_busy);
EXPORT_SYMBOL_GPL(i915_bpo_gpu_busy);
/**
* i915_gpu_turbo_disable - disable graphics turbo
* i915_bpo_gpu_turbo_disable - disable graphics turbo
*
* Disable graphics turbo by resetting the max frequency and setting the
* current frequency to the default.
*/
bool i915_gpu_turbo_disable(void)
bool i915_bpo_gpu_turbo_disable(void)
{
struct drm_i915_private *dev_priv;
bool ret = true;
......@@ -5992,7 +5992,7 @@ bool i915_gpu_turbo_disable(void)
return ret;
}
EXPORT_SYMBOL_GPL(i915_gpu_turbo_disable);
EXPORT_SYMBOL_GPL(i915_bpo_gpu_turbo_disable);
/**
* Tells the intel_ips driver that the i915 driver is now loaded, if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment