2012-04-17 01:20:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2012 Intel Corporation
|
|
|
|
*
|
|
|
|
* 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, sublicense,
|
|
|
|
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS 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.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Eugeni Dodonov <eugeni.dodonov@intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-01-26 12:25:24 +00:00
|
|
|
#include <linux/module.h>
|
2018-08-12 22:36:31 +00:00
|
|
|
#include <linux/pm_runtime.h>
|
2019-01-26 12:25:24 +00:00
|
|
|
|
|
|
|
#include <drm/drm_atomic_helper.h>
|
|
|
|
#include <drm/drm_fourcc.h>
|
2016-05-16 22:52:00 +00:00
|
|
|
#include <drm/drm_plane_helper.h>
|
2019-01-26 12:25:24 +00:00
|
|
|
|
2019-06-13 08:44:16 +00:00
|
|
|
#include "display/intel_atomic.h"
|
2019-08-06 11:39:33 +00:00
|
|
|
#include "display/intel_display_types.h"
|
2019-06-13 08:44:16 +00:00
|
|
|
#include "display/intel_fbc.h"
|
|
|
|
#include "display/intel_sprite.h"
|
|
|
|
|
2019-10-20 18:41:39 +00:00
|
|
|
#include "gt/intel_llc.h"
|
|
|
|
|
2012-04-17 01:20:34 +00:00
|
|
|
#include "i915_drv.h"
|
2019-04-29 12:29:27 +00:00
|
|
|
#include "i915_irq.h"
|
2019-08-06 10:07:28 +00:00
|
|
|
#include "i915_trace.h"
|
2019-04-05 11:00:15 +00:00
|
|
|
#include "intel_pm.h"
|
2019-04-26 08:17:22 +00:00
|
|
|
#include "intel_sideband.h"
|
2012-04-26 21:28:12 +00:00
|
|
|
#include "../../../platform/x86/intel_ips.h"
|
2012-04-17 01:20:34 +00:00
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
static void gen9_init_clock_gating(struct drm_i915_private *dev_priv)
|
2015-03-27 12:00:04 +00:00
|
|
|
{
|
2017-08-24 19:10:51 +00:00
|
|
|
if (HAS_LLC(dev_priv)) {
|
|
|
|
/*
|
|
|
|
* WaCompressedResourceDisplayNewHashMode:skl,kbl
|
2017-12-05 19:01:17 +00:00
|
|
|
* Display WA #0390: skl,kbl
|
2017-08-24 19:10:51 +00:00
|
|
|
*
|
|
|
|
* Must match Sampler, Pixel Back End, and Media. See
|
|
|
|
* WaCompressedResourceSamplerPbeMediaNewHashMode.
|
|
|
|
*/
|
|
|
|
I915_WRITE(CHICKEN_PAR1_1,
|
|
|
|
I915_READ(CHICKEN_PAR1_1) |
|
|
|
|
SKL_DE_COMPRESSED_HASH_MODE);
|
|
|
|
}
|
|
|
|
|
2017-06-08 15:50:00 +00:00
|
|
|
/* See Bspec note for PSR2_CTL bit 31, Wa#828:skl,bxt,kbl,cfl */
|
2016-05-19 07:14:20 +00:00
|
|
|
I915_WRITE(CHICKEN_PAR1_1,
|
|
|
|
I915_READ(CHICKEN_PAR1_1) | SKL_EDP_PSR_FIX_RDWRAP);
|
|
|
|
|
2017-06-08 15:50:00 +00:00
|
|
|
/* WaEnableChickenDCPR:skl,bxt,kbl,glk,cfl */
|
2016-06-07 14:19:13 +00:00
|
|
|
I915_WRITE(GEN8_CHICKEN_DCPR_1,
|
|
|
|
I915_READ(GEN8_CHICKEN_DCPR_1) | MASK_WAKEMEM);
|
2016-06-07 14:19:16 +00:00
|
|
|
|
2017-06-08 15:50:00 +00:00
|
|
|
/* WaFbcTurnOffFbcWatermark:skl,bxt,kbl,cfl */
|
|
|
|
/* WaFbcWakeMemOn:skl,bxt,kbl,glk,cfl */
|
2016-06-07 14:19:17 +00:00
|
|
|
I915_WRITE(DISP_ARB_CTL, I915_READ(DISP_ARB_CTL) |
|
|
|
|
DISP_FBC_WM_DIS |
|
|
|
|
DISP_FBC_MEMORY_WAKE);
|
2016-06-07 14:19:19 +00:00
|
|
|
|
2017-06-08 15:50:00 +00:00
|
|
|
/* WaFbcHighMemBwCorruptionAvoidance:skl,bxt,kbl,cfl */
|
2016-06-07 14:19:19 +00:00
|
|
|
I915_WRITE(ILK_DPFC_CHICKEN, I915_READ(ILK_DPFC_CHICKEN) |
|
|
|
|
ILK_DPFC_DISABLE_DUMMY0);
|
2017-08-03 17:32:10 +00:00
|
|
|
|
|
|
|
if (IS_SKYLAKE(dev_priv)) {
|
|
|
|
/* WaDisableDopClockGating */
|
|
|
|
I915_WRITE(GEN7_MISCCPCTL, I915_READ(GEN7_MISCCPCTL)
|
|
|
|
& ~GEN7_DOP_CLOCK_GATE_ENABLE);
|
|
|
|
}
|
2016-06-07 14:19:04 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
static void bxt_init_clock_gating(struct drm_i915_private *dev_priv)
|
2016-06-07 14:19:04 +00:00
|
|
|
{
|
2016-10-31 20:37:22 +00:00
|
|
|
gen9_init_clock_gating(dev_priv);
|
2016-06-07 14:19:04 +00:00
|
|
|
|
2015-06-29 13:07:32 +00:00
|
|
|
/* WaDisableSDEUnitClockGating:bxt */
|
|
|
|
I915_WRITE(GEN8_UCGCTL6, I915_READ(GEN8_UCGCTL6) |
|
|
|
|
GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
|
|
|
|
|
2015-03-11 09:10:27 +00:00
|
|
|
/*
|
|
|
|
* FIXME:
|
2015-03-11 08:49:32 +00:00
|
|
|
* GEN8_HDCUNIT_CLOCK_GATE_DISABLE_HDCREQ applies on 3x6 GT SKUs only.
|
2015-03-11 09:10:27 +00:00
|
|
|
*/
|
|
|
|
I915_WRITE(GEN8_UCGCTL6, I915_READ(GEN8_UCGCTL6) |
|
2015-03-11 08:49:32 +00:00
|
|
|
GEN8_HDCUNIT_CLOCK_GATE_DISABLE_HDCREQ);
|
2015-12-01 08:23:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Wa: Backlight PWM may stop in the asserted state, causing backlight
|
|
|
|
* to stay fully on.
|
|
|
|
*/
|
2017-02-15 15:21:37 +00:00
|
|
|
I915_WRITE(GEN9_CLKGATE_DIS_0, I915_READ(GEN9_CLKGATE_DIS_0) |
|
|
|
|
PWM1_GATING_DIS | PWM2_GATING_DIS);
|
2018-08-07 15:45:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Lower the display internal timeout.
|
|
|
|
* This is needed to avoid any hard hangs when DSI port PLL
|
|
|
|
* is off and a MMIO access is attempted by any privilege
|
|
|
|
* application, using batch buffers or any other means.
|
|
|
|
*/
|
|
|
|
I915_WRITE(RM_TIMEOUT, MMIO_TIMEOUT_US(950));
|
2015-03-27 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 09:16:58 +00:00
|
|
|
static void glk_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
gen9_init_clock_gating(dev_priv);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WaDisablePWMClockGating:glk
|
|
|
|
* Backlight PWM may stop in the asserted state, causing backlight
|
|
|
|
* to stay fully on.
|
|
|
|
*/
|
|
|
|
I915_WRITE(GEN9_CLKGATE_DIS_0, I915_READ(GEN9_CLKGATE_DIS_0) |
|
|
|
|
PWM1_GATING_DIS | PWM2_GATING_DIS);
|
2017-02-22 06:34:29 +00:00
|
|
|
|
|
|
|
/* WaDDIIOTimeout:glk */
|
|
|
|
if (IS_GLK_REVID(dev_priv, 0, GLK_REVID_A1)) {
|
|
|
|
u32 val = I915_READ(CHICKEN_MISC_2);
|
|
|
|
val &= ~(GLK_CL0_PWR_DOWN |
|
|
|
|
GLK_CL1_PWR_DOWN |
|
|
|
|
GLK_CL2_PWR_DOWN);
|
|
|
|
I915_WRITE(CHICKEN_MISC_2, val);
|
|
|
|
}
|
|
|
|
|
2017-01-26 09:16:58 +00:00
|
|
|
}
|
|
|
|
|
2019-12-24 08:40:04 +00:00
|
|
|
static void pnv_get_mem_freq(struct drm_i915_private *dev_priv)
|
2012-04-26 21:28:17 +00:00
|
|
|
{
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = I915_READ(CLKCFG);
|
|
|
|
|
|
|
|
switch (tmp & CLKCFG_FSB_MASK) {
|
|
|
|
case CLKCFG_FSB_533:
|
|
|
|
dev_priv->fsb_freq = 533; /* 133*4 */
|
|
|
|
break;
|
|
|
|
case CLKCFG_FSB_800:
|
|
|
|
dev_priv->fsb_freq = 800; /* 200*4 */
|
|
|
|
break;
|
|
|
|
case CLKCFG_FSB_667:
|
|
|
|
dev_priv->fsb_freq = 667; /* 167*4 */
|
|
|
|
break;
|
|
|
|
case CLKCFG_FSB_400:
|
|
|
|
dev_priv->fsb_freq = 400; /* 100*4 */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (tmp & CLKCFG_MEM_MASK) {
|
|
|
|
case CLKCFG_MEM_533:
|
|
|
|
dev_priv->mem_freq = 533;
|
|
|
|
break;
|
|
|
|
case CLKCFG_MEM_667:
|
|
|
|
dev_priv->mem_freq = 667;
|
|
|
|
break;
|
|
|
|
case CLKCFG_MEM_800:
|
|
|
|
dev_priv->mem_freq = 800;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* detect pineview DDR3 setting */
|
|
|
|
tmp = I915_READ(CSHRDDR3CTL);
|
|
|
|
dev_priv->is_ddr3 = (tmp & CSHRDDR3CTL_DDR3) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2019-12-24 08:40:09 +00:00
|
|
|
static void ilk_get_mem_freq(struct drm_i915_private *dev_priv)
|
2012-04-26 21:28:17 +00:00
|
|
|
{
|
|
|
|
u16 ddrpll, csipll;
|
|
|
|
|
2019-06-11 10:45:48 +00:00
|
|
|
ddrpll = intel_uncore_read16(&dev_priv->uncore, DDRMPLL1);
|
|
|
|
csipll = intel_uncore_read16(&dev_priv->uncore, CSIPLL0);
|
2012-04-26 21:28:17 +00:00
|
|
|
|
|
|
|
switch (ddrpll & 0xff) {
|
|
|
|
case 0xc:
|
|
|
|
dev_priv->mem_freq = 800;
|
|
|
|
break;
|
|
|
|
case 0x10:
|
|
|
|
dev_priv->mem_freq = 1066;
|
|
|
|
break;
|
|
|
|
case 0x14:
|
|
|
|
dev_priv->mem_freq = 1333;
|
|
|
|
break;
|
|
|
|
case 0x18:
|
|
|
|
dev_priv->mem_freq = 1600;
|
|
|
|
break;
|
|
|
|
default:
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg(&dev_priv->drm, "unknown memory frequency 0x%02x\n",
|
|
|
|
ddrpll & 0xff);
|
2012-04-26 21:28:17 +00:00
|
|
|
dev_priv->mem_freq = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (csipll & 0x3ff) {
|
|
|
|
case 0x00c:
|
|
|
|
dev_priv->fsb_freq = 3200;
|
|
|
|
break;
|
|
|
|
case 0x00e:
|
|
|
|
dev_priv->fsb_freq = 3733;
|
|
|
|
break;
|
|
|
|
case 0x010:
|
|
|
|
dev_priv->fsb_freq = 4266;
|
|
|
|
break;
|
|
|
|
case 0x012:
|
|
|
|
dev_priv->fsb_freq = 4800;
|
|
|
|
break;
|
|
|
|
case 0x014:
|
|
|
|
dev_priv->fsb_freq = 5333;
|
|
|
|
break;
|
|
|
|
case 0x016:
|
|
|
|
dev_priv->fsb_freq = 5866;
|
|
|
|
break;
|
|
|
|
case 0x018:
|
|
|
|
dev_priv->fsb_freq = 6400;
|
|
|
|
break;
|
|
|
|
default:
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg(&dev_priv->drm, "unknown fsb frequency 0x%04x\n",
|
|
|
|
csipll & 0x3ff);
|
2012-04-26 21:28:17 +00:00
|
|
|
dev_priv->fsb_freq = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
static const struct cxsr_latency cxsr_latency_table[] = {
|
|
|
|
{1, 0, 800, 400, 3382, 33382, 3983, 33983}, /* DDR2-400 SC */
|
|
|
|
{1, 0, 800, 667, 3354, 33354, 3807, 33807}, /* DDR2-667 SC */
|
|
|
|
{1, 0, 800, 800, 3347, 33347, 3763, 33763}, /* DDR2-800 SC */
|
|
|
|
{1, 1, 800, 667, 6420, 36420, 6873, 36873}, /* DDR3-667 SC */
|
|
|
|
{1, 1, 800, 800, 5902, 35902, 6318, 36318}, /* DDR3-800 SC */
|
|
|
|
|
|
|
|
{1, 0, 667, 400, 3400, 33400, 4021, 34021}, /* DDR2-400 SC */
|
|
|
|
{1, 0, 667, 667, 3372, 33372, 3845, 33845}, /* DDR2-667 SC */
|
|
|
|
{1, 0, 667, 800, 3386, 33386, 3822, 33822}, /* DDR2-800 SC */
|
|
|
|
{1, 1, 667, 667, 6438, 36438, 6911, 36911}, /* DDR3-667 SC */
|
|
|
|
{1, 1, 667, 800, 5941, 35941, 6377, 36377}, /* DDR3-800 SC */
|
|
|
|
|
|
|
|
{1, 0, 400, 400, 3472, 33472, 4173, 34173}, /* DDR2-400 SC */
|
|
|
|
{1, 0, 400, 667, 3443, 33443, 3996, 33996}, /* DDR2-667 SC */
|
|
|
|
{1, 0, 400, 800, 3430, 33430, 3946, 33946}, /* DDR2-800 SC */
|
|
|
|
{1, 1, 400, 667, 6509, 36509, 7062, 37062}, /* DDR3-667 SC */
|
|
|
|
{1, 1, 400, 800, 5985, 35985, 6501, 36501}, /* DDR3-800 SC */
|
|
|
|
|
|
|
|
{0, 0, 800, 400, 3438, 33438, 4065, 34065}, /* DDR2-400 SC */
|
|
|
|
{0, 0, 800, 667, 3410, 33410, 3889, 33889}, /* DDR2-667 SC */
|
|
|
|
{0, 0, 800, 800, 3403, 33403, 3845, 33845}, /* DDR2-800 SC */
|
|
|
|
{0, 1, 800, 667, 6476, 36476, 6955, 36955}, /* DDR3-667 SC */
|
|
|
|
{0, 1, 800, 800, 5958, 35958, 6400, 36400}, /* DDR3-800 SC */
|
|
|
|
|
|
|
|
{0, 0, 667, 400, 3456, 33456, 4103, 34106}, /* DDR2-400 SC */
|
|
|
|
{0, 0, 667, 667, 3428, 33428, 3927, 33927}, /* DDR2-667 SC */
|
|
|
|
{0, 0, 667, 800, 3443, 33443, 3905, 33905}, /* DDR2-800 SC */
|
|
|
|
{0, 1, 667, 667, 6494, 36494, 6993, 36993}, /* DDR3-667 SC */
|
|
|
|
{0, 1, 667, 800, 5998, 35998, 6460, 36460}, /* DDR3-800 SC */
|
|
|
|
|
|
|
|
{0, 0, 400, 400, 3528, 33528, 4255, 34255}, /* DDR2-400 SC */
|
|
|
|
{0, 0, 400, 667, 3500, 33500, 4079, 34079}, /* DDR2-667 SC */
|
|
|
|
{0, 0, 400, 800, 3487, 33487, 4029, 34029}, /* DDR2-800 SC */
|
|
|
|
{0, 1, 400, 667, 6566, 36566, 7145, 37145}, /* DDR3-667 SC */
|
|
|
|
{0, 1, 400, 800, 6042, 36042, 6584, 36584}, /* DDR3-800 SC */
|
|
|
|
};
|
|
|
|
|
2016-10-13 10:09:23 +00:00
|
|
|
static const struct cxsr_latency *intel_get_cxsr_latency(bool is_desktop,
|
|
|
|
bool is_ddr3,
|
2012-04-17 01:20:35 +00:00
|
|
|
int fsb,
|
|
|
|
int mem)
|
|
|
|
{
|
|
|
|
const struct cxsr_latency *latency;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (fsb == 0 || mem == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(cxsr_latency_table); i++) {
|
|
|
|
latency = &cxsr_latency_table[i];
|
|
|
|
if (is_desktop == latency->is_desktop &&
|
|
|
|
is_ddr3 == latency->is_ddr3 &&
|
|
|
|
fsb == latency->fsb_freq && mem == latency->mem_freq)
|
|
|
|
return latency;
|
|
|
|
}
|
|
|
|
|
|
|
|
DRM_DEBUG_KMS("Unknown FSB/MEM found, disable CxSR\n");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-03-05 19:19:52 +00:00
|
|
|
static void chv_set_memory_dvfs(struct drm_i915_private *dev_priv, bool enable)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
2019-04-26 08:17:20 +00:00
|
|
|
vlv_punit_get(dev_priv);
|
2015-03-05 19:19:52 +00:00
|
|
|
|
|
|
|
val = vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2);
|
|
|
|
if (enable)
|
|
|
|
val &= ~FORCE_DDR_HIGH_FREQ;
|
|
|
|
else
|
|
|
|
val |= FORCE_DDR_HIGH_FREQ;
|
|
|
|
val &= ~FORCE_DDR_LOW_FREQ;
|
|
|
|
val |= FORCE_DDR_FREQ_REQ_ACK;
|
|
|
|
vlv_punit_write(dev_priv, PUNIT_REG_DDR_SETUP2, val);
|
|
|
|
|
|
|
|
if (wait_for((vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2) &
|
|
|
|
FORCE_DDR_FREQ_REQ_ACK) == 0, 3))
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"timed out waiting for Punit DDR DVFS request\n");
|
2015-03-05 19:19:52 +00:00
|
|
|
|
2019-04-26 08:17:20 +00:00
|
|
|
vlv_punit_put(dev_priv);
|
2015-03-05 19:19:52 +00:00
|
|
|
}
|
|
|
|
|
2015-03-05 19:19:51 +00:00
|
|
|
static void chv_set_memory_pm5(struct drm_i915_private *dev_priv, bool enable)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
2019-04-26 08:17:20 +00:00
|
|
|
vlv_punit_get(dev_priv);
|
2015-03-05 19:19:51 +00:00
|
|
|
|
2018-11-29 17:55:03 +00:00
|
|
|
val = vlv_punit_read(dev_priv, PUNIT_REG_DSPSSPM);
|
2015-03-05 19:19:51 +00:00
|
|
|
if (enable)
|
|
|
|
val |= DSP_MAXFIFO_PM5_ENABLE;
|
|
|
|
else
|
|
|
|
val &= ~DSP_MAXFIFO_PM5_ENABLE;
|
2018-11-29 17:55:03 +00:00
|
|
|
vlv_punit_write(dev_priv, PUNIT_REG_DSPSSPM, val);
|
2015-03-05 19:19:51 +00:00
|
|
|
|
2019-04-26 08:17:20 +00:00
|
|
|
vlv_punit_put(dev_priv);
|
2015-03-05 19:19:51 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 15:02:21 +00:00
|
|
|
#define FW_WM(value, plane) \
|
|
|
|
(((value) << DSPFW_ ## plane ## _SHIFT) & DSPFW_ ## plane ## _MASK)
|
|
|
|
|
2016-11-28 17:37:12 +00:00
|
|
|
static bool _intel_set_memory_cxsr(struct drm_i915_private *dev_priv, bool enable)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2016-11-28 17:37:12 +00:00
|
|
|
bool was_enabled;
|
2014-07-01 09:36:17 +00:00
|
|
|
u32 val;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2016-10-14 09:13:44 +00:00
|
|
|
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
|
2016-11-28 17:37:12 +00:00
|
|
|
was_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
|
2014-07-01 09:36:17 +00:00
|
|
|
I915_WRITE(FW_BLC_SELF_VLV, enable ? FW_CSPWRDWNEN : 0);
|
2015-06-24 19:00:01 +00:00
|
|
|
POSTING_READ(FW_BLC_SELF_VLV);
|
2016-12-07 10:13:04 +00:00
|
|
|
} else if (IS_G4X(dev_priv) || IS_I965GM(dev_priv)) {
|
2016-11-28 17:37:12 +00:00
|
|
|
was_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
|
2014-07-01 09:36:17 +00:00
|
|
|
I915_WRITE(FW_BLC_SELF, enable ? FW_BLC_SELF_EN : 0);
|
2015-06-24 19:00:01 +00:00
|
|
|
POSTING_READ(FW_BLC_SELF);
|
2016-10-31 20:37:15 +00:00
|
|
|
} else if (IS_PINEVIEW(dev_priv)) {
|
2016-11-28 17:37:12 +00:00
|
|
|
val = I915_READ(DSPFW3);
|
|
|
|
was_enabled = val & PINEVIEW_SELF_REFRESH_EN;
|
|
|
|
if (enable)
|
|
|
|
val |= PINEVIEW_SELF_REFRESH_EN;
|
|
|
|
else
|
|
|
|
val &= ~PINEVIEW_SELF_REFRESH_EN;
|
2014-07-01 09:36:17 +00:00
|
|
|
I915_WRITE(DSPFW3, val);
|
2015-06-24 19:00:01 +00:00
|
|
|
POSTING_READ(DSPFW3);
|
2016-10-13 10:02:58 +00:00
|
|
|
} else if (IS_I945G(dev_priv) || IS_I945GM(dev_priv)) {
|
2016-11-28 17:37:12 +00:00
|
|
|
was_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
|
2014-07-01 09:36:17 +00:00
|
|
|
val = enable ? _MASKED_BIT_ENABLE(FW_BLC_SELF_EN) :
|
|
|
|
_MASKED_BIT_DISABLE(FW_BLC_SELF_EN);
|
|
|
|
I915_WRITE(FW_BLC_SELF, val);
|
2015-06-24 19:00:01 +00:00
|
|
|
POSTING_READ(FW_BLC_SELF);
|
2016-10-13 10:02:58 +00:00
|
|
|
} else if (IS_I915GM(dev_priv)) {
|
2016-07-29 14:57:02 +00:00
|
|
|
/*
|
|
|
|
* FIXME can't find a bit like this for 915G, and
|
|
|
|
* and yet it does have the related watermark in
|
|
|
|
* FW_BLC_SELF. What's going on?
|
|
|
|
*/
|
2016-11-28 17:37:12 +00:00
|
|
|
was_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
|
2014-07-01 09:36:17 +00:00
|
|
|
val = enable ? _MASKED_BIT_ENABLE(INSTPM_SELF_EN) :
|
|
|
|
_MASKED_BIT_DISABLE(INSTPM_SELF_EN);
|
|
|
|
I915_WRITE(INSTPM, val);
|
2015-06-24 19:00:01 +00:00
|
|
|
POSTING_READ(INSTPM);
|
2014-07-01 09:36:17 +00:00
|
|
|
} else {
|
2016-11-28 17:37:12 +00:00
|
|
|
return false;
|
2014-07-01 09:36:17 +00:00
|
|
|
}
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2017-03-02 17:15:07 +00:00
|
|
|
trace_intel_memory_cxsr(dev_priv, was_enabled, enable);
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "memory self-refresh is %s (was %s)\n",
|
|
|
|
enableddisabled(enable),
|
|
|
|
enableddisabled(was_enabled));
|
2016-11-28 17:37:12 +00:00
|
|
|
|
|
|
|
return was_enabled;
|
2012-04-17 01:20:35 +00:00
|
|
|
}
|
|
|
|
|
2017-04-21 18:14:23 +00:00
|
|
|
/**
|
|
|
|
* intel_set_memory_cxsr - Configure CxSR state
|
|
|
|
* @dev_priv: i915 device
|
|
|
|
* @enable: Allow vs. disallow CxSR
|
|
|
|
*
|
|
|
|
* Allow or disallow the system to enter a special CxSR
|
|
|
|
* (C-state self refresh) state. What typically happens in CxSR mode
|
|
|
|
* is that several display FIFOs may get combined into a single larger
|
|
|
|
* FIFO for a particular plane (so called max FIFO mode) to allow the
|
|
|
|
* system to defer memory fetches longer, and the memory will enter
|
|
|
|
* self refresh.
|
|
|
|
*
|
|
|
|
* Note that enabling CxSR does not guarantee that the system enter
|
|
|
|
* this special mode, nor does it guarantee that the system stays
|
|
|
|
* in that mode once entered. So this just allows/disallows the system
|
|
|
|
* to autonomously utilize the CxSR mode. Other factors such as core
|
|
|
|
* C-states will affect when/if the system actually enters/exits the
|
|
|
|
* CxSR mode.
|
|
|
|
*
|
|
|
|
* Note that on VLV/CHV this actually only controls the max FIFO mode,
|
|
|
|
* and the system is free to enter/exit memory self refresh at any time
|
|
|
|
* even when the use of CxSR has been disallowed.
|
|
|
|
*
|
|
|
|
* While the system is actually in the CxSR/max FIFO mode, some plane
|
|
|
|
* control registers will not get latched on vblank. Thus in order to
|
|
|
|
* guarantee the system will respond to changes in the plane registers
|
|
|
|
* we must always disallow CxSR prior to making changes to those registers.
|
|
|
|
* Unfortunately the system will re-evaluate the CxSR conditions at
|
|
|
|
* frame start which happens after vblank start (which is when the plane
|
|
|
|
* registers would get latched), so we can't proceed with the plane update
|
|
|
|
* during the same frame where we disallowed CxSR.
|
|
|
|
*
|
|
|
|
* Certain platforms also have a deeper HPLL SR mode. Fortunately the
|
|
|
|
* HPLL SR mode depends on CxSR itself, so we don't have to hand hold
|
|
|
|
* the hardware w.r.t. HPLL SR when writing to plane registers.
|
|
|
|
* Disallowing just CxSR is sufficient.
|
|
|
|
*/
|
2016-11-28 17:37:12 +00:00
|
|
|
bool intel_set_memory_cxsr(struct drm_i915_private *dev_priv, bool enable)
|
2016-11-28 17:37:11 +00:00
|
|
|
{
|
2016-11-28 17:37:12 +00:00
|
|
|
bool ret;
|
|
|
|
|
2016-11-28 17:37:11 +00:00
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
2016-11-28 17:37:12 +00:00
|
|
|
ret = _intel_set_memory_cxsr(dev_priv, enable);
|
2017-04-21 18:14:29 +00:00
|
|
|
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
|
|
|
|
dev_priv->wm.vlv.cxsr = enable;
|
|
|
|
else if (IS_G4X(dev_priv))
|
|
|
|
dev_priv->wm.g4x.cxsr = enable;
|
2016-11-28 17:37:11 +00:00
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
2016-11-28 17:37:12 +00:00
|
|
|
|
|
|
|
return ret;
|
2016-11-28 17:37:11 +00:00
|
|
|
}
|
2015-03-05 19:19:52 +00:00
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
/*
|
|
|
|
* Latency for FIFO fetches is dependent on several factors:
|
|
|
|
* - memory configuration (speed, channels)
|
|
|
|
* - chipset
|
|
|
|
* - current MCH state
|
|
|
|
* It can be fairly high in some situations, so here we assume a fairly
|
|
|
|
* pessimal value. It's a tradeoff between extra memory fetches (if we
|
|
|
|
* set this value too high, the FIFO will fetch frequently to stay full)
|
|
|
|
* and power consumption (set it too low to save power and we might see
|
|
|
|
* FIFO underruns and display "flicker").
|
|
|
|
*
|
|
|
|
* A value of 5us seems to be a good balance; safe for very low end
|
|
|
|
* platforms but not overly aggressive on lower latency configs.
|
|
|
|
*/
|
2014-09-03 10:56:07 +00:00
|
|
|
static const int pessimal_latency_ns = 5000;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2015-03-05 19:19:47 +00:00
|
|
|
#define VLV_FIFO_START(dsparb, dsparb2, lo_shift, hi_shift) \
|
|
|
|
((((dsparb) >> (lo_shift)) & 0xff) | ((((dsparb2) >> (hi_shift)) & 0x1) << 8))
|
|
|
|
|
2017-03-02 17:14:55 +00:00
|
|
|
static void vlv_get_fifo_size(struct intel_crtc_state *crtc_state)
|
2015-03-05 19:19:47 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2017-03-02 17:14:52 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2017-03-02 17:14:55 +00:00
|
|
|
struct vlv_fifo_state *fifo_state = &crtc_state->wm.vlv.fifo_state;
|
2017-03-02 17:14:52 +00:00
|
|
|
enum pipe pipe = crtc->pipe;
|
|
|
|
int sprite0_start, sprite1_start;
|
2016-11-22 16:02:01 +00:00
|
|
|
|
2017-03-02 17:14:52 +00:00
|
|
|
switch (pipe) {
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 dsparb, dsparb2, dsparb3;
|
2015-03-05 19:19:47 +00:00
|
|
|
case PIPE_A:
|
|
|
|
dsparb = I915_READ(DSPARB);
|
|
|
|
dsparb2 = I915_READ(DSPARB2);
|
|
|
|
sprite0_start = VLV_FIFO_START(dsparb, dsparb2, 0, 0);
|
|
|
|
sprite1_start = VLV_FIFO_START(dsparb, dsparb2, 8, 4);
|
|
|
|
break;
|
|
|
|
case PIPE_B:
|
|
|
|
dsparb = I915_READ(DSPARB);
|
|
|
|
dsparb2 = I915_READ(DSPARB2);
|
|
|
|
sprite0_start = VLV_FIFO_START(dsparb, dsparb2, 16, 8);
|
|
|
|
sprite1_start = VLV_FIFO_START(dsparb, dsparb2, 24, 12);
|
|
|
|
break;
|
|
|
|
case PIPE_C:
|
|
|
|
dsparb2 = I915_READ(DSPARB2);
|
|
|
|
dsparb3 = I915_READ(DSPARB3);
|
|
|
|
sprite0_start = VLV_FIFO_START(dsparb3, dsparb2, 0, 16);
|
|
|
|
sprite1_start = VLV_FIFO_START(dsparb3, dsparb2, 8, 20);
|
|
|
|
break;
|
|
|
|
default:
|
2017-03-02 17:14:52 +00:00
|
|
|
MISSING_CASE(pipe);
|
|
|
|
return;
|
2015-03-05 19:19:47 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:52 +00:00
|
|
|
fifo_state->plane[PLANE_PRIMARY] = sprite0_start;
|
|
|
|
fifo_state->plane[PLANE_SPRITE0] = sprite1_start - sprite0_start;
|
|
|
|
fifo_state->plane[PLANE_SPRITE1] = 511 - sprite1_start;
|
|
|
|
fifo_state->plane[PLANE_CURSOR] = 63;
|
2015-03-05 19:19:47 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 19:19:11 +00:00
|
|
|
static int i9xx_get_fifo_size(struct drm_i915_private *dev_priv,
|
|
|
|
enum i9xx_plane_id i9xx_plane)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 dsparb = I915_READ(DSPARB);
|
2012-04-17 01:20:35 +00:00
|
|
|
int size;
|
|
|
|
|
|
|
|
size = dsparb & 0x7f;
|
2017-11-17 19:19:11 +00:00
|
|
|
if (i9xx_plane == PLANE_B)
|
2012-04-17 01:20:35 +00:00
|
|
|
size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) - size;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "FIFO size - (0x%08x) %c: %d\n",
|
|
|
|
dsparb, plane_name(i9xx_plane), size);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2017-11-17 19:19:11 +00:00
|
|
|
static int i830_get_fifo_size(struct drm_i915_private *dev_priv,
|
|
|
|
enum i9xx_plane_id i9xx_plane)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 dsparb = I915_READ(DSPARB);
|
2012-04-17 01:20:35 +00:00
|
|
|
int size;
|
|
|
|
|
|
|
|
size = dsparb & 0x1ff;
|
2017-11-17 19:19:11 +00:00
|
|
|
if (i9xx_plane == PLANE_B)
|
2012-04-17 01:20:35 +00:00
|
|
|
size = ((dsparb >> DSPARB_BEND_SHIFT) & 0x1ff) - size;
|
|
|
|
size >>= 1; /* Convert to cachelines */
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "FIFO size - (0x%08x) %c: %d\n",
|
|
|
|
dsparb, plane_name(i9xx_plane), size);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2017-11-17 19:19:11 +00:00
|
|
|
static int i845_get_fifo_size(struct drm_i915_private *dev_priv,
|
|
|
|
enum i9xx_plane_id i9xx_plane)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 dsparb = I915_READ(DSPARB);
|
2012-04-17 01:20:35 +00:00
|
|
|
int size;
|
|
|
|
|
|
|
|
size = dsparb & 0x7f;
|
|
|
|
size >>= 2; /* Convert to cachelines */
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "FIFO size - (0x%08x) %c: %d\n",
|
|
|
|
dsparb, plane_name(i9xx_plane), size);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pineview has different values for various configs */
|
2019-12-24 08:40:04 +00:00
|
|
|
static const struct intel_watermark_params pnv_display_wm = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = PINEVIEW_DISPLAY_FIFO,
|
|
|
|
.max_wm = PINEVIEW_MAX_WM,
|
|
|
|
.default_wm = PINEVIEW_DFT_WM,
|
|
|
|
.guard_size = PINEVIEW_GUARD_WM,
|
|
|
|
.cacheline_size = PINEVIEW_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
|
|
|
static const struct intel_watermark_params pnv_display_hplloff_wm = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = PINEVIEW_DISPLAY_FIFO,
|
|
|
|
.max_wm = PINEVIEW_MAX_WM,
|
|
|
|
.default_wm = PINEVIEW_DFT_HPLLOFF_WM,
|
|
|
|
.guard_size = PINEVIEW_GUARD_WM,
|
|
|
|
.cacheline_size = PINEVIEW_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
|
|
|
static const struct intel_watermark_params pnv_cursor_wm = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = PINEVIEW_CURSOR_FIFO,
|
|
|
|
.max_wm = PINEVIEW_CURSOR_MAX_WM,
|
|
|
|
.default_wm = PINEVIEW_CURSOR_DFT_WM,
|
|
|
|
.guard_size = PINEVIEW_CURSOR_GUARD_WM,
|
|
|
|
.cacheline_size = PINEVIEW_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
|
|
|
static const struct intel_watermark_params pnv_cursor_hplloff_wm = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = PINEVIEW_CURSOR_FIFO,
|
|
|
|
.max_wm = PINEVIEW_CURSOR_MAX_WM,
|
|
|
|
.default_wm = PINEVIEW_CURSOR_DFT_WM,
|
|
|
|
.guard_size = PINEVIEW_CURSOR_GUARD_WM,
|
|
|
|
.cacheline_size = PINEVIEW_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
static const struct intel_watermark_params i965_cursor_wm_info = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = I965_CURSOR_FIFO,
|
|
|
|
.max_wm = I965_CURSOR_MAX_WM,
|
|
|
|
.default_wm = I965_CURSOR_DFT_WM,
|
|
|
|
.guard_size = 2,
|
|
|
|
.cacheline_size = I915_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
static const struct intel_watermark_params i945_wm_info = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = I945_FIFO_SIZE,
|
|
|
|
.max_wm = I915_MAX_WM,
|
|
|
|
.default_wm = 1,
|
|
|
|
.guard_size = 2,
|
|
|
|
.cacheline_size = I915_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
static const struct intel_watermark_params i915_wm_info = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = I915_FIFO_SIZE,
|
|
|
|
.max_wm = I915_MAX_WM,
|
|
|
|
.default_wm = 1,
|
|
|
|
.guard_size = 2,
|
|
|
|
.cacheline_size = I915_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
2014-08-14 22:21:53 +00:00
|
|
|
static const struct intel_watermark_params i830_a_wm_info = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = I855GM_FIFO_SIZE,
|
|
|
|
.max_wm = I915_MAX_WM,
|
|
|
|
.default_wm = 1,
|
|
|
|
.guard_size = 2,
|
|
|
|
.cacheline_size = I830_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
2014-08-14 22:21:53 +00:00
|
|
|
static const struct intel_watermark_params i830_bc_wm_info = {
|
|
|
|
.fifo_size = I855GM_FIFO_SIZE,
|
|
|
|
.max_wm = I915_MAX_WM/2,
|
|
|
|
.default_wm = 1,
|
|
|
|
.guard_size = 2,
|
|
|
|
.cacheline_size = I830_FIFO_LINE_SIZE,
|
|
|
|
};
|
2019-12-24 08:40:04 +00:00
|
|
|
|
2013-12-14 22:38:30 +00:00
|
|
|
static const struct intel_watermark_params i845_wm_info = {
|
2014-06-05 16:15:50 +00:00
|
|
|
.fifo_size = I830_FIFO_SIZE,
|
|
|
|
.max_wm = I915_MAX_WM,
|
|
|
|
.default_wm = 1,
|
|
|
|
.guard_size = 2,
|
|
|
|
.cacheline_size = I830_FIFO_LINE_SIZE,
|
2012-04-17 01:20:35 +00:00
|
|
|
};
|
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
/**
|
|
|
|
* intel_wm_method1 - Method 1 / "small buffer" watermark formula
|
|
|
|
* @pixel_rate: Pipe pixel rate in kHz
|
|
|
|
* @cpp: Plane bytes per pixel
|
|
|
|
* @latency: Memory wakeup latency in 0.1us units
|
|
|
|
*
|
|
|
|
* Compute the watermark using the method 1 or "small buffer"
|
|
|
|
* formula. The caller may additonally add extra cachelines
|
|
|
|
* to account for TLB misses and clock crossings.
|
|
|
|
*
|
|
|
|
* This method is concerned with the short term drain rate
|
|
|
|
* of the FIFO, ie. it does not account for blanking periods
|
|
|
|
* which would effectively reduce the average drain rate across
|
|
|
|
* a longer period. The name "small" refers to the fact the
|
|
|
|
* FIFO is relatively small compared to the amount of data
|
|
|
|
* fetched.
|
|
|
|
*
|
|
|
|
* The FIFO level vs. time graph might look something like:
|
|
|
|
*
|
|
|
|
* |\ |\
|
|
|
|
* | \ | \
|
|
|
|
* __---__---__ (- plane active, _ blanking)
|
|
|
|
* -> time
|
|
|
|
*
|
|
|
|
* or perhaps like this:
|
|
|
|
*
|
|
|
|
* |\|\ |\|\
|
|
|
|
* __----__----__ (- plane active, _ blanking)
|
|
|
|
* -> time
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The watermark in bytes
|
|
|
|
*/
|
|
|
|
static unsigned int intel_wm_method1(unsigned int pixel_rate,
|
|
|
|
unsigned int cpp,
|
|
|
|
unsigned int latency)
|
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u64 ret;
|
2017-04-21 18:14:27 +00:00
|
|
|
|
2019-04-08 15:27:01 +00:00
|
|
|
ret = mul_u32_u32(pixel_rate, cpp * latency);
|
2017-04-21 18:14:27 +00:00
|
|
|
ret = DIV_ROUND_UP_ULL(ret, 10000);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* intel_wm_method2 - Method 2 / "large buffer" watermark formula
|
|
|
|
* @pixel_rate: Pipe pixel rate in kHz
|
|
|
|
* @htotal: Pipe horizontal total
|
|
|
|
* @width: Plane width in pixels
|
|
|
|
* @cpp: Plane bytes per pixel
|
|
|
|
* @latency: Memory wakeup latency in 0.1us units
|
|
|
|
*
|
|
|
|
* Compute the watermark using the method 2 or "large buffer"
|
|
|
|
* formula. The caller may additonally add extra cachelines
|
|
|
|
* to account for TLB misses and clock crossings.
|
|
|
|
*
|
|
|
|
* This method is concerned with the long term drain rate
|
|
|
|
* of the FIFO, ie. it does account for blanking periods
|
|
|
|
* which effectively reduce the average drain rate across
|
|
|
|
* a longer period. The name "large" refers to the fact the
|
|
|
|
* FIFO is relatively large compared to the amount of data
|
|
|
|
* fetched.
|
|
|
|
*
|
|
|
|
* The FIFO level vs. time graph might look something like:
|
|
|
|
*
|
|
|
|
* |\___ |\___
|
|
|
|
* | \___ | \___
|
|
|
|
* | \ | \
|
|
|
|
* __ --__--__--__--__--__--__ (- plane active, _ blanking)
|
|
|
|
* -> time
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The watermark in bytes
|
|
|
|
*/
|
|
|
|
static unsigned int intel_wm_method2(unsigned int pixel_rate,
|
|
|
|
unsigned int htotal,
|
|
|
|
unsigned int width,
|
|
|
|
unsigned int cpp,
|
|
|
|
unsigned int latency)
|
|
|
|
{
|
|
|
|
unsigned int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME remove once all users are computing
|
|
|
|
* watermarks in the correct place.
|
|
|
|
*/
|
|
|
|
if (WARN_ON_ONCE(htotal == 0))
|
|
|
|
htotal = 1;
|
|
|
|
|
|
|
|
ret = (latency * pixel_rate) / (htotal * 10000);
|
|
|
|
ret = (ret + 1) * width * cpp;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
/**
|
|
|
|
* intel_calculate_wm - calculate watermark level
|
2017-04-21 18:14:27 +00:00
|
|
|
* @pixel_rate: pixel clock
|
2012-04-17 01:20:35 +00:00
|
|
|
* @wm: chip FIFO params
|
2018-02-14 14:03:03 +00:00
|
|
|
* @fifo_size: size of the FIFO buffer
|
2016-01-20 19:05:26 +00:00
|
|
|
* @cpp: bytes per pixel
|
2012-04-17 01:20:35 +00:00
|
|
|
* @latency_ns: memory latency for the platform
|
|
|
|
*
|
|
|
|
* Calculate the watermark level (the level at which the display plane will
|
|
|
|
* start fetching from memory again). Each chip has a different display
|
|
|
|
* FIFO size and allocation, so the caller needs to figure that out and pass
|
|
|
|
* in the correct intel_watermark_params structure.
|
|
|
|
*
|
|
|
|
* As the pixel clock runs, the FIFO will be drained at a rate that depends
|
|
|
|
* on the pixel size. When it reaches the watermark level, it'll start
|
|
|
|
* fetching FIFO line sized based chunks from memory until the FIFO fills
|
|
|
|
* past the watermark point. If the FIFO drains completely, a FIFO underrun
|
|
|
|
* will occur, and a display engine hang could result.
|
|
|
|
*/
|
2017-04-21 18:14:27 +00:00
|
|
|
static unsigned int intel_calculate_wm(int pixel_rate,
|
|
|
|
const struct intel_watermark_params *wm,
|
|
|
|
int fifo_size, int cpp,
|
|
|
|
unsigned int latency_ns)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2017-04-21 18:14:27 +00:00
|
|
|
int entries, wm_size;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: we need to make sure we don't overflow for various clock &
|
|
|
|
* latency values.
|
|
|
|
* clocks go from a few thousand to several hundred thousand.
|
|
|
|
* latency is usually a few thousand
|
|
|
|
*/
|
2017-04-21 18:14:27 +00:00
|
|
|
entries = intel_wm_method1(pixel_rate, cpp,
|
|
|
|
latency_ns / 100);
|
|
|
|
entries = DIV_ROUND_UP(entries, wm->cacheline_size) +
|
|
|
|
wm->guard_size;
|
|
|
|
DRM_DEBUG_KMS("FIFO entries required for mode: %d\n", entries);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
wm_size = fifo_size - entries;
|
|
|
|
DRM_DEBUG_KMS("FIFO watermark level: %d\n", wm_size);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
/* Don't promote wm_size to unsigned... */
|
2017-04-21 18:14:27 +00:00
|
|
|
if (wm_size > wm->max_wm)
|
2012-04-17 01:20:35 +00:00
|
|
|
wm_size = wm->max_wm;
|
|
|
|
if (wm_size <= 0)
|
|
|
|
wm_size = wm->default_wm;
|
2014-09-05 18:54:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Bspec seems to indicate that the value shouldn't be lower than
|
|
|
|
* 'burst size + 1'. Certainly 830 is quite unhappy with low values.
|
|
|
|
* Lets go for 8 which is the burst size since certain platforms
|
|
|
|
* already use a hardcoded 8 (which is what the spec says should be
|
|
|
|
* done).
|
|
|
|
*/
|
|
|
|
if (wm_size <= 8)
|
|
|
|
wm_size = 8;
|
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
return wm_size;
|
|
|
|
}
|
|
|
|
|
2017-04-21 18:14:29 +00:00
|
|
|
static bool is_disabling(int old, int new, int threshold)
|
|
|
|
{
|
|
|
|
return old >= threshold && new < threshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool is_enabling(int old, int new, int threshold)
|
|
|
|
{
|
|
|
|
return old < threshold && new >= threshold;
|
|
|
|
}
|
|
|
|
|
2017-04-21 18:14:20 +00:00
|
|
|
static int intel_wm_num_levels(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
return dev_priv->wm.max_level + 1;
|
|
|
|
}
|
|
|
|
|
2017-03-14 15:10:49 +00:00
|
|
|
static bool intel_wm_plane_visible(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state)
|
|
|
|
{
|
2019-10-31 11:26:08 +00:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2017-03-14 15:10:49 +00:00
|
|
|
|
|
|
|
/* FIXME check the 'enable' instead */
|
2019-10-31 11:26:02 +00:00
|
|
|
if (!crtc_state->hw.active)
|
2017-03-14 15:10:49 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Treat cursor with fb as always visible since cursor updates
|
|
|
|
* can happen faster than the vrefresh rate, and the current
|
|
|
|
* watermark code doesn't handle that correctly. Cursor updates
|
|
|
|
* which set/clear the fb or change the cursor size are going
|
|
|
|
* to get throttled by intel_legacy_cursor_update() to work
|
|
|
|
* around this problem with the watermark code.
|
|
|
|
*/
|
|
|
|
if (plane->id == PLANE_CURSOR)
|
2019-10-31 11:26:07 +00:00
|
|
|
return plane_state->hw.fb != NULL;
|
2017-03-14 15:10:49 +00:00
|
|
|
else
|
2019-10-31 11:26:08 +00:00
|
|
|
return plane_state->uapi.visible;
|
2017-03-14 15:10:49 +00:00
|
|
|
}
|
|
|
|
|
2019-11-27 20:12:11 +00:00
|
|
|
static bool intel_crtc_active(struct intel_crtc *crtc)
|
|
|
|
{
|
|
|
|
/* Be paranoid as we can arrive here with only partial
|
|
|
|
* state retrieved from the hardware during setup.
|
|
|
|
*
|
|
|
|
* We can ditch the adjusted_mode.crtc_clock check as soon
|
|
|
|
* as Haswell has gained clock readout/fastboot support.
|
|
|
|
*
|
|
|
|
* We can ditch the crtc->primary->state->fb check as soon as we can
|
|
|
|
* properly reconstruct framebuffers.
|
|
|
|
*
|
|
|
|
* FIXME: The intel_crtc->active here should be switched to
|
|
|
|
* crtc->state->active once we have proper CRTC states wired up
|
|
|
|
* for atomic.
|
|
|
|
*/
|
|
|
|
return crtc->active && crtc->base.primary->state->fb &&
|
|
|
|
crtc->config->hw.adjusted_mode.crtc_clock;
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:21 +00:00
|
|
|
static struct intel_crtc *single_enabled_crtc(struct drm_i915_private *dev_priv)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2016-10-31 20:37:04 +00:00
|
|
|
struct intel_crtc *crtc, *enabled = NULL;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2016-10-31 20:37:21 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2016-10-31 20:37:04 +00:00
|
|
|
if (intel_crtc_active(crtc)) {
|
2012-04-17 01:20:35 +00:00
|
|
|
if (enabled)
|
|
|
|
return NULL;
|
|
|
|
enabled = crtc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
2019-12-24 08:40:04 +00:00
|
|
|
static void pnv_update_wm(struct intel_crtc *unused_crtc)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2016-10-31 20:37:21 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(unused_crtc->base.dev);
|
2016-10-31 20:37:04 +00:00
|
|
|
struct intel_crtc *crtc;
|
2012-04-17 01:20:35 +00:00
|
|
|
const struct cxsr_latency *latency;
|
|
|
|
u32 reg;
|
2017-04-21 18:14:27 +00:00
|
|
|
unsigned int wm;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2019-03-26 07:40:54 +00:00
|
|
|
latency = intel_get_cxsr_latency(!IS_MOBILE(dev_priv),
|
2016-10-13 10:02:58 +00:00
|
|
|
dev_priv->is_ddr3,
|
|
|
|
dev_priv->fsb_freq,
|
|
|
|
dev_priv->mem_freq);
|
2012-04-17 01:20:35 +00:00
|
|
|
if (!latency) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Unknown FSB/MEM found, disable CxSR\n");
|
2014-07-01 09:36:17 +00:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-17 01:20:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:21 +00:00
|
|
|
crtc = single_enabled_crtc(dev_priv);
|
2012-04-17 01:20:35 +00:00
|
|
|
if (crtc) {
|
2016-10-31 20:37:04 +00:00
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&crtc->config->hw.adjusted_mode;
|
2016-10-31 20:37:04 +00:00
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
crtc->base.primary->state->fb;
|
2016-12-14 21:30:57 +00:00
|
|
|
int cpp = fb->format->cpp[0];
|
2015-09-08 10:40:49 +00:00
|
|
|
int clock = adjusted_mode->crtc_clock;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
/* Display SR */
|
2019-12-24 08:40:04 +00:00
|
|
|
wm = intel_calculate_wm(clock, &pnv_display_wm,
|
|
|
|
pnv_display_wm.fifo_size,
|
2016-01-20 19:05:26 +00:00
|
|
|
cpp, latency->display_sr);
|
2012-04-17 01:20:35 +00:00
|
|
|
reg = I915_READ(DSPFW1);
|
|
|
|
reg &= ~DSPFW_SR_MASK;
|
2015-03-10 15:02:21 +00:00
|
|
|
reg |= FW_WM(wm, SR);
|
2012-04-17 01:20:35 +00:00
|
|
|
I915_WRITE(DSPFW1, reg);
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "DSPFW1 register is %x\n", reg);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
/* cursor SR */
|
2019-12-24 08:40:04 +00:00
|
|
|
wm = intel_calculate_wm(clock, &pnv_cursor_wm,
|
|
|
|
pnv_display_wm.fifo_size,
|
2017-04-21 18:14:24 +00:00
|
|
|
4, latency->cursor_sr);
|
2012-04-17 01:20:35 +00:00
|
|
|
reg = I915_READ(DSPFW3);
|
|
|
|
reg &= ~DSPFW_CURSOR_SR_MASK;
|
2015-03-10 15:02:21 +00:00
|
|
|
reg |= FW_WM(wm, CURSOR_SR);
|
2012-04-17 01:20:35 +00:00
|
|
|
I915_WRITE(DSPFW3, reg);
|
|
|
|
|
|
|
|
/* Display HPLL off SR */
|
2019-12-24 08:40:04 +00:00
|
|
|
wm = intel_calculate_wm(clock, &pnv_display_hplloff_wm,
|
|
|
|
pnv_display_hplloff_wm.fifo_size,
|
2016-01-20 19:05:26 +00:00
|
|
|
cpp, latency->display_hpll_disable);
|
2012-04-17 01:20:35 +00:00
|
|
|
reg = I915_READ(DSPFW3);
|
|
|
|
reg &= ~DSPFW_HPLL_SR_MASK;
|
2015-03-10 15:02:21 +00:00
|
|
|
reg |= FW_WM(wm, HPLL_SR);
|
2012-04-17 01:20:35 +00:00
|
|
|
I915_WRITE(DSPFW3, reg);
|
|
|
|
|
|
|
|
/* cursor HPLL off SR */
|
2019-12-24 08:40:04 +00:00
|
|
|
wm = intel_calculate_wm(clock, &pnv_cursor_hplloff_wm,
|
|
|
|
pnv_display_hplloff_wm.fifo_size,
|
2017-04-21 18:14:24 +00:00
|
|
|
4, latency->cursor_hpll_disable);
|
2012-04-17 01:20:35 +00:00
|
|
|
reg = I915_READ(DSPFW3);
|
|
|
|
reg &= ~DSPFW_HPLL_CURSOR_MASK;
|
2015-03-10 15:02:21 +00:00
|
|
|
reg |= FW_WM(wm, HPLL_CURSOR);
|
2012-04-17 01:20:35 +00:00
|
|
|
I915_WRITE(DSPFW3, reg);
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "DSPFW3 register is %x\n", reg);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2014-07-01 09:36:17 +00:00
|
|
|
intel_set_memory_cxsr(dev_priv, true);
|
2012-04-17 01:20:35 +00:00
|
|
|
} else {
|
2014-07-01 09:36:17 +00:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-17 01:20:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-21 18:14:26 +00:00
|
|
|
/*
|
|
|
|
* Documentation says:
|
|
|
|
* "If the line size is small, the TLB fetches can get in the way of the
|
|
|
|
* data fetches, causing some lag in the pixel data return which is not
|
|
|
|
* accounted for in the above formulas. The following adjustment only
|
|
|
|
* needs to be applied if eight whole lines fit in the buffer at once.
|
|
|
|
* The WM is adjusted upwards by the difference between the FIFO size
|
|
|
|
* and the size of 8 whole lines. This adjustment is always performed
|
|
|
|
* in the actual pixel depth regardless of whether FBC is enabled or not."
|
|
|
|
*/
|
2017-11-07 14:03:38 +00:00
|
|
|
static unsigned int g4x_tlb_miss_wa(int fifo_size, int width, int cpp)
|
2017-04-21 18:14:26 +00:00
|
|
|
{
|
|
|
|
int tlb_miss = fifo_size * 64 - width * cpp * 8;
|
|
|
|
|
|
|
|
return max(0, tlb_miss);
|
|
|
|
}
|
|
|
|
|
2017-04-21 18:14:29 +00:00
|
|
|
static void g4x_write_wm_values(struct drm_i915_private *dev_priv,
|
|
|
|
const struct g4x_wm_values *wm)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2017-04-21 18:14:31 +00:00
|
|
|
enum pipe pipe;
|
|
|
|
|
|
|
|
for_each_pipe(dev_priv, pipe)
|
|
|
|
trace_g4x_wm(intel_get_crtc_for_pipe(dev_priv, pipe), wm);
|
|
|
|
|
2017-04-21 18:14:29 +00:00
|
|
|
I915_WRITE(DSPFW1,
|
|
|
|
FW_WM(wm->sr.plane, SR) |
|
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_CURSOR], CURSORB) |
|
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_PRIMARY], PLANEB) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_PRIMARY], PLANEA));
|
|
|
|
I915_WRITE(DSPFW2,
|
|
|
|
(wm->fbc_en ? DSPFW_FBC_SR_EN : 0) |
|
|
|
|
FW_WM(wm->sr.fbc, FBC_SR) |
|
|
|
|
FW_WM(wm->hpll.fbc, FBC_HPLL_SR) |
|
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_SPRITE0], SPRITEB) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_CURSOR], CURSORA) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_SPRITE0], SPRITEA));
|
|
|
|
I915_WRITE(DSPFW3,
|
|
|
|
(wm->hpll_en ? DSPFW_HPLL_SR_EN : 0) |
|
|
|
|
FW_WM(wm->sr.cursor, CURSOR_SR) |
|
|
|
|
FW_WM(wm->hpll.cursor, HPLL_CURSOR) |
|
|
|
|
FW_WM(wm->hpll.plane, HPLL_SR));
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2017-04-21 18:14:29 +00:00
|
|
|
POSTING_READ(DSPFW1);
|
2012-04-17 01:20:35 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 14:16:28 +00:00
|
|
|
#define FW_WM_VLV(value, plane) \
|
|
|
|
(((value) << DSPFW_ ## plane ## _SHIFT) & DSPFW_ ## plane ## _MASK_VLV)
|
|
|
|
|
2016-11-28 17:37:15 +00:00
|
|
|
static void vlv_write_wm_values(struct drm_i915_private *dev_priv,
|
2015-03-05 19:19:45 +00:00
|
|
|
const struct vlv_wm_values *wm)
|
|
|
|
{
|
2016-11-28 17:37:15 +00:00
|
|
|
enum pipe pipe;
|
|
|
|
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2017-03-02 17:15:06 +00:00
|
|
|
trace_vlv_wm(intel_get_crtc_for_pipe(dev_priv, pipe), wm);
|
|
|
|
|
2016-11-28 17:37:15 +00:00
|
|
|
I915_WRITE(VLV_DDL(pipe),
|
|
|
|
(wm->ddl[pipe].plane[PLANE_CURSOR] << DDL_CURSOR_SHIFT) |
|
|
|
|
(wm->ddl[pipe].plane[PLANE_SPRITE1] << DDL_SPRITE_SHIFT(1)) |
|
|
|
|
(wm->ddl[pipe].plane[PLANE_SPRITE0] << DDL_SPRITE_SHIFT(0)) |
|
|
|
|
(wm->ddl[pipe].plane[PLANE_PRIMARY] << DDL_PLANE_SHIFT));
|
|
|
|
}
|
2015-03-05 19:19:45 +00:00
|
|
|
|
2016-11-28 17:37:14 +00:00
|
|
|
/*
|
|
|
|
* Zero the (unused) WM1 watermarks, and also clear all the
|
|
|
|
* high order bits so that there are no out of bounds values
|
|
|
|
* present in the registers during the reprogramming.
|
|
|
|
*/
|
|
|
|
I915_WRITE(DSPHOWM, 0);
|
|
|
|
I915_WRITE(DSPHOWM1, 0);
|
|
|
|
I915_WRITE(DSPFW4, 0);
|
|
|
|
I915_WRITE(DSPFW5, 0);
|
|
|
|
I915_WRITE(DSPFW6, 0);
|
|
|
|
|
2015-03-05 19:19:49 +00:00
|
|
|
I915_WRITE(DSPFW1,
|
2015-03-10 14:16:28 +00:00
|
|
|
FW_WM(wm->sr.plane, SR) |
|
2016-11-28 17:37:08 +00:00
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_CURSOR], CURSORB) |
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_PRIMARY], PLANEB) |
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_A].plane[PLANE_PRIMARY], PLANEA));
|
2015-03-05 19:19:49 +00:00
|
|
|
I915_WRITE(DSPFW2,
|
2016-11-28 17:37:08 +00:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_A].plane[PLANE_SPRITE1], SPRITEB) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_CURSOR], CURSORA) |
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_A].plane[PLANE_SPRITE0], SPRITEA));
|
2015-03-05 19:19:49 +00:00
|
|
|
I915_WRITE(DSPFW3,
|
2015-03-10 14:16:28 +00:00
|
|
|
FW_WM(wm->sr.cursor, CURSOR_SR));
|
2015-03-05 19:19:49 +00:00
|
|
|
|
|
|
|
if (IS_CHERRYVIEW(dev_priv)) {
|
|
|
|
I915_WRITE(DSPFW7_CHV,
|
2016-11-28 17:37:08 +00:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_SPRITE1], SPRITED) |
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_SPRITE0], SPRITEC));
|
2015-03-05 19:19:49 +00:00
|
|
|
I915_WRITE(DSPFW8_CHV,
|
2016-11-28 17:37:08 +00:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_C].plane[PLANE_SPRITE1], SPRITEF) |
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_C].plane[PLANE_SPRITE0], SPRITEE));
|
2015-03-05 19:19:49 +00:00
|
|
|
I915_WRITE(DSPFW9_CHV,
|
2016-11-28 17:37:08 +00:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_C].plane[PLANE_PRIMARY], PLANEC) |
|
|
|
|
FW_WM(wm->pipe[PIPE_C].plane[PLANE_CURSOR], CURSORC));
|
2015-03-05 19:19:49 +00:00
|
|
|
I915_WRITE(DSPHOWM,
|
2015-03-10 14:16:28 +00:00
|
|
|
FW_WM(wm->sr.plane >> 9, SR_HI) |
|
2016-11-28 17:37:08 +00:00
|
|
|
FW_WM(wm->pipe[PIPE_C].plane[PLANE_SPRITE1] >> 8, SPRITEF_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_C].plane[PLANE_SPRITE0] >> 8, SPRITEE_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_C].plane[PLANE_PRIMARY] >> 8, PLANEC_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_SPRITE1] >> 8, SPRITED_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_SPRITE0] >> 8, SPRITEC_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_PRIMARY] >> 8, PLANEB_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_SPRITE1] >> 8, SPRITEB_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_SPRITE0] >> 8, SPRITEA_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_PRIMARY] >> 8, PLANEA_HI));
|
2015-03-05 19:19:49 +00:00
|
|
|
} else {
|
|
|
|
I915_WRITE(DSPFW7,
|
2016-11-28 17:37:08 +00:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_SPRITE1], SPRITED) |
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_SPRITE0], SPRITEC));
|
2015-03-05 19:19:49 +00:00
|
|
|
I915_WRITE(DSPHOWM,
|
2015-03-10 14:16:28 +00:00
|
|
|
FW_WM(wm->sr.plane >> 9, SR_HI) |
|
2016-11-28 17:37:08 +00:00
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_SPRITE1] >> 8, SPRITED_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_SPRITE0] >> 8, SPRITEC_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_B].plane[PLANE_PRIMARY] >> 8, PLANEB_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_SPRITE1] >> 8, SPRITEB_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_SPRITE0] >> 8, SPRITEA_HI) |
|
|
|
|
FW_WM(wm->pipe[PIPE_A].plane[PLANE_PRIMARY] >> 8, PLANEA_HI));
|
2015-03-05 19:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
POSTING_READ(DSPFW1);
|
2015-03-05 19:19:45 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 14:16:28 +00:00
|
|
|
#undef FW_WM_VLV
|
|
|
|
|
2017-04-21 18:14:29 +00:00
|
|
|
static void g4x_setup_wm_latency(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
/* all latencies in usec */
|
|
|
|
dev_priv->wm.pri_latency[G4X_WM_LEVEL_NORMAL] = 5;
|
|
|
|
dev_priv->wm.pri_latency[G4X_WM_LEVEL_SR] = 12;
|
2017-04-21 18:14:30 +00:00
|
|
|
dev_priv->wm.pri_latency[G4X_WM_LEVEL_HPLL] = 35;
|
2017-04-21 18:14:29 +00:00
|
|
|
|
2017-04-21 18:14:30 +00:00
|
|
|
dev_priv->wm.max_level = G4X_WM_LEVEL_HPLL;
|
2017-04-21 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int g4x_plane_fifo_size(enum plane_id plane_id, int level)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* DSPCNTR[13] supposedly controls whether the
|
|
|
|
* primary plane can use the FIFO space otherwise
|
|
|
|
* reserved for the sprite plane. It's not 100% clear
|
|
|
|
* what the actual FIFO size is, but it looks like we
|
|
|
|
* can happily set both primary and sprite watermarks
|
|
|
|
* up to 127 cachelines. So that would seem to mean
|
|
|
|
* that either DSPCNTR[13] doesn't do anything, or that
|
|
|
|
* the total FIFO is >= 256 cachelines in size. Either
|
|
|
|
* way, we don't seem to have to worry about this
|
|
|
|
* repartitioning as the maximum watermark value the
|
|
|
|
* register can hold for each plane is lower than the
|
|
|
|
* minimum FIFO size.
|
|
|
|
*/
|
|
|
|
switch (plane_id) {
|
|
|
|
case PLANE_CURSOR:
|
|
|
|
return 63;
|
|
|
|
case PLANE_PRIMARY:
|
|
|
|
return level == G4X_WM_LEVEL_NORMAL ? 127 : 511;
|
|
|
|
case PLANE_SPRITE0:
|
|
|
|
return level == G4X_WM_LEVEL_NORMAL ? 127 : 0;
|
|
|
|
default:
|
|
|
|
MISSING_CASE(plane_id);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int g4x_fbc_fifo_size(int level)
|
|
|
|
{
|
|
|
|
switch (level) {
|
|
|
|
case G4X_WM_LEVEL_SR:
|
|
|
|
return 7;
|
|
|
|
case G4X_WM_LEVEL_HPLL:
|
|
|
|
return 15;
|
|
|
|
default:
|
|
|
|
MISSING_CASE(level);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
static u16 g4x_compute_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
|
|
|
int level)
|
2017-04-21 18:14:29 +00:00
|
|
|
{
|
2019-10-31 11:26:08 +00:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2017-04-21 18:14:29 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
|
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&crtc_state->hw.adjusted_mode;
|
2017-11-07 14:03:38 +00:00
|
|
|
unsigned int latency = dev_priv->wm.pri_latency[level] * 10;
|
|
|
|
unsigned int clock, htotal, cpp, width, wm;
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
if (latency == 0)
|
|
|
|
return USHRT_MAX;
|
|
|
|
|
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
|
|
|
return 0;
|
|
|
|
|
2019-10-31 11:26:07 +00:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2019-07-03 20:08:22 +00:00
|
|
|
|
2017-04-21 18:14:29 +00:00
|
|
|
/*
|
|
|
|
* Not 100% sure which way ELK should go here as the
|
|
|
|
* spec only says CL/CTG should assume 32bpp and BW
|
|
|
|
* doesn't need to. But as these things followed the
|
|
|
|
* mobile vs. desktop lines on gen3 as well, let's
|
|
|
|
* assume ELK doesn't need this.
|
|
|
|
*
|
|
|
|
* The spec also fails to list such a restriction for
|
|
|
|
* the HPLL watermark, which seems a little strange.
|
|
|
|
* Let's use 32bpp for the HPLL watermark as well.
|
|
|
|
*/
|
|
|
|
if (IS_GM45(dev_priv) && plane->id == PLANE_PRIMARY &&
|
|
|
|
level != G4X_WM_LEVEL_NORMAL)
|
2019-07-03 20:08:22 +00:00
|
|
|
cpp = max(cpp, 4u);
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
clock = adjusted_mode->crtc_clock;
|
|
|
|
htotal = adjusted_mode->crtc_htotal;
|
|
|
|
|
2019-10-31 11:26:08 +00:00
|
|
|
width = drm_rect_width(&plane_state->uapi.dst);
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
if (plane->id == PLANE_CURSOR) {
|
|
|
|
wm = intel_wm_method2(clock, htotal, width, cpp, latency);
|
|
|
|
} else if (plane->id == PLANE_PRIMARY &&
|
|
|
|
level == G4X_WM_LEVEL_NORMAL) {
|
|
|
|
wm = intel_wm_method1(clock, cpp, latency);
|
|
|
|
} else {
|
2017-11-07 14:03:38 +00:00
|
|
|
unsigned int small, large;
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
small = intel_wm_method1(clock, cpp, latency);
|
|
|
|
large = intel_wm_method2(clock, htotal, width, cpp, latency);
|
|
|
|
|
|
|
|
wm = min(small, large);
|
|
|
|
}
|
|
|
|
|
|
|
|
wm += g4x_tlb_miss_wa(g4x_plane_fifo_size(plane->id, level),
|
|
|
|
width, cpp);
|
|
|
|
|
|
|
|
wm = DIV_ROUND_UP(wm, 64) + 2;
|
|
|
|
|
2017-11-07 14:03:38 +00:00
|
|
|
return min_t(unsigned int, wm, USHRT_MAX);
|
2017-04-21 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool g4x_raw_plane_wm_set(struct intel_crtc_state *crtc_state,
|
|
|
|
int level, enum plane_id plane_id, u16 value)
|
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 18:14:29 +00:00
|
|
|
bool dirty = false;
|
|
|
|
|
|
|
|
for (; level < intel_wm_num_levels(dev_priv); level++) {
|
|
|
|
struct g4x_pipe_wm *raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
|
|
|
|
dirty |= raw->plane[plane_id] != value;
|
|
|
|
raw->plane[plane_id] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool g4x_raw_fbc_wm_set(struct intel_crtc_state *crtc_state,
|
|
|
|
int level, u16 value)
|
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 18:14:29 +00:00
|
|
|
bool dirty = false;
|
|
|
|
|
|
|
|
/* NORMAL level doesn't have an FBC watermark */
|
|
|
|
level = max(level, G4X_WM_LEVEL_SR);
|
|
|
|
|
|
|
|
for (; level < intel_wm_num_levels(dev_priv); level++) {
|
|
|
|
struct g4x_pipe_wm *raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
|
|
|
|
dirty |= raw->fbc != value;
|
|
|
|
raw->fbc = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
static u32 ilk_compute_fbc_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 pri_val);
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
static bool g4x_raw_plane_wm_compute(struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state)
|
|
|
|
{
|
2019-10-31 11:26:08 +00:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2020-01-07 15:13:30 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 18:14:29 +00:00
|
|
|
int num_levels = intel_wm_num_levels(to_i915(plane->base.dev));
|
|
|
|
enum plane_id plane_id = plane->id;
|
|
|
|
bool dirty = false;
|
|
|
|
int level;
|
|
|
|
|
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state)) {
|
|
|
|
dirty |= g4x_raw_plane_wm_set(crtc_state, 0, plane_id, 0);
|
|
|
|
if (plane_id == PLANE_PRIMARY)
|
|
|
|
dirty |= g4x_raw_fbc_wm_set(crtc_state, 0, 0);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (level = 0; level < num_levels; level++) {
|
|
|
|
struct g4x_pipe_wm *raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
int wm, max_wm;
|
|
|
|
|
|
|
|
wm = g4x_compute_wm(crtc_state, plane_state, level);
|
|
|
|
max_wm = g4x_plane_fifo_size(plane_id, level);
|
|
|
|
|
|
|
|
if (wm > max_wm)
|
|
|
|
break;
|
|
|
|
|
|
|
|
dirty |= raw->plane[plane_id] != wm;
|
|
|
|
raw->plane[plane_id] = wm;
|
|
|
|
|
|
|
|
if (plane_id != PLANE_PRIMARY ||
|
|
|
|
level == G4X_WM_LEVEL_NORMAL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wm = ilk_compute_fbc_wm(crtc_state, plane_state,
|
|
|
|
raw->plane[plane_id]);
|
|
|
|
max_wm = g4x_fbc_fifo_size(level);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FBC wm is not mandatory as we
|
|
|
|
* can always just disable its use.
|
|
|
|
*/
|
|
|
|
if (wm > max_wm)
|
|
|
|
wm = USHRT_MAX;
|
|
|
|
|
|
|
|
dirty |= raw->fbc != wm;
|
|
|
|
raw->fbc = wm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mark watermarks as invalid */
|
|
|
|
dirty |= g4x_raw_plane_wm_set(crtc_state, level, plane_id, USHRT_MAX);
|
|
|
|
|
|
|
|
if (plane_id == PLANE_PRIMARY)
|
|
|
|
dirty |= g4x_raw_fbc_wm_set(crtc_state, level, USHRT_MAX);
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (dirty) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"%s watermarks: normal=%d, SR=%d, HPLL=%d\n",
|
|
|
|
plane->base.name,
|
|
|
|
crtc_state->wm.g4x.raw[G4X_WM_LEVEL_NORMAL].plane[plane_id],
|
|
|
|
crtc_state->wm.g4x.raw[G4X_WM_LEVEL_SR].plane[plane_id],
|
|
|
|
crtc_state->wm.g4x.raw[G4X_WM_LEVEL_HPLL].plane[plane_id]);
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
if (plane_id == PLANE_PRIMARY)
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"FBC watermarks: SR=%d, HPLL=%d\n",
|
|
|
|
crtc_state->wm.g4x.raw[G4X_WM_LEVEL_SR].fbc,
|
|
|
|
crtc_state->wm.g4x.raw[G4X_WM_LEVEL_HPLL].fbc);
|
2017-04-21 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool g4x_raw_plane_wm_is_valid(const struct intel_crtc_state *crtc_state,
|
|
|
|
enum plane_id plane_id, int level)
|
|
|
|
{
|
|
|
|
const struct g4x_pipe_wm *raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
|
|
|
|
return raw->plane[plane_id] <= g4x_plane_fifo_size(plane_id, level);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool g4x_raw_crtc_wm_is_valid(const struct intel_crtc_state *crtc_state,
|
|
|
|
int level)
|
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
if (level > dev_priv->wm.max_level)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return g4x_raw_plane_wm_is_valid(crtc_state, PLANE_PRIMARY, level) &&
|
|
|
|
g4x_raw_plane_wm_is_valid(crtc_state, PLANE_SPRITE0, level) &&
|
|
|
|
g4x_raw_plane_wm_is_valid(crtc_state, PLANE_CURSOR, level);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mark all levels starting from 'level' as invalid */
|
|
|
|
static void g4x_invalidate_wms(struct intel_crtc *crtc,
|
|
|
|
struct g4x_wm_state *wm_state, int level)
|
|
|
|
{
|
|
|
|
if (level <= G4X_WM_LEVEL_NORMAL) {
|
|
|
|
enum plane_id plane_id;
|
|
|
|
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id)
|
|
|
|
wm_state->wm.plane[plane_id] = USHRT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level <= G4X_WM_LEVEL_SR) {
|
|
|
|
wm_state->cxsr = false;
|
|
|
|
wm_state->sr.cursor = USHRT_MAX;
|
|
|
|
wm_state->sr.plane = USHRT_MAX;
|
|
|
|
wm_state->sr.fbc = USHRT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level <= G4X_WM_LEVEL_HPLL) {
|
|
|
|
wm_state->hpll_en = false;
|
|
|
|
wm_state->hpll.cursor = USHRT_MAX;
|
|
|
|
wm_state->hpll.plane = USHRT_MAX;
|
|
|
|
wm_state->hpll.fbc = USHRT_MAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int g4x_compute_pipe_wm(struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2017-04-21 18:14:29 +00:00
|
|
|
struct intel_atomic_state *state =
|
2019-10-31 11:26:03 +00:00
|
|
|
to_intel_atomic_state(crtc_state->uapi.state);
|
2017-04-21 18:14:29 +00:00
|
|
|
struct g4x_wm_state *wm_state = &crtc_state->wm.g4x.optimal;
|
2019-08-21 17:30:33 +00:00
|
|
|
int num_active_planes = hweight8(crtc_state->active_planes &
|
|
|
|
~BIT(PLANE_CURSOR));
|
2017-04-21 18:14:29 +00:00
|
|
|
const struct g4x_pipe_wm *raw;
|
2017-08-23 15:22:22 +00:00
|
|
|
const struct intel_plane_state *old_plane_state;
|
|
|
|
const struct intel_plane_state *new_plane_state;
|
2017-04-21 18:14:29 +00:00
|
|
|
struct intel_plane *plane;
|
|
|
|
enum plane_id plane_id;
|
|
|
|
int i, level;
|
|
|
|
unsigned int dirty = 0;
|
|
|
|
|
2017-08-23 15:22:22 +00:00
|
|
|
for_each_oldnew_intel_plane_in_state(state, plane,
|
|
|
|
old_plane_state,
|
|
|
|
new_plane_state, i) {
|
2019-10-31 11:26:07 +00:00
|
|
|
if (new_plane_state->hw.crtc != &crtc->base &&
|
|
|
|
old_plane_state->hw.crtc != &crtc->base)
|
2017-04-21 18:14:29 +00:00
|
|
|
continue;
|
|
|
|
|
2017-08-23 15:22:22 +00:00
|
|
|
if (g4x_raw_plane_wm_compute(crtc_state, new_plane_state))
|
2017-04-21 18:14:29 +00:00
|
|
|
dirty |= BIT(plane->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dirty)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
level = G4X_WM_LEVEL_NORMAL;
|
|
|
|
if (!g4x_raw_crtc_wm_is_valid(crtc_state, level))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id)
|
|
|
|
wm_state->wm.plane[plane_id] = raw->plane[plane_id];
|
|
|
|
|
|
|
|
level = G4X_WM_LEVEL_SR;
|
|
|
|
|
|
|
|
if (!g4x_raw_crtc_wm_is_valid(crtc_state, level))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
wm_state->sr.plane = raw->plane[PLANE_PRIMARY];
|
|
|
|
wm_state->sr.cursor = raw->plane[PLANE_CURSOR];
|
|
|
|
wm_state->sr.fbc = raw->fbc;
|
|
|
|
|
|
|
|
wm_state->cxsr = num_active_planes == BIT(PLANE_PRIMARY);
|
|
|
|
|
|
|
|
level = G4X_WM_LEVEL_HPLL;
|
|
|
|
|
|
|
|
if (!g4x_raw_crtc_wm_is_valid(crtc_state, level))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
wm_state->hpll.plane = raw->plane[PLANE_PRIMARY];
|
|
|
|
wm_state->hpll.cursor = raw->plane[PLANE_CURSOR];
|
|
|
|
wm_state->hpll.fbc = raw->fbc;
|
|
|
|
|
|
|
|
wm_state->hpll_en = wm_state->cxsr;
|
|
|
|
|
|
|
|
level++;
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (level == G4X_WM_LEVEL_NORMAL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* invalidate the higher levels */
|
|
|
|
g4x_invalidate_wms(crtc, wm_state, level);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine if the FBC watermark(s) can be used. IF
|
|
|
|
* this isn't the case we prefer to disable the FBC
|
|
|
|
( watermark(s) rather than disable the SR/HPLL
|
|
|
|
* level(s) entirely.
|
|
|
|
*/
|
|
|
|
wm_state->fbc_en = level > G4X_WM_LEVEL_NORMAL;
|
|
|
|
|
|
|
|
if (level >= G4X_WM_LEVEL_SR &&
|
|
|
|
wm_state->sr.fbc > g4x_fbc_fifo_size(G4X_WM_LEVEL_SR))
|
|
|
|
wm_state->fbc_en = false;
|
|
|
|
else if (level >= G4X_WM_LEVEL_HPLL &&
|
|
|
|
wm_state->hpll.fbc > g4x_fbc_fifo_size(G4X_WM_LEVEL_HPLL))
|
|
|
|
wm_state->fbc_en = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
static int g4x_compute_intermediate_wm(struct intel_crtc_state *new_crtc_state)
|
2017-04-21 18:14:29 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->uapi.crtc);
|
2017-11-15 16:31:57 +00:00
|
|
|
struct g4x_wm_state *intermediate = &new_crtc_state->wm.g4x.intermediate;
|
|
|
|
const struct g4x_wm_state *optimal = &new_crtc_state->wm.g4x.optimal;
|
|
|
|
struct intel_atomic_state *intel_state =
|
2019-10-31 11:26:03 +00:00
|
|
|
to_intel_atomic_state(new_crtc_state->uapi.state);
|
2017-11-15 16:31:57 +00:00
|
|
|
const struct intel_crtc_state *old_crtc_state =
|
|
|
|
intel_atomic_get_old_crtc_state(intel_state, crtc);
|
|
|
|
const struct g4x_wm_state *active = &old_crtc_state->wm.g4x.optimal;
|
2017-04-21 18:14:29 +00:00
|
|
|
enum plane_id plane_id;
|
|
|
|
|
2019-10-31 11:26:03 +00:00
|
|
|
if (!new_crtc_state->hw.active || drm_atomic_crtc_needs_modeset(&new_crtc_state->uapi)) {
|
2017-11-15 16:31:57 +00:00
|
|
|
*intermediate = *optimal;
|
|
|
|
|
|
|
|
intermediate->cxsr = false;
|
|
|
|
intermediate->hpll_en = false;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-04-21 18:14:29 +00:00
|
|
|
intermediate->cxsr = optimal->cxsr && active->cxsr &&
|
2017-11-15 16:31:57 +00:00
|
|
|
!new_crtc_state->disable_cxsr;
|
2017-04-21 18:14:29 +00:00
|
|
|
intermediate->hpll_en = optimal->hpll_en && active->hpll_en &&
|
2017-11-15 16:31:57 +00:00
|
|
|
!new_crtc_state->disable_cxsr;
|
2017-04-21 18:14:29 +00:00
|
|
|
intermediate->fbc_en = optimal->fbc_en && active->fbc_en;
|
|
|
|
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
|
|
|
intermediate->wm.plane[plane_id] =
|
|
|
|
max(optimal->wm.plane[plane_id],
|
|
|
|
active->wm.plane[plane_id]);
|
|
|
|
|
|
|
|
WARN_ON(intermediate->wm.plane[plane_id] >
|
|
|
|
g4x_plane_fifo_size(plane_id, G4X_WM_LEVEL_NORMAL));
|
|
|
|
}
|
|
|
|
|
|
|
|
intermediate->sr.plane = max(optimal->sr.plane,
|
|
|
|
active->sr.plane);
|
|
|
|
intermediate->sr.cursor = max(optimal->sr.cursor,
|
|
|
|
active->sr.cursor);
|
|
|
|
intermediate->sr.fbc = max(optimal->sr.fbc,
|
|
|
|
active->sr.fbc);
|
|
|
|
|
|
|
|
intermediate->hpll.plane = max(optimal->hpll.plane,
|
|
|
|
active->hpll.plane);
|
|
|
|
intermediate->hpll.cursor = max(optimal->hpll.cursor,
|
|
|
|
active->hpll.cursor);
|
|
|
|
intermediate->hpll.fbc = max(optimal->hpll.fbc,
|
|
|
|
active->hpll.fbc);
|
|
|
|
|
|
|
|
WARN_ON((intermediate->sr.plane >
|
|
|
|
g4x_plane_fifo_size(PLANE_PRIMARY, G4X_WM_LEVEL_SR) ||
|
|
|
|
intermediate->sr.cursor >
|
|
|
|
g4x_plane_fifo_size(PLANE_CURSOR, G4X_WM_LEVEL_SR)) &&
|
|
|
|
intermediate->cxsr);
|
|
|
|
WARN_ON((intermediate->sr.plane >
|
|
|
|
g4x_plane_fifo_size(PLANE_PRIMARY, G4X_WM_LEVEL_HPLL) ||
|
|
|
|
intermediate->sr.cursor >
|
|
|
|
g4x_plane_fifo_size(PLANE_CURSOR, G4X_WM_LEVEL_HPLL)) &&
|
|
|
|
intermediate->hpll_en);
|
|
|
|
|
|
|
|
WARN_ON(intermediate->sr.fbc > g4x_fbc_fifo_size(1) &&
|
|
|
|
intermediate->fbc_en && intermediate->cxsr);
|
|
|
|
WARN_ON(intermediate->hpll.fbc > g4x_fbc_fifo_size(2) &&
|
|
|
|
intermediate->fbc_en && intermediate->hpll_en);
|
|
|
|
|
2017-11-15 16:31:57 +00:00
|
|
|
out:
|
2017-04-21 18:14:29 +00:00
|
|
|
/*
|
|
|
|
* If our intermediate WM are identical to the final WM, then we can
|
|
|
|
* omit the post-vblank programming; only update if it's different.
|
|
|
|
*/
|
|
|
|
if (memcmp(intermediate, optimal, sizeof(*intermediate)) != 0)
|
2017-11-15 16:31:57 +00:00
|
|
|
new_crtc_state->wm.need_postvbl_update = true;
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void g4x_merge_wm(struct drm_i915_private *dev_priv,
|
|
|
|
struct g4x_wm_values *wm)
|
|
|
|
{
|
|
|
|
struct intel_crtc *crtc;
|
2019-08-21 17:30:32 +00:00
|
|
|
int num_active_pipes = 0;
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
wm->cxsr = true;
|
|
|
|
wm->hpll_en = true;
|
|
|
|
wm->fbc_en = true;
|
|
|
|
|
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
|
|
|
const struct g4x_wm_state *wm_state = &crtc->wm.active.g4x;
|
|
|
|
|
|
|
|
if (!crtc->active)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!wm_state->cxsr)
|
|
|
|
wm->cxsr = false;
|
|
|
|
if (!wm_state->hpll_en)
|
|
|
|
wm->hpll_en = false;
|
|
|
|
if (!wm_state->fbc_en)
|
|
|
|
wm->fbc_en = false;
|
|
|
|
|
2019-08-21 17:30:32 +00:00
|
|
|
num_active_pipes++;
|
2017-04-21 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
2019-08-21 17:30:32 +00:00
|
|
|
if (num_active_pipes != 1) {
|
2017-04-21 18:14:29 +00:00
|
|
|
wm->cxsr = false;
|
|
|
|
wm->hpll_en = false;
|
|
|
|
wm->fbc_en = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
|
|
|
const struct g4x_wm_state *wm_state = &crtc->wm.active.g4x;
|
|
|
|
enum pipe pipe = crtc->pipe;
|
|
|
|
|
|
|
|
wm->pipe[pipe] = wm_state->wm;
|
|
|
|
if (crtc->active && wm->cxsr)
|
|
|
|
wm->sr = wm_state->sr;
|
|
|
|
if (crtc->active && wm->hpll_en)
|
|
|
|
wm->hpll = wm_state->hpll;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void g4x_program_watermarks(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
struct g4x_wm_values *old_wm = &dev_priv->wm.g4x;
|
|
|
|
struct g4x_wm_values new_wm = {};
|
|
|
|
|
|
|
|
g4x_merge_wm(dev_priv, &new_wm);
|
|
|
|
|
|
|
|
if (memcmp(old_wm, &new_wm, sizeof(new_wm)) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (is_disabling(old_wm->cxsr, new_wm.cxsr, true))
|
|
|
|
_intel_set_memory_cxsr(dev_priv, false);
|
|
|
|
|
|
|
|
g4x_write_wm_values(dev_priv, &new_wm);
|
|
|
|
|
|
|
|
if (is_enabling(old_wm->cxsr, new_wm.cxsr, true))
|
|
|
|
_intel_set_memory_cxsr(dev_priv, true);
|
|
|
|
|
|
|
|
*old_wm = new_wm;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void g4x_initial_watermarks(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
2017-04-21 18:14:29 +00:00
|
|
|
{
|
2019-11-18 16:44:26 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
|
|
|
crtc->wm.active.g4x = crtc_state->wm.g4x.intermediate;
|
|
|
|
g4x_program_watermarks(dev_priv);
|
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void g4x_optimize_watermarks(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
2017-04-21 18:14:29 +00:00
|
|
|
{
|
2019-11-18 16:44:26 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
if (!crtc_state->wm.need_postvbl_update)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
2019-07-01 16:05:45 +00:00
|
|
|
crtc->wm.active.g4x = crtc_state->wm.g4x.optimal;
|
2017-04-21 18:14:29 +00:00
|
|
|
g4x_program_watermarks(dev_priv);
|
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
|
|
|
}
|
|
|
|
|
2015-06-24 19:00:04 +00:00
|
|
|
/* latency must be in 0.1us units. */
|
|
|
|
static unsigned int vlv_wm_method2(unsigned int pixel_rate,
|
2017-04-21 18:14:27 +00:00
|
|
|
unsigned int htotal,
|
|
|
|
unsigned int width,
|
2016-01-20 19:05:26 +00:00
|
|
|
unsigned int cpp,
|
2015-06-24 19:00:04 +00:00
|
|
|
unsigned int latency)
|
|
|
|
{
|
|
|
|
unsigned int ret;
|
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
ret = intel_wm_method2(pixel_rate, htotal,
|
|
|
|
width, cpp, latency);
|
2015-06-24 19:00:04 +00:00
|
|
|
ret = DIV_ROUND_UP(ret, 64);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:24 +00:00
|
|
|
static void vlv_setup_wm_latency(struct drm_i915_private *dev_priv)
|
2015-06-24 19:00:04 +00:00
|
|
|
{
|
|
|
|
/* all latencies in usec */
|
|
|
|
dev_priv->wm.pri_latency[VLV_WM_LEVEL_PM2] = 3;
|
|
|
|
|
2015-09-08 18:05:12 +00:00
|
|
|
dev_priv->wm.max_level = VLV_WM_LEVEL_PM2;
|
|
|
|
|
2015-06-24 19:00:04 +00:00
|
|
|
if (IS_CHERRYVIEW(dev_priv)) {
|
|
|
|
dev_priv->wm.pri_latency[VLV_WM_LEVEL_PM5] = 12;
|
|
|
|
dev_priv->wm.pri_latency[VLV_WM_LEVEL_DDR_DVFS] = 33;
|
2015-09-08 18:05:12 +00:00
|
|
|
|
|
|
|
dev_priv->wm.max_level = VLV_WM_LEVEL_DDR_DVFS;
|
2015-06-24 19:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
static u16 vlv_compute_wm_level(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
|
|
|
int level)
|
2015-06-24 19:00:04 +00:00
|
|
|
{
|
2019-10-31 11:26:08 +00:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2015-06-24 19:00:04 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
|
2016-11-28 17:37:17 +00:00
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&crtc_state->hw.adjusted_mode;
|
2017-11-07 14:03:38 +00:00
|
|
|
unsigned int clock, htotal, cpp, width, wm;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
|
|
|
if (dev_priv->wm.pri_latency[level] == 0)
|
|
|
|
return USHRT_MAX;
|
|
|
|
|
2017-03-03 15:19:27 +00:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2015-06-24 19:00:04 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-10-31 11:26:07 +00:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2016-11-28 17:37:17 +00:00
|
|
|
clock = adjusted_mode->crtc_clock;
|
|
|
|
htotal = adjusted_mode->crtc_htotal;
|
|
|
|
width = crtc_state->pipe_src_w;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-03 15:19:26 +00:00
|
|
|
if (plane->id == PLANE_CURSOR) {
|
2015-06-24 19:00:04 +00:00
|
|
|
/*
|
|
|
|
* FIXME the formula gives values that are
|
|
|
|
* too big for the cursor FIFO, and hence we
|
|
|
|
* would never be able to use cursors. For
|
|
|
|
* now just hardcode the watermark.
|
|
|
|
*/
|
|
|
|
wm = 63;
|
|
|
|
} else {
|
2016-01-20 19:05:26 +00:00
|
|
|
wm = vlv_wm_method2(clock, htotal, width, cpp,
|
2015-06-24 19:00:04 +00:00
|
|
|
dev_priv->wm.pri_latency[level] * 10);
|
|
|
|
}
|
|
|
|
|
2017-11-07 14:03:38 +00:00
|
|
|
return min_t(unsigned int, wm, USHRT_MAX);
|
2015-06-24 19:00:04 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:15:03 +00:00
|
|
|
static bool vlv_need_sprite0_fifo_workaround(unsigned int active_planes)
|
|
|
|
{
|
|
|
|
return (active_planes & (BIT(PLANE_SPRITE0) |
|
|
|
|
BIT(PLANE_SPRITE1))) == BIT(PLANE_SPRITE1);
|
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
static int vlv_compute_fifo(struct intel_crtc_state *crtc_state)
|
2015-06-24 19:00:05 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2017-04-21 18:14:21 +00:00
|
|
|
const struct g4x_pipe_wm *raw =
|
2017-03-02 17:14:56 +00:00
|
|
|
&crtc_state->wm.vlv.raw[VLV_WM_LEVEL_PM2];
|
2017-03-02 17:14:55 +00:00
|
|
|
struct vlv_fifo_state *fifo_state = &crtc_state->wm.vlv.fifo_state;
|
2017-03-02 17:14:56 +00:00
|
|
|
unsigned int active_planes = crtc_state->active_planes & ~BIT(PLANE_CURSOR);
|
2019-08-21 17:30:33 +00:00
|
|
|
int num_active_planes = hweight8(active_planes);
|
2017-03-02 17:14:56 +00:00
|
|
|
const int fifo_size = 511;
|
2015-06-24 19:00:05 +00:00
|
|
|
int fifo_extra, fifo_left = fifo_size;
|
2017-03-02 17:15:03 +00:00
|
|
|
int sprite0_fifo_extra = 0;
|
2017-03-02 17:14:56 +00:00
|
|
|
unsigned int total_rate;
|
|
|
|
enum plane_id plane_id;
|
2015-06-24 19:00:05 +00:00
|
|
|
|
2017-03-02 17:15:03 +00:00
|
|
|
/*
|
|
|
|
* When enabling sprite0 after sprite1 has already been enabled
|
|
|
|
* we tend to get an underrun unless sprite0 already has some
|
|
|
|
* FIFO space allcoated. Hence we always allocate at least one
|
|
|
|
* cacheline for sprite0 whenever sprite1 is enabled.
|
|
|
|
*
|
|
|
|
* All other plane enable sequences appear immune to this problem.
|
|
|
|
*/
|
|
|
|
if (vlv_need_sprite0_fifo_workaround(active_planes))
|
|
|
|
sprite0_fifo_extra = 1;
|
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
total_rate = raw->plane[PLANE_PRIMARY] +
|
|
|
|
raw->plane[PLANE_SPRITE0] +
|
2017-03-02 17:15:03 +00:00
|
|
|
raw->plane[PLANE_SPRITE1] +
|
|
|
|
sprite0_fifo_extra;
|
2015-06-24 19:00:05 +00:00
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
if (total_rate > fifo_size)
|
|
|
|
return -EINVAL;
|
2015-06-24 19:00:05 +00:00
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
if (total_rate == 0)
|
|
|
|
total_rate = 1;
|
2015-06-24 19:00:05 +00:00
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
2015-06-24 19:00:05 +00:00
|
|
|
unsigned int rate;
|
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
if ((active_planes & BIT(plane_id)) == 0) {
|
|
|
|
fifo_state->plane[plane_id] = 0;
|
2015-06-24 19:00:05 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
rate = raw->plane[plane_id];
|
|
|
|
fifo_state->plane[plane_id] = fifo_size * rate / total_rate;
|
|
|
|
fifo_left -= fifo_state->plane[plane_id];
|
2015-06-24 19:00:05 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:15:03 +00:00
|
|
|
fifo_state->plane[PLANE_SPRITE0] += sprite0_fifo_extra;
|
|
|
|
fifo_left -= sprite0_fifo_extra;
|
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
fifo_state->plane[PLANE_CURSOR] = 63;
|
|
|
|
|
|
|
|
fifo_extra = DIV_ROUND_UP(fifo_left, num_active_planes ?: 1);
|
2015-06-24 19:00:05 +00:00
|
|
|
|
|
|
|
/* spread the remainder evenly */
|
2017-03-02 17:14:56 +00:00
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
2015-06-24 19:00:05 +00:00
|
|
|
int plane_extra;
|
|
|
|
|
|
|
|
if (fifo_left == 0)
|
|
|
|
break;
|
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
if ((active_planes & BIT(plane_id)) == 0)
|
2015-06-24 19:00:05 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
plane_extra = min(fifo_extra, fifo_left);
|
2017-03-02 17:14:56 +00:00
|
|
|
fifo_state->plane[plane_id] += plane_extra;
|
2015-06-24 19:00:05 +00:00
|
|
|
fifo_left -= plane_extra;
|
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
WARN_ON(active_planes != 0 && fifo_left != 0);
|
|
|
|
|
|
|
|
/* give it all to the first plane if none are active */
|
|
|
|
if (active_planes == 0) {
|
|
|
|
WARN_ON(fifo_left != fifo_size);
|
|
|
|
fifo_state->plane[PLANE_PRIMARY] = fifo_left;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2015-06-24 19:00:05 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
/* mark all levels starting from 'level' as invalid */
|
|
|
|
static void vlv_invalidate_wms(struct intel_crtc *crtc,
|
|
|
|
struct vlv_wm_state *wm_state, int level)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
|
2017-04-21 18:14:20 +00:00
|
|
|
for (; level < intel_wm_num_levels(dev_priv); level++) {
|
2017-03-02 17:14:57 +00:00
|
|
|
enum plane_id plane_id;
|
|
|
|
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id)
|
|
|
|
wm_state->wm[level].plane[plane_id] = USHRT_MAX;
|
|
|
|
|
|
|
|
wm_state->sr[level].cursor = USHRT_MAX;
|
|
|
|
wm_state->sr[level].plane = USHRT_MAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-28 17:37:09 +00:00
|
|
|
static u16 vlv_invert_wm_value(u16 wm, u16 fifo_size)
|
|
|
|
{
|
|
|
|
if (wm > fifo_size)
|
|
|
|
return USHRT_MAX;
|
|
|
|
else
|
|
|
|
return fifo_size - wm;
|
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
/*
|
|
|
|
* Starting from 'level' set all higher
|
|
|
|
* levels to 'value' in the "raw" watermarks.
|
|
|
|
*/
|
2017-03-02 17:14:58 +00:00
|
|
|
static bool vlv_raw_plane_wm_set(struct intel_crtc_state *crtc_state,
|
2017-03-02 17:14:57 +00:00
|
|
|
int level, enum plane_id plane_id, u16 value)
|
2015-06-24 19:00:04 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 18:14:20 +00:00
|
|
|
int num_levels = intel_wm_num_levels(dev_priv);
|
2017-03-02 17:14:58 +00:00
|
|
|
bool dirty = false;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
for (; level < num_levels; level++) {
|
2017-04-21 18:14:21 +00:00
|
|
|
struct g4x_pipe_wm *raw = &crtc_state->wm.vlv.raw[level];
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:58 +00:00
|
|
|
dirty |= raw->plane[plane_id] != value;
|
2017-03-02 17:14:57 +00:00
|
|
|
raw->plane[plane_id] = value;
|
2015-06-24 19:00:04 +00:00
|
|
|
}
|
2017-03-02 17:14:58 +00:00
|
|
|
|
|
|
|
return dirty;
|
2015-06-24 19:00:04 +00:00
|
|
|
}
|
|
|
|
|
2017-04-21 18:14:18 +00:00
|
|
|
static bool vlv_raw_plane_wm_compute(struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state)
|
2015-06-24 19:00:04 +00:00
|
|
|
{
|
2019-10-31 11:26:08 +00:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2020-01-07 15:13:30 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-03-02 17:14:57 +00:00
|
|
|
enum plane_id plane_id = plane->id;
|
2017-04-21 18:14:20 +00:00
|
|
|
int num_levels = intel_wm_num_levels(to_i915(plane->base.dev));
|
2015-06-24 19:00:04 +00:00
|
|
|
int level;
|
2017-03-02 17:14:58 +00:00
|
|
|
bool dirty = false;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-03 15:19:27 +00:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state)) {
|
2017-03-02 17:14:58 +00:00
|
|
|
dirty |= vlv_raw_plane_wm_set(crtc_state, 0, plane_id, 0);
|
|
|
|
goto out;
|
2017-03-02 17:14:57 +00:00
|
|
|
}
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
for (level = 0; level < num_levels; level++) {
|
2017-04-21 18:14:21 +00:00
|
|
|
struct g4x_pipe_wm *raw = &crtc_state->wm.vlv.raw[level];
|
2017-03-02 17:14:57 +00:00
|
|
|
int wm = vlv_compute_wm_level(crtc_state, plane_state, level);
|
|
|
|
int max_wm = plane_id == PLANE_CURSOR ? 63 : 511;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
if (wm > max_wm)
|
|
|
|
break;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:58 +00:00
|
|
|
dirty |= raw->plane[plane_id] != wm;
|
2017-03-02 17:14:57 +00:00
|
|
|
raw->plane[plane_id] = wm;
|
|
|
|
}
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
/* mark all higher levels as invalid */
|
2017-03-02 17:14:58 +00:00
|
|
|
dirty |= vlv_raw_plane_wm_set(crtc_state, level, plane_id, USHRT_MAX);
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:58 +00:00
|
|
|
out:
|
|
|
|
if (dirty)
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"%s watermarks: PM2=%d, PM5=%d, DDR DVFS=%d\n",
|
|
|
|
plane->base.name,
|
|
|
|
crtc_state->wm.vlv.raw[VLV_WM_LEVEL_PM2].plane[plane_id],
|
|
|
|
crtc_state->wm.vlv.raw[VLV_WM_LEVEL_PM5].plane[plane_id],
|
|
|
|
crtc_state->wm.vlv.raw[VLV_WM_LEVEL_DDR_DVFS].plane[plane_id]);
|
2017-03-02 17:14:58 +00:00
|
|
|
|
|
|
|
return dirty;
|
2017-03-02 17:14:57 +00:00
|
|
|
}
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-04-21 18:14:18 +00:00
|
|
|
static bool vlv_raw_plane_wm_is_valid(const struct intel_crtc_state *crtc_state,
|
|
|
|
enum plane_id plane_id, int level)
|
2017-03-02 17:14:57 +00:00
|
|
|
{
|
2017-04-21 18:14:21 +00:00
|
|
|
const struct g4x_pipe_wm *raw =
|
2017-03-02 17:14:57 +00:00
|
|
|
&crtc_state->wm.vlv.raw[level];
|
|
|
|
const struct vlv_fifo_state *fifo_state =
|
|
|
|
&crtc_state->wm.vlv.fifo_state;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
return raw->plane[plane_id] <= fifo_state->plane[plane_id];
|
|
|
|
}
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-04-21 18:14:18 +00:00
|
|
|
static bool vlv_raw_crtc_wm_is_valid(const struct intel_crtc_state *crtc_state, int level)
|
2017-03-02 17:14:57 +00:00
|
|
|
{
|
2017-04-21 18:14:18 +00:00
|
|
|
return vlv_raw_plane_wm_is_valid(crtc_state, PLANE_PRIMARY, level) &&
|
|
|
|
vlv_raw_plane_wm_is_valid(crtc_state, PLANE_SPRITE0, level) &&
|
|
|
|
vlv_raw_plane_wm_is_valid(crtc_state, PLANE_SPRITE1, level) &&
|
|
|
|
vlv_raw_plane_wm_is_valid(crtc_state, PLANE_CURSOR, level);
|
2017-03-02 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vlv_compute_pipe_wm(struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2017-03-02 17:14:57 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
struct intel_atomic_state *state =
|
2019-10-31 11:26:03 +00:00
|
|
|
to_intel_atomic_state(crtc_state->uapi.state);
|
2017-03-02 17:14:57 +00:00
|
|
|
struct vlv_wm_state *wm_state = &crtc_state->wm.vlv.optimal;
|
|
|
|
const struct vlv_fifo_state *fifo_state =
|
|
|
|
&crtc_state->wm.vlv.fifo_state;
|
2019-08-21 17:30:33 +00:00
|
|
|
int num_active_planes = hweight8(crtc_state->active_planes &
|
|
|
|
~BIT(PLANE_CURSOR));
|
2019-10-31 11:26:03 +00:00
|
|
|
bool needs_modeset = drm_atomic_crtc_needs_modeset(&crtc_state->uapi);
|
2017-08-23 15:22:22 +00:00
|
|
|
const struct intel_plane_state *old_plane_state;
|
|
|
|
const struct intel_plane_state *new_plane_state;
|
2017-03-02 17:14:57 +00:00
|
|
|
struct intel_plane *plane;
|
|
|
|
enum plane_id plane_id;
|
|
|
|
int level, ret, i;
|
2017-03-02 17:14:58 +00:00
|
|
|
unsigned int dirty = 0;
|
2017-03-02 17:14:57 +00:00
|
|
|
|
2017-08-23 15:22:22 +00:00
|
|
|
for_each_oldnew_intel_plane_in_state(state, plane,
|
|
|
|
old_plane_state,
|
|
|
|
new_plane_state, i) {
|
2019-10-31 11:26:07 +00:00
|
|
|
if (new_plane_state->hw.crtc != &crtc->base &&
|
|
|
|
old_plane_state->hw.crtc != &crtc->base)
|
2017-03-02 17:14:57 +00:00
|
|
|
continue;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-08-23 15:22:22 +00:00
|
|
|
if (vlv_raw_plane_wm_compute(crtc_state, new_plane_state))
|
2017-03-02 17:14:58 +00:00
|
|
|
dirty |= BIT(plane->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DSPARB registers may have been reset due to the
|
|
|
|
* power well being turned off. Make sure we restore
|
|
|
|
* them to a consistent state even if no primary/sprite
|
|
|
|
* planes are initially active.
|
|
|
|
*/
|
|
|
|
if (needs_modeset)
|
|
|
|
crtc_state->fifo_changed = true;
|
|
|
|
|
|
|
|
if (!dirty)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* cursor changes don't warrant a FIFO recompute */
|
|
|
|
if (dirty & ~BIT(PLANE_CURSOR)) {
|
|
|
|
const struct intel_crtc_state *old_crtc_state =
|
2017-08-23 15:22:22 +00:00
|
|
|
intel_atomic_get_old_crtc_state(state, crtc);
|
2017-03-02 17:14:58 +00:00
|
|
|
const struct vlv_fifo_state *old_fifo_state =
|
|
|
|
&old_crtc_state->wm.vlv.fifo_state;
|
|
|
|
|
|
|
|
ret = vlv_compute_fifo(crtc_state);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (needs_modeset ||
|
|
|
|
memcmp(old_fifo_state, fifo_state,
|
|
|
|
sizeof(*fifo_state)) != 0)
|
|
|
|
crtc_state->fifo_changed = true;
|
2017-03-02 17:14:56 +00:00
|
|
|
}
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
/* initially allow all levels */
|
2017-04-21 18:14:20 +00:00
|
|
|
wm_state->num_levels = intel_wm_num_levels(dev_priv);
|
2017-03-02 17:14:57 +00:00
|
|
|
/*
|
|
|
|
* Note that enabling cxsr with no primary/sprite planes
|
|
|
|
* enabled can wedge the pipe. Hence we only allow cxsr
|
|
|
|
* with exactly one enabled primary/sprite plane.
|
|
|
|
*/
|
2017-03-02 17:15:00 +00:00
|
|
|
wm_state->cxsr = crtc->pipe != PIPE_C && num_active_planes == 1;
|
2017-03-02 17:14:57 +00:00
|
|
|
|
2017-03-02 17:14:56 +00:00
|
|
|
for (level = 0; level < wm_state->num_levels; level++) {
|
2017-04-21 18:14:21 +00:00
|
|
|
const struct g4x_pipe_wm *raw = &crtc_state->wm.vlv.raw[level];
|
2019-09-11 09:26:08 +00:00
|
|
|
const int sr_fifo_size = INTEL_NUM_PIPES(dev_priv) * 512 - 1;
|
2017-03-02 17:14:56 +00:00
|
|
|
|
2017-04-21 18:14:18 +00:00
|
|
|
if (!vlv_raw_crtc_wm_is_valid(crtc_state, level))
|
2017-03-02 17:14:57 +00:00
|
|
|
break;
|
2017-03-02 17:14:56 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
|
|
|
wm_state->wm[level].plane[plane_id] =
|
|
|
|
vlv_invert_wm_value(raw->plane[plane_id],
|
|
|
|
fifo_state->plane[plane_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
wm_state->sr[level].plane =
|
|
|
|
vlv_invert_wm_value(max3(raw->plane[PLANE_PRIMARY],
|
2017-03-02 17:14:56 +00:00
|
|
|
raw->plane[PLANE_SPRITE0],
|
2017-03-02 17:14:57 +00:00
|
|
|
raw->plane[PLANE_SPRITE1]),
|
|
|
|
sr_fifo_size);
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
wm_state->sr[level].cursor =
|
|
|
|
vlv_invert_wm_value(raw->plane[PLANE_CURSOR],
|
|
|
|
63);
|
2015-06-24 19:00:04 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
if (level == 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* limit to only levels we can actually handle */
|
|
|
|
wm_state->num_levels = level;
|
|
|
|
|
|
|
|
/* invalidate the higher levels */
|
|
|
|
vlv_invalidate_wms(crtc, wm_state, level);
|
|
|
|
|
|
|
|
return 0;
|
2015-06-24 19:00:04 +00:00
|
|
|
}
|
|
|
|
|
2015-06-24 19:00:05 +00:00
|
|
|
#define VLV_FIFO(plane, value) \
|
|
|
|
(((value) << DSPARB_ ## plane ## _SHIFT_VLV) & DSPARB_ ## plane ## _MASK_VLV)
|
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
static void vlv_atomic_update_fifo(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
2015-06-24 19:00:05 +00:00
|
|
|
{
|
2017-03-02 17:14:52 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2019-06-11 10:45:44 +00:00
|
|
|
struct intel_uncore *uncore = &dev_priv->uncore;
|
2019-11-18 16:44:26 +00:00
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2017-03-02 17:14:55 +00:00
|
|
|
const struct vlv_fifo_state *fifo_state =
|
|
|
|
&crtc_state->wm.vlv.fifo_state;
|
2017-03-02 17:14:52 +00:00
|
|
|
int sprite0_start, sprite1_start, fifo_size;
|
2015-06-24 19:00:05 +00:00
|
|
|
|
2017-03-02 17:14:58 +00:00
|
|
|
if (!crtc_state->fifo_changed)
|
|
|
|
return;
|
|
|
|
|
2017-03-02 17:14:52 +00:00
|
|
|
sprite0_start = fifo_state->plane[PLANE_PRIMARY];
|
|
|
|
sprite1_start = fifo_state->plane[PLANE_SPRITE0] + sprite0_start;
|
|
|
|
fifo_size = fifo_state->plane[PLANE_SPRITE1] + sprite1_start;
|
2015-06-24 19:00:05 +00:00
|
|
|
|
2017-03-02 17:14:52 +00:00
|
|
|
WARN_ON(fifo_state->plane[PLANE_CURSOR] != 63);
|
|
|
|
WARN_ON(fifo_size != 511);
|
2015-06-24 19:00:05 +00:00
|
|
|
|
2017-03-02 17:15:06 +00:00
|
|
|
trace_vlv_fifo_size(crtc, sprite0_start, sprite1_start, fifo_size);
|
|
|
|
|
2017-03-09 15:44:34 +00:00
|
|
|
/*
|
|
|
|
* uncore.lock serves a double purpose here. It allows us to
|
|
|
|
* use the less expensive I915_{READ,WRITE}_FW() functions, and
|
|
|
|
* it protects the DSPARB registers from getting clobbered by
|
|
|
|
* parallel updates from multiple pipes.
|
|
|
|
*
|
|
|
|
* intel_pipe_update_start() has already disabled interrupts
|
|
|
|
* for us, so a plain spin_lock() is sufficient here.
|
|
|
|
*/
|
2019-06-11 10:45:44 +00:00
|
|
|
spin_lock(&uncore->lock);
|
2016-12-05 14:13:28 +00:00
|
|
|
|
2015-06-24 19:00:05 +00:00
|
|
|
switch (crtc->pipe) {
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 dsparb, dsparb2, dsparb3;
|
2015-06-24 19:00:05 +00:00
|
|
|
case PIPE_A:
|
2019-06-11 10:45:44 +00:00
|
|
|
dsparb = intel_uncore_read_fw(uncore, DSPARB);
|
|
|
|
dsparb2 = intel_uncore_read_fw(uncore, DSPARB2);
|
2015-06-24 19:00:05 +00:00
|
|
|
|
|
|
|
dsparb &= ~(VLV_FIFO(SPRITEA, 0xff) |
|
|
|
|
VLV_FIFO(SPRITEB, 0xff));
|
|
|
|
dsparb |= (VLV_FIFO(SPRITEA, sprite0_start) |
|
|
|
|
VLV_FIFO(SPRITEB, sprite1_start));
|
|
|
|
|
|
|
|
dsparb2 &= ~(VLV_FIFO(SPRITEA_HI, 0x1) |
|
|
|
|
VLV_FIFO(SPRITEB_HI, 0x1));
|
|
|
|
dsparb2 |= (VLV_FIFO(SPRITEA_HI, sprite0_start >> 8) |
|
|
|
|
VLV_FIFO(SPRITEB_HI, sprite1_start >> 8));
|
|
|
|
|
2019-06-11 10:45:44 +00:00
|
|
|
intel_uncore_write_fw(uncore, DSPARB, dsparb);
|
|
|
|
intel_uncore_write_fw(uncore, DSPARB2, dsparb2);
|
2015-06-24 19:00:05 +00:00
|
|
|
break;
|
|
|
|
case PIPE_B:
|
2019-06-11 10:45:44 +00:00
|
|
|
dsparb = intel_uncore_read_fw(uncore, DSPARB);
|
|
|
|
dsparb2 = intel_uncore_read_fw(uncore, DSPARB2);
|
2015-06-24 19:00:05 +00:00
|
|
|
|
|
|
|
dsparb &= ~(VLV_FIFO(SPRITEC, 0xff) |
|
|
|
|
VLV_FIFO(SPRITED, 0xff));
|
|
|
|
dsparb |= (VLV_FIFO(SPRITEC, sprite0_start) |
|
|
|
|
VLV_FIFO(SPRITED, sprite1_start));
|
|
|
|
|
|
|
|
dsparb2 &= ~(VLV_FIFO(SPRITEC_HI, 0xff) |
|
|
|
|
VLV_FIFO(SPRITED_HI, 0xff));
|
|
|
|
dsparb2 |= (VLV_FIFO(SPRITEC_HI, sprite0_start >> 8) |
|
|
|
|
VLV_FIFO(SPRITED_HI, sprite1_start >> 8));
|
|
|
|
|
2019-06-11 10:45:44 +00:00
|
|
|
intel_uncore_write_fw(uncore, DSPARB, dsparb);
|
|
|
|
intel_uncore_write_fw(uncore, DSPARB2, dsparb2);
|
2015-06-24 19:00:05 +00:00
|
|
|
break;
|
|
|
|
case PIPE_C:
|
2019-06-11 10:45:44 +00:00
|
|
|
dsparb3 = intel_uncore_read_fw(uncore, DSPARB3);
|
|
|
|
dsparb2 = intel_uncore_read_fw(uncore, DSPARB2);
|
2015-06-24 19:00:05 +00:00
|
|
|
|
|
|
|
dsparb3 &= ~(VLV_FIFO(SPRITEE, 0xff) |
|
|
|
|
VLV_FIFO(SPRITEF, 0xff));
|
|
|
|
dsparb3 |= (VLV_FIFO(SPRITEE, sprite0_start) |
|
|
|
|
VLV_FIFO(SPRITEF, sprite1_start));
|
|
|
|
|
|
|
|
dsparb2 &= ~(VLV_FIFO(SPRITEE_HI, 0xff) |
|
|
|
|
VLV_FIFO(SPRITEF_HI, 0xff));
|
|
|
|
dsparb2 |= (VLV_FIFO(SPRITEE_HI, sprite0_start >> 8) |
|
|
|
|
VLV_FIFO(SPRITEF_HI, sprite1_start >> 8));
|
|
|
|
|
2019-06-11 10:45:44 +00:00
|
|
|
intel_uncore_write_fw(uncore, DSPARB3, dsparb3);
|
|
|
|
intel_uncore_write_fw(uncore, DSPARB2, dsparb2);
|
2015-06-24 19:00:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-12-05 14:13:28 +00:00
|
|
|
|
2019-06-11 10:45:44 +00:00
|
|
|
intel_uncore_posting_read_fw(uncore, DSPARB);
|
2016-12-05 14:13:28 +00:00
|
|
|
|
2019-06-11 10:45:44 +00:00
|
|
|
spin_unlock(&uncore->lock);
|
2015-06-24 19:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef VLV_FIFO
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
static int vlv_compute_intermediate_wm(struct intel_crtc_state *new_crtc_state)
|
2017-03-02 17:14:59 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->uapi.crtc);
|
2017-11-15 16:31:56 +00:00
|
|
|
struct vlv_wm_state *intermediate = &new_crtc_state->wm.vlv.intermediate;
|
|
|
|
const struct vlv_wm_state *optimal = &new_crtc_state->wm.vlv.optimal;
|
|
|
|
struct intel_atomic_state *intel_state =
|
2019-10-31 11:26:03 +00:00
|
|
|
to_intel_atomic_state(new_crtc_state->uapi.state);
|
2017-11-15 16:31:56 +00:00
|
|
|
const struct intel_crtc_state *old_crtc_state =
|
|
|
|
intel_atomic_get_old_crtc_state(intel_state, crtc);
|
|
|
|
const struct vlv_wm_state *active = &old_crtc_state->wm.vlv.optimal;
|
2017-03-02 17:14:59 +00:00
|
|
|
int level;
|
|
|
|
|
2019-10-31 11:26:03 +00:00
|
|
|
if (!new_crtc_state->hw.active || drm_atomic_crtc_needs_modeset(&new_crtc_state->uapi)) {
|
2017-11-15 16:31:56 +00:00
|
|
|
*intermediate = *optimal;
|
|
|
|
|
|
|
|
intermediate->cxsr = false;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:59 +00:00
|
|
|
intermediate->num_levels = min(optimal->num_levels, active->num_levels);
|
2017-03-02 17:15:00 +00:00
|
|
|
intermediate->cxsr = optimal->cxsr && active->cxsr &&
|
2017-11-15 16:31:56 +00:00
|
|
|
!new_crtc_state->disable_cxsr;
|
2017-03-02 17:14:59 +00:00
|
|
|
|
|
|
|
for (level = 0; level < intermediate->num_levels; level++) {
|
|
|
|
enum plane_id plane_id;
|
|
|
|
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
|
|
|
intermediate->wm[level].plane[plane_id] =
|
|
|
|
min(optimal->wm[level].plane[plane_id],
|
|
|
|
active->wm[level].plane[plane_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
intermediate->sr[level].plane = min(optimal->sr[level].plane,
|
|
|
|
active->sr[level].plane);
|
|
|
|
intermediate->sr[level].cursor = min(optimal->sr[level].cursor,
|
|
|
|
active->sr[level].cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
vlv_invalidate_wms(crtc, intermediate, level);
|
|
|
|
|
2017-11-15 16:31:56 +00:00
|
|
|
out:
|
2017-03-02 17:14:59 +00:00
|
|
|
/*
|
|
|
|
* If our intermediate WM are identical to the final WM, then we can
|
|
|
|
* omit the post-vblank programming; only update if it's different.
|
|
|
|
*/
|
2017-03-02 17:15:00 +00:00
|
|
|
if (memcmp(intermediate, optimal, sizeof(*intermediate)) != 0)
|
2017-11-15 16:31:56 +00:00
|
|
|
new_crtc_state->wm.need_postvbl_update = true;
|
2017-03-02 17:14:59 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-28 17:37:10 +00:00
|
|
|
static void vlv_merge_wm(struct drm_i915_private *dev_priv,
|
2015-06-24 19:00:04 +00:00
|
|
|
struct vlv_wm_values *wm)
|
|
|
|
{
|
|
|
|
struct intel_crtc *crtc;
|
2019-08-21 17:30:32 +00:00
|
|
|
int num_active_pipes = 0;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2016-11-28 17:37:10 +00:00
|
|
|
wm->level = dev_priv->wm.max_level;
|
2015-06-24 19:00:04 +00:00
|
|
|
wm->cxsr = true;
|
|
|
|
|
2016-11-28 17:37:10 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2017-03-02 17:14:53 +00:00
|
|
|
const struct vlv_wm_state *wm_state = &crtc->wm.active.vlv;
|
2015-06-24 19:00:04 +00:00
|
|
|
|
|
|
|
if (!crtc->active)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!wm_state->cxsr)
|
|
|
|
wm->cxsr = false;
|
|
|
|
|
2019-08-21 17:30:32 +00:00
|
|
|
num_active_pipes++;
|
2015-06-24 19:00:04 +00:00
|
|
|
wm->level = min_t(int, wm->level, wm_state->num_levels - 1);
|
|
|
|
}
|
|
|
|
|
2019-08-21 17:30:32 +00:00
|
|
|
if (num_active_pipes != 1)
|
2015-06-24 19:00:04 +00:00
|
|
|
wm->cxsr = false;
|
|
|
|
|
2019-08-21 17:30:32 +00:00
|
|
|
if (num_active_pipes > 1)
|
2015-06-24 19:00:08 +00:00
|
|
|
wm->level = VLV_WM_LEVEL_PM2;
|
|
|
|
|
2016-11-28 17:37:10 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2017-03-02 17:14:53 +00:00
|
|
|
const struct vlv_wm_state *wm_state = &crtc->wm.active.vlv;
|
2015-06-24 19:00:04 +00:00
|
|
|
enum pipe pipe = crtc->pipe;
|
|
|
|
|
|
|
|
wm->pipe[pipe] = wm_state->wm[wm->level];
|
2017-03-02 17:14:57 +00:00
|
|
|
if (crtc->active && wm->cxsr)
|
2015-06-24 19:00:04 +00:00
|
|
|
wm->sr = wm_state->sr[wm->level];
|
|
|
|
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->ddl[pipe].plane[PLANE_PRIMARY] = DDL_PRECISION_HIGH | 2;
|
|
|
|
wm->ddl[pipe].plane[PLANE_SPRITE0] = DDL_PRECISION_HIGH | 2;
|
|
|
|
wm->ddl[pipe].plane[PLANE_SPRITE1] = DDL_PRECISION_HIGH | 2;
|
|
|
|
wm->ddl[pipe].plane[PLANE_CURSOR] = DDL_PRECISION_HIGH | 2;
|
2015-06-24 19:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
static void vlv_program_watermarks(struct drm_i915_private *dev_priv)
|
2015-06-24 19:00:04 +00:00
|
|
|
{
|
2016-11-28 17:37:16 +00:00
|
|
|
struct vlv_wm_values *old_wm = &dev_priv->wm.vlv;
|
|
|
|
struct vlv_wm_values new_wm = {};
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
vlv_merge_wm(dev_priv, &new_wm);
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
if (memcmp(old_wm, &new_wm, sizeof(new_wm)) == 0)
|
2015-06-24 19:00:04 +00:00
|
|
|
return;
|
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
if (is_disabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_DDR_DVFS))
|
2015-06-24 19:00:04 +00:00
|
|
|
chv_set_memory_dvfs(dev_priv, false);
|
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
if (is_disabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_PM5))
|
2015-06-24 19:00:04 +00:00
|
|
|
chv_set_memory_pm5(dev_priv, false);
|
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
if (is_disabling(old_wm->cxsr, new_wm.cxsr, true))
|
2016-11-28 17:37:11 +00:00
|
|
|
_intel_set_memory_cxsr(dev_priv, false);
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
vlv_write_wm_values(dev_priv, &new_wm);
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
if (is_enabling(old_wm->cxsr, new_wm.cxsr, true))
|
2016-11-28 17:37:11 +00:00
|
|
|
_intel_set_memory_cxsr(dev_priv, true);
|
2015-06-24 19:00:04 +00:00
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
if (is_enabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_PM5))
|
2015-06-24 19:00:04 +00:00
|
|
|
chv_set_memory_pm5(dev_priv, true);
|
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
if (is_enabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_DDR_DVFS))
|
2015-06-24 19:00:04 +00:00
|
|
|
chv_set_memory_dvfs(dev_priv, true);
|
|
|
|
|
2016-11-28 17:37:16 +00:00
|
|
|
*old_wm = new_wm;
|
2014-06-26 14:03:06 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:14:57 +00:00
|
|
|
static void vlv_initial_watermarks(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
2017-03-02 17:14:57 +00:00
|
|
|
{
|
2019-11-18 16:44:26 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2017-03-02 17:14:57 +00:00
|
|
|
|
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
2017-03-02 17:14:59 +00:00
|
|
|
crtc->wm.active.vlv = crtc_state->wm.vlv.intermediate;
|
|
|
|
vlv_program_watermarks(dev_priv);
|
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vlv_optimize_watermarks(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
2017-03-02 17:14:59 +00:00
|
|
|
{
|
2019-11-18 16:44:26 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2017-03-02 17:14:59 +00:00
|
|
|
|
|
|
|
if (!crtc_state->wm.need_postvbl_update)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
2019-07-01 16:05:45 +00:00
|
|
|
crtc->wm.active.vlv = crtc_state->wm.vlv.optimal;
|
2017-03-02 17:14:57 +00:00
|
|
|
vlv_program_watermarks(dev_priv);
|
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:03 +00:00
|
|
|
static void i965_update_wm(struct intel_crtc *unused_crtc)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2016-10-31 20:37:21 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(unused_crtc->base.dev);
|
2016-10-31 20:37:04 +00:00
|
|
|
struct intel_crtc *crtc;
|
2012-04-17 01:20:35 +00:00
|
|
|
int srwm = 1;
|
|
|
|
int cursor_sr = 16;
|
2014-06-13 11:54:20 +00:00
|
|
|
bool cxsr_enabled;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
/* Calc sr entries for one plane configs */
|
2016-10-31 20:37:21 +00:00
|
|
|
crtc = single_enabled_crtc(dev_priv);
|
2012-04-17 01:20:35 +00:00
|
|
|
if (crtc) {
|
|
|
|
/* self-refresh has much higher latency */
|
|
|
|
static const int sr_latency_ns = 12000;
|
2016-10-31 20:37:04 +00:00
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&crtc->config->hw.adjusted_mode;
|
2016-10-31 20:37:04 +00:00
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
crtc->base.primary->state->fb;
|
2013-09-25 15:45:37 +00:00
|
|
|
int clock = adjusted_mode->crtc_clock;
|
2013-11-27 19:10:26 +00:00
|
|
|
int htotal = adjusted_mode->crtc_htotal;
|
2016-10-31 20:37:04 +00:00
|
|
|
int hdisplay = crtc->config->pipe_src_w;
|
2016-12-14 21:30:57 +00:00
|
|
|
int cpp = fb->format->cpp[0];
|
2012-04-17 01:20:35 +00:00
|
|
|
int entries;
|
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
entries = intel_wm_method2(clock, htotal,
|
|
|
|
hdisplay, cpp, sr_latency_ns / 100);
|
2012-04-17 01:20:35 +00:00
|
|
|
entries = DIV_ROUND_UP(entries, I915_FIFO_LINE_SIZE);
|
|
|
|
srwm = I965_FIFO_SIZE - entries;
|
|
|
|
if (srwm < 0)
|
|
|
|
srwm = 1;
|
|
|
|
srwm &= 0x1ff;
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"self-refresh entries: %d, wm: %d\n",
|
|
|
|
entries, srwm);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
entries = intel_wm_method2(clock, htotal,
|
|
|
|
crtc->base.cursor->state->crtc_w, 4,
|
|
|
|
sr_latency_ns / 100);
|
2012-04-17 01:20:35 +00:00
|
|
|
entries = DIV_ROUND_UP(entries,
|
2017-04-21 18:14:27 +00:00
|
|
|
i965_cursor_wm_info.cacheline_size) +
|
|
|
|
i965_cursor_wm_info.guard_size;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
cursor_sr = i965_cursor_wm_info.fifo_size - entries;
|
2012-04-17 01:20:35 +00:00
|
|
|
if (cursor_sr > i965_cursor_wm_info.max_wm)
|
|
|
|
cursor_sr = i965_cursor_wm_info.max_wm;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"self-refresh watermark: display plane %d "
|
|
|
|
"cursor %d\n", srwm, cursor_sr);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2014-06-13 11:54:20 +00:00
|
|
|
cxsr_enabled = true;
|
2012-04-17 01:20:35 +00:00
|
|
|
} else {
|
2014-06-13 11:54:20 +00:00
|
|
|
cxsr_enabled = false;
|
2012-04-17 01:20:35 +00:00
|
|
|
/* Turn off self refresh if both pipes are enabled */
|
2014-07-01 09:36:17 +00:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-17 01:20:35 +00:00
|
|
|
}
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Setting FIFO watermarks - A: 8, B: 8, C: 8, SR %d\n",
|
|
|
|
srwm);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
/* 965 has limitations... */
|
2015-03-10 15:02:21 +00:00
|
|
|
I915_WRITE(DSPFW1, FW_WM(srwm, SR) |
|
|
|
|
FW_WM(8, CURSORB) |
|
|
|
|
FW_WM(8, PLANEB) |
|
|
|
|
FW_WM(8, PLANEA));
|
|
|
|
I915_WRITE(DSPFW2, FW_WM(8, CURSORA) |
|
|
|
|
FW_WM(8, PLANEC_OLD));
|
2012-04-17 01:20:35 +00:00
|
|
|
/* update cursor SR watermark */
|
2015-03-10 15:02:21 +00:00
|
|
|
I915_WRITE(DSPFW3, FW_WM(cursor_sr, CURSOR_SR));
|
2014-06-13 11:54:20 +00:00
|
|
|
|
|
|
|
if (cxsr_enabled)
|
|
|
|
intel_set_memory_cxsr(dev_priv, true);
|
2012-04-17 01:20:35 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 15:02:21 +00:00
|
|
|
#undef FW_WM
|
|
|
|
|
2016-10-31 20:37:03 +00:00
|
|
|
static void i9xx_update_wm(struct intel_crtc *unused_crtc)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2016-10-31 20:37:21 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(unused_crtc->base.dev);
|
2012-04-17 01:20:35 +00:00
|
|
|
const struct intel_watermark_params *wm_info;
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 fwater_lo;
|
|
|
|
u32 fwater_hi;
|
2012-04-17 01:20:35 +00:00
|
|
|
int cwm, srwm = 1;
|
|
|
|
int fifo_size;
|
|
|
|
int planea_wm, planeb_wm;
|
2016-10-31 20:37:04 +00:00
|
|
|
struct intel_crtc *crtc, *enabled = NULL;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2016-10-31 20:37:20 +00:00
|
|
|
if (IS_I945GM(dev_priv))
|
2012-04-17 01:20:35 +00:00
|
|
|
wm_info = &i945_wm_info;
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
else if (!IS_GEN(dev_priv, 2))
|
2012-04-17 01:20:35 +00:00
|
|
|
wm_info = &i915_wm_info;
|
|
|
|
else
|
2014-08-14 22:21:53 +00:00
|
|
|
wm_info = &i830_a_wm_info;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2017-11-17 19:19:11 +00:00
|
|
|
fifo_size = dev_priv->display.get_fifo_size(dev_priv, PLANE_A);
|
|
|
|
crtc = intel_get_crtc_for_plane(dev_priv, PLANE_A);
|
2016-10-31 20:37:04 +00:00
|
|
|
if (intel_crtc_active(crtc)) {
|
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&crtc->config->hw.adjusted_mode;
|
2016-10-31 20:37:04 +00:00
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
crtc->base.primary->state->fb;
|
|
|
|
int cpp;
|
|
|
|
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(dev_priv, 2))
|
2012-10-22 11:32:15 +00:00
|
|
|
cpp = 4;
|
2016-10-31 20:37:04 +00:00
|
|
|
else
|
2016-12-14 21:30:57 +00:00
|
|
|
cpp = fb->format->cpp[0];
|
2012-10-22 11:32:15 +00:00
|
|
|
|
2013-09-25 15:45:37 +00:00
|
|
|
planea_wm = intel_calculate_wm(adjusted_mode->crtc_clock,
|
2012-10-22 11:32:15 +00:00
|
|
|
wm_info, fifo_size, cpp,
|
2014-09-03 10:56:07 +00:00
|
|
|
pessimal_latency_ns);
|
2012-04-17 01:20:35 +00:00
|
|
|
enabled = crtc;
|
2014-08-14 22:21:53 +00:00
|
|
|
} else {
|
2012-04-17 01:20:35 +00:00
|
|
|
planea_wm = fifo_size - wm_info->guard_size;
|
2014-08-14 22:21:53 +00:00
|
|
|
if (planea_wm > (long)wm_info->max_wm)
|
|
|
|
planea_wm = wm_info->max_wm;
|
|
|
|
}
|
|
|
|
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(dev_priv, 2))
|
2014-08-14 22:21:53 +00:00
|
|
|
wm_info = &i830_bc_wm_info;
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2017-11-17 19:19:11 +00:00
|
|
|
fifo_size = dev_priv->display.get_fifo_size(dev_priv, PLANE_B);
|
|
|
|
crtc = intel_get_crtc_for_plane(dev_priv, PLANE_B);
|
2016-10-31 20:37:04 +00:00
|
|
|
if (intel_crtc_active(crtc)) {
|
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&crtc->config->hw.adjusted_mode;
|
2016-10-31 20:37:04 +00:00
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
crtc->base.primary->state->fb;
|
|
|
|
int cpp;
|
|
|
|
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(dev_priv, 2))
|
2012-10-22 11:32:15 +00:00
|
|
|
cpp = 4;
|
2016-10-31 20:37:04 +00:00
|
|
|
else
|
2016-12-14 21:30:57 +00:00
|
|
|
cpp = fb->format->cpp[0];
|
2012-10-22 11:32:15 +00:00
|
|
|
|
2013-09-25 15:45:37 +00:00
|
|
|
planeb_wm = intel_calculate_wm(adjusted_mode->crtc_clock,
|
2012-10-22 11:32:15 +00:00
|
|
|
wm_info, fifo_size, cpp,
|
2014-09-03 10:56:07 +00:00
|
|
|
pessimal_latency_ns);
|
2012-04-17 01:20:35 +00:00
|
|
|
if (enabled == NULL)
|
|
|
|
enabled = crtc;
|
|
|
|
else
|
|
|
|
enabled = NULL;
|
2014-08-14 22:21:53 +00:00
|
|
|
} else {
|
2012-04-17 01:20:35 +00:00
|
|
|
planeb_wm = fifo_size - wm_info->guard_size;
|
2014-08-14 22:21:53 +00:00
|
|
|
if (planeb_wm > (long)wm_info->max_wm)
|
|
|
|
planeb_wm = wm_info->max_wm;
|
|
|
|
}
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"FIFO watermarks - A: %d, B: %d\n", planea_wm, planeb_wm);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
2016-10-13 10:02:58 +00:00
|
|
|
if (IS_I915GM(dev_priv) && enabled) {
|
2014-07-08 14:50:07 +00:00
|
|
|
struct drm_i915_gem_object *obj;
|
2014-04-07 06:54:21 +00:00
|
|
|
|
2016-10-31 20:37:04 +00:00
|
|
|
obj = intel_fb_obj(enabled->base.primary->state->fb);
|
2014-04-07 06:54:21 +00:00
|
|
|
|
|
|
|
/* self-refresh seems busted with untiled */
|
2016-08-05 09:14:23 +00:00
|
|
|
if (!i915_gem_object_is_tiled(obj))
|
2014-04-07 06:54:21 +00:00
|
|
|
enabled = NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
/*
|
|
|
|
* Overlay gets an aggressive default since video jitter is bad.
|
|
|
|
*/
|
|
|
|
cwm = 2;
|
|
|
|
|
|
|
|
/* Play safe and disable self-refresh before adjusting watermarks. */
|
2014-07-01 09:36:17 +00:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
/* Calc sr entries for one plane configs */
|
2016-10-31 20:37:18 +00:00
|
|
|
if (HAS_FW_BLC(dev_priv) && enabled) {
|
2012-04-17 01:20:35 +00:00
|
|
|
/* self-refresh has much higher latency */
|
|
|
|
static const int sr_latency_ns = 6000;
|
2016-10-31 20:37:04 +00:00
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&enabled->config->hw.adjusted_mode;
|
2016-10-31 20:37:04 +00:00
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
enabled->base.primary->state->fb;
|
2013-09-25 15:45:37 +00:00
|
|
|
int clock = adjusted_mode->crtc_clock;
|
2013-11-27 19:10:26 +00:00
|
|
|
int htotal = adjusted_mode->crtc_htotal;
|
2016-10-31 20:37:04 +00:00
|
|
|
int hdisplay = enabled->config->pipe_src_w;
|
|
|
|
int cpp;
|
2012-04-17 01:20:35 +00:00
|
|
|
int entries;
|
|
|
|
|
2016-10-13 10:02:58 +00:00
|
|
|
if (IS_I915GM(dev_priv) || IS_I945GM(dev_priv))
|
2016-07-29 14:57:01 +00:00
|
|
|
cpp = 4;
|
2016-10-31 20:37:04 +00:00
|
|
|
else
|
2016-12-14 21:30:57 +00:00
|
|
|
cpp = fb->format->cpp[0];
|
2016-07-29 14:57:01 +00:00
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
entries = intel_wm_method2(clock, htotal, hdisplay, cpp,
|
|
|
|
sr_latency_ns / 100);
|
2012-04-17 01:20:35 +00:00
|
|
|
entries = DIV_ROUND_UP(entries, wm_info->cacheline_size);
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"self-refresh entries: %d\n", entries);
|
2012-04-17 01:20:35 +00:00
|
|
|
srwm = wm_info->fifo_size - entries;
|
|
|
|
if (srwm < 0)
|
|
|
|
srwm = 1;
|
|
|
|
|
2016-10-13 10:02:58 +00:00
|
|
|
if (IS_I945G(dev_priv) || IS_I945GM(dev_priv))
|
2012-04-17 01:20:35 +00:00
|
|
|
I915_WRITE(FW_BLC_SELF,
|
|
|
|
FW_BLC_SELF_FIFO_MASK | (srwm & 0xff));
|
2016-07-29 14:57:02 +00:00
|
|
|
else
|
2012-04-17 01:20:35 +00:00
|
|
|
I915_WRITE(FW_BLC_SELF, srwm & 0x3f);
|
|
|
|
}
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Setting FIFO watermarks - A: %d, B: %d, C: %d, SR %d\n",
|
|
|
|
planea_wm, planeb_wm, cwm, srwm);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
fwater_lo = ((planeb_wm & 0x3f) << 16) | (planea_wm & 0x3f);
|
|
|
|
fwater_hi = (cwm & 0x1f);
|
|
|
|
|
|
|
|
/* Set request length to 8 cachelines per fetch */
|
|
|
|
fwater_lo = fwater_lo | (1 << 24) | (1 << 8);
|
|
|
|
fwater_hi = fwater_hi | (1 << 8);
|
|
|
|
|
|
|
|
I915_WRITE(FW_BLC, fwater_lo);
|
|
|
|
I915_WRITE(FW_BLC2, fwater_hi);
|
|
|
|
|
2014-07-01 09:36:17 +00:00
|
|
|
if (enabled)
|
|
|
|
intel_set_memory_cxsr(dev_priv, true);
|
2012-04-17 01:20:35 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:03 +00:00
|
|
|
static void i845_update_wm(struct intel_crtc *unused_crtc)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2016-10-31 20:37:21 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(unused_crtc->base.dev);
|
2016-10-31 20:37:04 +00:00
|
|
|
struct intel_crtc *crtc;
|
2013-09-25 15:45:37 +00:00
|
|
|
const struct drm_display_mode *adjusted_mode;
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 fwater_lo;
|
2012-04-17 01:20:35 +00:00
|
|
|
int planea_wm;
|
|
|
|
|
2016-10-31 20:37:21 +00:00
|
|
|
crtc = single_enabled_crtc(dev_priv);
|
2012-04-17 01:20:35 +00:00
|
|
|
if (crtc == NULL)
|
|
|
|
return;
|
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
adjusted_mode = &crtc->config->hw.adjusted_mode;
|
2013-09-25 15:45:37 +00:00
|
|
|
planea_wm = intel_calculate_wm(adjusted_mode->crtc_clock,
|
2013-12-14 22:38:30 +00:00
|
|
|
&i845_wm_info,
|
2017-11-17 19:19:11 +00:00
|
|
|
dev_priv->display.get_fifo_size(dev_priv, PLANE_A),
|
2014-09-03 10:56:07 +00:00
|
|
|
4, pessimal_latency_ns);
|
2012-04-17 01:20:35 +00:00
|
|
|
fwater_lo = I915_READ(FW_BLC) & ~0xfff;
|
|
|
|
fwater_lo |= (3<<8) | planea_wm;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Setting FIFO watermarks - A: %d\n", planea_wm);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
I915_WRITE(FW_BLC, fwater_lo);
|
|
|
|
}
|
|
|
|
|
2013-08-01 13:18:55 +00:00
|
|
|
/* latency must be in 0.1us units. */
|
2017-04-21 18:14:27 +00:00
|
|
|
static unsigned int ilk_wm_method1(unsigned int pixel_rate,
|
|
|
|
unsigned int cpp,
|
|
|
|
unsigned int latency)
|
2013-05-31 13:08:35 +00:00
|
|
|
{
|
2017-04-21 18:14:27 +00:00
|
|
|
unsigned int ret;
|
2013-08-01 13:18:53 +00:00
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
ret = intel_wm_method1(pixel_rate, cpp, latency);
|
|
|
|
ret = DIV_ROUND_UP(ret, 64) + 2;
|
2013-05-31 13:08:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-08-01 13:18:55 +00:00
|
|
|
/* latency must be in 0.1us units. */
|
2017-04-21 18:14:27 +00:00
|
|
|
static unsigned int ilk_wm_method2(unsigned int pixel_rate,
|
|
|
|
unsigned int htotal,
|
|
|
|
unsigned int width,
|
|
|
|
unsigned int cpp,
|
|
|
|
unsigned int latency)
|
2013-05-31 13:08:35 +00:00
|
|
|
{
|
2017-04-21 18:14:27 +00:00
|
|
|
unsigned int ret;
|
2013-08-01 13:18:53 +00:00
|
|
|
|
2017-04-21 18:14:27 +00:00
|
|
|
ret = intel_wm_method2(pixel_rate, htotal,
|
|
|
|
width, cpp, latency);
|
2013-05-31 13:08:35 +00:00
|
|
|
ret = DIV_ROUND_UP(ret, 64) + 2;
|
2017-04-21 18:14:27 +00:00
|
|
|
|
2013-05-31 13:08:35 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
static u32 ilk_wm_fbc(u32 pri_val, u32 horiz_pixels, u8 cpp)
|
2013-05-31 14:45:06 +00:00
|
|
|
{
|
2015-12-03 19:37:40 +00:00
|
|
|
/*
|
|
|
|
* Neither of these should be possible since this function shouldn't be
|
|
|
|
* called if the CRTC is off or the plane is invisible. But let's be
|
|
|
|
* extra paranoid to avoid a potential divide-by-zero if we screw up
|
|
|
|
* elsewhere in the driver.
|
|
|
|
*/
|
2016-01-20 19:05:26 +00:00
|
|
|
if (WARN_ON(!cpp))
|
2015-12-03 19:37:40 +00:00
|
|
|
return 0;
|
|
|
|
if (WARN_ON(!horiz_pixels))
|
|
|
|
return 0;
|
|
|
|
|
2016-01-20 19:05:26 +00:00
|
|
|
return DIV_ROUND_UP(pri_val * 64, horiz_pixels * cpp) + 2;
|
2013-05-31 14:45:06 +00:00
|
|
|
}
|
|
|
|
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_maximums {
|
2019-01-18 12:01:20 +00:00
|
|
|
u16 pri;
|
|
|
|
u16 spr;
|
|
|
|
u16 cur;
|
|
|
|
u16 fbc;
|
2013-05-31 14:45:06 +00:00
|
|
|
};
|
|
|
|
|
2013-08-01 13:18:55 +00:00
|
|
|
/*
|
|
|
|
* For both WM_PIPE and WM_LP.
|
|
|
|
* mem_value must be in 0.1us units.
|
|
|
|
*/
|
2019-06-28 08:55:17 +00:00
|
|
|
static u32 ilk_compute_pri_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 mem_value, bool is_lp)
|
2013-05-31 13:08:35 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 method1, method2;
|
2016-11-18 19:53:00 +00:00
|
|
|
int cpp;
|
2013-05-31 14:45:06 +00:00
|
|
|
|
2018-11-14 17:34:40 +00:00
|
|
|
if (mem_value == 0)
|
|
|
|
return U32_MAX;
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2013-05-31 13:08:35 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-10-31 11:26:07 +00:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2016-11-18 19:53:00 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
method1 = ilk_wm_method1(crtc_state->pixel_rate, cpp, mem_value);
|
2013-05-31 14:45:06 +00:00
|
|
|
|
|
|
|
if (!is_lp)
|
|
|
|
return method1;
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
method2 = ilk_wm_method2(crtc_state->pixel_rate,
|
2019-10-31 11:26:02 +00:00
|
|
|
crtc_state->hw.adjusted_mode.crtc_htotal,
|
2019-10-31 11:26:08 +00:00
|
|
|
drm_rect_width(&plane_state->uapi.dst),
|
2016-01-20 19:05:26 +00:00
|
|
|
cpp, mem_value);
|
2013-05-31 14:45:06 +00:00
|
|
|
|
|
|
|
return min(method1, method2);
|
2013-05-31 13:08:35 +00:00
|
|
|
}
|
|
|
|
|
2013-08-01 13:18:55 +00:00
|
|
|
/*
|
|
|
|
* For both WM_PIPE and WM_LP.
|
|
|
|
* mem_value must be in 0.1us units.
|
|
|
|
*/
|
2019-06-28 08:55:17 +00:00
|
|
|
static u32 ilk_compute_spr_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 mem_value)
|
2013-05-31 13:08:35 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 method1, method2;
|
2016-11-18 19:53:00 +00:00
|
|
|
int cpp;
|
2013-05-31 13:08:35 +00:00
|
|
|
|
2018-11-14 17:34:40 +00:00
|
|
|
if (mem_value == 0)
|
|
|
|
return U32_MAX;
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2013-05-31 13:08:35 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-10-31 11:26:07 +00:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2016-11-18 19:53:00 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
method1 = ilk_wm_method1(crtc_state->pixel_rate, cpp, mem_value);
|
|
|
|
method2 = ilk_wm_method2(crtc_state->pixel_rate,
|
2019-10-31 11:26:02 +00:00
|
|
|
crtc_state->hw.adjusted_mode.crtc_htotal,
|
2019-10-31 11:26:08 +00:00
|
|
|
drm_rect_width(&plane_state->uapi.dst),
|
2016-01-20 19:05:26 +00:00
|
|
|
cpp, mem_value);
|
2013-05-31 13:08:35 +00:00
|
|
|
return min(method1, method2);
|
|
|
|
}
|
|
|
|
|
2013-08-01 13:18:55 +00:00
|
|
|
/*
|
|
|
|
* For both WM_PIPE and WM_LP.
|
|
|
|
* mem_value must be in 0.1us units.
|
|
|
|
*/
|
2019-06-28 08:55:17 +00:00
|
|
|
static u32 ilk_compute_cur_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 mem_value)
|
2013-05-31 13:08:35 +00:00
|
|
|
{
|
2017-02-17 15:01:59 +00:00
|
|
|
int cpp;
|
|
|
|
|
2018-11-14 17:34:40 +00:00
|
|
|
if (mem_value == 0)
|
|
|
|
return U32_MAX;
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2013-05-31 13:08:35 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-10-31 11:26:07 +00:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2017-02-17 15:01:59 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
return ilk_wm_method2(crtc_state->pixel_rate,
|
2019-10-31 11:26:02 +00:00
|
|
|
crtc_state->hw.adjusted_mode.crtc_htotal,
|
2019-10-31 11:26:08 +00:00
|
|
|
drm_rect_width(&plane_state->uapi.dst),
|
2019-10-04 11:34:54 +00:00
|
|
|
cpp, mem_value);
|
2013-05-31 13:08:35 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:45:06 +00:00
|
|
|
/* Only for WM_LP. */
|
2019-06-28 08:55:17 +00:00
|
|
|
static u32 ilk_compute_fbc_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 pri_val)
|
2013-05-31 14:45:06 +00:00
|
|
|
{
|
2016-11-18 19:53:00 +00:00
|
|
|
int cpp;
|
2015-09-24 22:53:07 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2013-05-31 14:45:06 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-10-31 11:26:07 +00:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2016-11-18 19:53:00 +00:00
|
|
|
|
2019-10-31 11:26:08 +00:00
|
|
|
return ilk_wm_fbc(pri_val, drm_rect_width(&plane_state->uapi.dst),
|
|
|
|
cpp);
|
2013-05-31 14:45:06 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
static unsigned int
|
|
|
|
ilk_display_fifo_size(const struct drm_i915_private *dev_priv)
|
2013-08-07 10:28:19 +00:00
|
|
|
{
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 8)
|
2013-11-03 04:07:46 +00:00
|
|
|
return 3072;
|
2016-11-16 08:55:42 +00:00
|
|
|
else if (INTEL_GEN(dev_priv) >= 7)
|
2013-08-07 10:28:19 +00:00
|
|
|
return 768;
|
|
|
|
else
|
|
|
|
return 512;
|
|
|
|
}
|
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
static unsigned int
|
|
|
|
ilk_plane_wm_reg_max(const struct drm_i915_private *dev_priv,
|
|
|
|
int level, bool is_sprite)
|
2014-03-07 16:32:11 +00:00
|
|
|
{
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 8)
|
2014-03-07 16:32:11 +00:00
|
|
|
/* BDW primary/sprite plane watermarks */
|
|
|
|
return level == 0 ? 255 : 2047;
|
2016-11-16 08:55:42 +00:00
|
|
|
else if (INTEL_GEN(dev_priv) >= 7)
|
2014-03-07 16:32:11 +00:00
|
|
|
/* IVB/HSW primary/sprite plane watermarks */
|
|
|
|
return level == 0 ? 127 : 1023;
|
|
|
|
else if (!is_sprite)
|
|
|
|
/* ILK/SNB primary plane watermarks */
|
|
|
|
return level == 0 ? 127 : 511;
|
|
|
|
else
|
|
|
|
/* ILK/SNB sprite plane watermarks */
|
|
|
|
return level == 0 ? 63 : 255;
|
|
|
|
}
|
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
static unsigned int
|
|
|
|
ilk_cursor_wm_reg_max(const struct drm_i915_private *dev_priv, int level)
|
2014-03-07 16:32:11 +00:00
|
|
|
{
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 7)
|
2014-03-07 16:32:11 +00:00
|
|
|
return level == 0 ? 63 : 255;
|
|
|
|
else
|
|
|
|
return level == 0 ? 31 : 63;
|
|
|
|
}
|
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
static unsigned int ilk_fbc_wm_reg_max(const struct drm_i915_private *dev_priv)
|
2014-03-07 16:32:11 +00:00
|
|
|
{
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 8)
|
2014-03-07 16:32:11 +00:00
|
|
|
return 31;
|
|
|
|
else
|
|
|
|
return 15;
|
|
|
|
}
|
|
|
|
|
2013-08-07 10:28:19 +00:00
|
|
|
/* Calculate the maximum primary/sprite plane watermark */
|
2018-12-10 21:54:14 +00:00
|
|
|
static unsigned int ilk_plane_wm_max(const struct drm_i915_private *dev_priv,
|
2013-08-07 10:28:19 +00:00
|
|
|
int level,
|
2013-08-07 10:29:12 +00:00
|
|
|
const struct intel_wm_config *config,
|
2013-08-07 10:28:19 +00:00
|
|
|
enum intel_ddb_partitioning ddb_partitioning,
|
|
|
|
bool is_sprite)
|
|
|
|
{
|
2016-11-16 08:55:42 +00:00
|
|
|
unsigned int fifo_size = ilk_display_fifo_size(dev_priv);
|
2013-08-07 10:28:19 +00:00
|
|
|
|
|
|
|
/* if sprites aren't enabled, sprites get nothing */
|
2013-08-07 10:29:12 +00:00
|
|
|
if (is_sprite && !config->sprites_enabled)
|
2013-08-07 10:28:19 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* HSW allows LP1+ watermarks even with multiple pipes */
|
2013-08-07 10:29:12 +00:00
|
|
|
if (level == 0 || config->num_pipes_active > 1) {
|
2019-09-11 09:26:08 +00:00
|
|
|
fifo_size /= INTEL_NUM_PIPES(dev_priv);
|
2013-08-07 10:28:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For some reason the non self refresh
|
|
|
|
* FIFO size is only half of the self
|
|
|
|
* refresh FIFO size on ILK/SNB.
|
|
|
|
*/
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) <= 6)
|
2013-08-07 10:28:19 +00:00
|
|
|
fifo_size /= 2;
|
|
|
|
}
|
|
|
|
|
2013-08-07 10:29:12 +00:00
|
|
|
if (config->sprites_enabled) {
|
2013-08-07 10:28:19 +00:00
|
|
|
/* level 0 is always calculated with 1:1 split */
|
|
|
|
if (level > 0 && ddb_partitioning == INTEL_DDB_PART_5_6) {
|
|
|
|
if (is_sprite)
|
|
|
|
fifo_size *= 5;
|
|
|
|
fifo_size /= 6;
|
|
|
|
} else {
|
|
|
|
fifo_size /= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clamp to max that the registers can hold */
|
2016-11-16 08:55:42 +00:00
|
|
|
return min(fifo_size, ilk_plane_wm_reg_max(dev_priv, level, is_sprite));
|
2013-08-07 10:28:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate the maximum cursor plane watermark */
|
2018-12-10 21:54:14 +00:00
|
|
|
static unsigned int ilk_cursor_wm_max(const struct drm_i915_private *dev_priv,
|
2013-08-07 10:29:12 +00:00
|
|
|
int level,
|
|
|
|
const struct intel_wm_config *config)
|
2013-08-07 10:28:19 +00:00
|
|
|
{
|
|
|
|
/* HSW LP1+ watermarks w/ multiple pipes */
|
2013-08-07 10:29:12 +00:00
|
|
|
if (level > 0 && config->num_pipes_active > 1)
|
2013-08-07 10:28:19 +00:00
|
|
|
return 64;
|
|
|
|
|
|
|
|
/* otherwise just report max that registers can hold */
|
2018-12-10 21:54:14 +00:00
|
|
|
return ilk_cursor_wm_reg_max(dev_priv, level);
|
2013-08-07 10:28:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
static void ilk_compute_wm_maximums(const struct drm_i915_private *dev_priv,
|
2013-10-09 16:18:09 +00:00
|
|
|
int level,
|
|
|
|
const struct intel_wm_config *config,
|
|
|
|
enum intel_ddb_partitioning ddb_partitioning,
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_maximums *max)
|
2013-08-07 10:28:19 +00:00
|
|
|
{
|
2018-12-10 21:54:14 +00:00
|
|
|
max->pri = ilk_plane_wm_max(dev_priv, level, config, ddb_partitioning, false);
|
|
|
|
max->spr = ilk_plane_wm_max(dev_priv, level, config, ddb_partitioning, true);
|
|
|
|
max->cur = ilk_cursor_wm_max(dev_priv, level, config);
|
|
|
|
max->fbc = ilk_fbc_wm_reg_max(dev_priv);
|
2013-08-07 10:28:19 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
static void ilk_compute_wm_reg_maximums(const struct drm_i915_private *dev_priv,
|
2014-04-28 12:44:56 +00:00
|
|
|
int level,
|
|
|
|
struct ilk_wm_maximums *max)
|
|
|
|
{
|
2016-11-16 08:55:42 +00:00
|
|
|
max->pri = ilk_plane_wm_reg_max(dev_priv, level, false);
|
|
|
|
max->spr = ilk_plane_wm_reg_max(dev_priv, level, true);
|
|
|
|
max->cur = ilk_cursor_wm_reg_max(dev_priv, level);
|
|
|
|
max->fbc = ilk_fbc_wm_reg_max(dev_priv);
|
2014-04-28 12:44:56 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 16:18:10 +00:00
|
|
|
static bool ilk_validate_wm_level(int level,
|
2013-12-17 12:46:36 +00:00
|
|
|
const struct ilk_wm_maximums *max,
|
2013-10-09 16:18:10 +00:00
|
|
|
struct intel_wm_level *result)
|
2013-08-07 10:24:47 +00:00
|
|
|
{
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
/* already determined to be invalid? */
|
|
|
|
if (!result->enable)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
result->enable = result->pri_val <= max->pri &&
|
|
|
|
result->spr_val <= max->spr &&
|
|
|
|
result->cur_val <= max->cur;
|
|
|
|
|
|
|
|
ret = result->enable;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HACK until we can pre-compute everything,
|
|
|
|
* and thus fail gracefully if LP0 watermarks
|
|
|
|
* are exceeded...
|
|
|
|
*/
|
|
|
|
if (level == 0 && !result->enable) {
|
|
|
|
if (result->pri_val > max->pri)
|
|
|
|
DRM_DEBUG_KMS("Primary WM%d too large %u (max %u)\n",
|
|
|
|
level, result->pri_val, max->pri);
|
|
|
|
if (result->spr_val > max->spr)
|
|
|
|
DRM_DEBUG_KMS("Sprite WM%d too large %u (max %u)\n",
|
|
|
|
level, result->spr_val, max->spr);
|
|
|
|
if (result->cur_val > max->cur)
|
|
|
|
DRM_DEBUG_KMS("Cursor WM%d too large %u (max %u)\n",
|
|
|
|
level, result->cur_val, max->cur);
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
result->pri_val = min_t(u32, result->pri_val, max->pri);
|
|
|
|
result->spr_val = min_t(u32, result->spr_val, max->spr);
|
|
|
|
result->cur_val = min_t(u32, result->cur_val, max->cur);
|
2013-08-07 10:24:47 +00:00
|
|
|
result->enable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-01-06 19:17:23 +00:00
|
|
|
static void ilk_compute_wm_level(const struct drm_i915_private *dev_priv,
|
2015-09-24 22:53:07 +00:00
|
|
|
const struct intel_crtc *intel_crtc,
|
2013-08-06 19:24:02 +00:00
|
|
|
int level,
|
2019-06-28 08:55:17 +00:00
|
|
|
struct intel_crtc_state *crtc_state,
|
2017-10-19 15:13:40 +00:00
|
|
|
const struct intel_plane_state *pristate,
|
|
|
|
const struct intel_plane_state *sprstate,
|
|
|
|
const struct intel_plane_state *curstate,
|
2013-08-06 19:24:05 +00:00
|
|
|
struct intel_wm_level *result)
|
2013-08-06 19:24:02 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u16 pri_latency = dev_priv->wm.pri_latency[level];
|
|
|
|
u16 spr_latency = dev_priv->wm.spr_latency[level];
|
|
|
|
u16 cur_latency = dev_priv->wm.cur_latency[level];
|
2013-08-06 19:24:02 +00:00
|
|
|
|
|
|
|
/* WM1+ latency values stored in 0.5us units */
|
|
|
|
if (level > 0) {
|
|
|
|
pri_latency *= 5;
|
|
|
|
spr_latency *= 5;
|
|
|
|
cur_latency *= 5;
|
|
|
|
}
|
|
|
|
|
2016-03-01 10:07:22 +00:00
|
|
|
if (pristate) {
|
2019-06-28 08:55:17 +00:00
|
|
|
result->pri_val = ilk_compute_pri_wm(crtc_state, pristate,
|
2016-03-01 10:07:22 +00:00
|
|
|
pri_latency, level);
|
2019-06-28 08:55:17 +00:00
|
|
|
result->fbc_val = ilk_compute_fbc_wm(crtc_state, pristate, result->pri_val);
|
2016-03-01 10:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sprstate)
|
2019-06-28 08:55:17 +00:00
|
|
|
result->spr_val = ilk_compute_spr_wm(crtc_state, sprstate, spr_latency);
|
2016-03-01 10:07:22 +00:00
|
|
|
|
|
|
|
if (curstate)
|
2019-06-28 08:55:17 +00:00
|
|
|
result->cur_val = ilk_compute_cur_wm(crtc_state, curstate, cur_latency);
|
2016-03-01 10:07:22 +00:00
|
|
|
|
2013-08-06 19:24:02 +00:00
|
|
|
result->enable = true;
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
static u32
|
2019-06-28 08:55:17 +00:00
|
|
|
hsw_compute_linetime_wm(const struct intel_crtc_state *crtc_state)
|
2012-05-09 18:37:24 +00:00
|
|
|
{
|
2016-04-29 14:31:17 +00:00
|
|
|
const struct intel_atomic_state *intel_state =
|
2019-10-31 11:26:03 +00:00
|
|
|
to_intel_atomic_state(crtc_state->uapi.state);
|
2015-12-03 19:37:39 +00:00
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&crtc_state->hw.adjusted_mode;
|
2013-05-03 20:23:43 +00:00
|
|
|
u32 linetime, ips_linetime;
|
2012-05-09 18:37:24 +00:00
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
if (!crtc_state->hw.active)
|
2015-12-03 19:37:39 +00:00
|
|
|
return 0;
|
|
|
|
if (WARN_ON(adjusted_mode->crtc_clock == 0))
|
|
|
|
return 0;
|
2017-01-20 18:21:59 +00:00
|
|
|
if (WARN_ON(intel_state->cdclk.logical.cdclk == 0))
|
2013-05-31 13:08:35 +00:00
|
|
|
return 0;
|
2013-05-09 19:55:50 +00:00
|
|
|
|
2012-05-09 18:37:24 +00:00
|
|
|
/* The WM are computed with base on how long it takes to fill a single
|
|
|
|
* row at the given clock rate, multiplied by 8.
|
|
|
|
* */
|
2015-09-08 10:40:45 +00:00
|
|
|
linetime = DIV_ROUND_CLOSEST(adjusted_mode->crtc_htotal * 1000 * 8,
|
|
|
|
adjusted_mode->crtc_clock);
|
|
|
|
ips_linetime = DIV_ROUND_CLOSEST(adjusted_mode->crtc_htotal * 1000 * 8,
|
2017-01-20 18:21:59 +00:00
|
|
|
intel_state->cdclk.logical.cdclk);
|
2012-05-09 18:37:24 +00:00
|
|
|
|
2013-05-31 13:08:35 +00:00
|
|
|
return PIPE_WM_LINETIME_IPS_LINETIME(ips_linetime) |
|
|
|
|
PIPE_WM_LINETIME_TIME(linetime);
|
2012-05-09 18:37:24 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:24 +00:00
|
|
|
static void intel_read_wm_latency(struct drm_i915_private *dev_priv,
|
2019-01-18 12:01:20 +00:00
|
|
|
u16 wm[8])
|
2013-07-05 08:57:21 +00:00
|
|
|
{
|
2019-06-10 12:06:07 +00:00
|
|
|
struct intel_uncore *uncore = &dev_priv->uncore;
|
|
|
|
|
2017-08-09 20:52:43 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 9) {
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 val;
|
2014-11-04 17:06:47 +00:00
|
|
|
int ret, i;
|
2016-10-13 10:03:10 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2014-11-04 17:06:38 +00:00
|
|
|
|
|
|
|
/* read the first set of memory latencies[0:3] */
|
|
|
|
val = 0; /* data0 to be programmed to 0 for first set */
|
|
|
|
ret = sandybridge_pcode_read(dev_priv,
|
|
|
|
GEN9_PCODE_READ_MEM_LATENCY,
|
2019-05-21 16:40:24 +00:00
|
|
|
&val, NULL);
|
2014-11-04 17:06:38 +00:00
|
|
|
|
|
|
|
if (ret) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"SKL Mailbox read error = %d\n", ret);
|
2014-11-04 17:06:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wm[0] = val & GEN9_MEM_LATENCY_LEVEL_MASK;
|
|
|
|
wm[1] = (val >> GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT) &
|
|
|
|
GEN9_MEM_LATENCY_LEVEL_MASK;
|
|
|
|
wm[2] = (val >> GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT) &
|
|
|
|
GEN9_MEM_LATENCY_LEVEL_MASK;
|
|
|
|
wm[3] = (val >> GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT) &
|
|
|
|
GEN9_MEM_LATENCY_LEVEL_MASK;
|
|
|
|
|
|
|
|
/* read the second set of memory latencies[4:7] */
|
|
|
|
val = 1; /* data0 to be programmed to 1 for second set */
|
|
|
|
ret = sandybridge_pcode_read(dev_priv,
|
|
|
|
GEN9_PCODE_READ_MEM_LATENCY,
|
2019-05-21 16:40:24 +00:00
|
|
|
&val, NULL);
|
2014-11-04 17:06:38 +00:00
|
|
|
if (ret) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"SKL Mailbox read error = %d\n", ret);
|
2014-11-04 17:06:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wm[4] = val & GEN9_MEM_LATENCY_LEVEL_MASK;
|
|
|
|
wm[5] = (val >> GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT) &
|
|
|
|
GEN9_MEM_LATENCY_LEVEL_MASK;
|
|
|
|
wm[6] = (val >> GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT) &
|
|
|
|
GEN9_MEM_LATENCY_LEVEL_MASK;
|
|
|
|
wm[7] = (val >> GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT) &
|
|
|
|
GEN9_MEM_LATENCY_LEVEL_MASK;
|
|
|
|
|
2016-09-22 21:00:30 +00:00
|
|
|
/*
|
|
|
|
* If a level n (n > 1) has a 0us latency, all levels m (m >= n)
|
|
|
|
* need to be disabled. We make sure to sanitize the values out
|
|
|
|
* of the punit to satisfy this requirement.
|
|
|
|
*/
|
|
|
|
for (level = 1; level <= max_level; level++) {
|
|
|
|
if (wm[level] == 0) {
|
|
|
|
for (i = level + 1; i <= max_level; i++)
|
|
|
|
wm[i] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-04 17:06:46 +00:00
|
|
|
/*
|
2017-08-09 20:52:43 +00:00
|
|
|
* WaWmMemoryReadLatency:skl+,glk
|
2015-02-09 19:33:07 +00:00
|
|
|
*
|
2014-11-04 17:06:46 +00:00
|
|
|
* punit doesn't take into account the read latency so we need
|
2016-09-22 21:00:30 +00:00
|
|
|
* to add 2us to the various latency levels we retrieve from the
|
|
|
|
* punit when level 0 response data us 0us.
|
2014-11-04 17:06:46 +00:00
|
|
|
*/
|
2016-09-22 21:00:30 +00:00
|
|
|
if (wm[0] == 0) {
|
|
|
|
wm[0] += 2;
|
|
|
|
for (level = 1; level <= max_level; level++) {
|
|
|
|
if (wm[level] == 0)
|
|
|
|
break;
|
2014-11-04 17:06:46 +00:00
|
|
|
wm[level] += 2;
|
2014-11-04 17:06:47 +00:00
|
|
|
}
|
2016-09-22 21:00:30 +00:00
|
|
|
}
|
|
|
|
|
2018-08-31 11:09:42 +00:00
|
|
|
/*
|
|
|
|
* WA Level-0 adjustment for 16GB DIMMs: SKL+
|
|
|
|
* If we could not get dimm info enable this WA to prevent from
|
|
|
|
* any underrun. If not able to get Dimm info assume 16GB dimm
|
|
|
|
* to avoid any underrun.
|
|
|
|
*/
|
2018-10-23 18:21:02 +00:00
|
|
|
if (dev_priv->dram_info.is_16gb_dimm)
|
2018-08-31 11:09:42 +00:00
|
|
|
wm[0] += 1;
|
|
|
|
|
2016-10-13 10:03:00 +00:00
|
|
|
} else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
|
2019-06-10 12:06:07 +00:00
|
|
|
u64 sskpd = intel_uncore_read64(uncore, MCH_SSKPD);
|
2013-07-05 08:57:21 +00:00
|
|
|
|
|
|
|
wm[0] = (sskpd >> 56) & 0xFF;
|
|
|
|
if (wm[0] == 0)
|
|
|
|
wm[0] = sskpd & 0xF;
|
2013-07-05 08:57:22 +00:00
|
|
|
wm[1] = (sskpd >> 4) & 0xFF;
|
|
|
|
wm[2] = (sskpd >> 12) & 0xFF;
|
|
|
|
wm[3] = (sskpd >> 20) & 0x1FF;
|
|
|
|
wm[4] = (sskpd >> 32) & 0x1FF;
|
2016-10-31 20:37:24 +00:00
|
|
|
} else if (INTEL_GEN(dev_priv) >= 6) {
|
2019-06-10 12:06:07 +00:00
|
|
|
u32 sskpd = intel_uncore_read(uncore, MCH_SSKPD);
|
2013-07-05 08:57:23 +00:00
|
|
|
|
|
|
|
wm[0] = (sskpd >> SSKPD_WM0_SHIFT) & SSKPD_WM_MASK;
|
|
|
|
wm[1] = (sskpd >> SSKPD_WM1_SHIFT) & SSKPD_WM_MASK;
|
|
|
|
wm[2] = (sskpd >> SSKPD_WM2_SHIFT) & SSKPD_WM_MASK;
|
|
|
|
wm[3] = (sskpd >> SSKPD_WM3_SHIFT) & SSKPD_WM_MASK;
|
2016-10-31 20:37:24 +00:00
|
|
|
} else if (INTEL_GEN(dev_priv) >= 5) {
|
2019-06-10 12:06:07 +00:00
|
|
|
u32 mltr = intel_uncore_read(uncore, MLTR_ILK);
|
2013-08-01 13:18:49 +00:00
|
|
|
|
|
|
|
/* ILK primary LP0 latency is 700 ns */
|
|
|
|
wm[0] = 7;
|
|
|
|
wm[1] = (mltr >> MLTR_WM1_SHIFT) & ILK_SRLT_MASK;
|
|
|
|
wm[2] = (mltr >> MLTR_WM2_SHIFT) & ILK_SRLT_MASK;
|
2017-08-09 20:52:43 +00:00
|
|
|
} else {
|
|
|
|
MISSING_CASE(INTEL_DEVID(dev_priv));
|
2013-07-05 08:57:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-13 10:03:10 +00:00
|
|
|
static void intel_fixup_spr_wm_latency(struct drm_i915_private *dev_priv,
|
2019-01-18 12:01:20 +00:00
|
|
|
u16 wm[5])
|
2013-08-01 13:18:50 +00:00
|
|
|
{
|
|
|
|
/* ILK sprite LP0 latency is 1300 ns */
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(dev_priv, 5))
|
2013-08-01 13:18:50 +00:00
|
|
|
wm[0] = 13;
|
|
|
|
}
|
|
|
|
|
2016-10-14 09:13:06 +00:00
|
|
|
static void intel_fixup_cur_wm_latency(struct drm_i915_private *dev_priv,
|
2019-01-18 12:01:20 +00:00
|
|
|
u16 wm[5])
|
2013-08-01 13:18:50 +00:00
|
|
|
{
|
|
|
|
/* ILK cursor LP0 latency is 1300 ns */
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(dev_priv, 5))
|
2013-08-01 13:18:50 +00:00
|
|
|
wm[0] = 13;
|
|
|
|
}
|
|
|
|
|
2016-10-13 10:03:10 +00:00
|
|
|
int ilk_wm_max_level(const struct drm_i915_private *dev_priv)
|
2013-08-01 13:18:52 +00:00
|
|
|
{
|
|
|
|
/* how many WM levels are we expecting */
|
2016-10-13 10:03:00 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 9)
|
2014-11-04 17:06:38 +00:00
|
|
|
return 7;
|
2016-10-13 10:03:00 +00:00
|
|
|
else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
|
2013-08-30 11:30:25 +00:00
|
|
|
return 4;
|
2016-10-13 10:03:00 +00:00
|
|
|
else if (INTEL_GEN(dev_priv) >= 6)
|
2013-08-30 11:30:25 +00:00
|
|
|
return 3;
|
2013-08-01 13:18:52 +00:00
|
|
|
else
|
2013-08-30 11:30:25 +00:00
|
|
|
return 2;
|
|
|
|
}
|
2014-09-29 13:07:19 +00:00
|
|
|
|
2016-10-13 10:03:10 +00:00
|
|
|
static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
|
2013-08-30 11:30:25 +00:00
|
|
|
const char *name,
|
2019-01-18 12:01:20 +00:00
|
|
|
const u16 wm[8])
|
2013-08-30 11:30:25 +00:00
|
|
|
{
|
2016-10-13 10:03:10 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2013-08-01 13:18:52 +00:00
|
|
|
|
|
|
|
for (level = 0; level <= max_level; level++) {
|
|
|
|
unsigned int latency = wm[level];
|
|
|
|
|
|
|
|
if (latency == 0) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"%s WM%d latency not provided\n",
|
|
|
|
name, level);
|
2013-08-01 13:18:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-11-04 17:06:38 +00:00
|
|
|
/*
|
|
|
|
* - latencies are in us on gen9.
|
|
|
|
* - before then, WM1+ latency values are in 0.5us units
|
|
|
|
*/
|
2017-08-09 20:52:46 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 9)
|
2014-11-04 17:06:38 +00:00
|
|
|
latency *= 10;
|
|
|
|
else if (level > 0)
|
2013-08-01 13:18:52 +00:00
|
|
|
latency *= 5;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"%s WM%d latency %u (%u.%u usec)\n", name, level,
|
|
|
|
wm[level], latency / 10, latency % 10);
|
2013-08-01 13:18:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-08 12:09:19 +00:00
|
|
|
static bool ilk_increase_wm_latency(struct drm_i915_private *dev_priv,
|
2019-01-18 12:01:20 +00:00
|
|
|
u16 wm[5], u16 min)
|
2014-05-08 12:09:19 +00:00
|
|
|
{
|
2016-10-13 10:03:10 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2014-05-08 12:09:19 +00:00
|
|
|
|
|
|
|
if (wm[0] >= min)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
wm[0] = max(wm[0], min);
|
|
|
|
for (level = 1; level <= max_level; level++)
|
2019-01-18 12:01:20 +00:00
|
|
|
wm[level] = max_t(u16, wm[level], DIV_ROUND_UP(min, 5));
|
2014-05-08 12:09:19 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:24 +00:00
|
|
|
static void snb_wm_latency_quirk(struct drm_i915_private *dev_priv)
|
2014-05-08 12:09:19 +00:00
|
|
|
{
|
|
|
|
bool changed;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The BIOS provided WM memory latency values are often
|
|
|
|
* inadequate for high resolution displays. Adjust them.
|
|
|
|
*/
|
|
|
|
changed = ilk_increase_wm_latency(dev_priv, dev_priv->wm.pri_latency, 12) |
|
|
|
|
ilk_increase_wm_latency(dev_priv, dev_priv->wm.spr_latency, 12) |
|
|
|
|
ilk_increase_wm_latency(dev_priv, dev_priv->wm.cur_latency, 12);
|
|
|
|
|
|
|
|
if (!changed)
|
|
|
|
return;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"WM latency values increased to avoid potential underruns\n");
|
2016-10-13 10:03:10 +00:00
|
|
|
intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency);
|
|
|
|
intel_print_wm_latency(dev_priv, "Sprite", dev_priv->wm.spr_latency);
|
|
|
|
intel_print_wm_latency(dev_priv, "Cursor", dev_priv->wm.cur_latency);
|
2014-05-08 12:09:19 +00:00
|
|
|
}
|
|
|
|
|
2018-11-14 17:34:40 +00:00
|
|
|
static void snb_wm_lp3_irq_quirk(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* On some SNB machines (Thinkpad X220 Tablet at least)
|
|
|
|
* LP3 usage can cause vblank interrupts to be lost.
|
|
|
|
* The DEIIR bit will go high but it looks like the CPU
|
|
|
|
* never gets interrupted.
|
|
|
|
*
|
|
|
|
* It's not clear whether other interrupt source could
|
|
|
|
* be affected or if this is somehow limited to vblank
|
|
|
|
* interrupts only. To play it safe we disable LP3
|
|
|
|
* watermarks entirely.
|
|
|
|
*/
|
|
|
|
if (dev_priv->wm.pri_latency[3] == 0 &&
|
|
|
|
dev_priv->wm.spr_latency[3] == 0 &&
|
|
|
|
dev_priv->wm.cur_latency[3] == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dev_priv->wm.pri_latency[3] = 0;
|
|
|
|
dev_priv->wm.spr_latency[3] = 0;
|
|
|
|
dev_priv->wm.cur_latency[3] = 0;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"LP3 watermarks disabled due to potential for lost interrupts\n");
|
2018-11-14 17:34:40 +00:00
|
|
|
intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency);
|
|
|
|
intel_print_wm_latency(dev_priv, "Sprite", dev_priv->wm.spr_latency);
|
|
|
|
intel_print_wm_latency(dev_priv, "Cursor", dev_priv->wm.cur_latency);
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:24 +00:00
|
|
|
static void ilk_setup_wm_latency(struct drm_i915_private *dev_priv)
|
2013-08-01 13:18:50 +00:00
|
|
|
{
|
2016-10-31 20:37:24 +00:00
|
|
|
intel_read_wm_latency(dev_priv, dev_priv->wm.pri_latency);
|
2013-08-01 13:18:50 +00:00
|
|
|
|
|
|
|
memcpy(dev_priv->wm.spr_latency, dev_priv->wm.pri_latency,
|
|
|
|
sizeof(dev_priv->wm.pri_latency));
|
|
|
|
memcpy(dev_priv->wm.cur_latency, dev_priv->wm.pri_latency,
|
|
|
|
sizeof(dev_priv->wm.pri_latency));
|
|
|
|
|
2016-10-13 10:03:10 +00:00
|
|
|
intel_fixup_spr_wm_latency(dev_priv, dev_priv->wm.spr_latency);
|
2016-10-14 09:13:06 +00:00
|
|
|
intel_fixup_cur_wm_latency(dev_priv, dev_priv->wm.cur_latency);
|
2013-08-01 13:18:52 +00:00
|
|
|
|
2016-10-13 10:03:10 +00:00
|
|
|
intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency);
|
|
|
|
intel_print_wm_latency(dev_priv, "Sprite", dev_priv->wm.spr_latency);
|
|
|
|
intel_print_wm_latency(dev_priv, "Cursor", dev_priv->wm.cur_latency);
|
2014-05-08 12:09:19 +00:00
|
|
|
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(dev_priv, 6)) {
|
2016-10-31 20:37:24 +00:00
|
|
|
snb_wm_latency_quirk(dev_priv);
|
2018-11-14 17:34:40 +00:00
|
|
|
snb_wm_lp3_irq_quirk(dev_priv);
|
|
|
|
}
|
2013-08-01 13:18:50 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:24 +00:00
|
|
|
static void skl_setup_wm_latency(struct drm_i915_private *dev_priv)
|
2014-11-04 17:06:38 +00:00
|
|
|
{
|
2016-10-31 20:37:24 +00:00
|
|
|
intel_read_wm_latency(dev_priv, dev_priv->wm.skl_latency);
|
2016-10-13 10:03:10 +00:00
|
|
|
intel_print_wm_latency(dev_priv, "Gen9 Plane", dev_priv->wm.skl_latency);
|
2014-11-04 17:06:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
static bool ilk_validate_pipe_wm(const struct drm_i915_private *dev_priv,
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
struct intel_pipe_wm *pipe_wm)
|
|
|
|
{
|
|
|
|
/* LP0 watermark maximums depend on this pipe alone */
|
|
|
|
const struct intel_wm_config config = {
|
|
|
|
.num_pipes_active = 1,
|
|
|
|
.sprites_enabled = pipe_wm->sprites_enabled,
|
|
|
|
.sprites_scaled = pipe_wm->sprites_scaled,
|
|
|
|
};
|
|
|
|
struct ilk_wm_maximums max;
|
|
|
|
|
|
|
|
/* LP0 watermarks always use 1/2 DDB partitioning */
|
2018-12-10 21:54:14 +00:00
|
|
|
ilk_compute_wm_maximums(dev_priv, 0, &config, INTEL_DDB_PART_1_2, &max);
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
|
|
|
|
/* At least LP0 must be valid */
|
|
|
|
if (!ilk_validate_wm_level(0, &max, &pipe_wm->wm[0])) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "LP0 watermark invalid\n");
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-09 16:17:55 +00:00
|
|
|
/* Compute new watermarks for the pipe */
|
2019-06-28 08:55:17 +00:00
|
|
|
static int ilk_compute_pipe_wm(struct intel_crtc_state *crtc_state)
|
2013-10-09 16:17:55 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
|
|
|
struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2015-09-24 22:53:16 +00:00
|
|
|
struct intel_pipe_wm *pipe_wm;
|
2019-10-04 11:34:53 +00:00
|
|
|
struct intel_plane *plane;
|
|
|
|
const struct intel_plane_state *plane_state;
|
2017-10-19 15:13:40 +00:00
|
|
|
const struct intel_plane_state *pristate = NULL;
|
|
|
|
const struct intel_plane_state *sprstate = NULL;
|
|
|
|
const struct intel_plane_state *curstate = NULL;
|
2016-10-13 10:03:10 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv), usable_level;
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_maximums max;
|
2013-10-09 16:17:55 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
pipe_wm = &crtc_state->wm.ilk.optimal;
|
2015-09-24 22:53:16 +00:00
|
|
|
|
2019-10-04 11:34:53 +00:00
|
|
|
intel_atomic_crtc_state_for_each_plane_state(plane, plane_state, crtc_state) {
|
|
|
|
if (plane->base.type == DRM_PLANE_TYPE_PRIMARY)
|
|
|
|
pristate = plane_state;
|
|
|
|
else if (plane->base.type == DRM_PLANE_TYPE_OVERLAY)
|
|
|
|
sprstate = plane_state;
|
|
|
|
else if (plane->base.type == DRM_PLANE_TYPE_CURSOR)
|
|
|
|
curstate = plane_state;
|
2015-09-24 22:53:07 +00:00
|
|
|
}
|
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
pipe_wm->pipe_enabled = crtc_state->hw.active;
|
2016-03-01 10:07:22 +00:00
|
|
|
if (sprstate) {
|
2019-10-31 11:26:08 +00:00
|
|
|
pipe_wm->sprites_enabled = sprstate->uapi.visible;
|
|
|
|
pipe_wm->sprites_scaled = sprstate->uapi.visible &&
|
|
|
|
(drm_rect_width(&sprstate->uapi.dst) != drm_rect_width(&sprstate->uapi.src) >> 16 ||
|
|
|
|
drm_rect_height(&sprstate->uapi.dst) != drm_rect_height(&sprstate->uapi.src) >> 16);
|
2016-03-01 10:07:22 +00:00
|
|
|
}
|
|
|
|
|
2016-03-02 11:38:06 +00:00
|
|
|
usable_level = max_level;
|
|
|
|
|
2013-12-05 13:51:30 +00:00
|
|
|
/* ILK/SNB: LP2+ watermarks only w/o sprites */
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) <= 6 && pipe_wm->sprites_enabled)
|
2016-03-02 11:38:06 +00:00
|
|
|
usable_level = 1;
|
2013-12-05 13:51:30 +00:00
|
|
|
|
|
|
|
/* ILK/SNB/IVB: LP1+ watermarks only w/o scaling */
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
if (pipe_wm->sprites_scaled)
|
2016-03-02 11:38:06 +00:00
|
|
|
usable_level = 0;
|
2013-12-05 13:51:30 +00:00
|
|
|
|
2016-03-08 09:57:16 +00:00
|
|
|
memset(&pipe_wm->wm, 0, sizeof(pipe_wm->wm));
|
2019-06-28 08:55:17 +00:00
|
|
|
ilk_compute_wm_level(dev_priv, intel_crtc, 0, crtc_state,
|
2017-10-19 15:13:40 +00:00
|
|
|
pristate, sprstate, curstate, &pipe_wm->wm[0]);
|
2013-10-09 16:17:55 +00:00
|
|
|
|
2016-10-13 10:03:00 +00:00
|
|
|
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
|
2019-06-28 08:55:17 +00:00
|
|
|
pipe_wm->linetime = hsw_compute_linetime_wm(crtc_state);
|
2013-10-09 16:17:55 +00:00
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
if (!ilk_validate_pipe_wm(dev_priv, pipe_wm))
|
2016-03-02 11:36:03 +00:00
|
|
|
return -EINVAL;
|
2014-04-28 12:44:56 +00:00
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
ilk_compute_wm_reg_maximums(dev_priv, 1, &max);
|
2014-04-28 12:44:56 +00:00
|
|
|
|
2017-10-19 15:13:40 +00:00
|
|
|
for (level = 1; level <= usable_level; level++) {
|
|
|
|
struct intel_wm_level *wm = &pipe_wm->wm[level];
|
2014-04-28 12:44:56 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
ilk_compute_wm_level(dev_priv, intel_crtc, level, crtc_state,
|
2016-03-02 11:38:06 +00:00
|
|
|
pristate, sprstate, curstate, wm);
|
2014-04-28 12:44:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable any watermark level that exceeds the
|
|
|
|
* register maximums since such watermarks are
|
|
|
|
* always invalid.
|
|
|
|
*/
|
2017-10-19 15:13:40 +00:00
|
|
|
if (!ilk_validate_wm_level(level, &max, wm)) {
|
|
|
|
memset(wm, 0, sizeof(*wm));
|
|
|
|
break;
|
|
|
|
}
|
2014-04-28 12:44:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 22:53:16 +00:00
|
|
|
return 0;
|
2013-10-09 16:17:55 +00:00
|
|
|
}
|
|
|
|
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
/*
|
|
|
|
* Build a set of 'intermediate' watermark values that satisfy both the old
|
|
|
|
* state and the new state. These can be programmed to the hardware
|
|
|
|
* immediately.
|
|
|
|
*/
|
2018-12-10 21:54:14 +00:00
|
|
|
static int ilk_compute_intermediate_wm(struct intel_crtc_state *newstate)
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_crtc *intel_crtc = to_intel_crtc(newstate->uapi.crtc);
|
2018-12-10 21:54:14 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev);
|
2016-05-12 14:05:55 +00:00
|
|
|
struct intel_pipe_wm *a = &newstate->wm.ilk.intermediate;
|
2017-10-19 15:13:41 +00:00
|
|
|
struct intel_atomic_state *intel_state =
|
2019-10-31 11:26:03 +00:00
|
|
|
to_intel_atomic_state(newstate->uapi.state);
|
2017-10-19 15:13:41 +00:00
|
|
|
const struct intel_crtc_state *oldstate =
|
|
|
|
intel_atomic_get_old_crtc_state(intel_state, intel_crtc);
|
|
|
|
const struct intel_pipe_wm *b = &oldstate->wm.ilk.optimal;
|
2018-12-10 21:54:14 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start with the final, target watermarks, then combine with the
|
|
|
|
* currently active watermarks to get values that are safe both before
|
|
|
|
* and after the vblank.
|
|
|
|
*/
|
2016-05-12 14:05:55 +00:00
|
|
|
*a = newstate->wm.ilk.optimal;
|
2019-10-31 11:26:03 +00:00
|
|
|
if (!newstate->hw.active || drm_atomic_crtc_needs_modeset(&newstate->uapi) ||
|
2018-11-08 15:10:13 +00:00
|
|
|
intel_state->skip_intermediate_wm)
|
2017-10-19 15:13:41 +00:00
|
|
|
return 0;
|
|
|
|
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
a->pipe_enabled |= b->pipe_enabled;
|
|
|
|
a->sprites_enabled |= b->sprites_enabled;
|
|
|
|
a->sprites_scaled |= b->sprites_scaled;
|
|
|
|
|
|
|
|
for (level = 0; level <= max_level; level++) {
|
|
|
|
struct intel_wm_level *a_wm = &a->wm[level];
|
|
|
|
const struct intel_wm_level *b_wm = &b->wm[level];
|
|
|
|
|
|
|
|
a_wm->enable &= b_wm->enable;
|
|
|
|
a_wm->pri_val = max(a_wm->pri_val, b_wm->pri_val);
|
|
|
|
a_wm->spr_val = max(a_wm->spr_val, b_wm->spr_val);
|
|
|
|
a_wm->cur_val = max(a_wm->cur_val, b_wm->cur_val);
|
|
|
|
a_wm->fbc_val = max(a_wm->fbc_val, b_wm->fbc_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to make sure that these merged watermark values are
|
|
|
|
* actually a valid configuration themselves. If they're not,
|
|
|
|
* there's no safe way to transition from the old state to
|
|
|
|
* the new state, so we need to fail the atomic transaction.
|
|
|
|
*/
|
2018-12-10 21:54:14 +00:00
|
|
|
if (!ilk_validate_pipe_wm(dev_priv, a))
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If our intermediate WM are identical to the final WM, then we can
|
|
|
|
* omit the post-vblank programming; only update if it's different.
|
|
|
|
*/
|
2017-03-02 17:15:00 +00:00
|
|
|
if (memcmp(a, &newstate->wm.ilk.optimal, sizeof(*a)) != 0)
|
|
|
|
newstate->wm.need_postvbl_update = true;
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-09 16:17:55 +00:00
|
|
|
/*
|
|
|
|
* Merge the watermarks from all active pipes for a specific level.
|
|
|
|
*/
|
2018-12-10 21:54:14 +00:00
|
|
|
static void ilk_merge_wm_level(struct drm_i915_private *dev_priv,
|
2013-10-09 16:17:55 +00:00
|
|
|
int level,
|
|
|
|
struct intel_wm_level *ret_wm)
|
|
|
|
{
|
|
|
|
const struct intel_crtc *intel_crtc;
|
|
|
|
|
2014-04-28 12:44:57 +00:00
|
|
|
ret_wm->enable = true;
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, intel_crtc) {
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
const struct intel_pipe_wm *active = &intel_crtc->wm.active.ilk;
|
2014-03-07 16:32:10 +00:00
|
|
|
const struct intel_wm_level *wm = &active->wm[level];
|
|
|
|
|
|
|
|
if (!active->pipe_enabled)
|
|
|
|
continue;
|
2013-10-09 16:17:55 +00:00
|
|
|
|
2014-04-28 12:44:57 +00:00
|
|
|
/*
|
|
|
|
* The watermark values may have been used in the past,
|
|
|
|
* so we must maintain them in the registers for some
|
|
|
|
* time even if the level is now disabled.
|
|
|
|
*/
|
2013-10-09 16:17:55 +00:00
|
|
|
if (!wm->enable)
|
2014-04-28 12:44:57 +00:00
|
|
|
ret_wm->enable = false;
|
2013-10-09 16:17:55 +00:00
|
|
|
|
|
|
|
ret_wm->pri_val = max(ret_wm->pri_val, wm->pri_val);
|
|
|
|
ret_wm->spr_val = max(ret_wm->spr_val, wm->spr_val);
|
|
|
|
ret_wm->cur_val = max(ret_wm->cur_val, wm->cur_val);
|
|
|
|
ret_wm->fbc_val = max(ret_wm->fbc_val, wm->fbc_val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Merge all low power watermarks for all active pipes.
|
|
|
|
*/
|
2018-12-10 21:54:14 +00:00
|
|
|
static void ilk_wm_merge(struct drm_i915_private *dev_priv,
|
2013-12-05 13:51:34 +00:00
|
|
|
const struct intel_wm_config *config,
|
2013-12-17 12:46:36 +00:00
|
|
|
const struct ilk_wm_maximums *max,
|
2013-10-09 16:17:55 +00:00
|
|
|
struct intel_pipe_wm *merged)
|
|
|
|
{
|
2016-10-13 10:03:10 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2014-04-28 12:44:57 +00:00
|
|
|
int last_enabled_level = max_level;
|
2013-10-09 16:17:55 +00:00
|
|
|
|
2013-12-05 13:51:34 +00:00
|
|
|
/* ILK/SNB/IVB: LP1+ watermarks only w/ single pipe */
|
2016-10-14 09:13:06 +00:00
|
|
|
if ((INTEL_GEN(dev_priv) <= 6 || IS_IVYBRIDGE(dev_priv)) &&
|
2013-12-05 13:51:34 +00:00
|
|
|
config->num_pipes_active > 1)
|
2016-04-01 18:53:18 +00:00
|
|
|
last_enabled_level = 0;
|
2013-12-05 13:51:34 +00:00
|
|
|
|
2013-12-05 13:51:35 +00:00
|
|
|
/* ILK: FBC WM must be disabled always */
|
2016-11-16 08:55:42 +00:00
|
|
|
merged->fbc_wm_enabled = INTEL_GEN(dev_priv) >= 6;
|
2013-10-09 16:17:55 +00:00
|
|
|
|
|
|
|
/* merge each WM1+ level */
|
|
|
|
for (level = 1; level <= max_level; level++) {
|
|
|
|
struct intel_wm_level *wm = &merged->wm[level];
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
ilk_merge_wm_level(dev_priv, level, wm);
|
2013-10-09 16:17:55 +00:00
|
|
|
|
2014-04-28 12:44:57 +00:00
|
|
|
if (level > last_enabled_level)
|
|
|
|
wm->enable = false;
|
|
|
|
else if (!ilk_validate_wm_level(level, max, wm))
|
|
|
|
/* make sure all following levels get disabled */
|
|
|
|
last_enabled_level = level - 1;
|
2013-10-09 16:17:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The spec says it is preferred to disable
|
|
|
|
* FBC WMs instead of disabling a WM level.
|
|
|
|
*/
|
|
|
|
if (wm->fbc_val > max->fbc) {
|
2014-04-28 12:44:57 +00:00
|
|
|
if (wm->enable)
|
|
|
|
merged->fbc_wm_enabled = false;
|
2013-10-09 16:17:55 +00:00
|
|
|
wm->fbc_val = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-12-05 13:51:35 +00:00
|
|
|
|
|
|
|
/* ILK: LP2+ must be disabled when FBC WM is disabled but FBC enabled */
|
|
|
|
/*
|
|
|
|
* FIXME this is racy. FBC might get enabled later.
|
|
|
|
* What we should check here is whether FBC can be
|
|
|
|
* enabled sometime later.
|
|
|
|
*/
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(dev_priv, 5) && !merged->fbc_wm_enabled &&
|
2015-10-14 20:45:36 +00:00
|
|
|
intel_fbc_is_active(dev_priv)) {
|
2013-12-05 13:51:35 +00:00
|
|
|
for (level = 2; level <= max_level; level++) {
|
|
|
|
struct intel_wm_level *wm = &merged->wm[level];
|
|
|
|
|
|
|
|
wm->enable = false;
|
|
|
|
}
|
|
|
|
}
|
2013-10-09 16:17:55 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 16:18:01 +00:00
|
|
|
static int ilk_wm_lp_to_level(int wm_lp, const struct intel_pipe_wm *pipe_wm)
|
|
|
|
{
|
|
|
|
/* LP1,LP2,LP3 levels are either 1,2,3 or 1,3,4 */
|
|
|
|
return wm_lp + (wm_lp >= 2 && pipe_wm->wm[4].enable);
|
|
|
|
}
|
|
|
|
|
2013-12-05 13:51:29 +00:00
|
|
|
/* The value we need to program into the WM_LPx latency field */
|
2018-12-10 21:54:14 +00:00
|
|
|
static unsigned int ilk_wm_lp_latency(struct drm_i915_private *dev_priv,
|
|
|
|
int level)
|
2013-12-05 13:51:29 +00:00
|
|
|
{
|
2016-10-13 10:03:00 +00:00
|
|
|
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
|
2013-12-05 13:51:29 +00:00
|
|
|
return 2 * level;
|
|
|
|
else
|
|
|
|
return dev_priv->wm.pri_latency[level];
|
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
static void ilk_compute_wm_results(struct drm_i915_private *dev_priv,
|
2013-10-09 16:17:57 +00:00
|
|
|
const struct intel_pipe_wm *merged,
|
2013-10-09 16:18:03 +00:00
|
|
|
enum intel_ddb_partitioning partitioning,
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_values *results)
|
2013-05-31 13:08:35 +00:00
|
|
|
{
|
2013-10-09 16:17:55 +00:00
|
|
|
struct intel_crtc *intel_crtc;
|
|
|
|
int level, wm_lp;
|
2013-05-31 14:45:06 +00:00
|
|
|
|
2013-10-09 16:17:57 +00:00
|
|
|
results->enable_fbc_wm = merged->fbc_wm_enabled;
|
2013-10-09 16:18:03 +00:00
|
|
|
results->partitioning = partitioning;
|
2013-05-31 14:45:06 +00:00
|
|
|
|
2013-10-09 16:17:55 +00:00
|
|
|
/* LP1+ register values */
|
2013-05-31 14:45:06 +00:00
|
|
|
for (wm_lp = 1; wm_lp <= 3; wm_lp++) {
|
2013-08-06 19:24:05 +00:00
|
|
|
const struct intel_wm_level *r;
|
2013-05-31 13:08:35 +00:00
|
|
|
|
2013-10-09 16:18:01 +00:00
|
|
|
level = ilk_wm_lp_to_level(wm_lp, merged);
|
2013-10-09 16:17:55 +00:00
|
|
|
|
2013-10-09 16:17:57 +00:00
|
|
|
r = &merged->wm[level];
|
2013-05-31 14:45:06 +00:00
|
|
|
|
2014-04-28 12:44:57 +00:00
|
|
|
/*
|
|
|
|
* Maintain the watermark values even if the level is
|
|
|
|
* disabled. Doing otherwise could cause underruns.
|
|
|
|
*/
|
|
|
|
results->wm_lp[wm_lp - 1] =
|
2018-12-10 21:54:14 +00:00
|
|
|
(ilk_wm_lp_latency(dev_priv, level) << WM1_LP_LATENCY_SHIFT) |
|
2013-11-03 04:07:46 +00:00
|
|
|
(r->pri_val << WM1_LP_SR_SHIFT) |
|
|
|
|
r->cur_val;
|
|
|
|
|
2014-04-28 12:44:57 +00:00
|
|
|
if (r->enable)
|
|
|
|
results->wm_lp[wm_lp - 1] |= WM1_LP_SR_EN;
|
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 8)
|
2013-11-03 04:07:46 +00:00
|
|
|
results->wm_lp[wm_lp - 1] |=
|
|
|
|
r->fbc_val << WM1_LP_FBC_SHIFT_BDW;
|
|
|
|
else
|
|
|
|
results->wm_lp[wm_lp - 1] |=
|
|
|
|
r->fbc_val << WM1_LP_FBC_SHIFT;
|
|
|
|
|
2014-04-28 12:44:57 +00:00
|
|
|
/*
|
|
|
|
* Always set WM1S_LP_EN when spr_val != 0, even if the
|
|
|
|
* level is disabled. Doing otherwise could cause underruns.
|
|
|
|
*/
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) <= 6 && r->spr_val) {
|
2013-12-05 13:51:32 +00:00
|
|
|
WARN_ON(wm_lp != 1);
|
|
|
|
results->wm_lp_spr[wm_lp - 1] = WM1S_LP_EN | r->spr_val;
|
|
|
|
} else
|
|
|
|
results->wm_lp_spr[wm_lp - 1] = r->spr_val;
|
2013-05-31 14:45:06 +00:00
|
|
|
}
|
2013-05-31 13:08:35 +00:00
|
|
|
|
2013-10-09 16:17:55 +00:00
|
|
|
/* LP0 register values */
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, intel_crtc) {
|
2013-10-09 16:17:55 +00:00
|
|
|
enum pipe pipe = intel_crtc->pipe;
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
const struct intel_wm_level *r =
|
|
|
|
&intel_crtc->wm.active.ilk.wm[0];
|
2013-10-09 16:17:55 +00:00
|
|
|
|
|
|
|
if (WARN_ON(!r->enable))
|
|
|
|
continue;
|
|
|
|
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
results->wm_linetime[pipe] = intel_crtc->wm.active.ilk.linetime;
|
2013-05-09 19:55:50 +00:00
|
|
|
|
2013-10-09 16:17:55 +00:00
|
|
|
results->wm_pipe[pipe] =
|
|
|
|
(r->pri_val << WM0_PIPE_PLANE_SHIFT) |
|
|
|
|
(r->spr_val << WM0_PIPE_SPRITE_SHIFT) |
|
|
|
|
r->cur_val;
|
2013-05-31 13:08:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 13:19:21 +00:00
|
|
|
/* Find the result with the highest level enabled. Check for enable_fbc_wm in
|
|
|
|
* case both are at the same level. Prefer r1 in case they're the same. */
|
2018-12-10 21:54:14 +00:00
|
|
|
static struct intel_pipe_wm *
|
|
|
|
ilk_find_best_result(struct drm_i915_private *dev_priv,
|
|
|
|
struct intel_pipe_wm *r1,
|
|
|
|
struct intel_pipe_wm *r2)
|
2013-05-31 13:19:21 +00:00
|
|
|
{
|
2018-12-10 21:54:14 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2013-10-09 16:17:58 +00:00
|
|
|
int level1 = 0, level2 = 0;
|
2013-05-31 13:19:21 +00:00
|
|
|
|
2013-10-09 16:17:58 +00:00
|
|
|
for (level = 1; level <= max_level; level++) {
|
|
|
|
if (r1->wm[level].enable)
|
|
|
|
level1 = level;
|
|
|
|
if (r2->wm[level].enable)
|
|
|
|
level2 = level;
|
2013-05-31 13:19:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 16:17:58 +00:00
|
|
|
if (level1 == level2) {
|
|
|
|
if (r2->fbc_wm_enabled && !r1->fbc_wm_enabled)
|
2013-05-31 13:19:21 +00:00
|
|
|
return r2;
|
|
|
|
else
|
|
|
|
return r1;
|
2013-10-09 16:17:58 +00:00
|
|
|
} else if (level1 > level2) {
|
2013-05-31 13:19:21 +00:00
|
|
|
return r1;
|
|
|
|
} else {
|
|
|
|
return r2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:39:52 +00:00
|
|
|
/* dirty bits used to track which watermarks need changes */
|
|
|
|
#define WM_DIRTY_PIPE(pipe) (1 << (pipe))
|
|
|
|
#define WM_DIRTY_LINETIME(pipe) (1 << (8 + (pipe)))
|
|
|
|
#define WM_DIRTY_LP(wm_lp) (1 << (15 + (wm_lp)))
|
|
|
|
#define WM_DIRTY_LP_ALL (WM_DIRTY_LP(1) | WM_DIRTY_LP(2) | WM_DIRTY_LP(3))
|
|
|
|
#define WM_DIRTY_FBC (1 << 24)
|
|
|
|
#define WM_DIRTY_DDB (1 << 25)
|
|
|
|
|
2014-08-18 12:49:10 +00:00
|
|
|
static unsigned int ilk_compute_wm_dirty(struct drm_i915_private *dev_priv,
|
2013-12-17 12:46:36 +00:00
|
|
|
const struct ilk_wm_values *old,
|
|
|
|
const struct ilk_wm_values *new)
|
2013-10-11 16:39:52 +00:00
|
|
|
{
|
|
|
|
unsigned int dirty = 0;
|
|
|
|
enum pipe pipe;
|
|
|
|
int wm_lp;
|
|
|
|
|
2014-08-18 12:49:10 +00:00
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2013-10-11 16:39:52 +00:00
|
|
|
if (old->wm_linetime[pipe] != new->wm_linetime[pipe]) {
|
|
|
|
dirty |= WM_DIRTY_LINETIME(pipe);
|
|
|
|
/* Must disable LP1+ watermarks too */
|
|
|
|
dirty |= WM_DIRTY_LP_ALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (old->wm_pipe[pipe] != new->wm_pipe[pipe]) {
|
|
|
|
dirty |= WM_DIRTY_PIPE(pipe);
|
|
|
|
/* Must disable LP1+ watermarks too */
|
|
|
|
dirty |= WM_DIRTY_LP_ALL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (old->enable_fbc_wm != new->enable_fbc_wm) {
|
|
|
|
dirty |= WM_DIRTY_FBC;
|
|
|
|
/* Must disable LP1+ watermarks too */
|
|
|
|
dirty |= WM_DIRTY_LP_ALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (old->partitioning != new->partitioning) {
|
|
|
|
dirty |= WM_DIRTY_DDB;
|
|
|
|
/* Must disable LP1+ watermarks too */
|
|
|
|
dirty |= WM_DIRTY_LP_ALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* LP1+ watermarks already deemed dirty, no need to continue */
|
|
|
|
if (dirty & WM_DIRTY_LP_ALL)
|
|
|
|
return dirty;
|
|
|
|
|
|
|
|
/* Find the lowest numbered LP1+ watermark in need of an update... */
|
|
|
|
for (wm_lp = 1; wm_lp <= 3; wm_lp++) {
|
|
|
|
if (old->wm_lp[wm_lp - 1] != new->wm_lp[wm_lp - 1] ||
|
|
|
|
old->wm_lp_spr[wm_lp - 1] != new->wm_lp_spr[wm_lp - 1])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ...and mark it and all higher numbered LP1+ watermarks as dirty */
|
|
|
|
for (; wm_lp <= 3; wm_lp++)
|
|
|
|
dirty |= WM_DIRTY_LP(wm_lp);
|
|
|
|
|
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
|
2013-12-05 13:51:39 +00:00
|
|
|
static bool _ilk_disable_lp_wm(struct drm_i915_private *dev_priv,
|
|
|
|
unsigned int dirty)
|
2013-05-31 13:08:35 +00:00
|
|
|
{
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_values *previous = &dev_priv->wm.hw;
|
2013-12-05 13:51:39 +00:00
|
|
|
bool changed = false;
|
2013-05-31 13:08:35 +00:00
|
|
|
|
2013-12-05 13:51:33 +00:00
|
|
|
if (dirty & WM_DIRTY_LP(3) && previous->wm_lp[2] & WM1_LP_SR_EN) {
|
|
|
|
previous->wm_lp[2] &= ~WM1_LP_SR_EN;
|
|
|
|
I915_WRITE(WM3_LP_ILK, previous->wm_lp[2]);
|
2013-12-05 13:51:39 +00:00
|
|
|
changed = true;
|
2013-12-05 13:51:33 +00:00
|
|
|
}
|
|
|
|
if (dirty & WM_DIRTY_LP(2) && previous->wm_lp[1] & WM1_LP_SR_EN) {
|
|
|
|
previous->wm_lp[1] &= ~WM1_LP_SR_EN;
|
|
|
|
I915_WRITE(WM2_LP_ILK, previous->wm_lp[1]);
|
2013-12-05 13:51:39 +00:00
|
|
|
changed = true;
|
2013-12-05 13:51:33 +00:00
|
|
|
}
|
|
|
|
if (dirty & WM_DIRTY_LP(1) && previous->wm_lp[0] & WM1_LP_SR_EN) {
|
|
|
|
previous->wm_lp[0] &= ~WM1_LP_SR_EN;
|
|
|
|
I915_WRITE(WM1_LP_ILK, previous->wm_lp[0]);
|
2013-12-05 13:51:39 +00:00
|
|
|
changed = true;
|
2013-12-05 13:51:33 +00:00
|
|
|
}
|
2013-05-31 13:08:35 +00:00
|
|
|
|
2013-12-05 13:51:33 +00:00
|
|
|
/*
|
|
|
|
* Don't touch WM1S_LP_EN here.
|
|
|
|
* Doing so could cause underruns.
|
|
|
|
*/
|
2013-12-05 13:51:32 +00:00
|
|
|
|
2013-12-05 13:51:39 +00:00
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The spec says we shouldn't write when we don't need, because every write
|
|
|
|
* causes WMs to be re-evaluated, expending some power.
|
|
|
|
*/
|
2013-12-17 12:46:36 +00:00
|
|
|
static void ilk_write_wm_values(struct drm_i915_private *dev_priv,
|
|
|
|
struct ilk_wm_values *results)
|
2013-12-05 13:51:39 +00:00
|
|
|
{
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_values *previous = &dev_priv->wm.hw;
|
2013-12-05 13:51:39 +00:00
|
|
|
unsigned int dirty;
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 val;
|
2013-12-05 13:51:39 +00:00
|
|
|
|
2014-08-18 12:49:10 +00:00
|
|
|
dirty = ilk_compute_wm_dirty(dev_priv, previous, results);
|
2013-12-05 13:51:39 +00:00
|
|
|
if (!dirty)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_ilk_disable_lp_wm(dev_priv, dirty);
|
|
|
|
|
2013-10-11 16:39:52 +00:00
|
|
|
if (dirty & WM_DIRTY_PIPE(PIPE_A))
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(WM0_PIPEA_ILK, results->wm_pipe[0]);
|
2013-10-11 16:39:52 +00:00
|
|
|
if (dirty & WM_DIRTY_PIPE(PIPE_B))
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(WM0_PIPEB_ILK, results->wm_pipe[1]);
|
2013-10-11 16:39:52 +00:00
|
|
|
if (dirty & WM_DIRTY_PIPE(PIPE_C))
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(WM0_PIPEC_IVB, results->wm_pipe[2]);
|
|
|
|
|
2013-10-11 16:39:52 +00:00
|
|
|
if (dirty & WM_DIRTY_LINETIME(PIPE_A))
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(PIPE_WM_LINETIME(PIPE_A), results->wm_linetime[0]);
|
2013-10-11 16:39:52 +00:00
|
|
|
if (dirty & WM_DIRTY_LINETIME(PIPE_B))
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(PIPE_WM_LINETIME(PIPE_B), results->wm_linetime[1]);
|
2013-10-11 16:39:52 +00:00
|
|
|
if (dirty & WM_DIRTY_LINETIME(PIPE_C))
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(PIPE_WM_LINETIME(PIPE_C), results->wm_linetime[2]);
|
|
|
|
|
2013-10-11 16:39:52 +00:00
|
|
|
if (dirty & WM_DIRTY_DDB) {
|
2016-10-13 10:03:00 +00:00
|
|
|
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
|
2013-12-05 13:51:28 +00:00
|
|
|
val = I915_READ(WM_MISC);
|
|
|
|
if (results->partitioning == INTEL_DDB_PART_1_2)
|
|
|
|
val &= ~WM_MISC_DATA_PARTITION_5_6;
|
|
|
|
else
|
|
|
|
val |= WM_MISC_DATA_PARTITION_5_6;
|
|
|
|
I915_WRITE(WM_MISC, val);
|
|
|
|
} else {
|
|
|
|
val = I915_READ(DISP_ARB_CTL2);
|
|
|
|
if (results->partitioning == INTEL_DDB_PART_1_2)
|
|
|
|
val &= ~DISP_DATA_PARTITION_5_6;
|
|
|
|
else
|
|
|
|
val |= DISP_DATA_PARTITION_5_6;
|
|
|
|
I915_WRITE(DISP_ARB_CTL2, val);
|
|
|
|
}
|
2013-05-09 19:55:50 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 16:39:52 +00:00
|
|
|
if (dirty & WM_DIRTY_FBC) {
|
2013-05-31 14:45:06 +00:00
|
|
|
val = I915_READ(DISP_ARB_CTL);
|
|
|
|
if (results->enable_fbc_wm)
|
|
|
|
val &= ~DISP_FBC_WM_DIS;
|
|
|
|
else
|
|
|
|
val |= DISP_FBC_WM_DIS;
|
|
|
|
I915_WRITE(DISP_ARB_CTL, val);
|
|
|
|
}
|
|
|
|
|
2013-12-17 12:46:34 +00:00
|
|
|
if (dirty & WM_DIRTY_LP(1) &&
|
|
|
|
previous->wm_lp_spr[0] != results->wm_lp_spr[0])
|
|
|
|
I915_WRITE(WM1S_LP_ILK, results->wm_lp_spr[0]);
|
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 7) {
|
2013-12-05 13:51:32 +00:00
|
|
|
if (dirty & WM_DIRTY_LP(2) && previous->wm_lp_spr[1] != results->wm_lp_spr[1])
|
|
|
|
I915_WRITE(WM2S_LP_IVB, results->wm_lp_spr[1]);
|
|
|
|
if (dirty & WM_DIRTY_LP(3) && previous->wm_lp_spr[2] != results->wm_lp_spr[2])
|
|
|
|
I915_WRITE(WM3S_LP_IVB, results->wm_lp_spr[2]);
|
|
|
|
}
|
2013-05-31 13:08:35 +00:00
|
|
|
|
2013-12-05 13:51:33 +00:00
|
|
|
if (dirty & WM_DIRTY_LP(1) && previous->wm_lp[0] != results->wm_lp[0])
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(WM1_LP_ILK, results->wm_lp[0]);
|
2013-12-05 13:51:33 +00:00
|
|
|
if (dirty & WM_DIRTY_LP(2) && previous->wm_lp[1] != results->wm_lp[1])
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(WM2_LP_ILK, results->wm_lp[1]);
|
2013-12-05 13:51:33 +00:00
|
|
|
if (dirty & WM_DIRTY_LP(3) && previous->wm_lp[2] != results->wm_lp[2])
|
2013-05-31 13:08:35 +00:00
|
|
|
I915_WRITE(WM3_LP_ILK, results->wm_lp[2]);
|
2013-10-09 16:18:03 +00:00
|
|
|
|
|
|
|
dev_priv->wm.hw = *results;
|
2013-05-31 13:08:35 +00:00
|
|
|
}
|
|
|
|
|
2019-11-27 19:05:51 +00:00
|
|
|
bool ilk_disable_lp_wm(struct drm_i915_private *dev_priv)
|
2013-12-05 13:51:39 +00:00
|
|
|
{
|
|
|
|
return _ilk_disable_lp_wm(dev_priv, WM_DIRTY_LP_ALL);
|
|
|
|
}
|
|
|
|
|
2018-04-26 14:25:15 +00:00
|
|
|
static u8 intel_enabled_dbuf_slices_num(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
u8 enabled_slices;
|
|
|
|
|
|
|
|
/* Slice 1 will always be enabled */
|
|
|
|
enabled_slices = 1;
|
|
|
|
|
|
|
|
/* Gen prior to GEN11 have only one DBuf slice */
|
|
|
|
if (INTEL_GEN(dev_priv) < 11)
|
|
|
|
return enabled_slices;
|
|
|
|
|
2019-03-07 10:32:35 +00:00
|
|
|
/*
|
|
|
|
* FIXME: for now we'll only ever use 1 slice; pretend that we have
|
|
|
|
* only that 1 slice enabled until we have a proper way for on-demand
|
|
|
|
* toggling of the second slice.
|
|
|
|
*/
|
|
|
|
if (0 && I915_READ(DBUF_CTL_S2) & DBUF_POWER_STATE)
|
2018-04-26 14:25:15 +00:00
|
|
|
enabled_slices++;
|
|
|
|
|
|
|
|
return enabled_slices;
|
|
|
|
}
|
|
|
|
|
2016-10-11 18:25:38 +00:00
|
|
|
/*
|
|
|
|
* FIXME: We still don't have the proper code detect if we need to apply the WA,
|
|
|
|
* so assume we'll always need it in order to avoid underruns.
|
|
|
|
*/
|
2018-12-21 17:14:33 +00:00
|
|
|
static bool skl_needs_memory_bw_wa(struct drm_i915_private *dev_priv)
|
2016-10-11 18:25:38 +00:00
|
|
|
{
|
2018-12-21 17:14:33 +00:00
|
|
|
return IS_GEN9_BC(dev_priv) || IS_BROXTON(dev_priv);
|
2016-10-11 18:25:38 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 21:00:28 +00:00
|
|
|
static bool
|
|
|
|
intel_has_sagv(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
2019-09-04 21:34:18 +00:00
|
|
|
/* HACK! */
|
|
|
|
if (IS_GEN(dev_priv, 12))
|
|
|
|
return false;
|
|
|
|
|
2018-10-26 20:03:17 +00:00
|
|
|
return (IS_GEN9_BC(dev_priv) || INTEL_GEN(dev_priv) >= 10) &&
|
|
|
|
dev_priv->sagv_status != I915_SAGV_NOT_CONTROLLED;
|
2016-09-22 21:00:28 +00:00
|
|
|
}
|
|
|
|
|
2019-10-09 17:23:14 +00:00
|
|
|
static void
|
|
|
|
skl_setup_sagv_block_time(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
2019-10-09 17:23:15 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 12) {
|
|
|
|
u32 val = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = sandybridge_pcode_read(dev_priv,
|
|
|
|
GEN12_PCODE_READ_SAGV_BLOCK_TIME_US,
|
|
|
|
&val, NULL);
|
|
|
|
if (!ret) {
|
|
|
|
dev_priv->sagv_block_time_us = val;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg(&dev_priv->drm, "Couldn't read SAGV block time!\n");
|
2019-10-09 17:23:15 +00:00
|
|
|
} else if (IS_GEN(dev_priv, 11)) {
|
2019-10-09 17:23:14 +00:00
|
|
|
dev_priv->sagv_block_time_us = 10;
|
|
|
|
return;
|
|
|
|
} else if (IS_GEN(dev_priv, 10)) {
|
|
|
|
dev_priv->sagv_block_time_us = 20;
|
|
|
|
return;
|
|
|
|
} else if (IS_GEN(dev_priv, 9)) {
|
|
|
|
dev_priv->sagv_block_time_us = 30;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
MISSING_CASE(INTEL_GEN(dev_priv));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Default to an unusable block time */
|
|
|
|
dev_priv->sagv_block_time_us = -1;
|
|
|
|
}
|
|
|
|
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
/*
|
|
|
|
* SAGV dynamically adjusts the system agent voltage and clock frequencies
|
|
|
|
* depending on power and performance requirements. The display engine access
|
|
|
|
* to system memory is blocked during the adjustment time. Because of the
|
|
|
|
* blocking time, having this enabled can cause full system hangs and/or pipe
|
|
|
|
* underruns if we don't meet all of the following requirements:
|
|
|
|
*
|
|
|
|
* - <= 1 pipe enabled
|
|
|
|
* - All planes can enable watermarks for latencies >= SAGV engine block time
|
|
|
|
* - We're not using an interlaced display configuration
|
|
|
|
*/
|
|
|
|
int
|
2016-09-22 21:00:27 +00:00
|
|
|
intel_enable_sagv(struct drm_i915_private *dev_priv)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2016-09-22 21:00:28 +00:00
|
|
|
if (!intel_has_sagv(dev_priv))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (dev_priv->sagv_status == I915_SAGV_ENABLED)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "Enabling SAGV\n");
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
ret = sandybridge_pcode_write(dev_priv, GEN9_PCODE_SAGV_CONTROL,
|
|
|
|
GEN9_SAGV_ENABLE);
|
|
|
|
|
2018-12-21 17:14:34 +00:00
|
|
|
/* We don't need to wait for SAGV when enabling */
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Some skl systems, pre-release machines in particular,
|
2018-12-21 17:14:34 +00:00
|
|
|
* don't actually have SAGV.
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
*/
|
2016-09-22 21:00:29 +00:00
|
|
|
if (IS_SKYLAKE(dev_priv) && ret == -ENXIO) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg(&dev_priv->drm, "No SAGV found on system, ignoring\n");
|
2016-09-22 21:00:27 +00:00
|
|
|
dev_priv->sagv_status = I915_SAGV_NOT_CONTROLLED;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return 0;
|
|
|
|
} else if (ret < 0) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_err(&dev_priv->drm, "Failed to enable SAGV\n");
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-09-22 21:00:27 +00:00
|
|
|
dev_priv->sagv_status = I915_SAGV_ENABLED;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2016-09-22 21:00:27 +00:00
|
|
|
intel_disable_sagv(struct drm_i915_private *dev_priv)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
{
|
2016-12-05 16:27:38 +00:00
|
|
|
int ret;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
|
2016-09-22 21:00:28 +00:00
|
|
|
if (!intel_has_sagv(dev_priv))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (dev_priv->sagv_status == I915_SAGV_DISABLED)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "Disabling SAGV\n");
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
/* bspec says to keep retrying for at least 1 ms */
|
2016-12-05 16:27:38 +00:00
|
|
|
ret = skl_pcode_request(dev_priv, GEN9_PCODE_SAGV_CONTROL,
|
|
|
|
GEN9_SAGV_DISABLE,
|
|
|
|
GEN9_SAGV_IS_DISABLED, GEN9_SAGV_IS_DISABLED,
|
|
|
|
1);
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
/*
|
|
|
|
* Some skl systems, pre-release machines in particular,
|
2018-12-21 17:14:34 +00:00
|
|
|
* don't actually have SAGV.
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
*/
|
2016-12-05 16:27:38 +00:00
|
|
|
if (IS_SKYLAKE(dev_priv) && ret == -ENXIO) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg(&dev_priv->drm, "No SAGV found on system, ignoring\n");
|
2016-09-22 21:00:27 +00:00
|
|
|
dev_priv->sagv_status = I915_SAGV_NOT_CONTROLLED;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return 0;
|
2016-12-05 16:27:38 +00:00
|
|
|
} else if (ret < 0) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_err(&dev_priv->drm, "Failed to disable SAGV (%d)\n", ret);
|
2016-12-05 16:27:38 +00:00
|
|
|
return ret;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 21:00:27 +00:00
|
|
|
dev_priv->sagv_status = I915_SAGV_DISABLED;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-28 08:55:13 +00:00
|
|
|
bool intel_can_enable_sagv(struct intel_atomic_state *state)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
{
|
2019-06-28 08:55:13 +00:00
|
|
|
struct drm_device *dev = state->base.dev;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2016-10-11 18:25:38 +00:00
|
|
|
struct intel_crtc *crtc;
|
|
|
|
struct intel_plane *plane;
|
2019-06-28 08:55:17 +00:00
|
|
|
struct intel_crtc_state *crtc_state;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
enum pipe pipe;
|
2016-10-18 18:09:49 +00:00
|
|
|
int level, latency;
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
|
2016-09-22 21:00:28 +00:00
|
|
|
if (!intel_has_sagv(dev_priv))
|
|
|
|
return false;
|
|
|
|
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
/*
|
|
|
|
* If there are no active CRTCs, no additional checks need be performed
|
|
|
|
*/
|
2019-08-21 17:30:33 +00:00
|
|
|
if (hweight8(state->active_pipes) == 0)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return true;
|
2019-04-04 23:04:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SKL+ workaround: bspec recommends we disable SAGV when we have
|
|
|
|
* more then one pipe enabled
|
|
|
|
*/
|
2019-08-21 17:30:33 +00:00
|
|
|
if (hweight8(state->active_pipes) > 1)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Since we're now guaranteed to only have one active CRTC... */
|
2019-08-21 17:30:29 +00:00
|
|
|
pipe = ffs(state->active_pipes) - 1;
|
2016-10-31 20:37:10 +00:00
|
|
|
crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
|
2019-06-28 08:55:17 +00:00
|
|
|
crtc_state = to_intel_crtc_state(crtc->base.state);
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
if (crtc_state->hw.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return false;
|
|
|
|
|
2016-10-11 18:25:38 +00:00
|
|
|
for_each_intel_plane_on_crtc(dev, crtc, plane) {
|
2016-11-22 16:01:58 +00:00
|
|
|
struct skl_plane_wm *wm =
|
2019-06-28 08:55:17 +00:00
|
|
|
&crtc_state->wm.skl.optimal.planes[plane->id];
|
2016-10-11 18:25:38 +00:00
|
|
|
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
/* Skip this plane if it's not enabled */
|
2016-10-18 18:09:49 +00:00
|
|
|
if (!wm->wm[0].plane_en)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Find the highest enabled wm level for this plane */
|
2016-10-13 10:03:10 +00:00
|
|
|
for (level = ilk_wm_max_level(dev_priv);
|
2016-10-18 18:09:49 +00:00
|
|
|
!wm->wm[level].plane_en; --level)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
{ }
|
|
|
|
|
2016-10-11 18:25:38 +00:00
|
|
|
latency = dev_priv->wm.skl_latency[level];
|
|
|
|
|
2018-12-21 17:14:33 +00:00
|
|
|
if (skl_needs_memory_bw_wa(dev_priv) &&
|
2016-11-16 11:33:16 +00:00
|
|
|
plane->base.state->fb->modifier ==
|
2016-10-11 18:25:38 +00:00
|
|
|
I915_FORMAT_MOD_X_TILED)
|
|
|
|
latency += 15;
|
|
|
|
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
/*
|
2017-08-09 20:52:45 +00:00
|
|
|
* If any of the planes on this pipe don't enable wm levels that
|
|
|
|
* incur memory latencies higher than sagv_block_time_us we
|
2018-12-21 17:14:34 +00:00
|
|
|
* can't enable SAGV.
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
*/
|
2019-10-09 17:23:14 +00:00
|
|
|
if (latency < dev_priv->sagv_block_time_us)
|
drm/i915/skl: Add support for the SAGV, fix underrun hangs
Since the watermark calculations for Skylake are still broken, we're apt
to hitting underruns very easily under multi-monitor configurations.
While it would be lovely if this was fixed, it's not. Another problem
that's been coming from this however, is the mysterious issue of
underruns causing full system hangs. An easy way to reproduce this with
a skylake system:
- Get a laptop with a skylake GPU, and hook up two external monitors to
it
- Move the cursor from the built-in LCD to one of the external displays
as quickly as you can
- You'll get a few pipe underruns, and eventually the entire system will
just freeze.
After doing a lot of investigation and reading through the bspec, I
found the existence of the SAGV, which is responsible for adjusting the
system agent voltage and clock frequencies depending on how much power
we need. According to the bspec:
"The display engine access to system memory is blocked during the
adjustment time. SAGV defaults to enabled. Software must use the
GT-driver pcode mailbox to disable SAGV when the display engine is not
able to tolerate the blocking time."
The rest of the bspec goes on to explain that software can simply leave
the SAGV enabled, and disable it when we use interlaced pipes/have more
then one pipe active.
Sure enough, with this patchset the system hangs resulting from pipe
underruns on Skylake have completely vanished on my T460s. Additionally,
the bspec mentions turning off the SAGV with more then one pipe enabled
as a workaround for display underruns. While this patch doesn't entirely
fix that, it looks like it does improve the situation a little bit so
it's likely this is going to be required to make watermarks on Skylake
fully functional.
This will still need additional work in the future: we shouldn't be
enabling the SAGV if any of the currently enabled planes can't enable WM
levels that introduce latencies >= 30 µs.
Changes since v11:
- Add skl_can_enable_sagv()
- Make sure we don't enable SAGV when not all planes can enable
watermarks >= the SAGV engine block time. I was originally going to
save this for later, but I recently managed to run into a machine
that was having problems with a single pipe configuration + SAGV.
- Make comparisons to I915_SKL_SAGV_NOT_CONTROLLED explicit
- Change I915_SAGV_DYNAMIC_FREQ to I915_SAGV_ENABLE
- Move printks outside of mutexes
- Don't print error messages twice
Changes since v10:
- Apparently sandybridge_pcode_read actually writes values and reads
them back, despite it's misleading function name. This means we've
been doing this mostly wrong and have been writing garbage to the
SAGV control. Because of this, we no longer attempt to read the SAGV
status during initialization (since there are no helpers for this).
- mlankhorst noticed that this patch was breaking on some very early
pre-release Skylake machines, which apparently don't allow you to
disable the SAGV. To prevent machines from failing tests due to SAGV
errors, if the first time we try to control the SAGV results in the
mailbox indicating an invalid command, we just disable future attempts
to control the SAGV state by setting dev_priv->skl_sagv_status to
I915_SKL_SAGV_NOT_CONTROLLED and make a note of it in dmesg.
- Move mutex_unlock() a little higher in skl_enable_sagv(). This
doesn't actually fix anything, but lets us release the lock a little
sooner since we're finished with it.
Changes since v9:
- Only enable/disable sagv on Skylake
Changes since v8:
- Add intel_state->modeset guard to the conditional for
skl_enable_sagv()
Changes since v7:
- Remove GEN9_SAGV_LOW_FREQ, replace with GEN9_SAGV_IS_ENABLED (that's
all we use it for anyway)
- Use GEN9_SAGV_IS_ENABLED instead of 0x1 for clarification
- Fix a styling error that snuck past me
Changes since v6:
- Protect skl_enable_sagv() with intel_state->modeset conditional in
intel_atomic_commit_tail()
Changes since v5:
- Don't use is_power_of_2. Makes things confusing
- Don't use the old state to figure out whether or not to
enable/disable the sagv, use the new one
- Split the loop in skl_disable_sagv into it's own function
- Move skl_sagv_enable/disable() calls into intel_atomic_commit_tail()
Changes since v4:
- Use is_power_of_2 against active_crtcs to check whether we have > 1
pipe enabled
- Fix skl_sagv_get_hw_state(): (temp & 0x1) indicates disabled, 0x0
enabled
- Call skl_sagv_enable/disable() from pre/post-plane updates
Changes since v3:
- Use time_before() to compare timeout to jiffies
Changes since v2:
- Really apply minor style nitpicks to patch this time
Changes since v1:
- Added comments about this probably being one of the requirements to
fixing Skylake's watermark issues
- Minor style nitpicks from Matt Roper
- Disable these functions on Broxton, since it doesn't have an SAGV
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471463761-26796-3-git-send-email-cpaul@redhat.com
[mlankhorst: ENOSYS -> ENXIO, whitespace fixes]
2016-08-17 19:55:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-31 14:24:44 +00:00
|
|
|
static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv,
|
2019-06-28 08:55:17 +00:00
|
|
|
const struct intel_crtc_state *crtc_state,
|
2018-10-22 10:20:00 +00:00
|
|
|
const u64 total_data_rate,
|
2018-07-31 14:24:44 +00:00
|
|
|
const int num_active,
|
|
|
|
struct skl_ddb_allocation *ddb)
|
2018-04-26 14:25:16 +00:00
|
|
|
{
|
|
|
|
const struct drm_display_mode *adjusted_mode;
|
|
|
|
u64 total_data_bw;
|
|
|
|
u16 ddb_size = INTEL_INFO(dev_priv)->ddb_size;
|
|
|
|
|
|
|
|
WARN_ON(ddb_size == 0);
|
|
|
|
|
|
|
|
if (INTEL_GEN(dev_priv) < 11)
|
|
|
|
return ddb_size - 4; /* 4 blocks for bypass path allocation */
|
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
adjusted_mode = &crtc_state->hw.adjusted_mode;
|
2018-10-22 10:20:00 +00:00
|
|
|
total_data_bw = total_data_rate * drm_mode_vrefresh(adjusted_mode);
|
2018-04-26 14:25:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 12GB/s is maximum BW supported by single DBuf slice.
|
2019-01-30 15:51:10 +00:00
|
|
|
*
|
|
|
|
* FIXME dbuf slice code is broken:
|
|
|
|
* - must wait for planes to stop using the slice before powering it off
|
|
|
|
* - plane straddling both slices is illegal in multi-pipe scenarios
|
|
|
|
* - should validate we stay within the hw bandwidth limits
|
2018-04-26 14:25:16 +00:00
|
|
|
*/
|
2019-01-30 15:51:10 +00:00
|
|
|
if (0 && (num_active > 1 || total_data_bw >= GBps(12))) {
|
2018-04-26 14:25:16 +00:00
|
|
|
ddb->enabled_slices = 2;
|
|
|
|
} else {
|
|
|
|
ddb->enabled_slices = 1;
|
|
|
|
ddb_size /= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ddb_size;
|
|
|
|
}
|
|
|
|
|
2014-11-04 17:06:43 +00:00
|
|
|
static void
|
2018-10-18 11:51:30 +00:00
|
|
|
skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv,
|
2019-06-28 08:55:17 +00:00
|
|
|
const struct intel_crtc_state *crtc_state,
|
2018-10-22 10:20:00 +00:00
|
|
|
const u64 total_data_rate,
|
2018-04-26 14:25:16 +00:00
|
|
|
struct skl_ddb_allocation *ddb,
|
2016-05-12 14:06:01 +00:00
|
|
|
struct skl_ddb_entry *alloc, /* out */
|
|
|
|
int *num_active /* out */)
|
2014-11-04 17:06:43 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_atomic_state *state = crtc_state->uapi.state;
|
2016-05-12 14:06:01 +00:00
|
|
|
struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_crtc *for_crtc = crtc_state->uapi.crtc;
|
2019-06-28 08:55:17 +00:00
|
|
|
const struct intel_crtc *crtc;
|
2018-08-01 15:11:13 +00:00
|
|
|
u32 pipe_width = 0, total_width = 0, width_before_pipe = 0;
|
|
|
|
enum pipe for_pipe = to_intel_crtc(for_crtc)->pipe;
|
|
|
|
u16 ddb_size;
|
|
|
|
u32 i;
|
2016-05-12 14:06:01 +00:00
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
if (WARN_ON(!state) || !crtc_state->hw.active) {
|
2014-11-04 17:06:43 +00:00
|
|
|
alloc->start = 0;
|
|
|
|
alloc->end = 0;
|
2019-08-21 17:30:33 +00:00
|
|
|
*num_active = hweight8(dev_priv->active_pipes);
|
2014-11-04 17:06:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-12 14:06:04 +00:00
|
|
|
if (intel_state->active_pipe_changes)
|
2019-08-21 17:30:33 +00:00
|
|
|
*num_active = hweight8(intel_state->active_pipes);
|
2016-05-12 14:06:04 +00:00
|
|
|
else
|
2019-08-21 17:30:33 +00:00
|
|
|
*num_active = hweight8(dev_priv->active_pipes);
|
2016-05-12 14:06:04 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
ddb_size = intel_get_ddb_size(dev_priv, crtc_state, total_data_rate,
|
2018-04-26 14:25:16 +00:00
|
|
|
*num_active, ddb);
|
2014-11-04 17:06:43 +00:00
|
|
|
|
2016-05-12 14:06:01 +00:00
|
|
|
/*
|
2018-08-01 15:11:13 +00:00
|
|
|
* If the state doesn't change the active CRTC's or there is no
|
|
|
|
* modeset request, then there's no need to recalculate;
|
|
|
|
* the existing pipe allocation limits should remain unchanged.
|
|
|
|
* Note that we're safe from racing commits since any racing commit
|
|
|
|
* that changes the active CRTC list or do modeset would need to
|
|
|
|
* grab _all_ crtc locks, including the one we currently hold.
|
2016-05-12 14:06:01 +00:00
|
|
|
*/
|
2018-08-01 15:11:13 +00:00
|
|
|
if (!intel_state->active_pipe_changes && !intel_state->modeset) {
|
2016-11-08 12:55:34 +00:00
|
|
|
/*
|
|
|
|
* alloc may be cleared by clear_intel_crtc_state,
|
|
|
|
* copy from old state to be sure
|
|
|
|
*/
|
|
|
|
*alloc = to_intel_crtc_state(for_crtc->state)->wm.skl.ddb;
|
2016-05-12 14:06:04 +00:00
|
|
|
return;
|
2016-05-12 14:06:01 +00:00
|
|
|
}
|
2016-05-12 14:06:04 +00:00
|
|
|
|
2018-08-01 15:11:13 +00:00
|
|
|
/*
|
|
|
|
* Watermark/ddb requirement highly depends upon width of the
|
|
|
|
* framebuffer, So instead of allocating DDB equally among pipes
|
|
|
|
* distribute DDB based on resolution/width of the display.
|
|
|
|
*/
|
2019-06-28 08:55:17 +00:00
|
|
|
for_each_new_intel_crtc_in_state(intel_state, crtc, crtc_state, i) {
|
|
|
|
const struct drm_display_mode *adjusted_mode =
|
2019-10-31 11:26:02 +00:00
|
|
|
&crtc_state->hw.adjusted_mode;
|
2019-06-28 08:55:17 +00:00
|
|
|
enum pipe pipe = crtc->pipe;
|
2018-08-01 15:11:13 +00:00
|
|
|
int hdisplay, vdisplay;
|
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
if (!crtc_state->hw.enable)
|
2018-08-01 15:11:13 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
drm_mode_get_hv_timing(adjusted_mode, &hdisplay, &vdisplay);
|
|
|
|
total_width += hdisplay;
|
|
|
|
|
|
|
|
if (pipe < for_pipe)
|
|
|
|
width_before_pipe += hdisplay;
|
|
|
|
else if (pipe == for_pipe)
|
|
|
|
pipe_width = hdisplay;
|
|
|
|
}
|
|
|
|
|
|
|
|
alloc->start = ddb_size * width_before_pipe / total_width;
|
|
|
|
alloc->end = ddb_size * (width_before_pipe + pipe_width) / total_width;
|
2014-11-04 17:06:43 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 16:03:11 +00:00
|
|
|
static int skl_compute_wm_params(const struct intel_crtc_state *crtc_state,
|
|
|
|
int width, const struct drm_format_info *format,
|
|
|
|
u64 modifier, unsigned int rotation,
|
|
|
|
u32 plane_pixel_rate, struct skl_wm_params *wp,
|
|
|
|
int color_plane);
|
2019-06-28 08:55:17 +00:00
|
|
|
static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,
|
2019-03-19 16:03:11 +00:00
|
|
|
int level,
|
|
|
|
const struct skl_wm_params *wp,
|
|
|
|
const struct skl_wm_level *result_prev,
|
|
|
|
struct skl_wm_level *result /* out */);
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
skl_cursor_allocation(const struct intel_crtc_state *crtc_state,
|
|
|
|
int num_active)
|
2014-11-04 17:06:43 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2019-03-19 16:03:11 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
|
|
|
struct skl_wm_level wm = {};
|
|
|
|
int ret, min_ddb_alloc = 0;
|
|
|
|
struct skl_wm_params wp;
|
|
|
|
|
|
|
|
ret = skl_compute_wm_params(crtc_state, 256,
|
|
|
|
drm_format_info(DRM_FORMAT_ARGB8888),
|
|
|
|
DRM_FORMAT_MOD_LINEAR,
|
|
|
|
DRM_MODE_ROTATE_0,
|
|
|
|
crtc_state->pixel_rate, &wp, 0);
|
|
|
|
WARN_ON(ret);
|
|
|
|
|
|
|
|
for (level = 0; level <= max_level; level++) {
|
2019-03-21 17:51:28 +00:00
|
|
|
skl_compute_plane_wm(crtc_state, level, &wp, &wm, &wm);
|
2019-03-19 16:03:11 +00:00
|
|
|
if (wm.min_ddb_alloc == U16_MAX)
|
|
|
|
break;
|
|
|
|
|
|
|
|
min_ddb_alloc = wm.min_ddb_alloc;
|
|
|
|
}
|
2014-11-04 17:06:43 +00:00
|
|
|
|
2019-03-19 16:03:11 +00:00
|
|
|
return max(num_active == 1 ? 32 : 8, min_ddb_alloc);
|
2014-11-04 17:06:43 +00:00
|
|
|
}
|
|
|
|
|
2018-04-26 14:25:17 +00:00
|
|
|
static void skl_ddb_entry_init_from_hw(struct drm_i915_private *dev_priv,
|
|
|
|
struct skl_ddb_entry *entry, u32 reg)
|
2014-11-04 17:06:49 +00:00
|
|
|
{
|
2018-04-26 14:25:17 +00:00
|
|
|
|
2019-02-05 20:50:56 +00:00
|
|
|
entry->start = reg & DDB_ENTRY_MASK;
|
|
|
|
entry->end = (reg >> DDB_ENTRY_END_SHIFT) & DDB_ENTRY_MASK;
|
2018-04-26 14:25:17 +00:00
|
|
|
|
2014-11-04 17:06:53 +00:00
|
|
|
if (entry->end)
|
|
|
|
entry->end += 1;
|
2014-11-04 17:06:49 +00:00
|
|
|
}
|
|
|
|
|
2018-04-09 03:41:03 +00:00
|
|
|
static void
|
|
|
|
skl_ddb_get_hw_plane_state(struct drm_i915_private *dev_priv,
|
|
|
|
const enum pipe pipe,
|
|
|
|
const enum plane_id plane_id,
|
2018-11-27 16:59:00 +00:00
|
|
|
struct skl_ddb_entry *ddb_y,
|
|
|
|
struct skl_ddb_entry *ddb_uv)
|
2018-04-09 03:41:03 +00:00
|
|
|
{
|
2018-11-27 16:59:00 +00:00
|
|
|
u32 val, val2;
|
|
|
|
u32 fourcc = 0;
|
2018-04-09 03:41:03 +00:00
|
|
|
|
|
|
|
/* Cursor doesn't support NV12/planar, so no extra calculation needed */
|
|
|
|
if (plane_id == PLANE_CURSOR) {
|
|
|
|
val = I915_READ(CUR_BUF_CFG(pipe));
|
2018-11-27 16:59:00 +00:00
|
|
|
skl_ddb_entry_init_from_hw(dev_priv, ddb_y, val);
|
2018-04-09 03:41:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = I915_READ(PLANE_CTL(pipe, plane_id));
|
|
|
|
|
|
|
|
/* No DDB allocated for disabled planes */
|
2018-11-27 16:59:00 +00:00
|
|
|
if (val & PLANE_CTL_ENABLE)
|
|
|
|
fourcc = skl_format_to_fourcc(val & PLANE_CTL_FORMAT_MASK,
|
|
|
|
val & PLANE_CTL_ORDER_RGBX,
|
|
|
|
val & PLANE_CTL_ALPHA_MASK);
|
2018-04-09 03:41:03 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 11) {
|
|
|
|
val = I915_READ(PLANE_BUF_CFG(pipe, plane_id));
|
|
|
|
skl_ddb_entry_init_from_hw(dev_priv, ddb_y, val);
|
|
|
|
} else {
|
|
|
|
val = I915_READ(PLANE_BUF_CFG(pipe, plane_id));
|
2018-08-01 00:46:14 +00:00
|
|
|
val2 = I915_READ(PLANE_NV12_BUF_CFG(pipe, plane_id));
|
2018-04-09 03:41:03 +00:00
|
|
|
|
2019-09-13 19:31:54 +00:00
|
|
|
if (fourcc &&
|
|
|
|
drm_format_info_is_yuv_semiplanar(drm_format_info(fourcc)))
|
2018-11-27 16:59:00 +00:00
|
|
|
swap(val, val2);
|
|
|
|
|
|
|
|
skl_ddb_entry_init_from_hw(dev_priv, ddb_y, val);
|
|
|
|
skl_ddb_entry_init_from_hw(dev_priv, ddb_uv, val2);
|
2018-04-09 03:41:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc,
|
|
|
|
struct skl_ddb_entry *ddb_y,
|
|
|
|
struct skl_ddb_entry *ddb_uv)
|
2014-11-04 17:06:49 +00:00
|
|
|
{
|
2018-11-27 16:59:00 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
enum intel_display_power_domain power_domain;
|
|
|
|
enum pipe pipe = crtc->pipe;
|
2019-01-14 14:21:24 +00:00
|
|
|
intel_wakeref_t wakeref;
|
2018-11-27 16:59:00 +00:00
|
|
|
enum plane_id plane_id;
|
2018-04-26 14:25:15 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
power_domain = POWER_DOMAIN_PIPE(pipe);
|
2019-01-14 14:21:24 +00:00
|
|
|
wakeref = intel_display_power_get_if_enabled(dev_priv, power_domain);
|
|
|
|
if (!wakeref)
|
2018-11-27 16:59:00 +00:00
|
|
|
return;
|
2016-02-17 14:31:29 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id)
|
|
|
|
skl_ddb_get_hw_plane_state(dev_priv, pipe,
|
|
|
|
plane_id,
|
|
|
|
&ddb_y[plane_id],
|
|
|
|
&ddb_uv[plane_id]);
|
2015-10-22 11:56:34 +00:00
|
|
|
|
2019-01-14 14:21:24 +00:00
|
|
|
intel_display_power_put(dev_priv, power_domain, wakeref);
|
2018-11-27 16:59:00 +00:00
|
|
|
}
|
2016-02-17 14:31:29 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
|
|
|
|
struct skl_ddb_allocation *ddb /* out */)
|
|
|
|
{
|
|
|
|
ddb->enabled_slices = intel_enabled_dbuf_slices_num(dev_priv);
|
2014-11-04 17:06:49 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 22:52:00 +00:00
|
|
|
/*
|
|
|
|
* Determines the downscale amount of a plane for the purposes of watermark calculations.
|
|
|
|
* The bspec defines downscale amount as:
|
|
|
|
*
|
|
|
|
* """
|
|
|
|
* Horizontal down scale amount = maximum[1, Horizontal source size /
|
|
|
|
* Horizontal destination size]
|
|
|
|
* Vertical down scale amount = maximum[1, Vertical source size /
|
|
|
|
* Vertical destination size]
|
|
|
|
* Total down scale amount = Horizontal down scale amount *
|
|
|
|
* Vertical down scale amount
|
|
|
|
* """
|
|
|
|
*
|
|
|
|
* Return value is provided in 16.16 fixed point form to retain fractional part.
|
|
|
|
* Caller should take care of dividing & rounding off the value.
|
|
|
|
*/
|
2017-05-17 11:58:23 +00:00
|
|
|
static uint_fixed_16_16_t
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_plane_downscale_amount(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state)
|
2016-05-16 22:52:00 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 src_w, src_h, dst_w, dst_h;
|
2017-05-17 11:58:23 +00:00
|
|
|
uint_fixed_16_16_t fp_w_ratio, fp_h_ratio;
|
|
|
|
uint_fixed_16_16_t downscale_h, downscale_w;
|
2016-05-16 22:52:00 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
if (WARN_ON(!intel_wm_plane_visible(crtc_state, plane_state)))
|
2017-07-05 14:31:46 +00:00
|
|
|
return u32_to_fixed16(0);
|
2016-05-16 22:52:00 +00:00
|
|
|
|
2019-10-04 11:34:54 +00:00
|
|
|
/*
|
|
|
|
* Src coordinates are already rotated by 270 degrees for
|
|
|
|
* the 90/270 degree plane rotation cases (to match the
|
|
|
|
* GTT mapping), hence no need to account for rotation here.
|
|
|
|
*
|
|
|
|
* n.b., src is 16.16 fixed point, dst is whole integer.
|
|
|
|
*/
|
2019-10-31 11:26:08 +00:00
|
|
|
src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
|
|
|
|
src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
|
|
|
|
dst_w = drm_rect_width(&plane_state->uapi.dst);
|
|
|
|
dst_h = drm_rect_height(&plane_state->uapi.dst);
|
2017-03-14 15:10:50 +00:00
|
|
|
|
2017-07-05 14:31:46 +00:00
|
|
|
fp_w_ratio = div_fixed16(src_w, dst_w);
|
|
|
|
fp_h_ratio = div_fixed16(src_h, dst_h);
|
|
|
|
downscale_w = max_fixed16(fp_w_ratio, u32_to_fixed16(1));
|
|
|
|
downscale_h = max_fixed16(fp_h_ratio, u32_to_fixed16(1));
|
2016-05-16 22:52:00 +00:00
|
|
|
|
2017-05-17 11:58:23 +00:00
|
|
|
return mul_fixed16(downscale_w, downscale_h);
|
2016-05-16 22:52:00 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 10:20:00 +00:00
|
|
|
static u64
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_plane_relative_data_rate(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-09-13 19:31:54 +00:00
|
|
|
int color_plane)
|
2014-11-04 17:06:43 +00:00
|
|
|
{
|
2019-10-31 11:26:08 +00:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2019-10-31 11:26:07 +00:00
|
|
|
const struct drm_framebuffer *fb = plane_state->hw.fb;
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 data_rate;
|
|
|
|
u32 width = 0, height = 0;
|
2017-05-17 11:58:23 +00:00
|
|
|
uint_fixed_16_16_t down_scale_amount;
|
2018-10-22 10:20:00 +00:00
|
|
|
u64 rate;
|
2016-05-12 14:05:57 +00:00
|
|
|
|
2019-10-31 11:26:08 +00:00
|
|
|
if (!plane_state->uapi.visible)
|
2016-05-12 14:05:57 +00:00
|
|
|
return 0;
|
2016-11-18 19:53:00 +00:00
|
|
|
|
2019-09-13 19:31:54 +00:00
|
|
|
if (plane->id == PLANE_CURSOR)
|
2016-05-12 14:05:57 +00:00
|
|
|
return 0;
|
2019-09-13 19:31:54 +00:00
|
|
|
|
|
|
|
if (color_plane == 1 &&
|
2019-12-21 12:05:43 +00:00
|
|
|
!intel_format_info_is_yuv_semiplanar(fb->format, fb->modifier))
|
2016-05-12 14:05:57 +00:00
|
|
|
return 0;
|
2016-04-06 15:26:39 +00:00
|
|
|
|
2017-03-31 18:00:55 +00:00
|
|
|
/*
|
|
|
|
* Src coordinates are already rotated by 270 degrees for
|
|
|
|
* the 90/270 degree plane rotation cases (to match the
|
|
|
|
* GTT mapping), hence no need to account for rotation here.
|
|
|
|
*/
|
2019-10-31 11:26:08 +00:00
|
|
|
width = drm_rect_width(&plane_state->uapi.src) >> 16;
|
|
|
|
height = drm_rect_height(&plane_state->uapi.src) >> 16;
|
2016-04-06 15:26:39 +00:00
|
|
|
|
2018-04-09 03:41:01 +00:00
|
|
|
/* UV plane does 1/2 pixel sub-sampling */
|
2019-09-13 19:31:54 +00:00
|
|
|
if (color_plane == 1) {
|
2018-04-09 03:41:01 +00:00
|
|
|
width /= 2;
|
|
|
|
height /= 2;
|
2015-04-27 22:47:37 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 10:20:00 +00:00
|
|
|
data_rate = width * height;
|
2018-04-09 03:41:01 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
down_scale_amount = skl_plane_downscale_amount(crtc_state, plane_state);
|
2016-05-19 22:03:01 +00:00
|
|
|
|
2018-10-22 10:20:00 +00:00
|
|
|
rate = mul_round_up_u32_fixed16(data_rate, down_scale_amount);
|
|
|
|
|
2019-09-13 19:31:54 +00:00
|
|
|
rate *= fb->format->cpp[color_plane];
|
2018-10-22 10:20:00 +00:00
|
|
|
return rate;
|
2014-11-04 17:06:43 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 10:20:00 +00:00
|
|
|
static u64
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_get_total_relative_data_rate(struct intel_crtc_state *crtc_state,
|
2018-10-22 10:20:00 +00:00
|
|
|
u64 *plane_data_rate,
|
|
|
|
u64 *uv_plane_data_rate)
|
2014-11-04 17:06:43 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_atomic_state *state = crtc_state->uapi.state;
|
2019-10-04 11:34:53 +00:00
|
|
|
struct intel_plane *plane;
|
|
|
|
const struct intel_plane_state *plane_state;
|
2018-10-22 10:20:00 +00:00
|
|
|
u64 total_data_rate = 0;
|
2016-05-12 14:06:04 +00:00
|
|
|
|
|
|
|
if (WARN_ON(!state))
|
|
|
|
return 0;
|
2014-11-04 17:06:43 +00:00
|
|
|
|
2016-05-12 14:05:57 +00:00
|
|
|
/* Calculate and cache data rate for each plane */
|
2019-10-04 11:34:53 +00:00
|
|
|
intel_atomic_crtc_state_for_each_plane_state(plane, plane_state, crtc_state) {
|
|
|
|
enum plane_id plane_id = plane->id;
|
2018-10-22 10:20:00 +00:00
|
|
|
u64 rate;
|
2016-05-12 14:06:04 +00:00
|
|
|
|
2018-04-09 03:41:01 +00:00
|
|
|
/* packed/y */
|
2019-06-28 08:55:17 +00:00
|
|
|
rate = skl_plane_relative_data_rate(crtc_state, plane_state, 0);
|
2016-11-22 16:01:58 +00:00
|
|
|
plane_data_rate[plane_id] = rate;
|
2016-10-26 13:41:32 +00:00
|
|
|
total_data_rate += rate;
|
2016-05-12 14:06:04 +00:00
|
|
|
|
2018-04-09 03:41:01 +00:00
|
|
|
/* uv-plane */
|
2019-06-28 08:55:17 +00:00
|
|
|
rate = skl_plane_relative_data_rate(crtc_state, plane_state, 1);
|
2018-04-09 03:41:01 +00:00
|
|
|
uv_plane_data_rate[plane_id] = rate;
|
2016-10-26 13:41:32 +00:00
|
|
|
total_data_rate += rate;
|
2014-11-04 17:06:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return total_data_rate;
|
|
|
|
}
|
|
|
|
|
2018-10-18 11:51:30 +00:00
|
|
|
static u64
|
2019-06-28 08:55:17 +00:00
|
|
|
icl_get_total_relative_data_rate(struct intel_crtc_state *crtc_state,
|
2018-10-18 11:51:30 +00:00
|
|
|
u64 *plane_data_rate)
|
|
|
|
{
|
2019-10-04 11:34:53 +00:00
|
|
|
struct intel_plane *plane;
|
|
|
|
const struct intel_plane_state *plane_state;
|
2018-10-18 11:51:30 +00:00
|
|
|
u64 total_data_rate = 0;
|
|
|
|
|
2019-10-31 11:26:03 +00:00
|
|
|
if (WARN_ON(!crtc_state->uapi.state))
|
2018-10-18 11:51:30 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Calculate and cache data rate for each plane */
|
2019-10-04 11:34:53 +00:00
|
|
|
intel_atomic_crtc_state_for_each_plane_state(plane, plane_state, crtc_state) {
|
|
|
|
enum plane_id plane_id = plane->id;
|
2018-10-18 11:51:30 +00:00
|
|
|
u64 rate;
|
|
|
|
|
2019-09-20 11:42:20 +00:00
|
|
|
if (!plane_state->planar_linked_plane) {
|
2019-06-28 08:55:17 +00:00
|
|
|
rate = skl_plane_relative_data_rate(crtc_state, plane_state, 0);
|
2018-10-18 11:51:30 +00:00
|
|
|
plane_data_rate[plane_id] = rate;
|
|
|
|
total_data_rate += rate;
|
|
|
|
} else {
|
|
|
|
enum plane_id y_plane_id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The slave plane might not iterate in
|
2019-10-04 11:34:53 +00:00
|
|
|
* intel_atomic_crtc_state_for_each_plane_state(),
|
2018-10-18 11:51:30 +00:00
|
|
|
* and needs the master plane state which may be
|
|
|
|
* NULL if we try get_new_plane_state(), so we
|
|
|
|
* always calculate from the master.
|
|
|
|
*/
|
2019-09-20 11:42:20 +00:00
|
|
|
if (plane_state->planar_slave)
|
2018-10-18 11:51:30 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Y plane rate is calculated on the slave */
|
2019-06-28 08:55:17 +00:00
|
|
|
rate = skl_plane_relative_data_rate(crtc_state, plane_state, 0);
|
2019-09-20 11:42:20 +00:00
|
|
|
y_plane_id = plane_state->planar_linked_plane->id;
|
2018-10-18 11:51:30 +00:00
|
|
|
plane_data_rate[y_plane_id] = rate;
|
|
|
|
total_data_rate += rate;
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
rate = skl_plane_relative_data_rate(crtc_state, plane_state, 1);
|
2018-10-18 11:51:30 +00:00
|
|
|
plane_data_rate[plane_id] = rate;
|
|
|
|
total_data_rate += rate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return total_data_rate;
|
|
|
|
}
|
|
|
|
|
2016-05-12 14:06:01 +00:00
|
|
|
static int
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_allocate_pipe_ddb(struct intel_crtc_state *crtc_state,
|
2014-11-04 17:06:43 +00:00
|
|
|
struct skl_ddb_allocation *ddb /* out */)
|
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_atomic_state *state = crtc_state->uapi.state;
|
|
|
|
struct drm_crtc *crtc = crtc_state->uapi.crtc;
|
2018-10-18 11:51:30 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->dev);
|
2014-11-04 17:06:43 +00:00
|
|
|
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
|
2019-06-28 08:55:17 +00:00
|
|
|
struct skl_ddb_entry *alloc = &crtc_state->wm.skl.ddb;
|
2019-01-18 12:01:20 +00:00
|
|
|
u16 alloc_size, start = 0;
|
|
|
|
u16 total[I915_MAX_PLANES] = {};
|
|
|
|
u16 uv_total[I915_MAX_PLANES] = {};
|
2018-10-22 10:20:00 +00:00
|
|
|
u64 total_data_rate;
|
2016-11-22 16:01:58 +00:00
|
|
|
enum plane_id plane_id;
|
2016-05-12 14:06:01 +00:00
|
|
|
int num_active;
|
2018-10-22 10:20:00 +00:00
|
|
|
u64 plane_data_rate[I915_MAX_PLANES] = {};
|
|
|
|
u64 uv_plane_data_rate[I915_MAX_PLANES] = {};
|
2019-02-05 15:50:53 +00:00
|
|
|
u32 blocks;
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
int level;
|
2014-11-04 17:06:43 +00:00
|
|
|
|
2016-10-04 17:37:32 +00:00
|
|
|
/* Clear the partitioning for disabled planes. */
|
2019-06-28 08:55:17 +00:00
|
|
|
memset(crtc_state->wm.skl.plane_ddb_y, 0, sizeof(crtc_state->wm.skl.plane_ddb_y));
|
|
|
|
memset(crtc_state->wm.skl.plane_ddb_uv, 0, sizeof(crtc_state->wm.skl.plane_ddb_uv));
|
2016-10-04 17:37:32 +00:00
|
|
|
|
2016-05-12 14:06:04 +00:00
|
|
|
if (WARN_ON(!state))
|
|
|
|
return 0;
|
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
if (!crtc_state->hw.active) {
|
2016-09-15 14:46:35 +00:00
|
|
|
alloc->start = alloc->end = 0;
|
2016-05-12 14:06:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-04 23:04:25 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 11)
|
|
|
|
total_data_rate =
|
2019-06-28 08:55:17 +00:00
|
|
|
icl_get_total_relative_data_rate(crtc_state,
|
2019-04-04 23:04:25 +00:00
|
|
|
plane_data_rate);
|
|
|
|
else
|
2018-10-18 11:51:30 +00:00
|
|
|
total_data_rate =
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_get_total_relative_data_rate(crtc_state,
|
2018-10-18 11:51:30 +00:00
|
|
|
plane_data_rate,
|
|
|
|
uv_plane_data_rate);
|
2019-04-04 23:04:25 +00:00
|
|
|
|
2018-10-18 11:51:30 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_ddb_get_pipe_allocation_limits(dev_priv, crtc_state, total_data_rate,
|
2018-10-18 11:51:30 +00:00
|
|
|
ddb, alloc, &num_active);
|
2014-11-04 17:07:01 +00:00
|
|
|
alloc_size = skl_ddb_entry_size(alloc);
|
2017-05-17 11:58:25 +00:00
|
|
|
if (alloc_size == 0)
|
2016-05-12 14:06:01 +00:00
|
|
|
return 0;
|
2014-11-04 17:06:43 +00:00
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
/* Allocate fixed number of blocks for cursor. */
|
2019-06-28 08:55:17 +00:00
|
|
|
total[PLANE_CURSOR] = skl_cursor_allocation(crtc_state, num_active);
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
alloc_size -= total[PLANE_CURSOR];
|
2019-06-28 08:55:17 +00:00
|
|
|
crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR].start =
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
alloc->end - total[PLANE_CURSOR];
|
2019-06-28 08:55:17 +00:00
|
|
|
crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR].end = alloc->end;
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
|
|
|
|
if (total_data_rate == 0)
|
|
|
|
return 0;
|
2016-05-12 14:06:04 +00:00
|
|
|
|
2016-10-26 13:41:34 +00:00
|
|
|
/*
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
* Find the highest watermark level for which we can satisfy the block
|
|
|
|
* requirement of active planes.
|
2016-10-26 13:41:34 +00:00
|
|
|
*/
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
for (level = ilk_wm_max_level(dev_priv); level >= 0; level--) {
|
2018-12-12 19:17:20 +00:00
|
|
|
blocks = 0;
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
for_each_plane_id_on_crtc(intel_crtc, plane_id) {
|
2019-03-12 20:58:42 +00:00
|
|
|
const struct skl_plane_wm *wm =
|
2019-06-28 08:55:17 +00:00
|
|
|
&crtc_state->wm.skl.optimal.planes[plane_id];
|
2019-03-12 20:58:40 +00:00
|
|
|
|
|
|
|
if (plane_id == PLANE_CURSOR) {
|
2019-12-16 08:06:19 +00:00
|
|
|
if (wm->wm[level].min_ddb_alloc > total[PLANE_CURSOR]) {
|
|
|
|
WARN_ON(wm->wm[level].min_ddb_alloc != U16_MAX);
|
2019-03-12 20:58:40 +00:00
|
|
|
blocks = U32_MAX;
|
|
|
|
break;
|
|
|
|
}
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
continue;
|
2019-03-12 20:58:40 +00:00
|
|
|
}
|
2015-02-09 13:35:10 +00:00
|
|
|
|
2018-12-21 17:14:32 +00:00
|
|
|
blocks += wm->wm[level].min_ddb_alloc;
|
|
|
|
blocks += wm->uv_wm[level].min_ddb_alloc;
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
}
|
|
|
|
|
2019-03-12 20:58:36 +00:00
|
|
|
if (blocks <= alloc_size) {
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
alloc_size -= blocks;
|
|
|
|
break;
|
|
|
|
}
|
2015-02-09 13:35:10 +00:00
|
|
|
}
|
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
if (level < 0) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Requested display configuration exceeds system DDB limitations");
|
|
|
|
drm_dbg_kms(&dev_priv->drm, "minimum required %d/%d\n",
|
|
|
|
blocks, alloc_size);
|
2017-05-17 11:58:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-11-04 17:06:43 +00:00
|
|
|
/*
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
* Grant each plane the blocks it requires at the highest achievable
|
|
|
|
* watermark level, plus an extra share of the leftover blocks
|
|
|
|
* proportional to its relative data rate.
|
2014-11-04 17:06:43 +00:00
|
|
|
*/
|
2016-11-22 16:01:58 +00:00
|
|
|
for_each_plane_id_on_crtc(intel_crtc, plane_id) {
|
2019-03-12 20:58:42 +00:00
|
|
|
const struct skl_plane_wm *wm =
|
2019-06-28 08:55:17 +00:00
|
|
|
&crtc_state->wm.skl.optimal.planes[plane_id];
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
u64 rate;
|
|
|
|
u16 extra;
|
2014-11-04 17:06:43 +00:00
|
|
|
|
2016-11-22 16:01:58 +00:00
|
|
|
if (plane_id == PLANE_CURSOR)
|
2016-10-26 13:41:34 +00:00
|
|
|
continue;
|
|
|
|
|
2014-11-04 17:06:43 +00:00
|
|
|
/*
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
* We've accounted for all active planes; remaining planes are
|
|
|
|
* all disabled.
|
2014-11-04 17:06:43 +00:00
|
|
|
*/
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
if (total_data_rate == 0)
|
|
|
|
break;
|
2014-11-04 17:06:43 +00:00
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
rate = plane_data_rate[plane_id];
|
|
|
|
extra = min_t(u16, alloc_size,
|
|
|
|
DIV64_U64_ROUND_UP(alloc_size * rate,
|
|
|
|
total_data_rate));
|
2018-12-21 17:14:32 +00:00
|
|
|
total[plane_id] = wm->wm[level].min_ddb_alloc + extra;
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
alloc_size -= extra;
|
|
|
|
total_data_rate -= rate;
|
2017-06-13 17:52:30 +00:00
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
if (total_data_rate == 0)
|
|
|
|
break;
|
2016-05-12 14:05:57 +00:00
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
rate = uv_plane_data_rate[plane_id];
|
|
|
|
extra = min_t(u16, alloc_size,
|
|
|
|
DIV64_U64_ROUND_UP(alloc_size * rate,
|
|
|
|
total_data_rate));
|
2018-12-21 17:14:32 +00:00
|
|
|
uv_total[plane_id] = wm->uv_wm[level].min_ddb_alloc + extra;
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
alloc_size -= extra;
|
|
|
|
total_data_rate -= rate;
|
|
|
|
}
|
|
|
|
WARN_ON(alloc_size != 0 || total_data_rate != 0);
|
|
|
|
|
|
|
|
/* Set the actual DDB start/end points for each plane */
|
|
|
|
start = alloc->start;
|
|
|
|
for_each_plane_id_on_crtc(intel_crtc, plane_id) {
|
2019-03-12 20:58:42 +00:00
|
|
|
struct skl_ddb_entry *plane_alloc =
|
2019-06-28 08:55:17 +00:00
|
|
|
&crtc_state->wm.skl.plane_ddb_y[plane_id];
|
2019-03-12 20:58:42 +00:00
|
|
|
struct skl_ddb_entry *uv_plane_alloc =
|
2019-06-28 08:55:17 +00:00
|
|
|
&crtc_state->wm.skl.plane_ddb_uv[plane_id];
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
|
|
|
|
if (plane_id == PLANE_CURSOR)
|
|
|
|
continue;
|
|
|
|
|
2018-10-18 11:51:30 +00:00
|
|
|
/* Gen11+ uses a separate plane for UV watermarks */
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
WARN_ON(INTEL_GEN(dev_priv) >= 11 && uv_total[plane_id]);
|
|
|
|
|
|
|
|
/* Leave disabled planes at (0,0) */
|
|
|
|
if (total[plane_id]) {
|
|
|
|
plane_alloc->start = start;
|
|
|
|
start += total[plane_id];
|
|
|
|
plane_alloc->end = start;
|
|
|
|
}
|
2018-10-18 11:51:30 +00:00
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
if (uv_total[plane_id]) {
|
|
|
|
uv_plane_alloc->start = start;
|
|
|
|
start += uv_total[plane_id];
|
|
|
|
uv_plane_alloc->end = start;
|
2016-05-12 14:06:01 +00:00
|
|
|
}
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
}
|
2017-06-13 17:52:30 +00:00
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
/*
|
|
|
|
* When we calculated watermark values we didn't know how high
|
|
|
|
* of a level we'd actually be able to hit, so we just marked
|
|
|
|
* all levels as "enabled." Go back now and disable the ones
|
|
|
|
* that aren't actually possible.
|
|
|
|
*/
|
|
|
|
for (level++; level <= ilk_wm_max_level(dev_priv); level++) {
|
|
|
|
for_each_plane_id_on_crtc(intel_crtc, plane_id) {
|
2019-03-12 20:58:42 +00:00
|
|
|
struct skl_plane_wm *wm =
|
2019-06-28 08:55:17 +00:00
|
|
|
&crtc_state->wm.skl.optimal.planes[plane_id];
|
2019-03-12 20:58:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We only disable the watermarks for each plane if
|
|
|
|
* they exceed the ddb allocation of said plane. This
|
|
|
|
* is done so that we don't end up touching cursor
|
|
|
|
* watermarks needlessly when some other plane reduces
|
|
|
|
* our max possible watermark level.
|
|
|
|
*
|
|
|
|
* Bspec has this to say about the PLANE_WM enable bit:
|
|
|
|
* "All the watermarks at this level for all enabled
|
|
|
|
* planes must be enabled before the level will be used."
|
|
|
|
* So this is actually safe to do.
|
|
|
|
*/
|
|
|
|
if (wm->wm[level].min_ddb_alloc > total[plane_id] ||
|
|
|
|
wm->uv_wm[level].min_ddb_alloc > uv_total[plane_id])
|
|
|
|
memset(&wm->wm[level], 0, sizeof(wm->wm[level]));
|
2019-02-13 16:54:24 +00:00
|
|
|
|
2019-02-28 17:36:39 +00:00
|
|
|
/*
|
2019-04-12 18:09:20 +00:00
|
|
|
* Wa_1408961008:icl, ehl
|
2019-02-28 17:36:39 +00:00
|
|
|
* Underruns with WM1+ disabled
|
|
|
|
*/
|
2019-04-12 18:09:20 +00:00
|
|
|
if (IS_GEN(dev_priv, 11) &&
|
2019-02-13 16:54:24 +00:00
|
|
|
level == 1 && wm->wm[0].plane_en) {
|
|
|
|
wm->wm[level].plane_res_b = wm->wm[0].plane_res_b;
|
2019-02-28 17:36:39 +00:00
|
|
|
wm->wm[level].plane_res_l = wm->wm[0].plane_res_l;
|
|
|
|
wm->wm[level].ignore_lines = wm->wm[0].ignore_lines;
|
2019-02-13 16:54:24 +00:00
|
|
|
}
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Go back and disable the transition watermark if it turns out we
|
|
|
|
* don't have enough DDB blocks for it.
|
|
|
|
*/
|
|
|
|
for_each_plane_id_on_crtc(intel_crtc, plane_id) {
|
2019-03-12 20:58:42 +00:00
|
|
|
struct skl_plane_wm *wm =
|
2019-06-28 08:55:17 +00:00
|
|
|
&crtc_state->wm.skl.optimal.planes[plane_id];
|
2019-03-12 20:58:42 +00:00
|
|
|
|
2018-12-21 17:14:31 +00:00
|
|
|
if (wm->trans_wm.plane_res_b >= total[plane_id])
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
memset(&wm->trans_wm, 0, sizeof(wm->trans_wm));
|
2014-11-04 17:06:43 +00:00
|
|
|
}
|
|
|
|
|
2016-05-12 14:06:01 +00:00
|
|
|
return 0;
|
2014-11-04 17:06:43 +00:00
|
|
|
}
|
|
|
|
|
2014-11-04 17:06:42 +00:00
|
|
|
/*
|
|
|
|
* The max latency should be 257 (max the punit can code is 255 and we add 2us
|
2016-01-20 19:05:26 +00:00
|
|
|
* for the read latency) and cpp should always be <= 8, so that
|
2014-11-04 17:06:42 +00:00
|
|
|
* should allow pixel_rate up to ~2 GHz which seems sufficient since max
|
|
|
|
* 2xcdclk is 1350 MHz and the pixel rate should never exceed that.
|
|
|
|
*/
|
2017-08-11 23:38:25 +00:00
|
|
|
static uint_fixed_16_16_t
|
2019-01-18 12:01:20 +00:00
|
|
|
skl_wm_method1(const struct drm_i915_private *dev_priv, u32 pixel_rate,
|
|
|
|
u8 cpp, u32 latency, u32 dbuf_block_size)
|
2014-11-04 17:06:42 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 wm_intermediate_val;
|
2016-12-01 15:49:37 +00:00
|
|
|
uint_fixed_16_16_t ret;
|
2014-11-04 17:06:42 +00:00
|
|
|
|
|
|
|
if (latency == 0)
|
2016-12-01 15:49:37 +00:00
|
|
|
return FP_16_16_MAX;
|
2014-11-04 17:06:42 +00:00
|
|
|
|
2016-12-01 15:49:37 +00:00
|
|
|
wm_intermediate_val = latency * pixel_rate * cpp;
|
2018-01-30 13:49:11 +00:00
|
|
|
ret = div_fixed16(wm_intermediate_val, 1000 * dbuf_block_size);
|
2017-08-11 23:38:25 +00:00
|
|
|
|
|
|
|
if (INTEL_GEN(dev_priv) >= 10)
|
|
|
|
ret = add_fixed16_u32(ret, 1);
|
|
|
|
|
2014-11-04 17:06:42 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
static uint_fixed_16_16_t
|
|
|
|
skl_wm_method2(u32 pixel_rate, u32 pipe_htotal, u32 latency,
|
|
|
|
uint_fixed_16_16_t plane_blocks_per_line)
|
2014-11-04 17:06:42 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 wm_intermediate_val;
|
2016-12-01 15:49:37 +00:00
|
|
|
uint_fixed_16_16_t ret;
|
2014-11-04 17:06:42 +00:00
|
|
|
|
|
|
|
if (latency == 0)
|
2016-12-01 15:49:37 +00:00
|
|
|
return FP_16_16_MAX;
|
2014-11-04 17:06:42 +00:00
|
|
|
|
|
|
|
wm_intermediate_val = latency * pixel_rate;
|
2016-12-01 15:49:37 +00:00
|
|
|
wm_intermediate_val = DIV_ROUND_UP(wm_intermediate_val,
|
|
|
|
pipe_htotal * 1000);
|
2017-07-05 14:31:46 +00:00
|
|
|
ret = mul_u32_fixed16(wm_intermediate_val, plane_blocks_per_line);
|
2014-11-04 17:06:42 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:58:29 +00:00
|
|
|
static uint_fixed_16_16_t
|
2019-06-28 08:55:17 +00:00
|
|
|
intel_get_linetime_us(const struct intel_crtc_state *crtc_state)
|
2017-05-17 11:58:29 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 pixel_rate;
|
|
|
|
u32 crtc_htotal;
|
2017-05-17 11:58:29 +00:00
|
|
|
uint_fixed_16_16_t linetime_us;
|
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
if (!crtc_state->hw.active)
|
2017-07-05 14:31:46 +00:00
|
|
|
return u32_to_fixed16(0);
|
2017-05-17 11:58:29 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
pixel_rate = crtc_state->pixel_rate;
|
2017-05-17 11:58:29 +00:00
|
|
|
|
|
|
|
if (WARN_ON(pixel_rate == 0))
|
2017-07-05 14:31:46 +00:00
|
|
|
return u32_to_fixed16(0);
|
2017-05-17 11:58:29 +00:00
|
|
|
|
2019-10-31 11:26:02 +00:00
|
|
|
crtc_htotal = crtc_state->hw.adjusted_mode.crtc_htotal;
|
2017-07-05 14:31:46 +00:00
|
|
|
linetime_us = div_fixed16(crtc_htotal * 1000, pixel_rate);
|
2017-05-17 11:58:29 +00:00
|
|
|
|
|
|
|
return linetime_us;
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
static u32
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_adjusted_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state)
|
2016-05-16 22:52:00 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u64 adjusted_pixel_rate;
|
2017-05-17 11:58:23 +00:00
|
|
|
uint_fixed_16_16_t downscale_amount;
|
2016-05-16 22:52:00 +00:00
|
|
|
|
|
|
|
/* Shouldn't reach here on disabled planes... */
|
2019-06-28 08:55:17 +00:00
|
|
|
if (WARN_ON(!intel_wm_plane_visible(crtc_state, plane_state)))
|
2016-05-16 22:52:00 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Adjusted plane pixel rate is just the pipe's adjusted pixel rate
|
|
|
|
* with additional adjustments for plane-specific scaling.
|
|
|
|
*/
|
2019-06-28 08:55:17 +00:00
|
|
|
adjusted_pixel_rate = crtc_state->pixel_rate;
|
|
|
|
downscale_amount = skl_plane_downscale_amount(crtc_state, plane_state);
|
2016-05-16 22:52:00 +00:00
|
|
|
|
2017-05-17 11:58:23 +00:00
|
|
|
return mul_round_up_u32_fixed16(adjusted_pixel_rate,
|
|
|
|
downscale_amount);
|
2016-05-16 22:52:00 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 13:45:23 +00:00
|
|
|
static int
|
2019-03-12 20:58:38 +00:00
|
|
|
skl_compute_wm_params(const struct intel_crtc_state *crtc_state,
|
|
|
|
int width, const struct drm_format_info *format,
|
|
|
|
u64 modifier, unsigned int rotation,
|
|
|
|
u32 plane_pixel_rate, struct skl_wm_params *wp,
|
|
|
|
int color_plane)
|
2014-11-04 17:06:42 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2019-03-12 20:58:38 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 interm_pbpl;
|
2014-11-04 17:06:42 +00:00
|
|
|
|
2019-03-04 11:56:31 +00:00
|
|
|
/* only planar format has two planes */
|
2019-12-21 12:05:43 +00:00
|
|
|
if (color_plane == 1 &&
|
|
|
|
!intel_format_info_is_yuv_semiplanar(format, modifier)) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Non planar format have single plane\n");
|
2018-04-09 03:41:04 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2019-03-12 20:58:38 +00:00
|
|
|
wp->y_tiled = modifier == I915_FORMAT_MOD_Y_TILED ||
|
|
|
|
modifier == I915_FORMAT_MOD_Yf_TILED ||
|
|
|
|
modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
|
|
|
|
modifier == I915_FORMAT_MOD_Yf_TILED_CCS;
|
|
|
|
wp->x_tiled = modifier == I915_FORMAT_MOD_X_TILED;
|
|
|
|
wp->rc_surface = modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
|
|
|
|
modifier == I915_FORMAT_MOD_Yf_TILED_CCS;
|
2019-12-21 12:05:43 +00:00
|
|
|
wp->is_planar = intel_format_info_is_yuv_semiplanar(format, modifier);
|
2016-04-06 15:26:39 +00:00
|
|
|
|
2019-03-12 20:58:38 +00:00
|
|
|
wp->width = width;
|
2018-11-14 21:07:28 +00:00
|
|
|
if (color_plane == 1 && wp->is_planar)
|
2018-04-09 03:41:04 +00:00
|
|
|
wp->width /= 2;
|
|
|
|
|
2019-03-12 20:58:38 +00:00
|
|
|
wp->cpp = format->cpp[color_plane];
|
|
|
|
wp->plane_pixel_rate = plane_pixel_rate;
|
2016-05-16 22:52:00 +00:00
|
|
|
|
2018-01-30 13:49:11 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 11 &&
|
2019-03-12 20:58:38 +00:00
|
|
|
modifier == I915_FORMAT_MOD_Yf_TILED && wp->cpp == 1)
|
2018-01-30 13:49:11 +00:00
|
|
|
wp->dbuf_block_size = 256;
|
|
|
|
else
|
|
|
|
wp->dbuf_block_size = 512;
|
|
|
|
|
2019-03-12 20:58:38 +00:00
|
|
|
if (drm_rotation_90_or_270(rotation)) {
|
2017-08-17 13:45:23 +00:00
|
|
|
switch (wp->cpp) {
|
2016-09-22 21:00:31 +00:00
|
|
|
case 1:
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->y_min_scanlines = 16;
|
2016-09-22 21:00:31 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->y_min_scanlines = 8;
|
2016-09-22 21:00:31 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->y_min_scanlines = 4;
|
2016-09-22 21:00:31 +00:00
|
|
|
break;
|
2016-09-22 21:00:35 +00:00
|
|
|
default:
|
2017-08-17 13:45:23 +00:00
|
|
|
MISSING_CASE(wp->cpp);
|
2016-09-22 21:00:35 +00:00
|
|
|
return -EINVAL;
|
2016-09-22 21:00:31 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->y_min_scanlines = 4;
|
2016-09-22 21:00:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 17:14:33 +00:00
|
|
|
if (skl_needs_memory_bw_wa(dev_priv))
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->y_min_scanlines *= 2;
|
2016-11-08 20:22:11 +00:00
|
|
|
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->plane_bytes_per_line = wp->width * wp->cpp;
|
|
|
|
if (wp->y_tiled) {
|
|
|
|
interm_pbpl = DIV_ROUND_UP(wp->plane_bytes_per_line *
|
2018-01-30 13:49:11 +00:00
|
|
|
wp->y_min_scanlines,
|
|
|
|
wp->dbuf_block_size);
|
2017-08-11 23:38:25 +00:00
|
|
|
|
|
|
|
if (INTEL_GEN(dev_priv) >= 10)
|
|
|
|
interm_pbpl++;
|
|
|
|
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->plane_blocks_per_line = div_fixed16(interm_pbpl,
|
|
|
|
wp->y_min_scanlines);
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
} else if (wp->x_tiled && IS_GEN(dev_priv, 9)) {
|
2018-01-30 13:49:11 +00:00
|
|
|
interm_pbpl = DIV_ROUND_UP(wp->plane_bytes_per_line,
|
|
|
|
wp->dbuf_block_size);
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->plane_blocks_per_line = u32_to_fixed16(interm_pbpl);
|
2016-12-01 15:49:33 +00:00
|
|
|
} else {
|
2018-01-30 13:49:11 +00:00
|
|
|
interm_pbpl = DIV_ROUND_UP(wp->plane_bytes_per_line,
|
|
|
|
wp->dbuf_block_size) + 1;
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->plane_blocks_per_line = u32_to_fixed16(interm_pbpl);
|
2016-09-22 21:00:32 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->y_tile_minimum = mul_u32_fixed16(wp->y_min_scanlines,
|
|
|
|
wp->plane_blocks_per_line);
|
2019-03-12 20:58:38 +00:00
|
|
|
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->linetime_us = fixed16_to_u32_round_up(
|
2019-03-12 20:58:38 +00:00
|
|
|
intel_get_linetime_us(crtc_state));
|
2017-08-17 13:45:23 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-12 20:58:38 +00:00
|
|
|
static int
|
|
|
|
skl_compute_plane_wm_params(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct intel_plane_state *plane_state,
|
|
|
|
struct skl_wm_params *wp, int color_plane)
|
|
|
|
{
|
2019-10-31 11:26:07 +00:00
|
|
|
const struct drm_framebuffer *fb = plane_state->hw.fb;
|
2019-03-12 20:58:38 +00:00
|
|
|
int width;
|
|
|
|
|
2019-10-04 11:34:54 +00:00
|
|
|
/*
|
|
|
|
* Src coordinates are already rotated by 270 degrees for
|
|
|
|
* the 90/270 degree plane rotation cases (to match the
|
|
|
|
* GTT mapping), hence no need to account for rotation here.
|
|
|
|
*/
|
2019-10-31 11:26:08 +00:00
|
|
|
width = drm_rect_width(&plane_state->uapi.src) >> 16;
|
2019-03-12 20:58:38 +00:00
|
|
|
|
|
|
|
return skl_compute_wm_params(crtc_state, width,
|
|
|
|
fb->format, fb->modifier,
|
2019-10-31 11:26:07 +00:00
|
|
|
plane_state->hw.rotation,
|
2019-03-12 20:58:38 +00:00
|
|
|
skl_adjusted_plane_pixel_rate(crtc_state, plane_state),
|
|
|
|
wp, color_plane);
|
|
|
|
}
|
|
|
|
|
2018-12-21 17:14:28 +00:00
|
|
|
static bool skl_wm_has_lines(struct drm_i915_private *dev_priv, int level)
|
|
|
|
{
|
|
|
|
if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
/* The number of lines are ignored for the level 0 watermark. */
|
|
|
|
return level > 0;
|
|
|
|
}
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
int level,
|
|
|
|
const struct skl_wm_params *wp,
|
|
|
|
const struct skl_wm_level *result_prev,
|
|
|
|
struct skl_wm_level *result /* out */)
|
2017-08-17 13:45:23 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 latency = dev_priv->wm.skl_latency[level];
|
2017-08-17 13:45:23 +00:00
|
|
|
uint_fixed_16_16_t method1, method2;
|
|
|
|
uint_fixed_16_16_t selected_result;
|
2018-12-21 17:14:32 +00:00
|
|
|
u32 res_blocks, res_lines, min_ddb_alloc = 0;
|
2018-11-14 21:07:21 +00:00
|
|
|
|
2019-02-05 15:50:53 +00:00
|
|
|
if (latency == 0) {
|
|
|
|
/* reject it */
|
|
|
|
result->min_ddb_alloc = U16_MAX;
|
2018-12-21 17:14:29 +00:00
|
|
|
return;
|
2019-02-05 15:50:53 +00:00
|
|
|
}
|
2018-12-21 17:14:29 +00:00
|
|
|
|
2019-05-03 17:38:05 +00:00
|
|
|
/*
|
|
|
|
* WaIncreaseLatencyIPCEnabled: kbl,cfl
|
|
|
|
* Display WA #1141: kbl,cfl
|
|
|
|
*/
|
2019-05-03 17:38:06 +00:00
|
|
|
if ((IS_KABYLAKE(dev_priv) || IS_COFFEELAKE(dev_priv)) ||
|
2017-08-17 13:45:23 +00:00
|
|
|
dev_priv->ipc_enabled)
|
|
|
|
latency += 4;
|
|
|
|
|
2018-12-21 17:14:33 +00:00
|
|
|
if (skl_needs_memory_bw_wa(dev_priv) && wp->x_tiled)
|
2017-08-17 13:45:23 +00:00
|
|
|
latency += 15;
|
|
|
|
|
|
|
|
method1 = skl_wm_method1(dev_priv, wp->plane_pixel_rate,
|
2018-01-30 13:49:11 +00:00
|
|
|
wp->cpp, latency, wp->dbuf_block_size);
|
2017-08-17 13:45:23 +00:00
|
|
|
method2 = skl_wm_method2(wp->plane_pixel_rate,
|
2019-10-31 11:26:02 +00:00
|
|
|
crtc_state->hw.adjusted_mode.crtc_htotal,
|
2016-09-22 21:00:31 +00:00
|
|
|
latency,
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->plane_blocks_per_line);
|
2016-09-22 21:00:33 +00:00
|
|
|
|
2017-08-17 13:45:23 +00:00
|
|
|
if (wp->y_tiled) {
|
|
|
|
selected_result = max_fixed16(method2, wp->y_tile_minimum);
|
2015-02-27 15:12:35 +00:00
|
|
|
} else {
|
2019-10-31 11:26:02 +00:00
|
|
|
if ((wp->cpp * crtc_state->hw.adjusted_mode.crtc_htotal /
|
2018-01-30 13:49:11 +00:00
|
|
|
wp->dbuf_block_size < 1) &&
|
2018-10-04 23:15:57 +00:00
|
|
|
(wp->plane_bytes_per_line / wp->dbuf_block_size < 1)) {
|
2016-09-22 21:00:34 +00:00
|
|
|
selected_result = method2;
|
2018-10-04 23:15:57 +00:00
|
|
|
} else if (latency >= wp->linetime_us) {
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(dev_priv, 9) &&
|
2018-10-04 23:15:57 +00:00
|
|
|
!IS_GEMINILAKE(dev_priv))
|
|
|
|
selected_result = min_fixed16(method1, method2);
|
|
|
|
else
|
|
|
|
selected_result = method2;
|
|
|
|
} else {
|
2015-02-27 15:12:35 +00:00
|
|
|
selected_result = method1;
|
2018-10-04 23:15:57 +00:00
|
|
|
}
|
2015-02-27 15:12:35 +00:00
|
|
|
}
|
2014-11-04 17:06:42 +00:00
|
|
|
|
2017-07-05 14:31:46 +00:00
|
|
|
res_blocks = fixed16_to_u32_round_up(selected_result) + 1;
|
2017-05-17 11:58:22 +00:00
|
|
|
res_lines = div_round_up_fixed16(selected_result,
|
2017-08-17 13:45:23 +00:00
|
|
|
wp->plane_blocks_per_line);
|
2014-11-04 17:06:55 +00:00
|
|
|
|
2018-11-14 01:24:32 +00:00
|
|
|
if (IS_GEN9_BC(dev_priv) || IS_BROXTON(dev_priv)) {
|
|
|
|
/* Display WA #1125: skl,bxt,kbl */
|
|
|
|
if (level == 0 && wp->rc_surface)
|
|
|
|
res_blocks +=
|
|
|
|
fixed16_to_u32_round_up(wp->y_tile_minimum);
|
|
|
|
|
|
|
|
/* Display WA #1126: skl,bxt,kbl */
|
|
|
|
if (level >= 1 && level <= 7) {
|
|
|
|
if (wp->y_tiled) {
|
|
|
|
res_blocks +=
|
|
|
|
fixed16_to_u32_round_up(wp->y_tile_minimum);
|
|
|
|
res_lines += wp->y_min_scanlines;
|
|
|
|
} else {
|
|
|
|
res_blocks++;
|
|
|
|
}
|
2018-04-09 03:41:06 +00:00
|
|
|
|
2018-11-14 01:24:32 +00:00
|
|
|
/*
|
|
|
|
* Make sure result blocks for higher latency levels are
|
|
|
|
* atleast as high as level below the current level.
|
|
|
|
* Assumption in DDB algorithm optimization for special
|
|
|
|
* cases. Also covers Display WA #1125 for RC.
|
|
|
|
*/
|
|
|
|
if (result_prev->plane_res_b > res_blocks)
|
|
|
|
res_blocks = result_prev->plane_res_b;
|
|
|
|
}
|
2015-02-27 15:12:35 +00:00
|
|
|
}
|
2014-11-04 17:06:55 +00:00
|
|
|
|
2018-12-21 17:14:32 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 11) {
|
|
|
|
if (wp->y_tiled) {
|
|
|
|
int extra_lines;
|
|
|
|
|
|
|
|
if (res_lines % wp->y_min_scanlines == 0)
|
|
|
|
extra_lines = wp->y_min_scanlines;
|
|
|
|
else
|
|
|
|
extra_lines = wp->y_min_scanlines * 2 -
|
|
|
|
res_lines % wp->y_min_scanlines;
|
|
|
|
|
|
|
|
min_ddb_alloc = mul_round_up_u32_fixed16(res_lines + extra_lines,
|
|
|
|
wp->plane_blocks_per_line);
|
|
|
|
} else {
|
|
|
|
min_ddb_alloc = res_blocks +
|
|
|
|
DIV_ROUND_UP(res_blocks, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-21 17:14:28 +00:00
|
|
|
if (!skl_wm_has_lines(dev_priv, level))
|
|
|
|
res_lines = 0;
|
|
|
|
|
2019-02-05 15:50:53 +00:00
|
|
|
if (res_lines > 31) {
|
|
|
|
/* reject it */
|
|
|
|
result->min_ddb_alloc = U16_MAX;
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
return;
|
2019-02-05 15:50:53 +00:00
|
|
|
}
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If res_lines is valid, assume we can use this watermark level
|
|
|
|
* for now. We'll come back and disable it after we calculate the
|
|
|
|
* DDB allocation if it turns out we don't actually have enough
|
|
|
|
* blocks to satisfy it.
|
|
|
|
*/
|
2018-04-09 03:41:05 +00:00
|
|
|
result->plane_res_b = res_blocks;
|
|
|
|
result->plane_res_l = res_lines;
|
2018-12-21 17:14:32 +00:00
|
|
|
/* Bspec says: value >= plane ddb allocation -> invalid, hence the +1 here */
|
|
|
|
result->min_ddb_alloc = max(min_ddb_alloc, res_blocks) + 1;
|
2018-04-09 03:41:05 +00:00
|
|
|
result->plane_en = true;
|
2014-11-04 17:06:42 +00:00
|
|
|
}
|
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
static void
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_compute_wm_levels(const struct intel_crtc_state *crtc_state,
|
2017-08-17 13:45:23 +00:00
|
|
|
const struct skl_wm_params *wm_params,
|
2018-10-18 11:51:30 +00:00
|
|
|
struct skl_wm_level *levels)
|
2014-11-04 17:06:42 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-05-17 11:58:28 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2018-10-18 11:51:30 +00:00
|
|
|
struct skl_wm_level *result_prev = &levels[0];
|
2016-10-04 18:28:20 +00:00
|
|
|
|
2017-05-17 11:58:28 +00:00
|
|
|
for (level = 0; level <= max_level; level++) {
|
2018-10-18 11:51:30 +00:00
|
|
|
struct skl_wm_level *result = &levels[level];
|
2017-05-17 11:58:28 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_compute_plane_wm(crtc_state, level, wm_params,
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
result_prev, result);
|
2018-10-18 11:51:30 +00:00
|
|
|
|
|
|
|
result_prev = result;
|
2017-05-17 11:58:28 +00:00
|
|
|
}
|
2014-11-04 17:06:42 +00:00
|
|
|
}
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
static u32
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_compute_linetime_wm(const struct intel_crtc_state *crtc_state)
|
2014-11-04 17:06:57 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_atomic_state *state = crtc_state->uapi.state;
|
2016-12-01 15:49:34 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(state->dev);
|
2017-05-17 11:58:29 +00:00
|
|
|
uint_fixed_16_16_t linetime_us;
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 linetime_wm;
|
2016-10-07 20:28:58 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
linetime_us = intel_get_linetime_us(crtc_state);
|
2017-07-05 14:31:46 +00:00
|
|
|
linetime_wm = fixed16_to_u32_round_up(mul_u32_fixed16(8, linetime_us));
|
2016-12-01 15:49:34 +00:00
|
|
|
|
2018-12-21 17:14:36 +00:00
|
|
|
/* Display WA #1135: BXT:ALL GLK:ALL */
|
|
|
|
if (IS_GEN9_LP(dev_priv) && dev_priv->ipc_enabled)
|
2017-08-17 13:45:25 +00:00
|
|
|
linetime_wm /= 2;
|
2016-12-01 15:49:34 +00:00
|
|
|
|
|
|
|
return linetime_wm;
|
2014-11-04 17:06:57 +00:00
|
|
|
}
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
static void skl_compute_transition_wm(const struct intel_crtc_state *crtc_state,
|
2018-11-14 21:07:23 +00:00
|
|
|
const struct skl_wm_params *wp,
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
struct skl_plane_wm *wm)
|
2014-11-04 17:06:57 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_device *dev = crtc_state->uapi.crtc->dev;
|
2017-08-17 13:45:24 +00:00
|
|
|
const struct drm_i915_private *dev_priv = to_i915(dev);
|
2019-01-18 12:01:20 +00:00
|
|
|
u16 trans_min, trans_y_tile_min;
|
|
|
|
const u16 trans_amount = 10; /* This is configurable amount */
|
|
|
|
u16 wm0_sel_res_b, trans_offset_b, res_blocks;
|
2017-08-17 13:45:24 +00:00
|
|
|
|
|
|
|
/* Transition WM are not recommended by HW team for GEN9 */
|
|
|
|
if (INTEL_GEN(dev_priv) <= 9)
|
2018-11-14 21:07:22 +00:00
|
|
|
return;
|
2017-08-17 13:45:24 +00:00
|
|
|
|
|
|
|
/* Transition WM don't make any sense if ipc is disabled */
|
|
|
|
if (!dev_priv->ipc_enabled)
|
2018-11-14 21:07:22 +00:00
|
|
|
return;
|
2017-08-17 13:45:24 +00:00
|
|
|
|
2018-10-04 23:15:56 +00:00
|
|
|
trans_min = 14;
|
|
|
|
if (INTEL_GEN(dev_priv) >= 11)
|
2017-08-17 13:45:24 +00:00
|
|
|
trans_min = 4;
|
|
|
|
|
|
|
|
trans_offset_b = trans_min + trans_amount;
|
|
|
|
|
2018-10-04 23:15:58 +00:00
|
|
|
/*
|
|
|
|
* The spec asks for Selected Result Blocks for wm0 (the real value),
|
|
|
|
* not Result Blocks (the integer value). Pay attention to the capital
|
|
|
|
* letters. The value wm_l0->plane_res_b is actually Result Blocks, but
|
|
|
|
* since Result Blocks is the ceiling of Selected Result Blocks plus 1,
|
|
|
|
* and since we later will have to get the ceiling of the sum in the
|
|
|
|
* transition watermarks calculation, we can just pretend Selected
|
|
|
|
* Result Blocks is Result Blocks minus 1 and it should work for the
|
|
|
|
* current platforms.
|
|
|
|
*/
|
2018-11-14 21:07:23 +00:00
|
|
|
wm0_sel_res_b = wm->wm[0].plane_res_b - 1;
|
2018-10-04 23:15:58 +00:00
|
|
|
|
2017-08-17 13:45:24 +00:00
|
|
|
if (wp->y_tiled) {
|
2019-01-18 12:01:20 +00:00
|
|
|
trans_y_tile_min =
|
|
|
|
(u16)mul_round_up_u32_fixed16(2, wp->y_tile_minimum);
|
2018-10-04 23:15:58 +00:00
|
|
|
res_blocks = max(wm0_sel_res_b, trans_y_tile_min) +
|
2017-08-17 13:45:24 +00:00
|
|
|
trans_offset_b;
|
|
|
|
} else {
|
2018-10-04 23:15:58 +00:00
|
|
|
res_blocks = wm0_sel_res_b + trans_offset_b;
|
2017-08-17 13:45:24 +00:00
|
|
|
|
|
|
|
/* WA BUG:1938466 add one block for non y-tile planes */
|
|
|
|
if (IS_CNL_REVID(dev_priv, CNL_REVID_A0, CNL_REVID_A0))
|
|
|
|
res_blocks += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
/*
|
|
|
|
* Just assume we can enable the transition watermark. After
|
|
|
|
* computing the DDB we'll come back and disable it if that
|
|
|
|
* assumption turns out to be false.
|
|
|
|
*/
|
|
|
|
wm->trans_wm.plane_res_b = res_blocks + 1;
|
|
|
|
wm->trans_wm.plane_en = true;
|
2014-11-04 17:06:57 +00:00
|
|
|
}
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
static int skl_build_plane_wm_single(struct intel_crtc_state *crtc_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
const struct intel_plane_state *plane_state,
|
|
|
|
enum plane_id plane_id, int color_plane)
|
2018-10-18 11:51:30 +00:00
|
|
|
{
|
2018-11-27 16:57:26 +00:00
|
|
|
struct skl_plane_wm *wm = &crtc_state->wm.skl.optimal.planes[plane_id];
|
2018-10-18 11:51:30 +00:00
|
|
|
struct skl_wm_params wm_params;
|
|
|
|
int ret;
|
|
|
|
|
2018-11-14 21:07:25 +00:00
|
|
|
ret = skl_compute_plane_wm_params(crtc_state, plane_state,
|
2018-10-18 11:51:30 +00:00
|
|
|
&wm_params, color_plane);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-03-12 20:58:37 +00:00
|
|
|
skl_compute_wm_levels(crtc_state, &wm_params, wm->wm);
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
skl_compute_transition_wm(crtc_state, &wm_params, wm);
|
2018-10-18 11:51:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
static int skl_build_plane_wm_uv(struct intel_crtc_state *crtc_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
const struct intel_plane_state *plane_state,
|
|
|
|
enum plane_id plane_id)
|
2018-10-18 11:51:30 +00:00
|
|
|
{
|
2018-11-27 16:57:26 +00:00
|
|
|
struct skl_plane_wm *wm = &crtc_state->wm.skl.optimal.planes[plane_id];
|
2018-10-18 11:51:30 +00:00
|
|
|
struct skl_wm_params wm_params;
|
|
|
|
int ret;
|
|
|
|
|
2018-11-27 16:57:26 +00:00
|
|
|
wm->is_planar = true;
|
2018-10-18 11:51:30 +00:00
|
|
|
|
|
|
|
/* uv plane watermarks must also be validated for NV12/Planar */
|
2018-11-14 21:07:25 +00:00
|
|
|
ret = skl_compute_plane_wm_params(crtc_state, plane_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
&wm_params, 1);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2018-10-18 11:51:30 +00:00
|
|
|
|
2019-03-12 20:58:37 +00:00
|
|
|
skl_compute_wm_levels(crtc_state, &wm_params, wm->uv_wm);
|
2018-10-18 11:51:30 +00:00
|
|
|
|
2018-11-27 16:57:26 +00:00
|
|
|
return 0;
|
2018-10-18 11:51:30 +00:00
|
|
|
}
|
|
|
|
|
2019-03-12 20:58:43 +00:00
|
|
|
static int skl_build_plane_wm(struct intel_crtc_state *crtc_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
const struct intel_plane_state *plane_state)
|
2018-10-18 11:51:30 +00:00
|
|
|
{
|
2019-10-31 11:26:08 +00:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2019-10-31 11:26:07 +00:00
|
|
|
const struct drm_framebuffer *fb = plane_state->hw.fb;
|
2018-11-27 16:57:26 +00:00
|
|
|
enum plane_id plane_id = plane->id;
|
2018-10-18 11:51:30 +00:00
|
|
|
int ret;
|
|
|
|
|
2018-11-27 16:57:26 +00:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
|
|
|
return 0;
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
ret = skl_build_plane_wm_single(crtc_state, plane_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
plane_id, 0);
|
2018-10-18 11:51:30 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-11-27 16:57:26 +00:00
|
|
|
if (fb->format->is_yuv && fb->format->num_planes > 1) {
|
2018-11-27 16:59:00 +00:00
|
|
|
ret = skl_build_plane_wm_uv(crtc_state, plane_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
plane_id);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-12 20:58:43 +00:00
|
|
|
static int icl_build_plane_wm(struct intel_crtc_state *crtc_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
const struct intel_plane_state *plane_state)
|
|
|
|
{
|
2019-10-31 11:26:08 +00:00
|
|
|
enum plane_id plane_id = to_intel_plane(plane_state->uapi.plane)->id;
|
2018-11-27 16:57:26 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Watermarks calculated in master */
|
2019-09-20 11:42:20 +00:00
|
|
|
if (plane_state->planar_slave)
|
2018-11-27 16:57:26 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-09-20 11:42:20 +00:00
|
|
|
if (plane_state->planar_linked_plane) {
|
2019-10-31 11:26:07 +00:00
|
|
|
const struct drm_framebuffer *fb = plane_state->hw.fb;
|
2019-09-20 11:42:20 +00:00
|
|
|
enum plane_id y_plane_id = plane_state->planar_linked_plane->id;
|
2018-11-27 16:57:26 +00:00
|
|
|
|
|
|
|
WARN_ON(!intel_wm_plane_visible(crtc_state, plane_state));
|
|
|
|
WARN_ON(!fb->format->is_yuv ||
|
|
|
|
fb->format->num_planes == 1);
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
ret = skl_build_plane_wm_single(crtc_state, plane_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
y_plane_id, 0);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
ret = skl_build_plane_wm_single(crtc_state, plane_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
plane_id, 1);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
} else if (intel_wm_plane_visible(crtc_state, plane_state)) {
|
2018-11-27 16:59:00 +00:00
|
|
|
ret = skl_build_plane_wm_single(crtc_state, plane_state,
|
2018-11-27 16:57:26 +00:00
|
|
|
plane_id, 0);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2018-10-18 11:51:30 +00:00
|
|
|
}
|
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
static int skl_build_pipe_wm(struct intel_crtc_state *crtc_state)
|
2014-11-04 17:06:42 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2019-06-28 08:55:17 +00:00
|
|
|
struct skl_pipe_wm *pipe_wm = &crtc_state->wm.skl.optimal;
|
2019-10-04 11:34:53 +00:00
|
|
|
struct intel_plane *plane;
|
|
|
|
const struct intel_plane_state *plane_state;
|
2016-05-12 14:06:08 +00:00
|
|
|
int ret;
|
2014-11-04 17:06:42 +00:00
|
|
|
|
2016-10-04 18:28:20 +00:00
|
|
|
/*
|
|
|
|
* We'll only calculate watermarks for planes that are actually
|
|
|
|
* enabled, so make sure all other planes are set as disabled.
|
|
|
|
*/
|
|
|
|
memset(pipe_wm->planes, 0, sizeof(pipe_wm->planes));
|
|
|
|
|
2019-10-04 11:34:53 +00:00
|
|
|
intel_atomic_crtc_state_for_each_plane_state(plane, plane_state,
|
|
|
|
crtc_state) {
|
2017-05-17 11:58:27 +00:00
|
|
|
|
2018-11-27 16:57:26 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 11)
|
2019-06-28 08:55:17 +00:00
|
|
|
ret = icl_build_plane_wm(crtc_state, plane_state);
|
2018-10-18 11:51:30 +00:00
|
|
|
else
|
2019-06-28 08:55:17 +00:00
|
|
|
ret = skl_build_plane_wm(crtc_state, plane_state);
|
2017-05-17 11:58:28 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2014-11-04 17:06:42 +00:00
|
|
|
}
|
2018-04-09 03:41:04 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
pipe_wm->linetime = skl_compute_linetime_wm(crtc_state);
|
2014-11-04 17:06:42 +00:00
|
|
|
|
2016-05-12 14:06:08 +00:00
|
|
|
return 0;
|
2014-11-04 17:06:42 +00:00
|
|
|
}
|
|
|
|
|
drm/i915: Type safe register read/write
Make I915_READ and I915_WRITE more type safe by wrapping the register
offset in a struct. This should eliminate most of the fumbles we've had
with misplaced parens.
This only takes care of normal mmio registers. We could extend the idea
to other register types and define each with its own struct. That way
you wouldn't be able to accidentally pass the wrong thing to a specific
register access function.
The gpio_reg setup is probably the ugliest thing left. But I figure I'd
just leave it for now, and wait for some divine inspiration to strike
before making it nice.
As for the generated code, it's actually a bit better sometimes. Eg.
looking at i915_irq_handler(), we can see the following change:
lea 0x70024(%rdx,%rax,1),%r9d
mov $0x1,%edx
- movslq %r9d,%r9
- mov %r9,%rsi
- mov %r9,-0x58(%rbp)
- callq *0xd8(%rbx)
+ mov %r9d,%esi
+ mov %r9d,-0x48(%rbp)
callq *0xd8(%rbx)
So previously gcc thought the register offset might be signed and
decided to sign extend it, just in case. The rest appears to be
mostly just minor shuffling of instructions.
v2: i915_mmio_reg_{offset,equal,valid}() helpers added
s/_REG/_MMIO/ in the register defines
mo more switch statements left to worry about
ring_emit stuff got sorted in a prep patch
cmd parser, lrc context and w/a batch buildup also in prep patch
vgpu stuff cleaned up and moved to a prep patch
all other unrelated changes split out
v3: Rebased due to BXT DSI/BLC, MOCS, etc.
v4: Rebased due to churn, s/i915_mmio_reg_t/i915_reg_t/
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1447853606-2751-1-git-send-email-ville.syrjala@linux.intel.com
2015-11-18 13:33:26 +00:00
|
|
|
static void skl_ddb_entry_write(struct drm_i915_private *dev_priv,
|
|
|
|
i915_reg_t reg,
|
2014-11-04 17:06:53 +00:00
|
|
|
const struct skl_ddb_entry *entry)
|
|
|
|
{
|
|
|
|
if (entry->end)
|
2018-11-27 16:59:00 +00:00
|
|
|
I915_WRITE_FW(reg, (entry->end - 1) << 16 | entry->start);
|
2014-11-04 17:06:53 +00:00
|
|
|
else
|
2018-11-27 16:59:00 +00:00
|
|
|
I915_WRITE_FW(reg, 0);
|
2014-11-04 17:06:53 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 18:09:49 +00:00
|
|
|
static void skl_write_wm_level(struct drm_i915_private *dev_priv,
|
|
|
|
i915_reg_t reg,
|
|
|
|
const struct skl_wm_level *level)
|
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 val = 0;
|
2016-10-18 18:09:49 +00:00
|
|
|
|
2019-02-13 16:54:23 +00:00
|
|
|
if (level->plane_en)
|
2016-10-18 18:09:49 +00:00
|
|
|
val |= PLANE_WM_EN;
|
2019-02-13 16:54:23 +00:00
|
|
|
if (level->ignore_lines)
|
|
|
|
val |= PLANE_WM_IGNORE_LINES;
|
|
|
|
val |= level->plane_res_b;
|
|
|
|
val |= level->plane_res_l << PLANE_WM_LINES_SHIFT;
|
2016-10-18 18:09:49 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
I915_WRITE_FW(reg, val);
|
2016-10-18 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
void skl_write_plane_wm(struct intel_plane *plane,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
drm/i915/skl: Update plane watermarks atomically during plane updates
Thanks to Ville for suggesting this as a potential solution to pipe
underruns on Skylake.
On Skylake all of the registers for configuring planes, including the
registers for configuring their watermarks, are double buffered. New
values written to them won't take effect until said registers are
"armed", which is done by writing to the PLANE_SURF (or in the case of
cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl
like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written
yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place;
inside of the vblank evasion where we update all of the registers for
each plane. While this patch doesn't fix everything, it does allow us to
update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're
not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into
intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level
should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more
then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when
writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until
patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check
this in all places where we call this function, and it was supposed
to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of
IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this
needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
Changes since v8:
- Don't forget calls to skl_write_plane_wm() when disabling planes
- Use INTEL_GEN(), not INTEL_INFO()->gen in intel_begin_crtc_commit()
Fixes: 2d41c0b59afc ("drm/i915/skl: SKL Watermark Computation")
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Cc: stable@vger.kernel.org
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
2016-08-22 16:50:08 +00:00
|
|
|
{
|
2018-11-27 16:59:00 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
|
2016-10-13 10:03:10 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2018-11-27 16:59:00 +00:00
|
|
|
enum plane_id plane_id = plane->id;
|
|
|
|
enum pipe pipe = plane->pipe;
|
|
|
|
const struct skl_plane_wm *wm =
|
|
|
|
&crtc_state->wm.skl.optimal.planes[plane_id];
|
|
|
|
const struct skl_ddb_entry *ddb_y =
|
|
|
|
&crtc_state->wm.skl.plane_ddb_y[plane_id];
|
|
|
|
const struct skl_ddb_entry *ddb_uv =
|
|
|
|
&crtc_state->wm.skl.plane_ddb_uv[plane_id];
|
drm/i915/skl: Update plane watermarks atomically during plane updates
Thanks to Ville for suggesting this as a potential solution to pipe
underruns on Skylake.
On Skylake all of the registers for configuring planes, including the
registers for configuring their watermarks, are double buffered. New
values written to them won't take effect until said registers are
"armed", which is done by writing to the PLANE_SURF (or in the case of
cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl
like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written
yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place;
inside of the vblank evasion where we update all of the registers for
each plane. While this patch doesn't fix everything, it does allow us to
update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're
not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into
intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level
should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more
then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when
writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until
patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check
this in all places where we call this function, and it was supposed
to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of
IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this
needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
Changes since v8:
- Don't forget calls to skl_write_plane_wm() when disabling planes
- Use INTEL_GEN(), not INTEL_INFO()->gen in intel_begin_crtc_commit()
Fixes: 2d41c0b59afc ("drm/i915/skl: SKL Watermark Computation")
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Cc: stable@vger.kernel.org
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
2016-08-22 16:50:08 +00:00
|
|
|
|
|
|
|
for (level = 0; level <= max_level; level++) {
|
2016-11-22 16:01:58 +00:00
|
|
|
skl_write_wm_level(dev_priv, PLANE_WM(pipe, plane_id, level),
|
2016-10-18 18:09:49 +00:00
|
|
|
&wm->wm[level]);
|
drm/i915/skl: Update plane watermarks atomically during plane updates
Thanks to Ville for suggesting this as a potential solution to pipe
underruns on Skylake.
On Skylake all of the registers for configuring planes, including the
registers for configuring their watermarks, are double buffered. New
values written to them won't take effect until said registers are
"armed", which is done by writing to the PLANE_SURF (or in the case of
cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl
like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written
yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place;
inside of the vblank evasion where we update all of the registers for
each plane. While this patch doesn't fix everything, it does allow us to
update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're
not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into
intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level
should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more
then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when
writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until
patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check
this in all places where we call this function, and it was supposed
to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of
IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this
needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
Changes since v8:
- Don't forget calls to skl_write_plane_wm() when disabling planes
- Use INTEL_GEN(), not INTEL_INFO()->gen in intel_begin_crtc_commit()
Fixes: 2d41c0b59afc ("drm/i915/skl: SKL Watermark Computation")
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Cc: stable@vger.kernel.org
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
2016-08-22 16:50:08 +00:00
|
|
|
}
|
2016-11-22 16:01:58 +00:00
|
|
|
skl_write_wm_level(dev_priv, PLANE_WM_TRANS(pipe, plane_id),
|
2016-10-18 18:09:49 +00:00
|
|
|
&wm->trans_wm);
|
drm/i915/skl: Update DDB values atomically with wms/plane attrs
Now that we can hook into update_crtcs and control the order in which we
update CRTCs at each modeset, we can finish the final step of fixing
Skylake's watermark handling by performing DDB updates at the same time
as plane updates and watermark updates.
The first major change in this patch is skl_update_crtcs(), which
handles ensuring that we order each CRTC update in our atomic commits
properly so that they honor the DDB flush order.
The second major change in this patch is the order in which we flush the
pipes. While the previous order may have worked, it can't be used in
this approach since it no longer will do the right thing. For example,
using the old ddb flush order:
We have pipes A, B, and C enabled, and we're disabling C. Initial ddb
allocation looks like this:
| A | B |xxxxxxx|
Since we're performing the ddb updates after performing any CRTC
disablements in intel_atomic_commit_tail(), the space to the right of
pipe B is unallocated.
1. Flush pipes with new allocation contained into old space. None
apply, so we skip this
2. Flush pipes having their allocation reduced, but overlapping with a
previous allocation. None apply, so we also skip this
3. Flush pipes that got more space allocated. This applies to A and B,
giving us the following update order: A, B
This is wrong, since updating pipe A first will cause it to overlap with
B and potentially burst into flames. Our new order (see the code
comments for details) would update the pipes in the proper order: B, A.
As well, we calculate the order for each DDB update during the check
phase, and reference it later in the commit phase when we hit
skl_update_crtcs().
This long overdue patch fixes the rest of the underruns on Skylake.
Changes since v1:
- Add skl_ddb_entry_write() for cursor into skl_write_cursor_wm()
Changes since v2:
- Use the method for updating CRTCs that Ville suggested
- In skl_update_wm(), only copy the watermarks for the crtc that was
passed to us
Changes since v3:
- Small comment fix in skl_ddb_allocation_overlaps()
Changes since v4:
- Remove the second loop in intel_update_crtcs() and use Ville's
suggestion for updating the ddb allocations in the right order
- Get rid of the second loop and just use the ddb state as it updates
to determine what order to update everything in (thanks for the
suggestion Ville)
- Simplify skl_ddb_allocation_overlaps()
- Split actual overlap checking into it's own helper
Fixes: 0e8fb7ba7ca5 ("drm/i915/skl: Flush the WM configuration")
Fixes: 8211bd5bdf5e ("drm/i915/skl: Program the DDB allocation")
[omitting CC for stable, since this patch will need to be changed for
such backports first]
Testcase: kms_cursor_legacy
Testcase: plane-all-modeset-transition
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471961565-28540-2-git-send-email-cpaul@redhat.com
2016-08-24 05:48:10 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 11) {
|
2018-01-30 13:49:13 +00:00
|
|
|
skl_ddb_entry_write(dev_priv,
|
2018-11-27 16:59:00 +00:00
|
|
|
PLANE_BUF_CFG(pipe, plane_id), ddb_y);
|
|
|
|
return;
|
2018-04-09 03:41:01 +00:00
|
|
|
}
|
2018-11-27 16:59:00 +00:00
|
|
|
|
|
|
|
if (wm->is_planar)
|
|
|
|
swap(ddb_y, ddb_uv);
|
|
|
|
|
|
|
|
skl_ddb_entry_write(dev_priv,
|
|
|
|
PLANE_BUF_CFG(pipe, plane_id), ddb_y);
|
|
|
|
skl_ddb_entry_write(dev_priv,
|
|
|
|
PLANE_NV12_BUF_CFG(pipe, plane_id), ddb_uv);
|
drm/i915/skl: Update plane watermarks atomically during plane updates
Thanks to Ville for suggesting this as a potential solution to pipe
underruns on Skylake.
On Skylake all of the registers for configuring planes, including the
registers for configuring their watermarks, are double buffered. New
values written to them won't take effect until said registers are
"armed", which is done by writing to the PLANE_SURF (or in the case of
cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl
like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written
yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place;
inside of the vblank evasion where we update all of the registers for
each plane. While this patch doesn't fix everything, it does allow us to
update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're
not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into
intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level
should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more
then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when
writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until
patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check
this in all places where we call this function, and it was supposed
to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of
IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this
needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
Changes since v8:
- Don't forget calls to skl_write_plane_wm() when disabling planes
- Use INTEL_GEN(), not INTEL_INFO()->gen in intel_begin_crtc_commit()
Fixes: 2d41c0b59afc ("drm/i915/skl: SKL Watermark Computation")
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Cc: stable@vger.kernel.org
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
2016-08-22 16:50:08 +00:00
|
|
|
}
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
void skl_write_cursor_wm(struct intel_plane *plane,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
drm/i915/skl: Update plane watermarks atomically during plane updates
Thanks to Ville for suggesting this as a potential solution to pipe
underruns on Skylake.
On Skylake all of the registers for configuring planes, including the
registers for configuring their watermarks, are double buffered. New
values written to them won't take effect until said registers are
"armed", which is done by writing to the PLANE_SURF (or in the case of
cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl
like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written
yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place;
inside of the vblank evasion where we update all of the registers for
each plane. While this patch doesn't fix everything, it does allow us to
update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're
not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into
intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level
should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more
then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when
writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until
patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check
this in all places where we call this function, and it was supposed
to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of
IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this
needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
Changes since v8:
- Don't forget calls to skl_write_plane_wm() when disabling planes
- Use INTEL_GEN(), not INTEL_INFO()->gen in intel_begin_crtc_commit()
Fixes: 2d41c0b59afc ("drm/i915/skl: SKL Watermark Computation")
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Cc: stable@vger.kernel.org
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
2016-08-22 16:50:08 +00:00
|
|
|
{
|
2018-11-27 16:59:00 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
|
2016-10-13 10:03:10 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2018-11-27 16:59:00 +00:00
|
|
|
enum plane_id plane_id = plane->id;
|
|
|
|
enum pipe pipe = plane->pipe;
|
|
|
|
const struct skl_plane_wm *wm =
|
|
|
|
&crtc_state->wm.skl.optimal.planes[plane_id];
|
|
|
|
const struct skl_ddb_entry *ddb =
|
|
|
|
&crtc_state->wm.skl.plane_ddb_y[plane_id];
|
drm/i915/skl: Update plane watermarks atomically during plane updates
Thanks to Ville for suggesting this as a potential solution to pipe
underruns on Skylake.
On Skylake all of the registers for configuring planes, including the
registers for configuring their watermarks, are double buffered. New
values written to them won't take effect until said registers are
"armed", which is done by writing to the PLANE_SURF (or in the case of
cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl
like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written
yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place;
inside of the vblank evasion where we update all of the registers for
each plane. While this patch doesn't fix everything, it does allow us to
update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're
not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into
intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level
should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more
then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when
writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until
patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check
this in all places where we call this function, and it was supposed
to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of
IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this
needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
Changes since v8:
- Don't forget calls to skl_write_plane_wm() when disabling planes
- Use INTEL_GEN(), not INTEL_INFO()->gen in intel_begin_crtc_commit()
Fixes: 2d41c0b59afc ("drm/i915/skl: SKL Watermark Computation")
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Cc: stable@vger.kernel.org
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
2016-08-22 16:50:08 +00:00
|
|
|
|
|
|
|
for (level = 0; level <= max_level; level++) {
|
2016-10-18 18:09:49 +00:00
|
|
|
skl_write_wm_level(dev_priv, CUR_WM(pipe, level),
|
|
|
|
&wm->wm[level]);
|
drm/i915/skl: Update plane watermarks atomically during plane updates
Thanks to Ville for suggesting this as a potential solution to pipe
underruns on Skylake.
On Skylake all of the registers for configuring planes, including the
registers for configuring their watermarks, are double buffered. New
values written to them won't take effect until said registers are
"armed", which is done by writing to the PLANE_SURF (or in the case of
cursor planes, the CURBASE register) register.
With this in mind, up until now we've been updating watermarks on skl
like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
or
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks()
- {vblank happens; new watermarks + old plane values => underrun }
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- end vblank evasion
}
Now we update watermarks atomically like this:
non-modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- intel_pre_plane_update:
- intel_update_watermarks() (wm values aren't written yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
modeset {
- calculate (during atomic check phase)
- finish_atomic_commit:
- crtc_enable:
- intel_update_watermarks() (actual wm values aren't written
yet)
- drm_atomic_helper_commit_planes_on_crtc:
- start vblank evasion
- write new plane registers
- write new wm values
- end vblank evasion
}
So this patch moves all of the watermark writes into the right place;
inside of the vblank evasion where we update all of the registers for
each plane. While this patch doesn't fix everything, it does allow us to
update the watermark values in the way the hardware expects us to.
Changes since original patch series:
- Remove mutex_lock/mutex_unlock since they don't do anything and we're
not touching global state
- Move skl_write_cursor_wm/skl_write_plane_wm functions into
intel_pm.c, make externally visible
- Add skl_write_plane_wm calls to skl_update_plane
- Fix conditional for for loop in skl_write_plane_wm (level < max_level
should be level <= max_level)
- Make diagram in commit more accurate to what's actually happening
- Add Fixes:
Changes since v1:
- Use IS_GEN9() instead of IS_SKYLAKE() since these fixes apply to more
then just Skylake
- Update description to make it clear this patch doesn't fix everything
- Check if pipes were actually changed before writing watermarks
Changes since v2:
- Write PIPE_WM_LINETIME during vblank evasion
Changes since v3:
- Rebase against new SAGV patch changes
Changes since v4:
- Add a parameter to choose what skl_wm_values struct to use when
writing new plane watermarks
Changes since v5:
- Remove cursor ddb entry write in skl_write_cursor_wm(), defer until
patch 6
- Write WM_LINETIME in intel_begin_crtc_commit()
Changes since v6:
- Remove redundant dirty_pipes check in skl_write_plane_wm (we check
this in all places where we call this function, and it was supposed
to have been removed earlier anyway)
- In i9xx_update_cursor(), use dev_priv->info.gen >= 9 instead of
IS_GEN9(dev_priv). We do this everywhere else and I'd imagine this
needs to be done for gen10 as well
Changes since v7:
- Fix rebase fail (unused variable obj)
- Make struct skl_wm_values *wm const
- Fix indenting
- Use INTEL_GEN() instead of dev_priv->info.gen
Changes since v8:
- Don't forget calls to skl_write_plane_wm() when disabling planes
- Use INTEL_GEN(), not INTEL_INFO()->gen in intel_begin_crtc_commit()
Fixes: 2d41c0b59afc ("drm/i915/skl: SKL Watermark Computation")
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Cc: stable@vger.kernel.org
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
Link: http://patchwork.freedesktop.org/patch/msgid/1471884608-10671-1-git-send-email-cpaul@redhat.com
2016-08-22 16:50:08 +00:00
|
|
|
}
|
2016-10-18 18:09:49 +00:00
|
|
|
skl_write_wm_level(dev_priv, CUR_WM_TRANS(pipe), &wm->trans_wm);
|
2014-11-04 17:07:00 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
skl_ddb_entry_write(dev_priv, CUR_BUF_CFG(pipe), ddb);
|
2014-11-04 17:06:42 +00:00
|
|
|
}
|
|
|
|
|
2016-10-14 21:31:56 +00:00
|
|
|
bool skl_wm_level_equals(const struct skl_wm_level *l1,
|
|
|
|
const struct skl_wm_level *l2)
|
|
|
|
{
|
2018-11-27 16:59:00 +00:00
|
|
|
return l1->plane_en == l2->plane_en &&
|
2019-02-13 16:54:23 +00:00
|
|
|
l1->ignore_lines == l2->ignore_lines &&
|
2018-11-27 16:59:00 +00:00
|
|
|
l1->plane_res_l == l2->plane_res_l &&
|
|
|
|
l1->plane_res_b == l2->plane_res_b;
|
|
|
|
}
|
2016-10-14 21:31:56 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
static bool skl_plane_wm_equals(struct drm_i915_private *dev_priv,
|
|
|
|
const struct skl_plane_wm *wm1,
|
|
|
|
const struct skl_plane_wm *wm2)
|
|
|
|
{
|
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2016-10-14 21:31:56 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
for (level = 0; level <= max_level; level++) {
|
|
|
|
if (!skl_wm_level_equals(&wm1->wm[level], &wm2->wm[level]) ||
|
|
|
|
!skl_wm_level_equals(&wm1->uv_wm[level], &wm2->uv_wm[level]))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return skl_wm_level_equals(&wm1->trans_wm, &wm2->trans_wm);
|
2016-10-14 21:31:56 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 17:14:32 +00:00
|
|
|
static bool skl_pipe_wm_equals(struct intel_crtc *crtc,
|
|
|
|
const struct skl_pipe_wm *wm1,
|
|
|
|
const struct skl_pipe_wm *wm2)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
enum plane_id plane_id;
|
|
|
|
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
|
|
|
if (!skl_plane_wm_equals(dev_priv,
|
|
|
|
&wm1->planes[plane_id],
|
|
|
|
&wm2->planes[plane_id]))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wm1->linetime == wm2->linetime;
|
|
|
|
}
|
|
|
|
|
drm/i915/skl: Update DDB values atomically with wms/plane attrs
Now that we can hook into update_crtcs and control the order in which we
update CRTCs at each modeset, we can finish the final step of fixing
Skylake's watermark handling by performing DDB updates at the same time
as plane updates and watermark updates.
The first major change in this patch is skl_update_crtcs(), which
handles ensuring that we order each CRTC update in our atomic commits
properly so that they honor the DDB flush order.
The second major change in this patch is the order in which we flush the
pipes. While the previous order may have worked, it can't be used in
this approach since it no longer will do the right thing. For example,
using the old ddb flush order:
We have pipes A, B, and C enabled, and we're disabling C. Initial ddb
allocation looks like this:
| A | B |xxxxxxx|
Since we're performing the ddb updates after performing any CRTC
disablements in intel_atomic_commit_tail(), the space to the right of
pipe B is unallocated.
1. Flush pipes with new allocation contained into old space. None
apply, so we skip this
2. Flush pipes having their allocation reduced, but overlapping with a
previous allocation. None apply, so we also skip this
3. Flush pipes that got more space allocated. This applies to A and B,
giving us the following update order: A, B
This is wrong, since updating pipe A first will cause it to overlap with
B and potentially burst into flames. Our new order (see the code
comments for details) would update the pipes in the proper order: B, A.
As well, we calculate the order for each DDB update during the check
phase, and reference it later in the commit phase when we hit
skl_update_crtcs().
This long overdue patch fixes the rest of the underruns on Skylake.
Changes since v1:
- Add skl_ddb_entry_write() for cursor into skl_write_cursor_wm()
Changes since v2:
- Use the method for updating CRTCs that Ville suggested
- In skl_update_wm(), only copy the watermarks for the crtc that was
passed to us
Changes since v3:
- Small comment fix in skl_ddb_allocation_overlaps()
Changes since v4:
- Remove the second loop in intel_update_crtcs() and use Ville's
suggestion for updating the ddb allocations in the right order
- Get rid of the second loop and just use the ddb state as it updates
to determine what order to update everything in (thanks for the
suggestion Ville)
- Simplify skl_ddb_allocation_overlaps()
- Split actual overlap checking into it's own helper
Fixes: 0e8fb7ba7ca5 ("drm/i915/skl: Flush the WM configuration")
Fixes: 8211bd5bdf5e ("drm/i915/skl: Program the DDB allocation")
[omitting CC for stable, since this patch will need to be changed for
such backports first]
Testcase: kms_cursor_legacy
Testcase: plane-all-modeset-transition
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471961565-28540-2-git-send-email-cpaul@redhat.com
2016-08-24 05:48:10 +00:00
|
|
|
static inline bool skl_ddb_entries_overlap(const struct skl_ddb_entry *a,
|
|
|
|
const struct skl_ddb_entry *b)
|
2014-11-04 17:07:02 +00:00
|
|
|
{
|
drm/i915/skl: Update DDB values atomically with wms/plane attrs
Now that we can hook into update_crtcs and control the order in which we
update CRTCs at each modeset, we can finish the final step of fixing
Skylake's watermark handling by performing DDB updates at the same time
as plane updates and watermark updates.
The first major change in this patch is skl_update_crtcs(), which
handles ensuring that we order each CRTC update in our atomic commits
properly so that they honor the DDB flush order.
The second major change in this patch is the order in which we flush the
pipes. While the previous order may have worked, it can't be used in
this approach since it no longer will do the right thing. For example,
using the old ddb flush order:
We have pipes A, B, and C enabled, and we're disabling C. Initial ddb
allocation looks like this:
| A | B |xxxxxxx|
Since we're performing the ddb updates after performing any CRTC
disablements in intel_atomic_commit_tail(), the space to the right of
pipe B is unallocated.
1. Flush pipes with new allocation contained into old space. None
apply, so we skip this
2. Flush pipes having their allocation reduced, but overlapping with a
previous allocation. None apply, so we also skip this
3. Flush pipes that got more space allocated. This applies to A and B,
giving us the following update order: A, B
This is wrong, since updating pipe A first will cause it to overlap with
B and potentially burst into flames. Our new order (see the code
comments for details) would update the pipes in the proper order: B, A.
As well, we calculate the order for each DDB update during the check
phase, and reference it later in the commit phase when we hit
skl_update_crtcs().
This long overdue patch fixes the rest of the underruns on Skylake.
Changes since v1:
- Add skl_ddb_entry_write() for cursor into skl_write_cursor_wm()
Changes since v2:
- Use the method for updating CRTCs that Ville suggested
- In skl_update_wm(), only copy the watermarks for the crtc that was
passed to us
Changes since v3:
- Small comment fix in skl_ddb_allocation_overlaps()
Changes since v4:
- Remove the second loop in intel_update_crtcs() and use Ville's
suggestion for updating the ddb allocations in the right order
- Get rid of the second loop and just use the ddb state as it updates
to determine what order to update everything in (thanks for the
suggestion Ville)
- Simplify skl_ddb_allocation_overlaps()
- Split actual overlap checking into it's own helper
Fixes: 0e8fb7ba7ca5 ("drm/i915/skl: Flush the WM configuration")
Fixes: 8211bd5bdf5e ("drm/i915/skl: Program the DDB allocation")
[omitting CC for stable, since this patch will need to be changed for
such backports first]
Testcase: kms_cursor_legacy
Testcase: plane-all-modeset-transition
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471961565-28540-2-git-send-email-cpaul@redhat.com
2016-08-24 05:48:10 +00:00
|
|
|
return a->start < b->end && b->start < a->end;
|
2014-11-04 17:07:02 +00:00
|
|
|
}
|
|
|
|
|
2018-11-01 15:05:59 +00:00
|
|
|
bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry *ddb,
|
2019-04-05 11:00:15 +00:00
|
|
|
const struct skl_ddb_entry *entries,
|
2018-11-01 15:05:59 +00:00
|
|
|
int num_entries, int ignore_idx)
|
2014-11-04 17:07:02 +00:00
|
|
|
{
|
2018-11-01 15:05:59 +00:00
|
|
|
int i;
|
2014-11-04 17:07:02 +00:00
|
|
|
|
2018-11-01 15:05:59 +00:00
|
|
|
for (i = 0; i < num_entries; i++) {
|
|
|
|
if (i != ignore_idx &&
|
|
|
|
skl_ddb_entries_overlap(ddb, &entries[i]))
|
drm/i915/skl: Update DDB values atomically with wms/plane attrs
Now that we can hook into update_crtcs and control the order in which we
update CRTCs at each modeset, we can finish the final step of fixing
Skylake's watermark handling by performing DDB updates at the same time
as plane updates and watermark updates.
The first major change in this patch is skl_update_crtcs(), which
handles ensuring that we order each CRTC update in our atomic commits
properly so that they honor the DDB flush order.
The second major change in this patch is the order in which we flush the
pipes. While the previous order may have worked, it can't be used in
this approach since it no longer will do the right thing. For example,
using the old ddb flush order:
We have pipes A, B, and C enabled, and we're disabling C. Initial ddb
allocation looks like this:
| A | B |xxxxxxx|
Since we're performing the ddb updates after performing any CRTC
disablements in intel_atomic_commit_tail(), the space to the right of
pipe B is unallocated.
1. Flush pipes with new allocation contained into old space. None
apply, so we skip this
2. Flush pipes having their allocation reduced, but overlapping with a
previous allocation. None apply, so we also skip this
3. Flush pipes that got more space allocated. This applies to A and B,
giving us the following update order: A, B
This is wrong, since updating pipe A first will cause it to overlap with
B and potentially burst into flames. Our new order (see the code
comments for details) would update the pipes in the proper order: B, A.
As well, we calculate the order for each DDB update during the check
phase, and reference it later in the commit phase when we hit
skl_update_crtcs().
This long overdue patch fixes the rest of the underruns on Skylake.
Changes since v1:
- Add skl_ddb_entry_write() for cursor into skl_write_cursor_wm()
Changes since v2:
- Use the method for updating CRTCs that Ville suggested
- In skl_update_wm(), only copy the watermarks for the crtc that was
passed to us
Changes since v3:
- Small comment fix in skl_ddb_allocation_overlaps()
Changes since v4:
- Remove the second loop in intel_update_crtcs() and use Ville's
suggestion for updating the ddb allocations in the right order
- Get rid of the second loop and just use the ddb state as it updates
to determine what order to update everything in (thanks for the
suggestion Ville)
- Simplify skl_ddb_allocation_overlaps()
- Split actual overlap checking into it's own helper
Fixes: 0e8fb7ba7ca5 ("drm/i915/skl: Flush the WM configuration")
Fixes: 8211bd5bdf5e ("drm/i915/skl: Program the DDB allocation")
[omitting CC for stable, since this patch will need to be changed for
such backports first]
Testcase: kms_cursor_legacy
Testcase: plane-all-modeset-transition
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471961565-28540-2-git-send-email-cpaul@redhat.com
2016-08-24 05:48:10 +00:00
|
|
|
return true;
|
2017-10-10 10:17:03 +00:00
|
|
|
}
|
2014-11-04 17:07:02 +00:00
|
|
|
|
drm/i915/skl: Update DDB values atomically with wms/plane attrs
Now that we can hook into update_crtcs and control the order in which we
update CRTCs at each modeset, we can finish the final step of fixing
Skylake's watermark handling by performing DDB updates at the same time
as plane updates and watermark updates.
The first major change in this patch is skl_update_crtcs(), which
handles ensuring that we order each CRTC update in our atomic commits
properly so that they honor the DDB flush order.
The second major change in this patch is the order in which we flush the
pipes. While the previous order may have worked, it can't be used in
this approach since it no longer will do the right thing. For example,
using the old ddb flush order:
We have pipes A, B, and C enabled, and we're disabling C. Initial ddb
allocation looks like this:
| A | B |xxxxxxx|
Since we're performing the ddb updates after performing any CRTC
disablements in intel_atomic_commit_tail(), the space to the right of
pipe B is unallocated.
1. Flush pipes with new allocation contained into old space. None
apply, so we skip this
2. Flush pipes having their allocation reduced, but overlapping with a
previous allocation. None apply, so we also skip this
3. Flush pipes that got more space allocated. This applies to A and B,
giving us the following update order: A, B
This is wrong, since updating pipe A first will cause it to overlap with
B and potentially burst into flames. Our new order (see the code
comments for details) would update the pipes in the proper order: B, A.
As well, we calculate the order for each DDB update during the check
phase, and reference it later in the commit phase when we hit
skl_update_crtcs().
This long overdue patch fixes the rest of the underruns on Skylake.
Changes since v1:
- Add skl_ddb_entry_write() for cursor into skl_write_cursor_wm()
Changes since v2:
- Use the method for updating CRTCs that Ville suggested
- In skl_update_wm(), only copy the watermarks for the crtc that was
passed to us
Changes since v3:
- Small comment fix in skl_ddb_allocation_overlaps()
Changes since v4:
- Remove the second loop in intel_update_crtcs() and use Ville's
suggestion for updating the ddb allocations in the right order
- Get rid of the second loop and just use the ddb state as it updates
to determine what order to update everything in (thanks for the
suggestion Ville)
- Simplify skl_ddb_allocation_overlaps()
- Split actual overlap checking into it's own helper
Fixes: 0e8fb7ba7ca5 ("drm/i915/skl: Flush the WM configuration")
Fixes: 8211bd5bdf5e ("drm/i915/skl: Program the DDB allocation")
[omitting CC for stable, since this patch will need to be changed for
such backports first]
Testcase: kms_cursor_legacy
Testcase: plane-all-modeset-transition
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471961565-28540-2-git-send-email-cpaul@redhat.com
2016-08-24 05:48:10 +00:00
|
|
|
return false;
|
2014-11-04 17:07:02 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 09:29:17 +00:00
|
|
|
static int
|
2018-11-27 16:59:00 +00:00
|
|
|
skl_ddb_add_affected_planes(const struct intel_crtc_state *old_crtc_state,
|
|
|
|
struct intel_crtc_state *new_crtc_state)
|
2017-06-13 17:52:30 +00:00
|
|
|
{
|
2019-10-31 11:26:03 +00:00
|
|
|
struct intel_atomic_state *state = to_intel_atomic_state(new_crtc_state->uapi.state);
|
|
|
|
struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->uapi.crtc);
|
2018-11-27 16:59:00 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
struct intel_plane *plane;
|
2017-06-13 17:52:30 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) {
|
|
|
|
struct intel_plane_state *plane_state;
|
|
|
|
enum plane_id plane_id = plane->id;
|
2017-06-13 17:52:30 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
if (skl_ddb_entry_equal(&old_crtc_state->wm.skl.plane_ddb_y[plane_id],
|
|
|
|
&new_crtc_state->wm.skl.plane_ddb_y[plane_id]) &&
|
|
|
|
skl_ddb_entry_equal(&old_crtc_state->wm.skl.plane_ddb_uv[plane_id],
|
|
|
|
&new_crtc_state->wm.skl.plane_ddb_uv[plane_id]))
|
2017-06-13 17:52:30 +00:00
|
|
|
continue;
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
plane_state = intel_atomic_get_plane_state(state, plane);
|
2017-06-13 17:52:30 +00:00
|
|
|
if (IS_ERR(plane_state))
|
|
|
|
return PTR_ERR(plane_state);
|
drm/i915/gen11: Link nv12 Y and UV planes in the atomic state, v5.
To make NV12 working on icl, we need to update 2 planes simultaneously.
I've chosen to do this in the CRTC step after plane validation is done,
so we know what planes are (in)visible. The linked Y plane will get
updated in intel_plane_update_planes_on_crtc(), by the call to
update_slave, which gets the master's plane_state as argument.
The link requires both planes for atomic_update to work,
so make sure skl_ddb_add_affected_planes() adds both states.
Changes since v1:
- Introduce icl_is_nv12_y_plane(), instead of hardcoding sprite numbers.
- Put all the state updating login in intel_plane_atomic_check_with_state().
- Clean up changes in intel_plane_atomic_check().
Changes since v2:
- Fix intel_atomic_get_old_plane_state() to actually return old state.
- Move visibility changes to preparation patch.
- Only try to find a Y plane on gen11, earlier platforms only require
a single plane.
Changes since v3:
- Fix checkpatch warning about to_intel_crtc() usage.
- Add affected planes from icl_add_linked_planes() before check_planes(),
it's a cleaner way to do this. (Ville)
Changes since v4:
- Clear plane links in icl_check_nv12_planes() for clarity.
- Only pass crtc_state to icl_check_nv12_planes().
- Use for_each_new_intel_plane_in_state() in icl_check_nv12_planes.
- Rename aux to linked. (Ville)
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181022135152.15324-1-maarten.lankhorst@linux.intel.com
[mlankhorst: Change bool slave to u32, to satisfy checkpatch]
[mlankhorst: Add WARN_ON's based on Ville's suggestion]
2018-10-22 13:51:52 +00:00
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
new_crtc_state->update_planes |= BIT(plane_id);
|
2017-06-13 17:52:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2018-12-10 21:54:14 +00:00
|
|
|
skl_compute_ddb(struct intel_atomic_state *state)
|
2016-05-12 14:06:03 +00:00
|
|
|
{
|
2018-12-10 21:54:14 +00:00
|
|
|
const struct drm_i915_private *dev_priv = to_i915(state->base.dev);
|
|
|
|
struct skl_ddb_allocation *ddb = &state->wm_results.ddb;
|
2018-11-27 16:59:00 +00:00
|
|
|
struct intel_crtc_state *old_crtc_state;
|
|
|
|
struct intel_crtc_state *new_crtc_state;
|
2018-04-09 03:41:08 +00:00
|
|
|
struct intel_crtc *crtc;
|
|
|
|
int ret, i;
|
2016-05-12 14:06:03 +00:00
|
|
|
|
2016-10-04 17:37:32 +00:00
|
|
|
memcpy(ddb, &dev_priv->wm.skl_hw.ddb, sizeof(*ddb));
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
|
2018-11-27 16:59:00 +00:00
|
|
|
new_crtc_state, i) {
|
|
|
|
ret = skl_allocate_pipe_ddb(new_crtc_state, ddb);
|
2017-06-13 17:52:30 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
ret = skl_ddb_add_affected_planes(old_crtc_state,
|
|
|
|
new_crtc_state);
|
2017-06-13 17:52:30 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2016-05-12 14:06:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-08 20:05:27 +00:00
|
|
|
static char enast(bool enable)
|
|
|
|
{
|
|
|
|
return enable ? '*' : ' ';
|
|
|
|
}
|
|
|
|
|
2016-10-14 21:31:54 +00:00
|
|
|
static void
|
2018-11-27 16:59:00 +00:00
|
|
|
skl_print_wm_changes(struct intel_atomic_state *state)
|
2016-10-14 21:31:54 +00:00
|
|
|
{
|
2018-11-27 16:59:00 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(state->base.dev);
|
|
|
|
const struct intel_crtc_state *old_crtc_state;
|
|
|
|
const struct intel_crtc_state *new_crtc_state;
|
|
|
|
struct intel_plane *plane;
|
|
|
|
struct intel_crtc *crtc;
|
2016-11-01 11:04:10 +00:00
|
|
|
int i;
|
2016-10-14 21:31:54 +00:00
|
|
|
|
2019-10-28 10:38:15 +00:00
|
|
|
if (!drm_debug_enabled(DRM_UT_KMS))
|
2019-02-08 20:05:27 +00:00
|
|
|
return;
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
|
|
|
|
new_crtc_state, i) {
|
2019-02-08 20:05:27 +00:00
|
|
|
const struct skl_pipe_wm *old_pipe_wm, *new_pipe_wm;
|
|
|
|
|
|
|
|
old_pipe_wm = &old_crtc_state->wm.skl.optimal;
|
|
|
|
new_pipe_wm = &new_crtc_state->wm.skl.optimal;
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) {
|
|
|
|
enum plane_id plane_id = plane->id;
|
2016-10-14 21:31:54 +00:00
|
|
|
const struct skl_ddb_entry *old, *new;
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
old = &old_crtc_state->wm.skl.plane_ddb_y[plane_id];
|
|
|
|
new = &new_crtc_state->wm.skl.plane_ddb_y[plane_id];
|
2016-10-14 21:31:54 +00:00
|
|
|
|
|
|
|
if (skl_ddb_entry_equal(old, new))
|
|
|
|
continue;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"[PLANE:%d:%s] ddb (%4d - %4d) -> (%4d - %4d), size %4d -> %4d\n",
|
|
|
|
plane->base.base.id, plane->base.name,
|
|
|
|
old->start, old->end, new->start, new->end,
|
|
|
|
skl_ddb_entry_size(old), skl_ddb_entry_size(new));
|
2019-02-08 20:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) {
|
|
|
|
enum plane_id plane_id = plane->id;
|
|
|
|
const struct skl_plane_wm *old_wm, *new_wm;
|
|
|
|
|
|
|
|
old_wm = &old_pipe_wm->planes[plane_id];
|
|
|
|
new_wm = &new_pipe_wm->planes[plane_id];
|
|
|
|
|
|
|
|
if (skl_plane_wm_equals(dev_priv, old_wm, new_wm))
|
|
|
|
continue;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"[PLANE:%d:%s] level %cwm0,%cwm1,%cwm2,%cwm3,%cwm4,%cwm5,%cwm6,%cwm7,%ctwm"
|
|
|
|
" -> %cwm0,%cwm1,%cwm2,%cwm3,%cwm4,%cwm5,%cwm6,%cwm7,%ctwm\n",
|
|
|
|
plane->base.base.id, plane->base.name,
|
|
|
|
enast(old_wm->wm[0].plane_en), enast(old_wm->wm[1].plane_en),
|
|
|
|
enast(old_wm->wm[2].plane_en), enast(old_wm->wm[3].plane_en),
|
|
|
|
enast(old_wm->wm[4].plane_en), enast(old_wm->wm[5].plane_en),
|
|
|
|
enast(old_wm->wm[6].plane_en), enast(old_wm->wm[7].plane_en),
|
|
|
|
enast(old_wm->trans_wm.plane_en),
|
|
|
|
enast(new_wm->wm[0].plane_en), enast(new_wm->wm[1].plane_en),
|
|
|
|
enast(new_wm->wm[2].plane_en), enast(new_wm->wm[3].plane_en),
|
|
|
|
enast(new_wm->wm[4].plane_en), enast(new_wm->wm[5].plane_en),
|
|
|
|
enast(new_wm->wm[6].plane_en), enast(new_wm->wm[7].plane_en),
|
|
|
|
enast(new_wm->trans_wm.plane_en));
|
|
|
|
|
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"[PLANE:%d:%s] lines %c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d"
|
2019-02-13 16:54:23 +00:00
|
|
|
" -> %c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d,%c%3d\n",
|
2020-01-07 15:13:30 +00:00
|
|
|
plane->base.base.id, plane->base.name,
|
|
|
|
enast(old_wm->wm[0].ignore_lines), old_wm->wm[0].plane_res_l,
|
|
|
|
enast(old_wm->wm[1].ignore_lines), old_wm->wm[1].plane_res_l,
|
|
|
|
enast(old_wm->wm[2].ignore_lines), old_wm->wm[2].plane_res_l,
|
|
|
|
enast(old_wm->wm[3].ignore_lines), old_wm->wm[3].plane_res_l,
|
|
|
|
enast(old_wm->wm[4].ignore_lines), old_wm->wm[4].plane_res_l,
|
|
|
|
enast(old_wm->wm[5].ignore_lines), old_wm->wm[5].plane_res_l,
|
|
|
|
enast(old_wm->wm[6].ignore_lines), old_wm->wm[6].plane_res_l,
|
|
|
|
enast(old_wm->wm[7].ignore_lines), old_wm->wm[7].plane_res_l,
|
|
|
|
enast(old_wm->trans_wm.ignore_lines), old_wm->trans_wm.plane_res_l,
|
|
|
|
|
|
|
|
enast(new_wm->wm[0].ignore_lines), new_wm->wm[0].plane_res_l,
|
|
|
|
enast(new_wm->wm[1].ignore_lines), new_wm->wm[1].plane_res_l,
|
|
|
|
enast(new_wm->wm[2].ignore_lines), new_wm->wm[2].plane_res_l,
|
|
|
|
enast(new_wm->wm[3].ignore_lines), new_wm->wm[3].plane_res_l,
|
|
|
|
enast(new_wm->wm[4].ignore_lines), new_wm->wm[4].plane_res_l,
|
|
|
|
enast(new_wm->wm[5].ignore_lines), new_wm->wm[5].plane_res_l,
|
|
|
|
enast(new_wm->wm[6].ignore_lines), new_wm->wm[6].plane_res_l,
|
|
|
|
enast(new_wm->wm[7].ignore_lines), new_wm->wm[7].plane_res_l,
|
|
|
|
enast(new_wm->trans_wm.ignore_lines), new_wm->trans_wm.plane_res_l);
|
|
|
|
|
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"[PLANE:%d:%s] blocks %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d"
|
|
|
|
" -> %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d\n",
|
|
|
|
plane->base.base.id, plane->base.name,
|
|
|
|
old_wm->wm[0].plane_res_b, old_wm->wm[1].plane_res_b,
|
|
|
|
old_wm->wm[2].plane_res_b, old_wm->wm[3].plane_res_b,
|
|
|
|
old_wm->wm[4].plane_res_b, old_wm->wm[5].plane_res_b,
|
|
|
|
old_wm->wm[6].plane_res_b, old_wm->wm[7].plane_res_b,
|
|
|
|
old_wm->trans_wm.plane_res_b,
|
|
|
|
new_wm->wm[0].plane_res_b, new_wm->wm[1].plane_res_b,
|
|
|
|
new_wm->wm[2].plane_res_b, new_wm->wm[3].plane_res_b,
|
|
|
|
new_wm->wm[4].plane_res_b, new_wm->wm[5].plane_res_b,
|
|
|
|
new_wm->wm[6].plane_res_b, new_wm->wm[7].plane_res_b,
|
|
|
|
new_wm->trans_wm.plane_res_b);
|
|
|
|
|
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"[PLANE:%d:%s] min_ddb %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d"
|
|
|
|
" -> %4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d,%4d\n",
|
|
|
|
plane->base.base.id, plane->base.name,
|
|
|
|
old_wm->wm[0].min_ddb_alloc, old_wm->wm[1].min_ddb_alloc,
|
|
|
|
old_wm->wm[2].min_ddb_alloc, old_wm->wm[3].min_ddb_alloc,
|
|
|
|
old_wm->wm[4].min_ddb_alloc, old_wm->wm[5].min_ddb_alloc,
|
|
|
|
old_wm->wm[6].min_ddb_alloc, old_wm->wm[7].min_ddb_alloc,
|
|
|
|
old_wm->trans_wm.min_ddb_alloc,
|
|
|
|
new_wm->wm[0].min_ddb_alloc, new_wm->wm[1].min_ddb_alloc,
|
|
|
|
new_wm->wm[2].min_ddb_alloc, new_wm->wm[3].min_ddb_alloc,
|
|
|
|
new_wm->wm[4].min_ddb_alloc, new_wm->wm[5].min_ddb_alloc,
|
|
|
|
new_wm->wm[6].min_ddb_alloc, new_wm->wm[7].min_ddb_alloc,
|
|
|
|
new_wm->trans_wm.min_ddb_alloc);
|
2016-10-14 21:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 20:09:43 +00:00
|
|
|
static int intel_add_all_pipes(struct intel_atomic_state *state)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(state->base.dev);
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
|
|
|
struct intel_crtc_state *crtc_state;
|
|
|
|
|
|
|
|
crtc_state = intel_atomic_get_crtc_state(&state->base, crtc);
|
|
|
|
if (IS_ERR(crtc_state))
|
|
|
|
return PTR_ERR(crtc_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-05-12 14:06:03 +00:00
|
|
|
static int
|
2019-10-11 20:09:42 +00:00
|
|
|
skl_ddb_add_affected_pipes(struct intel_atomic_state *state)
|
2016-05-12 14:06:03 +00:00
|
|
|
{
|
2019-10-11 20:09:43 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(state->base.dev);
|
2019-10-11 20:09:42 +00:00
|
|
|
int ret;
|
2016-05-12 14:06:03 +00:00
|
|
|
|
2018-04-09 03:41:08 +00:00
|
|
|
/*
|
|
|
|
* If this is our first atomic update following hardware readout,
|
|
|
|
* we can't trust the DDB that the BIOS programmed for us. Let's
|
|
|
|
* pretend that all pipes switched active status so that we'll
|
|
|
|
* ensure a full DDB recompute.
|
|
|
|
*/
|
|
|
|
if (dev_priv->wm.distrust_bios_wm) {
|
2019-10-11 20:09:43 +00:00
|
|
|
ret = drm_modeset_lock(&dev_priv->drm.mode_config.connection_mutex,
|
2018-12-10 21:54:14 +00:00
|
|
|
state->base.acquire_ctx);
|
2018-04-09 03:41:08 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-10-11 20:09:45 +00:00
|
|
|
state->active_pipe_changes = INTEL_INFO(dev_priv)->pipe_mask;
|
2018-04-09 03:41:08 +00:00
|
|
|
|
|
|
|
/*
|
2019-08-21 17:30:29 +00:00
|
|
|
* We usually only initialize state->active_pipes if we
|
2018-04-09 03:41:08 +00:00
|
|
|
* we're doing a modeset; make sure this field is always
|
|
|
|
* initialized during the sanitization process that happens
|
|
|
|
* on the first commit too.
|
|
|
|
*/
|
2018-12-10 21:54:14 +00:00
|
|
|
if (!state->modeset)
|
2019-08-21 17:30:29 +00:00
|
|
|
state->active_pipes = dev_priv->active_pipes;
|
2018-04-09 03:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the modeset changes which CRTC's are active, we need to
|
|
|
|
* recompute the DDB allocation for *all* active pipes, even
|
|
|
|
* those that weren't otherwise being modified in any way by this
|
|
|
|
* atomic commit. Due to the shrinking of the per-pipe allocations
|
|
|
|
* when new active CRTC's are added, it's possible for a pipe that
|
|
|
|
* we were already using and aren't changing at all here to suddenly
|
|
|
|
* become invalid if its DDB needs exceeds its new allocation.
|
|
|
|
*
|
|
|
|
* Note that if we wind up doing a full DDB recompute, we can't let
|
|
|
|
* any other display updates race with this transaction, so we need
|
|
|
|
* to grab the lock on *all* CRTC's.
|
|
|
|
*/
|
2018-12-10 21:54:14 +00:00
|
|
|
if (state->active_pipe_changes || state->modeset) {
|
2019-10-11 20:09:45 +00:00
|
|
|
state->wm_results.dirty_pipes = INTEL_INFO(dev_priv)->pipe_mask;
|
2018-04-09 03:41:08 +00:00
|
|
|
|
2019-10-11 20:09:43 +00:00
|
|
|
ret = intel_add_all_pipes(state);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2018-04-09 03:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-27 16:59:00 +00:00
|
|
|
/*
|
|
|
|
* To make sure the cursor watermark registers are always consistent
|
|
|
|
* with our computed state the following scenario needs special
|
|
|
|
* treatment:
|
|
|
|
*
|
|
|
|
* 1. enable cursor
|
|
|
|
* 2. move cursor entirely offscreen
|
|
|
|
* 3. disable cursor
|
|
|
|
*
|
|
|
|
* Step 2. does call .disable_plane() but does not zero the watermarks
|
|
|
|
* (since we consider an offscreen cursor still active for the purposes
|
|
|
|
* of watermarks). Step 3. would not normally call .disable_plane()
|
|
|
|
* because the actual plane visibility isn't changing, and we don't
|
|
|
|
* deallocate the cursor ddb until the pipe gets disabled. So we must
|
|
|
|
* force step 3. to call .disable_plane() to update the watermark
|
|
|
|
* registers properly.
|
|
|
|
*
|
|
|
|
* Other planes do not suffer from this issues as their watermarks are
|
|
|
|
* calculated based on the actual plane visibility. The only time this
|
|
|
|
* can trigger for the other planes is during the initial readout as the
|
|
|
|
* default value of the watermarks registers is not zero.
|
|
|
|
*/
|
|
|
|
static int skl_wm_add_affected_planes(struct intel_atomic_state *state,
|
|
|
|
struct intel_crtc *crtc)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
const struct intel_crtc_state *old_crtc_state =
|
|
|
|
intel_atomic_get_old_crtc_state(state, crtc);
|
|
|
|
struct intel_crtc_state *new_crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
|
|
|
struct intel_plane *plane;
|
|
|
|
|
|
|
|
for_each_intel_plane_on_crtc(&dev_priv->drm, crtc, plane) {
|
|
|
|
struct intel_plane_state *plane_state;
|
|
|
|
enum plane_id plane_id = plane->id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Force a full wm update for every plane on modeset.
|
|
|
|
* Required because the reset value of the wm registers
|
|
|
|
* is non-zero, whereas we want all disabled planes to
|
|
|
|
* have zero watermarks. So if we turn off the relevant
|
|
|
|
* power well the hardware state will go out of sync
|
|
|
|
* with the software state.
|
|
|
|
*/
|
2019-10-31 11:26:03 +00:00
|
|
|
if (!drm_atomic_crtc_needs_modeset(&new_crtc_state->uapi) &&
|
2018-11-27 16:59:00 +00:00
|
|
|
skl_plane_wm_equals(dev_priv,
|
|
|
|
&old_crtc_state->wm.skl.optimal.planes[plane_id],
|
|
|
|
&new_crtc_state->wm.skl.optimal.planes[plane_id]))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
plane_state = intel_atomic_get_plane_state(state, plane);
|
|
|
|
if (IS_ERR(plane_state))
|
|
|
|
return PTR_ERR(plane_state);
|
|
|
|
|
|
|
|
new_crtc_state->update_planes |= BIT(plane_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-09 03:41:08 +00:00
|
|
|
static int
|
2018-12-10 21:54:14 +00:00
|
|
|
skl_compute_wm(struct intel_atomic_state *state)
|
2018-04-09 03:41:08 +00:00
|
|
|
{
|
2018-12-10 21:54:14 +00:00
|
|
|
struct intel_crtc *crtc;
|
2019-03-12 20:58:44 +00:00
|
|
|
struct intel_crtc_state *new_crtc_state;
|
2018-12-10 21:54:14 +00:00
|
|
|
struct intel_crtc_state *old_crtc_state;
|
|
|
|
struct skl_ddb_values *results = &state->wm_results;
|
2018-04-09 03:41:08 +00:00
|
|
|
int ret, i;
|
|
|
|
|
2016-05-12 22:11:40 +00:00
|
|
|
/* Clear all dirty flags */
|
|
|
|
results->dirty_pipes = 0;
|
|
|
|
|
2019-10-11 20:09:42 +00:00
|
|
|
ret = skl_ddb_add_affected_pipes(state);
|
|
|
|
if (ret)
|
2018-04-09 03:41:08 +00:00
|
|
|
return ret;
|
|
|
|
|
2016-05-12 22:11:40 +00:00
|
|
|
/*
|
|
|
|
* Calculate WM's for all pipes that are part of this transaction.
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
* Note that skl_ddb_add_affected_pipes may have added more CRTC's that
|
2016-05-12 22:11:40 +00:00
|
|
|
* weren't otherwise being modified (and set bits in dirty_pipes) if
|
|
|
|
* pipe allocations had to change.
|
|
|
|
*/
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
|
2019-03-12 20:58:44 +00:00
|
|
|
new_crtc_state, i) {
|
|
|
|
ret = skl_build_pipe_wm(new_crtc_state);
|
2018-11-27 16:59:00 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
ret = skl_wm_add_affected_planes(state, crtc);
|
2016-05-12 22:11:40 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-03-12 20:58:44 +00:00
|
|
|
if (!skl_pipe_wm_equals(crtc,
|
|
|
|
&old_crtc_state->wm.skl.optimal,
|
|
|
|
&new_crtc_state->wm.skl.optimal))
|
2019-10-11 20:09:44 +00:00
|
|
|
results->dirty_pipes |= BIT(crtc->pipe);
|
2016-05-12 22:11:40 +00:00
|
|
|
}
|
|
|
|
|
drm/i915: Switch to level-based DDB allocation algorithm (v5)
The DDB allocation algorithm currently used by the driver grants each
plane a very small minimum allocation of DDB blocks and then divies up
all of the remaining blocks based on the percentage of the total data
rate that the plane makes up. It turns out that this proportional
allocation approach is overly-generous with the larger planes and can
leave very small planes wthout a big enough allocation to even hit their
level 0 watermark requirements (especially on APL, which has a smaller
DDB in general than other gen9 platforms). Or there can be situations
where the smallest planes hit a lower watermark level than they should
have been able to hit with a more equitable division of DDB blocks, thus
limiting the overall system sleep state that can be achieved.
The bspec now describes an alternate algorithm that can be used to
overcome these types of issues. With the new algorithm, we calculate
all plane watermark values for all wm levels first, then go back and
partition a pipe's DDB space second. The DDB allocation will calculate
what the highest watermark level that can be achieved on *all* active
planes, and then grant the blocks necessary to hit that level to each
plane. Any remaining blocks are then divided up proportionally
according to data rate, similar to the old algorithm.
There was a previous attempt to implement this algorithm a couple years
ago in bb9d85f6e9d ("drm/i915/skl: New ddb allocation algorithm"), but
some regressions were reported, the patch was reverted, and nobody
ever got around to figuring out exactly where the bug was in that
version. Our watermark code has evolved significantly in the meantime,
but we're still getting bug reports caused by the unfair proportional
algorithm, so let's give this another shot.
v2:
- Make sure cursor allocation stays constant and fixed at the end of
the pipe allocation.
- Fix some watermark level iterators that weren't handling the max
level.
v3:
- Ensure we don't leave any DDB blocks unused by using DIV_ROUND_UP+min
to calculate the extra blocks for each plane. (Ville)
- Replace a while() loop with a for() loop to be more consistent with
surrounding code. (Ville)
- Clean unattainable watermark levels with memset rather than directly
clearing the member fields. Also do the same for the transition
watermark values if they can't be achieved. (Ville)
- Drop min_disp_buf_needed calculations in skl_compute_plane_wm() since
the results are no longer needed or used. (Ville)
- Drop skl_latency[0] != 0 sanity check; both watermark methods already
account for an invalid 0 latency by returning FP_16_16_MAX. (Ville)
v4:
- Break DDB allocation loop when total_data_rate=0 rather than
alloc_size=0. If total_data_rate has dropped to 0, all remaining
planes are disabled, which isn't true for alloc_size (we might just
have not had any remaining blocks to hand out). Plus
total_data_rate=0 is the case we need to avoid to a prevent a
div-by-0. (Ville)
- s/DIV_ROUND_UP/DIV64_U64_ROUND_UP/ to prevent 32-bit breakage (Ville)
v5:
- Don't forget to move 'start' pointer forward for UV surface when
setting plane DDB boundaries. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105458
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181211173107.11068-2-matthew.d.roper@intel.com
2018-12-11 17:31:07 +00:00
|
|
|
ret = skl_compute_ddb(state);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
skl_print_wm_changes(state);
|
2016-10-14 21:31:54 +00:00
|
|
|
|
2016-05-12 14:06:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-08 12:55:32 +00:00
|
|
|
static void skl_atomic_update_crtc_wm(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
2016-11-08 12:55:32 +00:00
|
|
|
{
|
2019-11-18 16:44:26 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
|
|
|
const struct skl_pipe_wm *pipe_wm = &crtc_state->wm.skl.optimal;
|
2016-11-08 12:55:32 +00:00
|
|
|
enum pipe pipe = crtc->pipe;
|
2016-11-08 12:55:33 +00:00
|
|
|
|
2019-10-11 20:09:44 +00:00
|
|
|
if ((state->wm_results.dirty_pipes & BIT(crtc->pipe)) == 0)
|
2016-11-08 12:55:33 +00:00
|
|
|
return;
|
2016-11-08 12:55:32 +00:00
|
|
|
|
|
|
|
I915_WRITE(PIPE_WM_LINETIME(pipe), pipe_wm->linetime);
|
|
|
|
}
|
|
|
|
|
2016-11-08 12:55:33 +00:00
|
|
|
static void skl_initial_wm(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
2014-11-04 17:06:42 +00:00
|
|
|
{
|
2019-10-11 20:09:44 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2019-11-18 16:44:26 +00:00
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2018-04-09 03:41:00 +00:00
|
|
|
struct skl_ddb_values *results = &state->wm_results;
|
2015-07-21 17:42:53 +00:00
|
|
|
|
2019-10-11 20:09:44 +00:00
|
|
|
if ((results->dirty_pipes & BIT(crtc->pipe)) == 0)
|
2014-11-04 17:06:42 +00:00
|
|
|
return;
|
|
|
|
|
2016-05-12 22:11:40 +00:00
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
2014-11-04 17:06:42 +00:00
|
|
|
|
2019-10-31 11:26:03 +00:00
|
|
|
if (crtc_state->uapi.active_changed)
|
2019-11-18 16:44:26 +00:00
|
|
|
skl_atomic_update_crtc_wm(state, crtc);
|
drm/i915/skl: Update DDB values atomically with wms/plane attrs
Now that we can hook into update_crtcs and control the order in which we
update CRTCs at each modeset, we can finish the final step of fixing
Skylake's watermark handling by performing DDB updates at the same time
as plane updates and watermark updates.
The first major change in this patch is skl_update_crtcs(), which
handles ensuring that we order each CRTC update in our atomic commits
properly so that they honor the DDB flush order.
The second major change in this patch is the order in which we flush the
pipes. While the previous order may have worked, it can't be used in
this approach since it no longer will do the right thing. For example,
using the old ddb flush order:
We have pipes A, B, and C enabled, and we're disabling C. Initial ddb
allocation looks like this:
| A | B |xxxxxxx|
Since we're performing the ddb updates after performing any CRTC
disablements in intel_atomic_commit_tail(), the space to the right of
pipe B is unallocated.
1. Flush pipes with new allocation contained into old space. None
apply, so we skip this
2. Flush pipes having their allocation reduced, but overlapping with a
previous allocation. None apply, so we also skip this
3. Flush pipes that got more space allocated. This applies to A and B,
giving us the following update order: A, B
This is wrong, since updating pipe A first will cause it to overlap with
B and potentially burst into flames. Our new order (see the code
comments for details) would update the pipes in the proper order: B, A.
As well, we calculate the order for each DDB update during the check
phase, and reference it later in the commit phase when we hit
skl_update_crtcs().
This long overdue patch fixes the rest of the underruns on Skylake.
Changes since v1:
- Add skl_ddb_entry_write() for cursor into skl_write_cursor_wm()
Changes since v2:
- Use the method for updating CRTCs that Ville suggested
- In skl_update_wm(), only copy the watermarks for the crtc that was
passed to us
Changes since v3:
- Small comment fix in skl_ddb_allocation_overlaps()
Changes since v4:
- Remove the second loop in intel_update_crtcs() and use Ville's
suggestion for updating the ddb allocations in the right order
- Get rid of the second loop and just use the ddb state as it updates
to determine what order to update everything in (thanks for the
suggestion Ville)
- Simplify skl_ddb_allocation_overlaps()
- Split actual overlap checking into it's own helper
Fixes: 0e8fb7ba7ca5 ("drm/i915/skl: Flush the WM configuration")
Fixes: 8211bd5bdf5e ("drm/i915/skl: Program the DDB allocation")
[omitting CC for stable, since this patch will need to be changed for
such backports first]
Testcase: kms_cursor_legacy
Testcase: plane-all-modeset-transition
Signed-off-by: Lyude <cpaul@redhat.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471961565-28540-2-git-send-email-cpaul@redhat.com
2016-08-24 05:48:10 +00:00
|
|
|
|
2016-05-12 22:11:40 +00:00
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
2014-11-04 17:06:42 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
static void ilk_compute_wm_config(struct drm_i915_private *dev_priv,
|
2016-01-14 12:53:35 +00:00
|
|
|
struct intel_wm_config *config)
|
|
|
|
{
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
/* Compute the currently _active_ config */
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2016-01-14 12:53:35 +00:00
|
|
|
const struct intel_pipe_wm *wm = &crtc->wm.active.ilk;
|
|
|
|
|
|
|
|
if (!wm->pipe_enabled)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
config->sprites_enabled |= wm->sprites_enabled;
|
|
|
|
config->sprites_scaled |= wm->sprites_scaled;
|
|
|
|
config->num_pipes_active++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
static void ilk_program_watermarks(struct drm_i915_private *dev_priv)
|
2013-05-31 13:08:35 +00:00
|
|
|
{
|
2015-09-24 22:53:14 +00:00
|
|
|
struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_maximums max;
|
2016-01-14 12:53:35 +00:00
|
|
|
struct intel_wm_config config = {};
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_values results = {};
|
2013-08-06 19:24:04 +00:00
|
|
|
enum intel_ddb_partitioning partitioning;
|
2015-10-08 22:28:25 +00:00
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
ilk_compute_wm_config(dev_priv, &config);
|
2016-01-14 12:53:35 +00:00
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
ilk_compute_wm_maximums(dev_priv, 1, &config, INTEL_DDB_PART_1_2, &max);
|
|
|
|
ilk_wm_merge(dev_priv, &config, &max, &lp_wm_1_2);
|
2013-10-09 16:17:59 +00:00
|
|
|
|
|
|
|
/* 5/6 split only in single pipe config on IVB+ */
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 7 &&
|
2016-01-14 12:53:35 +00:00
|
|
|
config.num_pipes_active == 1 && config.sprites_enabled) {
|
2018-12-10 21:54:14 +00:00
|
|
|
ilk_compute_wm_maximums(dev_priv, 1, &config, INTEL_DDB_PART_5_6, &max);
|
|
|
|
ilk_wm_merge(dev_priv, &config, &max, &lp_wm_5_6);
|
2013-10-09 16:17:57 +00:00
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
best_lp_wm = ilk_find_best_result(dev_priv, &lp_wm_1_2, &lp_wm_5_6);
|
2013-05-31 13:19:21 +00:00
|
|
|
} else {
|
2013-10-09 16:17:58 +00:00
|
|
|
best_lp_wm = &lp_wm_1_2;
|
2013-05-31 13:19:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 16:17:58 +00:00
|
|
|
partitioning = (best_lp_wm == &lp_wm_1_2) ?
|
2013-08-06 19:24:04 +00:00
|
|
|
INTEL_DDB_PART_1_2 : INTEL_DDB_PART_5_6;
|
2013-05-31 13:08:35 +00:00
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
ilk_compute_wm_results(dev_priv, best_lp_wm, partitioning, &results);
|
2013-10-09 16:18:03 +00:00
|
|
|
|
2013-12-17 12:46:36 +00:00
|
|
|
ilk_write_wm_values(dev_priv, &results);
|
2013-05-09 19:55:50 +00:00
|
|
|
}
|
|
|
|
|
2016-11-08 12:55:32 +00:00
|
|
|
static void ilk_initial_watermarks(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
2015-09-24 22:53:14 +00:00
|
|
|
{
|
2019-11-18 16:44:26 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2015-09-24 22:53:14 +00:00
|
|
|
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
2019-07-01 16:05:45 +00:00
|
|
|
crtc->wm.active.ilk = crtc_state->wm.ilk.intermediate;
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
ilk_program_watermarks(dev_priv);
|
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
|
|
|
}
|
2016-01-19 19:43:04 +00:00
|
|
|
|
2016-11-08 12:55:32 +00:00
|
|
|
static void ilk_optimize_watermarks(struct intel_atomic_state *state,
|
2019-11-18 16:44:26 +00:00
|
|
|
struct intel_crtc *crtc)
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
{
|
2019-11-18 16:44:26 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2019-07-01 16:05:45 +00:00
|
|
|
|
|
|
|
if (!crtc_state->wm.need_postvbl_update)
|
|
|
|
return;
|
2016-01-19 19:43:04 +00:00
|
|
|
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
2019-07-01 16:05:45 +00:00
|
|
|
crtc->wm.active.ilk = crtc_state->wm.ilk.optimal;
|
|
|
|
ilk_program_watermarks(dev_priv);
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
2015-09-24 22:53:14 +00:00
|
|
|
}
|
|
|
|
|
2019-01-18 12:01:20 +00:00
|
|
|
static inline void skl_wm_level_from_reg_val(u32 val,
|
2016-10-18 18:09:49 +00:00
|
|
|
struct skl_wm_level *level)
|
2014-11-04 17:06:45 +00:00
|
|
|
{
|
2016-10-18 18:09:49 +00:00
|
|
|
level->plane_en = val & PLANE_WM_EN;
|
2019-02-13 16:54:23 +00:00
|
|
|
level->ignore_lines = val & PLANE_WM_IGNORE_LINES;
|
2016-10-18 18:09:49 +00:00
|
|
|
level->plane_res_b = val & PLANE_WM_BLOCKS_MASK;
|
|
|
|
level->plane_res_l = (val >> PLANE_WM_LINES_SHIFT) &
|
|
|
|
PLANE_WM_LINES_MASK;
|
2014-11-04 17:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
void skl_pipe_wm_get_hw_state(struct intel_crtc *crtc,
|
2016-10-14 21:31:55 +00:00
|
|
|
struct skl_pipe_wm *out)
|
2014-11-04 17:06:45 +00:00
|
|
|
{
|
2018-12-10 21:54:14 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
enum pipe pipe = crtc->pipe;
|
2016-11-22 16:01:58 +00:00
|
|
|
int level, max_level;
|
|
|
|
enum plane_id plane_id;
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 val;
|
2014-11-04 17:06:45 +00:00
|
|
|
|
2016-10-13 10:03:10 +00:00
|
|
|
max_level = ilk_wm_max_level(dev_priv);
|
2014-11-04 17:06:45 +00:00
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
2016-11-22 16:01:58 +00:00
|
|
|
struct skl_plane_wm *wm = &out->planes[plane_id];
|
2014-11-04 17:06:45 +00:00
|
|
|
|
2016-10-18 18:09:49 +00:00
|
|
|
for (level = 0; level <= max_level; level++) {
|
2016-11-22 16:01:58 +00:00
|
|
|
if (plane_id != PLANE_CURSOR)
|
|
|
|
val = I915_READ(PLANE_WM(pipe, plane_id, level));
|
2016-10-18 18:09:49 +00:00
|
|
|
else
|
|
|
|
val = I915_READ(CUR_WM(pipe, level));
|
2014-11-04 17:06:45 +00:00
|
|
|
|
2016-10-18 18:09:49 +00:00
|
|
|
skl_wm_level_from_reg_val(val, &wm->wm[level]);
|
2014-11-04 17:06:45 +00:00
|
|
|
}
|
|
|
|
|
2016-11-22 16:01:58 +00:00
|
|
|
if (plane_id != PLANE_CURSOR)
|
|
|
|
val = I915_READ(PLANE_WM_TRANS(pipe, plane_id));
|
2016-10-18 18:09:49 +00:00
|
|
|
else
|
|
|
|
val = I915_READ(CUR_WM_TRANS(pipe));
|
|
|
|
|
|
|
|
skl_wm_level_from_reg_val(val, &wm->trans_wm);
|
2014-11-04 17:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
if (!crtc->active)
|
2016-10-18 18:09:49 +00:00
|
|
|
return;
|
2015-09-24 22:53:15 +00:00
|
|
|
|
2016-10-14 21:31:55 +00:00
|
|
|
out->linetime = I915_READ(PIPE_WM_LINETIME(pipe));
|
2014-11-04 17:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
void skl_wm_get_hw_state(struct drm_i915_private *dev_priv)
|
2014-11-04 17:06:45 +00:00
|
|
|
{
|
2018-04-09 03:41:00 +00:00
|
|
|
struct skl_ddb_values *hw = &dev_priv->wm.skl_hw;
|
2014-11-04 17:06:49 +00:00
|
|
|
struct skl_ddb_allocation *ddb = &dev_priv->wm.skl_hw.ddb;
|
2018-12-10 21:54:14 +00:00
|
|
|
struct intel_crtc *crtc;
|
2019-06-28 08:55:17 +00:00
|
|
|
struct intel_crtc_state *crtc_state;
|
2014-11-04 17:06:45 +00:00
|
|
|
|
2014-11-04 17:06:49 +00:00
|
|
|
skl_ddb_get_hw_state(dev_priv, ddb);
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2019-06-28 08:55:17 +00:00
|
|
|
crtc_state = to_intel_crtc_state(crtc->base.state);
|
2016-10-14 21:31:55 +00:00
|
|
|
|
2019-06-28 08:55:17 +00:00
|
|
|
skl_pipe_wm_get_hw_state(crtc, &crtc_state->wm.skl.optimal);
|
2016-10-14 21:31:55 +00:00
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
if (crtc->active)
|
2019-10-11 20:09:44 +00:00
|
|
|
hw->dirty_pipes |= BIT(crtc->pipe);
|
2016-10-14 21:31:55 +00:00
|
|
|
}
|
2016-05-12 14:05:57 +00:00
|
|
|
|
2019-08-21 17:30:29 +00:00
|
|
|
if (dev_priv->active_pipes) {
|
2016-05-12 14:06:02 +00:00
|
|
|
/* Fully recompute DDB on first atomic commit */
|
|
|
|
dev_priv->wm.distrust_bios_wm = true;
|
|
|
|
}
|
2014-11-04 17:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
static void ilk_pipe_wm_get_hw_state(struct intel_crtc *crtc)
|
2013-10-14 11:55:24 +00:00
|
|
|
{
|
2018-12-10 21:54:14 +00:00
|
|
|
struct drm_device *dev = crtc->base.dev;
|
2016-07-04 10:34:36 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_values *hw = &dev_priv->wm.hw;
|
2019-06-28 08:55:17 +00:00
|
|
|
struct intel_crtc_state *crtc_state = to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct intel_pipe_wm *active = &crtc_state->wm.ilk.optimal;
|
2018-12-10 21:54:14 +00:00
|
|
|
enum pipe pipe = crtc->pipe;
|
drm/i915: Type safe register read/write
Make I915_READ and I915_WRITE more type safe by wrapping the register
offset in a struct. This should eliminate most of the fumbles we've had
with misplaced parens.
This only takes care of normal mmio registers. We could extend the idea
to other register types and define each with its own struct. That way
you wouldn't be able to accidentally pass the wrong thing to a specific
register access function.
The gpio_reg setup is probably the ugliest thing left. But I figure I'd
just leave it for now, and wait for some divine inspiration to strike
before making it nice.
As for the generated code, it's actually a bit better sometimes. Eg.
looking at i915_irq_handler(), we can see the following change:
lea 0x70024(%rdx,%rax,1),%r9d
mov $0x1,%edx
- movslq %r9d,%r9
- mov %r9,%rsi
- mov %r9,-0x58(%rbp)
- callq *0xd8(%rbx)
+ mov %r9d,%esi
+ mov %r9d,-0x48(%rbp)
callq *0xd8(%rbx)
So previously gcc thought the register offset might be signed and
decided to sign extend it, just in case. The rest appears to be
mostly just minor shuffling of instructions.
v2: i915_mmio_reg_{offset,equal,valid}() helpers added
s/_REG/_MMIO/ in the register defines
mo more switch statements left to worry about
ring_emit stuff got sorted in a prep patch
cmd parser, lrc context and w/a batch buildup also in prep patch
vgpu stuff cleaned up and moved to a prep patch
all other unrelated changes split out
v3: Rebased due to BXT DSI/BLC, MOCS, etc.
v4: Rebased due to churn, s/i915_mmio_reg_t/i915_reg_t/
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1447853606-2751-1-git-send-email-ville.syrjala@linux.intel.com
2015-11-18 13:33:26 +00:00
|
|
|
static const i915_reg_t wm0_pipe_reg[] = {
|
2013-10-14 11:55:24 +00:00
|
|
|
[PIPE_A] = WM0_PIPEA_ILK,
|
|
|
|
[PIPE_B] = WM0_PIPEB_ILK,
|
|
|
|
[PIPE_C] = WM0_PIPEC_IVB,
|
|
|
|
};
|
|
|
|
|
|
|
|
hw->wm_pipe[pipe] = I915_READ(wm0_pipe_reg[pipe]);
|
2016-10-13 10:03:00 +00:00
|
|
|
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
|
2013-12-05 13:51:36 +00:00
|
|
|
hw->wm_linetime[pipe] = I915_READ(PIPE_WM_LINETIME(pipe));
|
2013-10-14 11:55:24 +00:00
|
|
|
|
2016-05-13 14:55:17 +00:00
|
|
|
memset(active, 0, sizeof(*active));
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
active->pipe_enabled = crtc->active;
|
2014-03-07 16:32:09 +00:00
|
|
|
|
|
|
|
if (active->pipe_enabled) {
|
2013-10-14 11:55:24 +00:00
|
|
|
u32 tmp = hw->wm_pipe[pipe];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For active pipes LP0 watermark is marked as
|
|
|
|
* enabled, and LP1+ watermaks as disabled since
|
|
|
|
* we can't really reverse compute them in case
|
|
|
|
* multiple pipes are active.
|
|
|
|
*/
|
|
|
|
active->wm[0].enable = true;
|
|
|
|
active->wm[0].pri_val = (tmp & WM0_PIPE_PLANE_MASK) >> WM0_PIPE_PLANE_SHIFT;
|
|
|
|
active->wm[0].spr_val = (tmp & WM0_PIPE_SPRITE_MASK) >> WM0_PIPE_SPRITE_SHIFT;
|
|
|
|
active->wm[0].cur_val = tmp & WM0_PIPE_CURSOR_MASK;
|
|
|
|
active->linetime = hw->wm_linetime[pipe];
|
|
|
|
} else {
|
2016-10-13 10:03:10 +00:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2013-10-14 11:55:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For inactive pipes, all watermark levels
|
|
|
|
* should be marked as enabled but zeroed,
|
|
|
|
* which is what we'd compute them to.
|
|
|
|
*/
|
|
|
|
for (level = 0; level <= max_level; level++)
|
|
|
|
active->wm[level].enable = true;
|
|
|
|
}
|
2015-09-24 22:53:15 +00:00
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
crtc->wm.active.ilk = *active;
|
2013-10-14 11:55:24 +00:00
|
|
|
}
|
|
|
|
|
2015-06-24 19:00:03 +00:00
|
|
|
#define _FW_WM(value, plane) \
|
|
|
|
(((value) & DSPFW_ ## plane ## _MASK) >> DSPFW_ ## plane ## _SHIFT)
|
|
|
|
#define _FW_WM_VLV(value, plane) \
|
|
|
|
(((value) & DSPFW_ ## plane ## _MASK_VLV) >> DSPFW_ ## plane ## _SHIFT)
|
|
|
|
|
2017-04-21 18:14:29 +00:00
|
|
|
static void g4x_read_wm_values(struct drm_i915_private *dev_priv,
|
|
|
|
struct g4x_wm_values *wm)
|
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 tmp;
|
2017-04-21 18:14:29 +00:00
|
|
|
|
|
|
|
tmp = I915_READ(DSPFW1);
|
|
|
|
wm->sr.plane = _FW_WM(tmp, SR);
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_CURSOR] = _FW_WM(tmp, CURSORB);
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_PRIMARY] = _FW_WM(tmp, PLANEB);
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_PRIMARY] = _FW_WM(tmp, PLANEA);
|
|
|
|
|
|
|
|
tmp = I915_READ(DSPFW2);
|
|
|
|
wm->fbc_en = tmp & DSPFW_FBC_SR_EN;
|
|
|
|
wm->sr.fbc = _FW_WM(tmp, FBC_SR);
|
|
|
|
wm->hpll.fbc = _FW_WM(tmp, FBC_HPLL_SR);
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE0] = _FW_WM(tmp, SPRITEB);
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_CURSOR] = _FW_WM(tmp, CURSORA);
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_SPRITE0] = _FW_WM(tmp, SPRITEA);
|
|
|
|
|
|
|
|
tmp = I915_READ(DSPFW3);
|
|
|
|
wm->hpll_en = tmp & DSPFW_HPLL_SR_EN;
|
|
|
|
wm->sr.cursor = _FW_WM(tmp, CURSOR_SR);
|
|
|
|
wm->hpll.cursor = _FW_WM(tmp, HPLL_CURSOR);
|
|
|
|
wm->hpll.plane = _FW_WM(tmp, HPLL_SR);
|
|
|
|
}
|
|
|
|
|
2015-06-24 19:00:03 +00:00
|
|
|
static void vlv_read_wm_values(struct drm_i915_private *dev_priv,
|
|
|
|
struct vlv_wm_values *wm)
|
|
|
|
{
|
|
|
|
enum pipe pipe;
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 tmp;
|
2015-06-24 19:00:03 +00:00
|
|
|
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
|
|
|
tmp = I915_READ(VLV_DDL(pipe));
|
|
|
|
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->ddl[pipe].plane[PLANE_PRIMARY] =
|
2015-06-24 19:00:03 +00:00
|
|
|
(tmp >> DDL_PLANE_SHIFT) & (DDL_PRECISION_HIGH | DRAIN_LATENCY_MASK);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->ddl[pipe].plane[PLANE_CURSOR] =
|
2015-06-24 19:00:03 +00:00
|
|
|
(tmp >> DDL_CURSOR_SHIFT) & (DDL_PRECISION_HIGH | DRAIN_LATENCY_MASK);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->ddl[pipe].plane[PLANE_SPRITE0] =
|
2015-06-24 19:00:03 +00:00
|
|
|
(tmp >> DDL_SPRITE_SHIFT(0)) & (DDL_PRECISION_HIGH | DRAIN_LATENCY_MASK);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->ddl[pipe].plane[PLANE_SPRITE1] =
|
2015-06-24 19:00:03 +00:00
|
|
|
(tmp >> DDL_SPRITE_SHIFT(1)) & (DDL_PRECISION_HIGH | DRAIN_LATENCY_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = I915_READ(DSPFW1);
|
|
|
|
wm->sr.plane = _FW_WM(tmp, SR);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->pipe[PIPE_B].plane[PLANE_CURSOR] = _FW_WM(tmp, CURSORB);
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_PRIMARY] = _FW_WM_VLV(tmp, PLANEB);
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_PRIMARY] = _FW_WM_VLV(tmp, PLANEA);
|
2015-06-24 19:00:03 +00:00
|
|
|
|
|
|
|
tmp = I915_READ(DSPFW2);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->pipe[PIPE_A].plane[PLANE_SPRITE1] = _FW_WM_VLV(tmp, SPRITEB);
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_CURSOR] = _FW_WM(tmp, CURSORA);
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_SPRITE0] = _FW_WM_VLV(tmp, SPRITEA);
|
2015-06-24 19:00:03 +00:00
|
|
|
|
|
|
|
tmp = I915_READ(DSPFW3);
|
|
|
|
wm->sr.cursor = _FW_WM(tmp, CURSOR_SR);
|
|
|
|
|
|
|
|
if (IS_CHERRYVIEW(dev_priv)) {
|
|
|
|
tmp = I915_READ(DSPFW7_CHV);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE1] = _FW_WM_VLV(tmp, SPRITED);
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE0] = _FW_WM_VLV(tmp, SPRITEC);
|
2015-06-24 19:00:03 +00:00
|
|
|
|
|
|
|
tmp = I915_READ(DSPFW8_CHV);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->pipe[PIPE_C].plane[PLANE_SPRITE1] = _FW_WM_VLV(tmp, SPRITEF);
|
|
|
|
wm->pipe[PIPE_C].plane[PLANE_SPRITE0] = _FW_WM_VLV(tmp, SPRITEE);
|
2015-06-24 19:00:03 +00:00
|
|
|
|
|
|
|
tmp = I915_READ(DSPFW9_CHV);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->pipe[PIPE_C].plane[PLANE_PRIMARY] = _FW_WM_VLV(tmp, PLANEC);
|
|
|
|
wm->pipe[PIPE_C].plane[PLANE_CURSOR] = _FW_WM(tmp, CURSORC);
|
2015-06-24 19:00:03 +00:00
|
|
|
|
|
|
|
tmp = I915_READ(DSPHOWM);
|
|
|
|
wm->sr.plane |= _FW_WM(tmp, SR_HI) << 9;
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->pipe[PIPE_C].plane[PLANE_SPRITE1] |= _FW_WM(tmp, SPRITEF_HI) << 8;
|
|
|
|
wm->pipe[PIPE_C].plane[PLANE_SPRITE0] |= _FW_WM(tmp, SPRITEE_HI) << 8;
|
|
|
|
wm->pipe[PIPE_C].plane[PLANE_PRIMARY] |= _FW_WM(tmp, PLANEC_HI) << 8;
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE1] |= _FW_WM(tmp, SPRITED_HI) << 8;
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE0] |= _FW_WM(tmp, SPRITEC_HI) << 8;
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_PRIMARY] |= _FW_WM(tmp, PLANEB_HI) << 8;
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_SPRITE1] |= _FW_WM(tmp, SPRITEB_HI) << 8;
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_SPRITE0] |= _FW_WM(tmp, SPRITEA_HI) << 8;
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_PRIMARY] |= _FW_WM(tmp, PLANEA_HI) << 8;
|
2015-06-24 19:00:03 +00:00
|
|
|
} else {
|
|
|
|
tmp = I915_READ(DSPFW7);
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE1] = _FW_WM_VLV(tmp, SPRITED);
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE0] = _FW_WM_VLV(tmp, SPRITEC);
|
2015-06-24 19:00:03 +00:00
|
|
|
|
|
|
|
tmp = I915_READ(DSPHOWM);
|
|
|
|
wm->sr.plane |= _FW_WM(tmp, SR_HI) << 9;
|
2016-11-28 17:37:08 +00:00
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE1] |= _FW_WM(tmp, SPRITED_HI) << 8;
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE0] |= _FW_WM(tmp, SPRITEC_HI) << 8;
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_PRIMARY] |= _FW_WM(tmp, PLANEB_HI) << 8;
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_SPRITE1] |= _FW_WM(tmp, SPRITEB_HI) << 8;
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_SPRITE0] |= _FW_WM(tmp, SPRITEA_HI) << 8;
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_PRIMARY] |= _FW_WM(tmp, PLANEA_HI) << 8;
|
2015-06-24 19:00:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef _FW_WM
|
|
|
|
#undef _FW_WM_VLV
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
void g4x_wm_get_hw_state(struct drm_i915_private *dev_priv)
|
2017-04-21 18:14:29 +00:00
|
|
|
{
|
|
|
|
struct g4x_wm_values *wm = &dev_priv->wm.g4x;
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
g4x_read_wm_values(dev_priv, wm);
|
|
|
|
|
|
|
|
wm->cxsr = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2017-04-21 18:14:29 +00:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct g4x_wm_state *active = &crtc->wm.active.g4x;
|
|
|
|
struct g4x_pipe_wm *raw;
|
|
|
|
enum pipe pipe = crtc->pipe;
|
|
|
|
enum plane_id plane_id;
|
|
|
|
int level, max_level;
|
|
|
|
|
|
|
|
active->cxsr = wm->cxsr;
|
|
|
|
active->hpll_en = wm->hpll_en;
|
|
|
|
active->fbc_en = wm->fbc_en;
|
|
|
|
|
|
|
|
active->sr = wm->sr;
|
|
|
|
active->hpll = wm->hpll;
|
|
|
|
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
|
|
|
active->wm.plane[plane_id] =
|
|
|
|
wm->pipe[pipe].plane[plane_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wm->cxsr && wm->hpll_en)
|
|
|
|
max_level = G4X_WM_LEVEL_HPLL;
|
|
|
|
else if (wm->cxsr)
|
|
|
|
max_level = G4X_WM_LEVEL_SR;
|
|
|
|
else
|
|
|
|
max_level = G4X_WM_LEVEL_NORMAL;
|
|
|
|
|
|
|
|
level = G4X_WM_LEVEL_NORMAL;
|
|
|
|
raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id)
|
|
|
|
raw->plane[plane_id] = active->wm.plane[plane_id];
|
|
|
|
|
|
|
|
if (++level > max_level)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
raw->plane[PLANE_PRIMARY] = active->sr.plane;
|
|
|
|
raw->plane[PLANE_CURSOR] = active->sr.cursor;
|
|
|
|
raw->plane[PLANE_SPRITE0] = 0;
|
|
|
|
raw->fbc = active->sr.fbc;
|
|
|
|
|
|
|
|
if (++level > max_level)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
raw = &crtc_state->wm.g4x.raw[level];
|
|
|
|
raw->plane[PLANE_PRIMARY] = active->hpll.plane;
|
|
|
|
raw->plane[PLANE_CURSOR] = active->hpll.cursor;
|
|
|
|
raw->plane[PLANE_SPRITE0] = 0;
|
|
|
|
raw->fbc = active->hpll.fbc;
|
|
|
|
|
|
|
|
out:
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id)
|
|
|
|
g4x_raw_plane_wm_set(crtc_state, level,
|
|
|
|
plane_id, USHRT_MAX);
|
|
|
|
g4x_raw_fbc_wm_set(crtc_state, level, USHRT_MAX);
|
|
|
|
|
|
|
|
crtc_state->wm.g4x.optimal = *active;
|
|
|
|
crtc_state->wm.g4x.intermediate = *active;
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Initial watermarks: pipe %c, plane=%d, cursor=%d, sprite=%d\n",
|
|
|
|
pipe_name(pipe),
|
|
|
|
wm->pipe[pipe].plane[PLANE_PRIMARY],
|
|
|
|
wm->pipe[pipe].plane[PLANE_CURSOR],
|
|
|
|
wm->pipe[pipe].plane[PLANE_SPRITE0]);
|
2017-04-21 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Initial SR watermarks: plane=%d, cursor=%d fbc=%d\n",
|
|
|
|
wm->sr.plane, wm->sr.cursor, wm->sr.fbc);
|
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Initial HPLL watermarks: plane=%d, SR cursor=%d fbc=%d\n",
|
|
|
|
wm->hpll.plane, wm->hpll.cursor, wm->hpll.fbc);
|
|
|
|
drm_dbg_kms(&dev_priv->drm, "Initial SR=%s HPLL=%s FBC=%s\n",
|
|
|
|
yesno(wm->cxsr), yesno(wm->hpll_en), yesno(wm->fbc_en));
|
2017-04-21 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void g4x_wm_sanitize(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
struct intel_plane *plane;
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
|
|
|
|
|
|
|
for_each_intel_plane(&dev_priv->drm, plane) {
|
|
|
|
struct intel_crtc *crtc =
|
|
|
|
intel_get_crtc_for_pipe(dev_priv, plane->pipe);
|
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct intel_plane_state *plane_state =
|
|
|
|
to_intel_plane_state(plane->base.state);
|
|
|
|
struct g4x_wm_state *wm_state = &crtc_state->wm.g4x.optimal;
|
|
|
|
enum plane_id plane_id = plane->id;
|
|
|
|
int level;
|
|
|
|
|
2019-10-31 11:26:08 +00:00
|
|
|
if (plane_state->uapi.visible)
|
2017-04-21 18:14:29 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
for (level = 0; level < 3; level++) {
|
|
|
|
struct g4x_pipe_wm *raw =
|
|
|
|
&crtc_state->wm.g4x.raw[level];
|
|
|
|
|
|
|
|
raw->plane[plane_id] = 0;
|
|
|
|
wm_state->wm.plane[plane_id] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plane_id == PLANE_PRIMARY) {
|
|
|
|
for (level = 0; level < 3; level++) {
|
|
|
|
struct g4x_pipe_wm *raw =
|
|
|
|
&crtc_state->wm.g4x.raw[level];
|
|
|
|
raw->fbc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
wm_state->sr.fbc = 0;
|
|
|
|
wm_state->hpll.fbc = 0;
|
|
|
|
wm_state->fbc_en = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
crtc_state->wm.g4x.intermediate =
|
|
|
|
crtc_state->wm.g4x.optimal;
|
|
|
|
crtc->wm.active.g4x = crtc_state->wm.g4x.optimal;
|
|
|
|
}
|
|
|
|
|
|
|
|
g4x_program_watermarks(dev_priv);
|
|
|
|
|
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
void vlv_wm_get_hw_state(struct drm_i915_private *dev_priv)
|
2015-06-24 19:00:03 +00:00
|
|
|
{
|
|
|
|
struct vlv_wm_values *wm = &dev_priv->wm.vlv;
|
2017-03-02 17:14:52 +00:00
|
|
|
struct intel_crtc *crtc;
|
2015-06-24 19:00:03 +00:00
|
|
|
u32 val;
|
|
|
|
|
|
|
|
vlv_read_wm_values(dev_priv, wm);
|
|
|
|
|
|
|
|
wm->cxsr = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
|
|
|
|
wm->level = VLV_WM_LEVEL_PM2;
|
|
|
|
|
|
|
|
if (IS_CHERRYVIEW(dev_priv)) {
|
2019-04-26 08:17:20 +00:00
|
|
|
vlv_punit_get(dev_priv);
|
2015-06-24 19:00:03 +00:00
|
|
|
|
2018-11-29 17:55:03 +00:00
|
|
|
val = vlv_punit_read(dev_priv, PUNIT_REG_DSPSSPM);
|
2015-06-24 19:00:03 +00:00
|
|
|
if (val & DSP_MAXFIFO_PM5_ENABLE)
|
|
|
|
wm->level = VLV_WM_LEVEL_PM5;
|
|
|
|
|
2015-09-08 18:05:12 +00:00
|
|
|
/*
|
|
|
|
* If DDR DVFS is disabled in the BIOS, Punit
|
|
|
|
* will never ack the request. So if that happens
|
|
|
|
* assume we don't have to enable/disable DDR DVFS
|
|
|
|
* dynamically. To test that just set the REQ_ACK
|
|
|
|
* bit to poke the Punit, but don't change the
|
|
|
|
* HIGH/LOW bits so that we don't actually change
|
|
|
|
* the current state.
|
|
|
|
*/
|
2015-06-24 19:00:03 +00:00
|
|
|
val = vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2);
|
2015-09-08 18:05:12 +00:00
|
|
|
val |= FORCE_DDR_FREQ_REQ_ACK;
|
|
|
|
vlv_punit_write(dev_priv, PUNIT_REG_DDR_SETUP2, val);
|
|
|
|
|
|
|
|
if (wait_for((vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2) &
|
|
|
|
FORCE_DDR_FREQ_REQ_ACK) == 0, 3)) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Punit not acking DDR DVFS request, "
|
|
|
|
"assuming DDR DVFS is disabled\n");
|
2015-09-08 18:05:12 +00:00
|
|
|
dev_priv->wm.max_level = VLV_WM_LEVEL_PM5;
|
|
|
|
} else {
|
|
|
|
val = vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2);
|
|
|
|
if ((val & FORCE_DDR_HIGH_FREQ) == 0)
|
|
|
|
wm->level = VLV_WM_LEVEL_DDR_DVFS;
|
|
|
|
}
|
2015-06-24 19:00:03 +00:00
|
|
|
|
2019-04-26 08:17:20 +00:00
|
|
|
vlv_punit_put(dev_priv);
|
2015-06-24 19:00:03 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2017-03-02 17:14:57 +00:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct vlv_wm_state *active = &crtc->wm.active.vlv;
|
|
|
|
const struct vlv_fifo_state *fifo_state =
|
|
|
|
&crtc_state->wm.vlv.fifo_state;
|
|
|
|
enum pipe pipe = crtc->pipe;
|
|
|
|
enum plane_id plane_id;
|
|
|
|
int level;
|
|
|
|
|
|
|
|
vlv_get_fifo_size(crtc_state);
|
|
|
|
|
|
|
|
active->num_levels = wm->level + 1;
|
|
|
|
active->cxsr = wm->cxsr;
|
|
|
|
|
|
|
|
for (level = 0; level < active->num_levels; level++) {
|
2017-04-21 18:14:21 +00:00
|
|
|
struct g4x_pipe_wm *raw =
|
2017-03-02 17:14:57 +00:00
|
|
|
&crtc_state->wm.vlv.raw[level];
|
|
|
|
|
|
|
|
active->sr[level].plane = wm->sr.plane;
|
|
|
|
active->sr[level].cursor = wm->sr.cursor;
|
|
|
|
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
|
|
|
active->wm[level].plane[plane_id] =
|
|
|
|
wm->pipe[pipe].plane[plane_id];
|
|
|
|
|
|
|
|
raw->plane[plane_id] =
|
|
|
|
vlv_invert_wm_value(active->wm[level].plane[plane_id],
|
|
|
|
fifo_state->plane[plane_id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id)
|
|
|
|
vlv_raw_plane_wm_set(crtc_state, level,
|
|
|
|
plane_id, USHRT_MAX);
|
|
|
|
vlv_invalidate_wms(crtc, active, level);
|
|
|
|
|
|
|
|
crtc_state->wm.vlv.optimal = *active;
|
2017-03-02 17:14:59 +00:00
|
|
|
crtc_state->wm.vlv.intermediate = *active;
|
2017-03-02 17:14:57 +00:00
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Initial watermarks: pipe %c, plane=%d, cursor=%d, sprite0=%d, sprite1=%d\n",
|
|
|
|
pipe_name(pipe),
|
|
|
|
wm->pipe[pipe].plane[PLANE_PRIMARY],
|
|
|
|
wm->pipe[pipe].plane[PLANE_CURSOR],
|
|
|
|
wm->pipe[pipe].plane[PLANE_SPRITE0],
|
|
|
|
wm->pipe[pipe].plane[PLANE_SPRITE1]);
|
2017-03-02 17:14:57 +00:00
|
|
|
}
|
2015-06-24 19:00:03 +00:00
|
|
|
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Initial watermarks: SR plane=%d, SR cursor=%d level=%d cxsr=%d\n",
|
|
|
|
wm->sr.plane, wm->sr.cursor, wm->level, wm->cxsr);
|
2015-06-24 19:00:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 17:15:02 +00:00
|
|
|
void vlv_wm_sanitize(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
struct intel_plane *plane;
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
mutex_lock(&dev_priv->wm.wm_mutex);
|
|
|
|
|
|
|
|
for_each_intel_plane(&dev_priv->drm, plane) {
|
|
|
|
struct intel_crtc *crtc =
|
|
|
|
intel_get_crtc_for_pipe(dev_priv, plane->pipe);
|
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
struct intel_plane_state *plane_state =
|
|
|
|
to_intel_plane_state(plane->base.state);
|
|
|
|
struct vlv_wm_state *wm_state = &crtc_state->wm.vlv.optimal;
|
|
|
|
const struct vlv_fifo_state *fifo_state =
|
|
|
|
&crtc_state->wm.vlv.fifo_state;
|
|
|
|
enum plane_id plane_id = plane->id;
|
|
|
|
int level;
|
|
|
|
|
2019-10-31 11:26:08 +00:00
|
|
|
if (plane_state->uapi.visible)
|
2017-03-02 17:15:02 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
for (level = 0; level < wm_state->num_levels; level++) {
|
2017-04-21 18:14:21 +00:00
|
|
|
struct g4x_pipe_wm *raw =
|
2017-03-02 17:15:02 +00:00
|
|
|
&crtc_state->wm.vlv.raw[level];
|
|
|
|
|
|
|
|
raw->plane[plane_id] = 0;
|
|
|
|
|
|
|
|
wm_state->wm[level].plane[plane_id] =
|
|
|
|
vlv_invert_wm_value(raw->plane[plane_id],
|
|
|
|
fifo_state->plane[plane_id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
|
|
|
crtc_state->wm.vlv.intermediate =
|
|
|
|
crtc_state->wm.vlv.optimal;
|
|
|
|
crtc->wm.active.vlv = crtc_state->wm.vlv.optimal;
|
|
|
|
}
|
|
|
|
|
|
|
|
vlv_program_watermarks(dev_priv);
|
|
|
|
|
|
|
|
mutex_unlock(&dev_priv->wm.wm_mutex);
|
|
|
|
}
|
|
|
|
|
2017-11-08 13:35:55 +00:00
|
|
|
/*
|
|
|
|
* FIXME should probably kill this and improve
|
|
|
|
* the real watermark readout/sanitation instead
|
|
|
|
*/
|
|
|
|
static void ilk_init_lp_watermarks(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
I915_WRITE(WM3_LP_ILK, I915_READ(WM3_LP_ILK) & ~WM1_LP_SR_EN);
|
|
|
|
I915_WRITE(WM2_LP_ILK, I915_READ(WM2_LP_ILK) & ~WM1_LP_SR_EN);
|
|
|
|
I915_WRITE(WM1_LP_ILK, I915_READ(WM1_LP_ILK) & ~WM1_LP_SR_EN);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't touch WM1S_LP_EN here.
|
|
|
|
* Doing so could cause underruns.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
void ilk_wm_get_hw_state(struct drm_i915_private *dev_priv)
|
2013-10-14 11:55:24 +00:00
|
|
|
{
|
2013-12-17 12:46:36 +00:00
|
|
|
struct ilk_wm_values *hw = &dev_priv->wm.hw;
|
2018-12-10 21:54:14 +00:00
|
|
|
struct intel_crtc *crtc;
|
2013-10-14 11:55:24 +00:00
|
|
|
|
2017-11-08 13:35:55 +00:00
|
|
|
ilk_init_lp_watermarks(dev_priv);
|
|
|
|
|
2018-12-10 21:54:14 +00:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc)
|
2013-10-14 11:55:24 +00:00
|
|
|
ilk_pipe_wm_get_hw_state(crtc);
|
|
|
|
|
|
|
|
hw->wm_lp[0] = I915_READ(WM1_LP_ILK);
|
|
|
|
hw->wm_lp[1] = I915_READ(WM2_LP_ILK);
|
|
|
|
hw->wm_lp[2] = I915_READ(WM3_LP_ILK);
|
|
|
|
|
|
|
|
hw->wm_lp_spr[0] = I915_READ(WM1S_LP_ILK);
|
2016-11-16 08:55:42 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 7) {
|
2014-03-07 16:32:08 +00:00
|
|
|
hw->wm_lp_spr[1] = I915_READ(WM2S_LP_IVB);
|
|
|
|
hw->wm_lp_spr[2] = I915_READ(WM3S_LP_IVB);
|
|
|
|
}
|
2013-10-14 11:55:24 +00:00
|
|
|
|
2016-10-13 10:03:00 +00:00
|
|
|
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
|
2013-12-05 13:51:28 +00:00
|
|
|
hw->partitioning = (I915_READ(WM_MISC) & WM_MISC_DATA_PARTITION_5_6) ?
|
|
|
|
INTEL_DDB_PART_5_6 : INTEL_DDB_PART_1_2;
|
2016-10-14 09:13:06 +00:00
|
|
|
else if (IS_IVYBRIDGE(dev_priv))
|
2013-12-05 13:51:28 +00:00
|
|
|
hw->partitioning = (I915_READ(DISP_ARB_CTL2) & DISP_DATA_PARTITION_5_6) ?
|
|
|
|
INTEL_DDB_PART_5_6 : INTEL_DDB_PART_1_2;
|
2013-10-14 11:55:24 +00:00
|
|
|
|
|
|
|
hw->enable_fbc_wm =
|
|
|
|
!(I915_READ(DISP_ARB_CTL) & DISP_FBC_WM_DIS);
|
|
|
|
}
|
|
|
|
|
2012-04-17 01:20:35 +00:00
|
|
|
/**
|
|
|
|
* intel_update_watermarks - update FIFO watermark values based on current modes
|
2018-02-14 14:03:03 +00:00
|
|
|
* @crtc: the #intel_crtc on which to compute the WM
|
2012-04-17 01:20:35 +00:00
|
|
|
*
|
|
|
|
* Calculate watermark values for the various WM regs based on current mode
|
|
|
|
* and plane configuration.
|
|
|
|
*
|
|
|
|
* There are several cases to deal with here:
|
|
|
|
* - normal (i.e. non-self-refresh)
|
|
|
|
* - self-refresh (SR) mode
|
|
|
|
* - lines are large relative to FIFO size (buffer can hold up to 2)
|
|
|
|
* - lines are small relative to FIFO size (buffer can hold more than 2
|
|
|
|
* lines), so need to account for TLB latency
|
|
|
|
*
|
|
|
|
* The normal calculation is:
|
|
|
|
* watermark = dotclock * bytes per pixel * latency
|
|
|
|
* where latency is platform & configuration dependent (we assume pessimal
|
|
|
|
* values here).
|
|
|
|
*
|
|
|
|
* The SR calculation is:
|
|
|
|
* watermark = (trunc(latency/line time)+1) * surface width *
|
|
|
|
* bytes per pixel
|
|
|
|
* where
|
|
|
|
* line time = htotal / dotclock
|
|
|
|
* surface width = hdisplay for normal plane and 64 for cursor
|
|
|
|
* and latency is assumed to be high, as above.
|
|
|
|
*
|
|
|
|
* The final value programmed to the register should always be rounded up,
|
|
|
|
* and include an extra 2 entries to account for clock crossings.
|
|
|
|
*
|
|
|
|
* We don't use the sprite, so we can ignore that. And on Crestline we have
|
|
|
|
* to set the non-SR watermarks to 8.
|
|
|
|
*/
|
2016-10-31 20:37:03 +00:00
|
|
|
void intel_update_watermarks(struct intel_crtc *crtc)
|
2012-04-17 01:20:35 +00:00
|
|
|
{
|
2016-10-31 20:37:03 +00:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2012-04-17 01:20:35 +00:00
|
|
|
|
|
|
|
if (dev_priv->display.update_wm)
|
2013-09-10 08:40:40 +00:00
|
|
|
dev_priv->display.update_wm(crtc);
|
2012-04-17 01:20:35 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 13:45:28 +00:00
|
|
|
void intel_enable_ipc(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
2018-09-18 20:47:11 +00:00
|
|
|
if (!HAS_IPC(dev_priv))
|
|
|
|
return;
|
|
|
|
|
2017-08-17 13:45:28 +00:00
|
|
|
val = I915_READ(DISP_ARB_CTL2);
|
|
|
|
|
|
|
|
if (dev_priv->ipc_enabled)
|
|
|
|
val |= DISP_IPC_ENABLE;
|
|
|
|
else
|
|
|
|
val &= ~DISP_IPC_ENABLE;
|
|
|
|
|
|
|
|
I915_WRITE(DISP_ARB_CTL2, val);
|
|
|
|
}
|
|
|
|
|
2019-05-03 17:38:07 +00:00
|
|
|
static bool intel_can_enable_ipc(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
/* Display WA #0477 WaDisableIPC: skl */
|
|
|
|
if (IS_SKYLAKE(dev_priv))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Display WA #1141: SKL:all KBL:all CFL */
|
|
|
|
if (IS_KABYLAKE(dev_priv) || IS_COFFEELAKE(dev_priv))
|
|
|
|
return dev_priv->dram_info.symmetric_memory;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-08-17 13:45:28 +00:00
|
|
|
void intel_init_ipc(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
if (!HAS_IPC(dev_priv))
|
|
|
|
return;
|
|
|
|
|
2019-05-03 17:38:07 +00:00
|
|
|
dev_priv->ipc_enabled = intel_can_enable_ipc(dev_priv);
|
2018-09-18 20:47:13 +00:00
|
|
|
|
2017-08-17 13:45:28 +00:00
|
|
|
intel_enable_ipc(dev_priv);
|
|
|
|
}
|
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
static void ibx_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* On Ibex Peak and Cougar Point, we need to disable clock
|
|
|
|
* gating for the panel power sequencer or it will fail to
|
|
|
|
* start up when no ports are active.
|
|
|
|
*/
|
|
|
|
I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
|
|
|
|
}
|
2012-08-09 14:46:01 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
static void g4x_disable_trickle_feed(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:23 +00:00
|
|
|
{
|
2019-10-24 21:16:41 +00:00
|
|
|
enum pipe pipe;
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
for_each_pipe(dev_priv, pipe) {
|
|
|
|
I915_WRITE(DSPCNTR(pipe),
|
|
|
|
I915_READ(DSPCNTR(pipe)) |
|
|
|
|
DISPPLANE_TRICKLE_FEED_DISABLE);
|
2012-08-09 14:46:01 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(DSPSURF(pipe), I915_READ(DSPSURF(pipe)));
|
|
|
|
POSTING_READ(DSPSURF(pipe));
|
2012-04-18 18:29:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
static void ilk_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:23 +00:00
|
|
|
{
|
2019-10-24 21:16:41 +00:00
|
|
|
u32 dspclk_gate = ILK_VRHUNIT_CLOCK_GATE_DISABLE;
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/*
|
|
|
|
* Required for FBC
|
|
|
|
* WaFbcDisableDpfcClockGating:ilk
|
|
|
|
*/
|
|
|
|
dspclk_gate |= ILK_DPFCRUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
ILK_DPFCUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
ILK_DPFDUNIT_CLOCK_GATE_ENABLE;
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(PCH_3DCGDIS0,
|
|
|
|
MARIUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
SVSMUNIT_CLOCK_GATE_DISABLE);
|
|
|
|
I915_WRITE(PCH_3DCGDIS1,
|
|
|
|
VFMUNIT_CLOCK_GATE_DISABLE);
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/*
|
|
|
|
* According to the spec the following bits should be set in
|
|
|
|
* order to enable memory self-refresh
|
|
|
|
* The bit 22/21 of 0x42004
|
|
|
|
* The bit 5 of 0x42020
|
|
|
|
* The bit 15 of 0x45000
|
|
|
|
*/
|
|
|
|
I915_WRITE(ILK_DISPLAY_CHICKEN2,
|
|
|
|
(I915_READ(ILK_DISPLAY_CHICKEN2) |
|
|
|
|
ILK_DPARB_GATE | ILK_VSDPFD_FULL));
|
|
|
|
dspclk_gate |= ILK_DPARBUNIT_CLOCK_GATE_ENABLE;
|
|
|
|
I915_WRITE(DISP_ARB_CTL,
|
|
|
|
(I915_READ(DISP_ARB_CTL) |
|
|
|
|
DISP_FBC_WM_DIS));
|
2012-04-18 18:29:23 +00:00
|
|
|
|
|
|
|
/*
|
2019-10-24 21:16:41 +00:00
|
|
|
* Based on the document from hardware guys the following bits
|
|
|
|
* should be set unconditionally in order to enable FBC.
|
|
|
|
* The bit 22 of 0x42000
|
|
|
|
* The bit 22 of 0x42004
|
|
|
|
* The bit 7,8,9 of 0x42020.
|
2012-04-18 18:29:23 +00:00
|
|
|
*/
|
2019-10-24 21:16:41 +00:00
|
|
|
if (IS_IRONLAKE_M(dev_priv)) {
|
|
|
|
/* WaFbcAsynchFlipDisableFbcQueue:ilk */
|
|
|
|
I915_WRITE(ILK_DISPLAY_CHICKEN1,
|
|
|
|
I915_READ(ILK_DISPLAY_CHICKEN1) |
|
|
|
|
ILK_FBCQ_DIS);
|
|
|
|
I915_WRITE(ILK_DISPLAY_CHICKEN2,
|
|
|
|
I915_READ(ILK_DISPLAY_CHICKEN2) |
|
|
|
|
ILK_DPARB_GATE);
|
|
|
|
}
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(ILK_DSPCLK_GATE_D, dspclk_gate);
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(ILK_DISPLAY_CHICKEN2,
|
|
|
|
I915_READ(ILK_DISPLAY_CHICKEN2) |
|
|
|
|
ILK_ELPIN_409_SELECT);
|
|
|
|
I915_WRITE(_3D_CHICKEN2,
|
|
|
|
_3D_CHICKEN2_WM_READ_PIPELINED << 16 |
|
|
|
|
_3D_CHICKEN2_WM_READ_PIPELINED);
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/* WaDisableRenderCachePipelinedFlush:ilk */
|
|
|
|
I915_WRITE(CACHE_MODE_0,
|
|
|
|
_MASKED_BIT_ENABLE(CM0_PIPELINED_RENDER_FLUSH_DISABLE));
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/* WaDisable_RenderCache_OperationalFlush:ilk */
|
|
|
|
I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
g4x_disable_trickle_feed(dev_priv);
|
2012-08-09 14:46:01 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
ibx_init_clock_gating(dev_priv);
|
2012-04-18 18:29:23 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
static void cpt_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:23 +00:00
|
|
|
{
|
2019-10-24 21:16:41 +00:00
|
|
|
enum pipe pipe;
|
|
|
|
u32 val;
|
2012-04-18 18:29:23 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/*
|
|
|
|
* On Ibex Peak and Cougar Point, we need to disable clock
|
|
|
|
* gating for the panel power sequencer or it will fail to
|
|
|
|
* start up when no ports are active.
|
|
|
|
*/
|
|
|
|
I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
PCH_DPLUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
PCH_CPUNIT_CLOCK_GATE_DISABLE);
|
|
|
|
I915_WRITE(SOUTH_CHICKEN2, I915_READ(SOUTH_CHICKEN2) |
|
|
|
|
DPLS_EDP_PPS_FIX_DIS);
|
|
|
|
/* The below fixes the weird display corruption, a few pixels shifted
|
|
|
|
* downward, on (only) LVDS of some HP laptops with IVY.
|
|
|
|
*/
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
|
|
|
val = I915_READ(TRANS_CHICKEN2(pipe));
|
|
|
|
val |= TRANS_CHICKEN2_TIMING_OVERRIDE;
|
|
|
|
val &= ~TRANS_CHICKEN2_FDI_POLARITY_REVERSED;
|
|
|
|
if (dev_priv->vbt.fdi_rx_polarity_inverted)
|
|
|
|
val |= TRANS_CHICKEN2_FDI_POLARITY_REVERSED;
|
|
|
|
val &= ~TRANS_CHICKEN2_DISABLE_DEEP_COLOR_COUNTER;
|
|
|
|
val &= ~TRANS_CHICKEN2_DISABLE_DEEP_COLOR_MODESWITCH;
|
|
|
|
I915_WRITE(TRANS_CHICKEN2(pipe), val);
|
|
|
|
}
|
|
|
|
/* WADP0ClockGatingDisable */
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
|
|
|
I915_WRITE(TRANS_CHICKEN1(pipe),
|
|
|
|
TRANS_CHICKEN1_DP0UNIT_GC_DISABLE);
|
|
|
|
}
|
2012-04-18 18:29:23 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
static void gen6_check_mch_setup(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:23 +00:00
|
|
|
{
|
2019-10-24 21:16:41 +00:00
|
|
|
u32 tmp;
|
2012-07-26 09:16:14 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
tmp = I915_READ(MCH_SSKPD);
|
|
|
|
if ((tmp & MCH_SSKPD_WM0_MASK) != MCH_SSKPD_WM0_VAL)
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Wrong MCH_SSKPD value: 0x%08x This can cause underruns.\n",
|
|
|
|
tmp);
|
2012-07-26 09:16:14 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
static void gen6_init_clock_gating(struct drm_i915_private *dev_priv)
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
{
|
2019-10-24 21:16:41 +00:00
|
|
|
u32 dspclk_gate = ILK_VRHUNIT_CLOCK_GATE_DISABLE;
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(ILK_DSPCLK_GATE_D, dspclk_gate);
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(ILK_DISPLAY_CHICKEN2,
|
|
|
|
I915_READ(ILK_DISPLAY_CHICKEN2) |
|
|
|
|
ILK_ELPIN_409_SELECT);
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/* WaDisableHiZPlanesWhenMSAAEnabled:snb */
|
|
|
|
I915_WRITE(_3D_CHICKEN,
|
|
|
|
_MASKED_BIT_ENABLE(_3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB));
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/* WaDisable_RenderCache_OperationalFlush:snb */
|
|
|
|
I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/*
|
|
|
|
* BSpec recoomends 8x4 when MSAA is used,
|
|
|
|
* however in practice 16x4 seems fastest.
|
|
|
|
*
|
|
|
|
* Note that PS/WM thread counts depend on the WIZ hashing
|
|
|
|
* disable bit, which we don't touch here, but it's good
|
|
|
|
* to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
|
|
|
|
*/
|
|
|
|
I915_WRITE(GEN6_GT_MODE,
|
|
|
|
_MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4));
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(CACHE_MODE_0,
|
|
|
|
_MASKED_BIT_DISABLE(CM0_STC_EVICT_DISABLE_LRA_SNB));
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(GEN6_UCGCTL1,
|
|
|
|
I915_READ(GEN6_UCGCTL1) |
|
|
|
|
GEN6_BLBUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
GEN6_CSUNIT_CLOCK_GATE_DISABLE);
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/* According to the BSpec vol1g, bit 12 (RCPBUNIT) clock
|
|
|
|
* gating disable must be set. Failure to set it results in
|
|
|
|
* flickering pixels due to Z write ordering failures after
|
|
|
|
* some amount of runtime in the Mesa "fire" demo, and Unigine
|
|
|
|
* Sanctuary and Tropics, and apparently anything else with
|
|
|
|
* alpha test or pixel discard.
|
|
|
|
*
|
|
|
|
* According to the spec, bit 11 (RCCUNIT) must also be set,
|
|
|
|
* but we didn't debug actual testcases to find it out.
|
|
|
|
*
|
|
|
|
* WaDisableRCCUnitClockGating:snb
|
|
|
|
* WaDisableRCPBUnitClockGating:snb
|
drm/i915: Avoid tweaking evaluation thresholds on Baytrail v3
Certain Baytrails, namely the 4 cpu core variants, have been
plaqued by spurious system hangs, mostly occurring with light loads.
Multiple bisects by various people point to a commit which changes the
reclocking strategy for Baytrail to follow its bigger brethen:
commit 8fb55197e64d ("drm/i915: Agressive downclocking on Baytrail")
There is also a review comment attached to this commit from Deepak S
on avoiding punit access on Cherryview and thus it was excluded on
common reclocking path. By taking the same approach and omitting
the punit access by not tweaking the thresholds when the hardware
has been asked to move into different frequency, considerable gains
in stability have been observed.
With J1900 box, light render/video load would end up in system hang
in usually less than 12 hours. With this patch applied, the cumulative
uptime has now been 34 days without issues. To provoke system hang,
light loads on both render and bsd engines in parallel have been used:
glxgears >/dev/null 2>/dev/null &
mpv --vo=vaapi --hwdec=vaapi --loop=inf vid.mp4
So far, author has not witnessed system hang with above load
and this patch applied. Reports from the tenacious people at
kernel bugzilla are also promising.
Considering that the punit access frequency with this patch is
considerably less, there is a possibility that this will push
the, still unknown, root cause past the triggering point on most loads.
But as we now can reliably reproduce the hang independently,
we can reduce the pain that users are having and use a
static thresholds until a root cause is found.
v3: don't break debugfs and simplification (Chris Wilson)
References: https://bugzilla.kernel.org/show_bug.cgi?id=109051
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: fritsch@xbmc.org
Cc: miku@iki.fi
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
CC: Michal Feix <michal@feix.cz>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Deepak S <deepak.s@linux.intel.com>
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: <stable@vger.kernel.org> # v4.2+
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1487166779-26945-1-git-send-email-mika.kuoppala@intel.com
2017-02-15 13:52:59 +00:00
|
|
|
*/
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(GEN6_UCGCTL2,
|
|
|
|
GEN6_RCPBUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
GEN6_RCCUNIT_CLOCK_GATE_DISABLE);
|
drm/i915: Interactive RPS mode
RPS provides a feedback loop where we use the load during the previous
evaluation interval to decide whether to up or down clock the GPU
frequency. Our responsiveness is split into 3 regimes, a high and low
plateau with the intent to keep the gpu clocked high to cover occasional
stalls under high load, and low despite occasional glitches under steady
low load, and inbetween. However, we run into situations like kodi where
we want to stay at low power (video decoding is done efficiently
inside the fixed function HW and doesn't need high clocks even for high
bitrate streams), but just occasionally the pipeline is more complex
than a video decode and we need a smidgen of extra GPU power to present
on time. In the high power regime, we sample at sub frame intervals with
a bias to upclocking, and conversely at low power we sample over a few
frames worth to provide what we consider to be the right levels of
responsiveness respectively. At low power, we more or less expect to be
kicked out to high power at the start of a busy sequence by waitboosting.
Prior to commit e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active
request") whenever we missed the frame or stalled, we would immediate go
full throttle and upclock the GPU to max. But in commit e9af4ea2b9e7, we
relaxed the waitboosting to only apply if the pipeline was deep to avoid
over-committing resources for a near miss. Sadly though, a near miss is
still a miss, and perceptible as jitter in the frame delivery.
To try and prevent the near miss before having to resort to boosting
after the fact, we use the pageflip queue as an indication that we are
in an "interactive" regime and so should sample the load more frequently
to provide power before the frame misses it vblank. This will make us
more favorable to providing a small power increase (one or two bins) as
required rather than going all the way to maximum and then having to
work back down again. (We still keep the waitboosting mechanism around
just in case a dramatic change in system load requires urgent uplocking,
faster than we can provide in a few evaluation intervals.)
v2: Reduce rps_set_interactive to a boolean parameter to avoid the
confusion of what if they wanted a new power mode after pinning to a
different mode (which to choose?)
v3: Only reprogram RPS while the GT is awake, it will be set when we
wake the GT, and while off warns about being used outside of rpm.
v4: Fix deferred application of interactive mode
v5: s/state/interactive/
v6: Group the mutex with its principle in a substruct
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107111
Fixes: e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active request")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180731132629.3381-1-chris@chris-wilson.co.uk
2018-07-31 13:26:29 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/* WaStripsFansDisableFastClipPerformanceFix:snb */
|
|
|
|
I915_WRITE(_3D_CHICKEN3,
|
|
|
|
_MASKED_BIT_ENABLE(_3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL));
|
drm/i915: Interactive RPS mode
RPS provides a feedback loop where we use the load during the previous
evaluation interval to decide whether to up or down clock the GPU
frequency. Our responsiveness is split into 3 regimes, a high and low
plateau with the intent to keep the gpu clocked high to cover occasional
stalls under high load, and low despite occasional glitches under steady
low load, and inbetween. However, we run into situations like kodi where
we want to stay at low power (video decoding is done efficiently
inside the fixed function HW and doesn't need high clocks even for high
bitrate streams), but just occasionally the pipeline is more complex
than a video decode and we need a smidgen of extra GPU power to present
on time. In the high power regime, we sample at sub frame intervals with
a bias to upclocking, and conversely at low power we sample over a few
frames worth to provide what we consider to be the right levels of
responsiveness respectively. At low power, we more or less expect to be
kicked out to high power at the start of a busy sequence by waitboosting.
Prior to commit e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active
request") whenever we missed the frame or stalled, we would immediate go
full throttle and upclock the GPU to max. But in commit e9af4ea2b9e7, we
relaxed the waitboosting to only apply if the pipeline was deep to avoid
over-committing resources for a near miss. Sadly though, a near miss is
still a miss, and perceptible as jitter in the frame delivery.
To try and prevent the near miss before having to resort to boosting
after the fact, we use the pageflip queue as an indication that we are
in an "interactive" regime and so should sample the load more frequently
to provide power before the frame misses it vblank. This will make us
more favorable to providing a small power increase (one or two bins) as
required rather than going all the way to maximum and then having to
work back down again. (We still keep the waitboosting mechanism around
just in case a dramatic change in system load requires urgent uplocking,
faster than we can provide in a few evaluation intervals.)
v2: Reduce rps_set_interactive to a boolean parameter to avoid the
confusion of what if they wanted a new power mode after pinning to a
different mode (which to choose?)
v3: Only reprogram RPS while the GT is awake, it will be set when we
wake the GT, and while off warns about being used outside of rpm.
v4: Fix deferred application of interactive mode
v5: s/state/interactive/
v6: Group the mutex with its principle in a substruct
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107111
Fixes: e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active request")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180731132629.3381-1-chris@chris-wilson.co.uk
2018-07-31 13:26:29 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/*
|
|
|
|
* Bspec says:
|
|
|
|
* "This bit must be set if 3DSTATE_CLIP clip mode is set to normal and
|
|
|
|
* 3DSTATE_SF number of SF output attributes is more than 16."
|
|
|
|
*/
|
|
|
|
I915_WRITE(_3D_CHICKEN3,
|
|
|
|
_MASKED_BIT_ENABLE(_3D_CHICKEN3_SF_DISABLE_PIPELINED_ATTR_FETCH));
|
drm/i915: Interactive RPS mode
RPS provides a feedback loop where we use the load during the previous
evaluation interval to decide whether to up or down clock the GPU
frequency. Our responsiveness is split into 3 regimes, a high and low
plateau with the intent to keep the gpu clocked high to cover occasional
stalls under high load, and low despite occasional glitches under steady
low load, and inbetween. However, we run into situations like kodi where
we want to stay at low power (video decoding is done efficiently
inside the fixed function HW and doesn't need high clocks even for high
bitrate streams), but just occasionally the pipeline is more complex
than a video decode and we need a smidgen of extra GPU power to present
on time. In the high power regime, we sample at sub frame intervals with
a bias to upclocking, and conversely at low power we sample over a few
frames worth to provide what we consider to be the right levels of
responsiveness respectively. At low power, we more or less expect to be
kicked out to high power at the start of a busy sequence by waitboosting.
Prior to commit e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active
request") whenever we missed the frame or stalled, we would immediate go
full throttle and upclock the GPU to max. But in commit e9af4ea2b9e7, we
relaxed the waitboosting to only apply if the pipeline was deep to avoid
over-committing resources for a near miss. Sadly though, a near miss is
still a miss, and perceptible as jitter in the frame delivery.
To try and prevent the near miss before having to resort to boosting
after the fact, we use the pageflip queue as an indication that we are
in an "interactive" regime and so should sample the load more frequently
to provide power before the frame misses it vblank. This will make us
more favorable to providing a small power increase (one or two bins) as
required rather than going all the way to maximum and then having to
work back down again. (We still keep the waitboosting mechanism around
just in case a dramatic change in system load requires urgent uplocking,
faster than we can provide in a few evaluation intervals.)
v2: Reduce rps_set_interactive to a boolean parameter to avoid the
confusion of what if they wanted a new power mode after pinning to a
different mode (which to choose?)
v3: Only reprogram RPS while the GT is awake, it will be set when we
wake the GT, and while off warns about being used outside of rpm.
v4: Fix deferred application of interactive mode
v5: s/state/interactive/
v6: Group the mutex with its principle in a substruct
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107111
Fixes: e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active request")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180731132629.3381-1-chris@chris-wilson.co.uk
2018-07-31 13:26:29 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/*
|
|
|
|
* According to the spec the following bits should be
|
|
|
|
* set in order to enable memory self-refresh and fbc:
|
|
|
|
* The bit21 and bit22 of 0x42000
|
|
|
|
* The bit21 and bit22 of 0x42004
|
|
|
|
* The bit5 and bit7 of 0x42020
|
|
|
|
* The bit14 of 0x70180
|
|
|
|
* The bit14 of 0x71180
|
|
|
|
*
|
|
|
|
* WaFbcAsynchFlipDisableFbcQueue:snb
|
|
|
|
*/
|
|
|
|
I915_WRITE(ILK_DISPLAY_CHICKEN1,
|
|
|
|
I915_READ(ILK_DISPLAY_CHICKEN1) |
|
|
|
|
ILK_FBCQ_DIS | ILK_PABSTRETCH_DIS);
|
|
|
|
I915_WRITE(ILK_DISPLAY_CHICKEN2,
|
|
|
|
I915_READ(ILK_DISPLAY_CHICKEN2) |
|
|
|
|
ILK_DPARB_GATE | ILK_VSDPFD_FULL);
|
|
|
|
I915_WRITE(ILK_DSPCLK_GATE_D,
|
|
|
|
I915_READ(ILK_DSPCLK_GATE_D) |
|
|
|
|
ILK_DPARBUNIT_CLOCK_GATE_ENABLE |
|
|
|
|
ILK_DPFDUNIT_CLOCK_GATE_ENABLE);
|
drm/i915: Tweak RPS thresholds to more aggressively downclock
After applying wait-boost we often find ourselves stuck at higher clocks
than required. The current threshold value requires the GPU to be
continuously and completely idle for 313ms before it is dropped by one
bin. Conversely, we require the GPU to be busy for an average of 90% over
a 84ms period before we upclock. So the current thresholds almost never
downclock the GPU, and respond very slowly to sudden demands for more
power. It is easy to observe that we currently lock into the wrong bin
and both underperform in benchmarks and consume more power than optimal
(just by repeating the task and measuring the different results).
An alternative approach, as discussed in the bspec, is to use a
continuous threshold for upclocking, and an average value for downclocking.
This is good for quickly detecting and reacting to state changes within a
frame, however it fails with the common throttling method of waiting
upon the outstanding frame - at least it is difficult to choose a
threshold that works well at 15,000fps and at 60fps. So continue to use
average busy/idle loads to determine frequency change.
v2: Use 3 power zones to keep frequencies low in steady-state mostly
idle (e.g. scrolling, interactive 2D drawing), and frequencies high
for demanding games. In between those end-states, we use a
fast-reclocking algorithm to converge more quickly on the desired bin.
v3: Bug fixes - make sure we reset adj after switching power zones.
v4: Tune - drop the continuous busy thresholds as it prevents us from
choosing the right frequency for glxgears style swap benchmarks. Instead
the goal is to be able to find the right clocks irrespective of the
wait-boost.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenneth@whitecape.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
Cc: Owen Taylor <otaylor@redhat.com>
Cc: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Cc: "Zhuang, Lena" <lena.zhuang@intel.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-25 16:34:57 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
g4x_disable_trickle_feed(dev_priv);
|
drm/i915: Interactive RPS mode
RPS provides a feedback loop where we use the load during the previous
evaluation interval to decide whether to up or down clock the GPU
frequency. Our responsiveness is split into 3 regimes, a high and low
plateau with the intent to keep the gpu clocked high to cover occasional
stalls under high load, and low despite occasional glitches under steady
low load, and inbetween. However, we run into situations like kodi where
we want to stay at low power (video decoding is done efficiently
inside the fixed function HW and doesn't need high clocks even for high
bitrate streams), but just occasionally the pipeline is more complex
than a video decode and we need a smidgen of extra GPU power to present
on time. In the high power regime, we sample at sub frame intervals with
a bias to upclocking, and conversely at low power we sample over a few
frames worth to provide what we consider to be the right levels of
responsiveness respectively. At low power, we more or less expect to be
kicked out to high power at the start of a busy sequence by waitboosting.
Prior to commit e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active
request") whenever we missed the frame or stalled, we would immediate go
full throttle and upclock the GPU to max. But in commit e9af4ea2b9e7, we
relaxed the waitboosting to only apply if the pipeline was deep to avoid
over-committing resources for a near miss. Sadly though, a near miss is
still a miss, and perceptible as jitter in the frame delivery.
To try and prevent the near miss before having to resort to boosting
after the fact, we use the pageflip queue as an indication that we are
in an "interactive" regime and so should sample the load more frequently
to provide power before the frame misses it vblank. This will make us
more favorable to providing a small power increase (one or two bins) as
required rather than going all the way to maximum and then having to
work back down again. (We still keep the waitboosting mechanism around
just in case a dramatic change in system load requires urgent uplocking,
faster than we can provide in a few evaluation intervals.)
v2: Reduce rps_set_interactive to a boolean parameter to avoid the
confusion of what if they wanted a new power mode after pinning to a
different mode (which to choose?)
v3: Only reprogram RPS while the GT is awake, it will be set when we
wake the GT, and while off warns about being used outside of rpm.
v4: Fix deferred application of interactive mode
v5: s/state/interactive/
v6: Group the mutex with its principle in a substruct
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107111
Fixes: e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active request")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180731132629.3381-1-chris@chris-wilson.co.uk
2018-07-31 13:26:29 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
cpt_init_clock_gating(dev_priv);
|
drm/i915: Interactive RPS mode
RPS provides a feedback loop where we use the load during the previous
evaluation interval to decide whether to up or down clock the GPU
frequency. Our responsiveness is split into 3 regimes, a high and low
plateau with the intent to keep the gpu clocked high to cover occasional
stalls under high load, and low despite occasional glitches under steady
low load, and inbetween. However, we run into situations like kodi where
we want to stay at low power (video decoding is done efficiently
inside the fixed function HW and doesn't need high clocks even for high
bitrate streams), but just occasionally the pipeline is more complex
than a video decode and we need a smidgen of extra GPU power to present
on time. In the high power regime, we sample at sub frame intervals with
a bias to upclocking, and conversely at low power we sample over a few
frames worth to provide what we consider to be the right levels of
responsiveness respectively. At low power, we more or less expect to be
kicked out to high power at the start of a busy sequence by waitboosting.
Prior to commit e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active
request") whenever we missed the frame or stalled, we would immediate go
full throttle and upclock the GPU to max. But in commit e9af4ea2b9e7, we
relaxed the waitboosting to only apply if the pipeline was deep to avoid
over-committing resources for a near miss. Sadly though, a near miss is
still a miss, and perceptible as jitter in the frame delivery.
To try and prevent the near miss before having to resort to boosting
after the fact, we use the pageflip queue as an indication that we are
in an "interactive" regime and so should sample the load more frequently
to provide power before the frame misses it vblank. This will make us
more favorable to providing a small power increase (one or two bins) as
required rather than going all the way to maximum and then having to
work back down again. (We still keep the waitboosting mechanism around
just in case a dramatic change in system load requires urgent uplocking,
faster than we can provide in a few evaluation intervals.)
v2: Reduce rps_set_interactive to a boolean parameter to avoid the
confusion of what if they wanted a new power mode after pinning to a
different mode (which to choose?)
v3: Only reprogram RPS while the GT is awake, it will be set when we
wake the GT, and while off warns about being used outside of rpm.
v4: Fix deferred application of interactive mode
v5: s/state/interactive/
v6: Group the mutex with its principle in a substruct
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107111
Fixes: e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active request")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180731132629.3381-1-chris@chris-wilson.co.uk
2018-07-31 13:26:29 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
gen6_check_mch_setup(dev_priv);
|
drm/i915: Interactive RPS mode
RPS provides a feedback loop where we use the load during the previous
evaluation interval to decide whether to up or down clock the GPU
frequency. Our responsiveness is split into 3 regimes, a high and low
plateau with the intent to keep the gpu clocked high to cover occasional
stalls under high load, and low despite occasional glitches under steady
low load, and inbetween. However, we run into situations like kodi where
we want to stay at low power (video decoding is done efficiently
inside the fixed function HW and doesn't need high clocks even for high
bitrate streams), but just occasionally the pipeline is more complex
than a video decode and we need a smidgen of extra GPU power to present
on time. In the high power regime, we sample at sub frame intervals with
a bias to upclocking, and conversely at low power we sample over a few
frames worth to provide what we consider to be the right levels of
responsiveness respectively. At low power, we more or less expect to be
kicked out to high power at the start of a busy sequence by waitboosting.
Prior to commit e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active
request") whenever we missed the frame or stalled, we would immediate go
full throttle and upclock the GPU to max. But in commit e9af4ea2b9e7, we
relaxed the waitboosting to only apply if the pipeline was deep to avoid
over-committing resources for a near miss. Sadly though, a near miss is
still a miss, and perceptible as jitter in the frame delivery.
To try and prevent the near miss before having to resort to boosting
after the fact, we use the pageflip queue as an indication that we are
in an "interactive" regime and so should sample the load more frequently
to provide power before the frame misses it vblank. This will make us
more favorable to providing a small power increase (one or two bins) as
required rather than going all the way to maximum and then having to
work back down again. (We still keep the waitboosting mechanism around
just in case a dramatic change in system load requires urgent uplocking,
faster than we can provide in a few evaluation intervals.)
v2: Reduce rps_set_interactive to a boolean parameter to avoid the
confusion of what if they wanted a new power mode after pinning to a
different mode (which to choose?)
v3: Only reprogram RPS while the GT is awake, it will be set when we
wake the GT, and while off warns about being used outside of rpm.
v4: Fix deferred application of interactive mode
v5: s/state/interactive/
v6: Group the mutex with its principle in a substruct
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107111
Fixes: e9af4ea2b9e7 ("drm/i915: Avoid waitboosting on the active request")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180731132629.3381-1-chris@chris-wilson.co.uk
2018-07-31 13:26:29 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv)
|
2014-03-28 08:03:34 +00:00
|
|
|
{
|
2019-10-24 21:16:41 +00:00
|
|
|
u32 reg = I915_READ(GEN7_FF_THREAD_MODE);
|
2014-03-28 08:03:34 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
/*
|
|
|
|
* WaVSThreadDispatchOverride:ivb,vlv
|
|
|
|
*
|
|
|
|
* This actually overrides the dispatch
|
|
|
|
* mode for all thread types.
|
|
|
|
*/
|
|
|
|
reg &= ~GEN7_FF_SCHED_MASK;
|
|
|
|
reg |= GEN7_FF_TS_SCHED_HW;
|
|
|
|
reg |= GEN7_FF_VS_SCHED_HW;
|
|
|
|
reg |= GEN7_FF_DS_SCHED_HW;
|
2014-07-10 19:31:19 +00:00
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
I915_WRITE(GEN7_FF_THREAD_MODE, reg);
|
2014-03-28 08:03:34 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 21:16:41 +00:00
|
|
|
static void lpt_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-07-26 09:16:14 +00:00
|
|
|
{
|
2019-10-24 21:16:41 +00:00
|
|
|
/*
|
|
|
|
* TODO: this bit should only be enabled when really needed, then
|
|
|
|
* disabled when not needed anymore in order to save power.
|
2012-11-20 17:12:07 +00:00
|
|
|
*/
|
2016-10-13 10:02:52 +00:00
|
|
|
if (HAS_PCH_LPT_LP(dev_priv))
|
2012-11-20 17:12:07 +00:00
|
|
|
I915_WRITE(SOUTH_DSPCLK_GATE_D,
|
|
|
|
I915_READ(SOUTH_DSPCLK_GATE_D) |
|
|
|
|
PCH_LP_PARTITION_LEVEL_DISABLE);
|
2013-04-17 21:15:49 +00:00
|
|
|
|
|
|
|
/* WADPOClockGatingDisable:hsw */
|
2015-09-18 17:03:31 +00:00
|
|
|
I915_WRITE(TRANS_CHICKEN1(PIPE_A),
|
|
|
|
I915_READ(TRANS_CHICKEN1(PIPE_A)) |
|
2013-04-17 21:15:49 +00:00
|
|
|
TRANS_CHICKEN1_DP0UNIT_GC_DISABLE);
|
2012-11-20 17:12:07 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:23 +00:00
|
|
|
static void lpt_suspend_hw(struct drm_i915_private *dev_priv)
|
2013-04-17 11:04:50 +00:00
|
|
|
{
|
2016-10-13 10:02:52 +00:00
|
|
|
if (HAS_PCH_LPT_LP(dev_priv)) {
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 val = I915_READ(SOUTH_DSPCLK_GATE_D);
|
2013-04-17 11:04:50 +00:00
|
|
|
|
|
|
|
val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
|
|
|
|
I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-03 12:54:21 +00:00
|
|
|
static void gen8_set_l3sqc_credits(struct drm_i915_private *dev_priv,
|
|
|
|
int general_prio_credits,
|
|
|
|
int high_prio_credits)
|
|
|
|
{
|
|
|
|
u32 misccpctl;
|
2017-10-17 20:25:45 +00:00
|
|
|
u32 val;
|
2016-05-03 12:54:21 +00:00
|
|
|
|
|
|
|
/* WaTempDisableDOPClkGating:bdw */
|
|
|
|
misccpctl = I915_READ(GEN7_MISCCPCTL);
|
|
|
|
I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE);
|
|
|
|
|
2017-10-17 20:25:45 +00:00
|
|
|
val = I915_READ(GEN8_L3SQCREG1);
|
|
|
|
val &= ~L3_PRIO_CREDITS_MASK;
|
|
|
|
val |= L3_GENERAL_PRIO_CREDITS(general_prio_credits);
|
|
|
|
val |= L3_HIGH_PRIO_CREDITS(high_prio_credits);
|
|
|
|
I915_WRITE(GEN8_L3SQCREG1, val);
|
2016-05-03 12:54:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait at least 100 clocks before re-enabling clock gating.
|
|
|
|
* See the definition of L3SQCREG1 in BSpec.
|
|
|
|
*/
|
|
|
|
POSTING_READ(GEN8_L3SQCREG1);
|
|
|
|
udelay(1);
|
|
|
|
I915_WRITE(GEN7_MISCCPCTL, misccpctl);
|
|
|
|
}
|
|
|
|
|
2018-05-08 21:29:24 +00:00
|
|
|
static void icl_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
/* This is not an Wa. Enable to reduce Sampler power */
|
|
|
|
I915_WRITE(GEN10_DFR_RATIO_EN_AND_CHICKEN,
|
|
|
|
I915_READ(GEN10_DFR_RATIO_EN_AND_CHICKEN) & ~DFR_DISABLE);
|
2018-10-30 08:45:01 +00:00
|
|
|
|
|
|
|
/* WaEnable32PlaneMode:icl */
|
|
|
|
I915_WRITE(GEN9_CSFE_CHICKEN1_RCS,
|
|
|
|
_MASKED_BIT_ENABLE(GEN11_ENABLE_32_PLANE_MODE));
|
2019-12-24 01:20:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Wa_1408615072:icl,ehl (vsunit)
|
|
|
|
* Wa_1407596294:icl,ehl (hsunit)
|
|
|
|
*/
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, UNSLICE_UNIT_LEVEL_CLKGATE,
|
|
|
|
0, VSUNIT_CLKGATE_DIS | HSUNIT_CLKGATE_DIS);
|
|
|
|
|
2019-12-31 19:07:13 +00:00
|
|
|
/* Wa_1407352427:icl,ehl */
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, UNSLICE_UNIT_LEVEL_CLKGATE2,
|
|
|
|
0, PSDUNIT_CLKGATE_DIS);
|
2020-01-14 04:11:28 +00:00
|
|
|
|
|
|
|
/*Wa_14010594013:icl, ehl */
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, GEN8_CHICKEN_DCPR_1,
|
|
|
|
0, CNL_DELAY_PMRSP);
|
2018-05-08 21:29:24 +00:00
|
|
|
}
|
|
|
|
|
2019-08-23 08:20:34 +00:00
|
|
|
static void tgl_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
u32 vd_pg_enable = 0;
|
|
|
|
unsigned int i;
|
|
|
|
|
2019-12-24 01:20:26 +00:00
|
|
|
/* Wa_1408615072:tgl */
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, UNSLICE_UNIT_LEVEL_CLKGATE2,
|
|
|
|
0, VSUNIT_CLKGATE_DIS_TGL);
|
|
|
|
|
2019-08-23 08:20:34 +00:00
|
|
|
/* This is not a WA. Enable VD HCP & MFX_ENC powergate */
|
|
|
|
for (i = 0; i < I915_MAX_VCS; i++) {
|
|
|
|
if (HAS_ENGINE(dev_priv, _VCS(i)))
|
|
|
|
vd_pg_enable |= VDN_HCP_POWERGATE_ENABLE(i) |
|
|
|
|
VDN_MFX_POWERGATE_ENABLE(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
I915_WRITE(POWERGATE_ENABLE,
|
|
|
|
I915_READ(POWERGATE_ENABLE) | vd_pg_enable);
|
2020-01-09 22:37:27 +00:00
|
|
|
|
|
|
|
/* Wa_1409825376:tgl (pre-prod)*/
|
|
|
|
if (IS_TGL_REVID(dev_priv, TGL_REVID_A0, TGL_REVID_A0))
|
|
|
|
I915_WRITE(GEN9_CLKGATE_DIS_3, I915_READ(GEN9_CLKGATE_DIS_3) |
|
|
|
|
TGL_VRH_GATING_DIS);
|
2019-08-23 08:20:34 +00:00
|
|
|
}
|
|
|
|
|
2017-08-31 04:52:23 +00:00
|
|
|
static void cnp_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
if (!HAS_PCH_CNP(dev_priv))
|
|
|
|
return;
|
|
|
|
|
2018-03-06 01:28:12 +00:00
|
|
|
/* Display WA #1181 WaSouthDisplayDisablePWMCGEGating: cnp */
|
2017-09-08 23:45:33 +00:00
|
|
|
I915_WRITE(SOUTH_DSPCLK_GATE_D, I915_READ(SOUTH_DSPCLK_GATE_D) |
|
|
|
|
CNP_PWM_CGE_GATING_DISABLE);
|
2017-08-31 04:52:23 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void cnl_init_clock_gating(struct drm_i915_private *dev_priv)
|
2017-08-15 23:16:48 +00:00
|
|
|
{
|
2017-09-05 19:30:13 +00:00
|
|
|
u32 val;
|
2017-08-31 04:52:23 +00:00
|
|
|
cnp_init_clock_gating(dev_priv);
|
|
|
|
|
2017-08-15 23:16:51 +00:00
|
|
|
/* This is not an Wa. Enable for better image quality */
|
|
|
|
I915_WRITE(_3D_CHICKEN3,
|
|
|
|
_MASKED_BIT_ENABLE(_3D_CHICKEN3_AA_LINE_QUALITY_FIX_ENABLE));
|
|
|
|
|
2017-08-15 23:16:48 +00:00
|
|
|
/* WaEnableChickenDCPR:cnl */
|
|
|
|
I915_WRITE(GEN8_CHICKEN_DCPR_1,
|
|
|
|
I915_READ(GEN8_CHICKEN_DCPR_1) | MASK_WAKEMEM);
|
|
|
|
|
|
|
|
/* WaFbcWakeMemOn:cnl */
|
|
|
|
I915_WRITE(DISP_ARB_CTL, I915_READ(DISP_ARB_CTL) |
|
|
|
|
DISP_FBC_MEMORY_WAKE);
|
|
|
|
|
2017-11-11 10:03:36 +00:00
|
|
|
val = I915_READ(SLICE_UNIT_LEVEL_CLKGATE);
|
|
|
|
/* ReadHitWriteOnlyDisable:cnl */
|
|
|
|
val |= RCCUNIT_CLKGATE_DIS;
|
2017-08-15 23:16:48 +00:00
|
|
|
/* WaSarbUnitClockGatingDisable:cnl (pre-prod) */
|
|
|
|
if (IS_CNL_REVID(dev_priv, CNL_REVID_A0, CNL_REVID_B0))
|
2017-11-11 10:03:36 +00:00
|
|
|
val |= SARBUNIT_CLKGATE_DIS;
|
|
|
|
I915_WRITE(SLICE_UNIT_LEVEL_CLKGATE, val);
|
2017-12-16 00:11:16 +00:00
|
|
|
|
2018-03-07 22:09:12 +00:00
|
|
|
/* Wa_2201832410:cnl */
|
|
|
|
val = I915_READ(SUBSLICE_UNIT_LEVEL_CLKGATE);
|
|
|
|
val |= GWUNIT_CLKGATE_DIS;
|
|
|
|
I915_WRITE(SUBSLICE_UNIT_LEVEL_CLKGATE, val);
|
|
|
|
|
2017-12-16 00:11:16 +00:00
|
|
|
/* WaDisableVFclkgate:cnl */
|
2018-03-06 01:20:00 +00:00
|
|
|
/* WaVFUnitClockGatingDisable:cnl */
|
2017-12-16 00:11:16 +00:00
|
|
|
val = I915_READ(UNSLICE_UNIT_LEVEL_CLKGATE);
|
|
|
|
val |= VFUNIT_CLKGATE_DIS;
|
|
|
|
I915_WRITE(UNSLICE_UNIT_LEVEL_CLKGATE, val);
|
2017-08-15 23:16:48 +00:00
|
|
|
}
|
|
|
|
|
2017-08-31 04:52:23 +00:00
|
|
|
static void cfl_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
cnp_init_clock_gating(dev_priv);
|
|
|
|
gen9_init_clock_gating(dev_priv);
|
|
|
|
|
|
|
|
/* WaFbcNukeOnHostModify:cfl */
|
|
|
|
I915_WRITE(ILK_DPFC_CHICKEN, I915_READ(ILK_DPFC_CHICKEN) |
|
|
|
|
ILK_DPFC_NUKE_ON_ANY_MODIFICATION);
|
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void kbl_init_clock_gating(struct drm_i915_private *dev_priv)
|
2016-06-07 14:19:01 +00:00
|
|
|
{
|
2016-10-31 20:37:22 +00:00
|
|
|
gen9_init_clock_gating(dev_priv);
|
2016-06-07 14:19:01 +00:00
|
|
|
|
|
|
|
/* WaDisableSDEUnitClockGating:kbl */
|
|
|
|
if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0))
|
|
|
|
I915_WRITE(GEN8_UCGCTL6, I915_READ(GEN8_UCGCTL6) |
|
|
|
|
GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
|
2016-06-07 14:19:05 +00:00
|
|
|
|
|
|
|
/* WaDisableGamClockGating:kbl */
|
|
|
|
if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0))
|
|
|
|
I915_WRITE(GEN6_UCGCTL1, I915_READ(GEN6_UCGCTL1) |
|
|
|
|
GEN6_GAMUNIT_CLOCK_GATE_DISABLE);
|
2016-06-07 14:19:18 +00:00
|
|
|
|
2017-08-31 04:52:23 +00:00
|
|
|
/* WaFbcNukeOnHostModify:kbl */
|
2016-06-07 14:19:18 +00:00
|
|
|
I915_WRITE(ILK_DPFC_CHICKEN, I915_READ(ILK_DPFC_CHICKEN) |
|
|
|
|
ILK_DPFC_NUKE_ON_ANY_MODIFICATION);
|
2016-06-07 14:19:01 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void skl_init_clock_gating(struct drm_i915_private *dev_priv)
|
2016-05-19 07:14:20 +00:00
|
|
|
{
|
2016-10-31 20:37:22 +00:00
|
|
|
gen9_init_clock_gating(dev_priv);
|
2016-06-07 14:19:09 +00:00
|
|
|
|
|
|
|
/* WAC6entrylatency:skl */
|
|
|
|
I915_WRITE(FBC_LLC_READ_CTRL, I915_READ(FBC_LLC_READ_CTRL) |
|
|
|
|
FBC_LLC_FULLY_OPEN);
|
2016-06-07 14:19:18 +00:00
|
|
|
|
|
|
|
/* WaFbcNukeOnHostModify:skl */
|
|
|
|
I915_WRITE(ILK_DPFC_CHICKEN, I915_READ(ILK_DPFC_CHICKEN) |
|
|
|
|
ILK_DPFC_NUKE_ON_ANY_MODIFICATION);
|
2016-05-19 07:14:20 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void bdw_init_clock_gating(struct drm_i915_private *dev_priv)
|
2013-11-03 04:07:06 +00:00
|
|
|
{
|
2014-03-03 17:31:46 +00:00
|
|
|
enum pipe pipe;
|
2013-11-03 04:07:06 +00:00
|
|
|
|
2013-12-12 23:28:04 +00:00
|
|
|
/* WaSwitchSolVfFArbitrationPriority:bdw */
|
2013-11-03 04:07:40 +00:00
|
|
|
I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | HSW_ECOCHK_ARB_PRIO_SOL);
|
2013-11-03 04:07:54 +00:00
|
|
|
|
2013-12-12 23:28:04 +00:00
|
|
|
/* WaPsrDPAMaskVBlankInSRD:bdw */
|
2013-11-03 04:07:54 +00:00
|
|
|
I915_WRITE(CHICKEN_PAR1_1,
|
|
|
|
I915_READ(CHICKEN_PAR1_1) | DPA_MASK_VBLANK_SRD);
|
|
|
|
|
2013-12-12 23:28:04 +00:00
|
|
|
/* WaPsrDPRSUnmaskVBlankInSRD:bdw */
|
2014-08-18 12:49:10 +00:00
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2014-03-03 17:31:46 +00:00
|
|
|
I915_WRITE(CHICKEN_PIPESL_1(pipe),
|
2014-03-05 11:05:45 +00:00
|
|
|
I915_READ(CHICKEN_PIPESL_1(pipe)) |
|
2014-03-05 11:05:47 +00:00
|
|
|
BDW_DPRS_MASK_VBLANK_SRD);
|
2013-11-03 04:07:54 +00:00
|
|
|
}
|
2013-12-13 01:26:03 +00:00
|
|
|
|
2013-12-12 23:28:04 +00:00
|
|
|
/* WaVSRefCountFullforceMissDisable:bdw */
|
|
|
|
/* WaDSRefCountFullforceMissDisable:bdw */
|
|
|
|
I915_WRITE(GEN7_FF_THREAD_MODE,
|
|
|
|
I915_READ(GEN7_FF_THREAD_MODE) &
|
|
|
|
~(GEN8_FF_DS_REF_CNT_FFME | GEN7_FF_VS_REF_CNT_FFME));
|
2014-02-04 19:59:21 +00:00
|
|
|
|
2014-02-27 19:59:01 +00:00
|
|
|
I915_WRITE(GEN6_RC_SLEEP_PSMI_CONTROL,
|
|
|
|
_MASKED_BIT_ENABLE(GEN8_RC_SEMA_IDLE_MSG_DISABLE));
|
2014-02-27 19:59:02 +00:00
|
|
|
|
|
|
|
/* WaDisableSDEUnitClockGating:bdw */
|
|
|
|
I915_WRITE(GEN8_UCGCTL6, I915_READ(GEN8_UCGCTL6) |
|
|
|
|
GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
|
2014-03-26 18:41:51 +00:00
|
|
|
|
2016-05-03 12:54:21 +00:00
|
|
|
/* WaProgramL3SqcReg1Default:bdw */
|
|
|
|
gen8_set_l3sqc_credits(dev_priv, 30, 2);
|
2015-05-19 17:32:56 +00:00
|
|
|
|
2016-06-07 14:19:02 +00:00
|
|
|
/* WaKVMNotificationOnConfigChange:bdw */
|
|
|
|
I915_WRITE(CHICKEN_PAR2_1, I915_READ(CHICKEN_PAR2_1)
|
|
|
|
| KVM_CONFIG_CHANGE_NOTIFICATION_SELECT);
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
lpt_init_clock_gating(dev_priv);
|
2017-02-12 13:32:52 +00:00
|
|
|
|
|
|
|
/* WaDisableDopClockGating:bdw
|
|
|
|
*
|
|
|
|
* Also see the CHICKEN2 write in bdw_init_workarounds() to disable DOP
|
|
|
|
* clock gating.
|
|
|
|
*/
|
|
|
|
I915_WRITE(GEN6_UCGCTL1,
|
|
|
|
I915_READ(GEN6_UCGCTL1) | GEN6_EU_TCUNIT_CLOCK_GATE_DISABLE);
|
2013-11-03 04:07:06 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void hsw_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-07-02 14:51:09 +00:00
|
|
|
{
|
2013-10-02 22:53:16 +00:00
|
|
|
/* L3 caching of data atomics doesn't work -- disable it. */
|
|
|
|
I915_WRITE(HSW_SCRATCH1, HSW_SCRATCH1_L3_DATA_ATOMICS_DISABLE);
|
|
|
|
I915_WRITE(HSW_ROW_CHICKEN3,
|
|
|
|
_MASKED_BIT_ENABLE(HSW_ROW_CHICKEN3_L3_GLOBAL_ATOMICS_DISABLE));
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* This is required by WaCatErrorRejectionIssue:hsw */
|
2012-07-02 14:51:09 +00:00
|
|
|
I915_WRITE(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
|
|
|
|
I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
|
|
|
|
GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
|
|
|
|
|
2014-01-22 19:33:00 +00:00
|
|
|
/* WaVSRefCountFullforceMissDisable:hsw */
|
|
|
|
I915_WRITE(GEN7_FF_THREAD_MODE,
|
|
|
|
I915_READ(GEN7_FF_THREAD_MODE) & ~GEN7_FF_VS_REF_CNT_FFME);
|
2012-07-02 14:51:09 +00:00
|
|
|
|
2014-04-04 11:44:38 +00:00
|
|
|
/* WaDisable_RenderCache_OperationalFlush:hsw */
|
|
|
|
I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
|
|
|
|
|
2014-01-28 05:29:33 +00:00
|
|
|
/* enable HiZ Raw Stall Optimization */
|
|
|
|
I915_WRITE(CACHE_MODE_0_GEN7,
|
|
|
|
_MASKED_BIT_DISABLE(HIZ_RAW_STALL_OPT_DISABLE));
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisable4x2SubspanOptimization:hsw */
|
2012-07-02 14:51:09 +00:00
|
|
|
I915_WRITE(CACHE_MODE_1,
|
|
|
|
_MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE));
|
2012-07-02 14:51:10 +00:00
|
|
|
|
2014-02-04 19:59:20 +00:00
|
|
|
/*
|
|
|
|
* BSpec recommends 8x4 when MSAA is used,
|
|
|
|
* however in practice 16x4 seems fastest.
|
2014-02-05 10:43:47 +00:00
|
|
|
*
|
|
|
|
* Note that PS/WM thread counts depend on the WIZ hashing
|
|
|
|
* disable bit, which we don't touch here, but it's good
|
|
|
|
* to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
|
2014-02-04 19:59:20 +00:00
|
|
|
*/
|
|
|
|
I915_WRITE(GEN7_GT_MODE,
|
2014-12-08 17:33:51 +00:00
|
|
|
_MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4));
|
2014-02-04 19:59:20 +00:00
|
|
|
|
drm/i915: Make sample_c messages go faster on Haswell.
Haswell significantly improved the performance of sampler_c messages,
but the optimization appears to be off by default. Later platforms
remove this bit, and apparently always enable the optimization.
Improves performance in "Counter Strike: Global Offensive" by 18%
at default settings on Iris Pro.
This may break sampling of paletted formats (P8/A8P8/P8A8). It's
unclear whether it affects sampling of paletted formats in general,
or just the sample_c message (which is never used).
While libva does have support for using paletted formats (primarily
for OSDs), that support appears to have been broken for at least a
year, so I couldn't observe a regression from this:
I tried to get libva-intel to use paletted formats, and observe a
regression...but the only thing I found that used it was mplayer's OSD
(on screen display). Even without my patch, the colors were totally
wrong with that, and it's according to a few distro wikis, that's been
the case for over a year.
If libva's code for paletted formats /is/ broken, they could always
add code to disable this bit using the command validator when fixing
it.
Further investigation from Haihao shows that libva mplayer OSD seems
to work at least on his setup (still unclear what's wron with Ken's),
and that it's not affected by this patch. Quoting the discussion
between Haihao and Ken:
> > > If you use "-vo gl" or "-vo xv", the OSD is solid white text with a black
> > > border around it. I presume that it's supposed to be white with vaapi as
> > > well, but I guess I'm not entirely sure.
> > >
> > > It's possible that the optimization doesn't affect the palette as long as
> > > you never use sample_c with the paletted textures.
> >
> > I verified the palette takes effect in the following way:
> >
> > 1. Only support P8A8 format in the driver
> >
> > 2. ran the above command and I saw white OSD text
> >
> > 3. Only support P4A4 format in the driver and don't use
> > 3DSTATE_SAMPLER_PALETTE_LOAD0 to load the value to the texture palette,
> > so the palette keeps unchanged.
> >
> > 4. ran the above command and I saw black OSD text.
> >
> > 5. Load the right value to the texture palette and ran the above command
> > again, I saw white OSD text.
> >
> > Hence I think sample_c with the paletted textures is used in the driver.
>
> That sounds like the palette is actually working, then. Great :)
>
> I doubt that libva would use sample_c - sampling with a shadow comparison?
> It looks like it just uses sample and sample+killpix.
You are right, libva driver doesn't use sample_c message.
> I'm pretty sure the sample_c optimization just uses the palette memory as
> storage for some stuff, so it's quite possible it just works if you're
> only using sample and sample+killpix.
Thanks for the explanation, it makes sense to me.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
[danvet: Add wa name from Ville's review to the comment and copypaste
the explanation why we don't care about libva (already broken) from
Ken. Also add conclusion from libva devs that&why this is all fine.]
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: "Xiang, Haihao" <haihao.xiang@intel.com>
Cc: libva@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-01 00:23:00 +00:00
|
|
|
/* WaSampleCChickenBitEnable:hsw */
|
|
|
|
I915_WRITE(HALF_SLICE_CHICKEN3,
|
|
|
|
_MASKED_BIT_ENABLE(HSW_SAMPLE_C_PERFORMANCE));
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaSwitchSolVfFArbitrationPriority:hsw */
|
2013-03-20 21:49:14 +00:00
|
|
|
I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | HSW_ECOCHK_ARB_PRIO_SOL);
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
lpt_init_clock_gating(dev_priv);
|
2012-07-02 14:51:09 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void ivb_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 snpcr;
|
2012-04-18 18:29:25 +00:00
|
|
|
|
2012-10-19 16:55:41 +00:00
|
|
|
I915_WRITE(ILK_DSPCLK_GATE_D, ILK_VRHUNIT_CLOCK_GATE_DISABLE);
|
2012-04-18 18:29:25 +00:00
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisableEarlyCull:ivb */
|
2012-10-02 22:43:41 +00:00
|
|
|
I915_WRITE(_3D_CHICKEN3,
|
|
|
|
_MASKED_BIT_ENABLE(_3D_CHICKEN_SF_DISABLE_OBJEND_CULL));
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisableBackToBackFlipFix:ivb */
|
2012-04-18 18:29:25 +00:00
|
|
|
I915_WRITE(IVB_CHICKEN3,
|
|
|
|
CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
|
|
|
|
CHICKEN3_DGMG_DONE_FIX_DISABLE);
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisablePSDDualDispatchEnable:ivb */
|
2016-10-13 10:02:58 +00:00
|
|
|
if (IS_IVB_GT1(dev_priv))
|
2012-10-25 19:15:45 +00:00
|
|
|
I915_WRITE(GEN7_HALF_SLICE_CHICKEN1,
|
|
|
|
_MASKED_BIT_ENABLE(GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE));
|
|
|
|
|
2014-04-04 11:44:38 +00:00
|
|
|
/* WaDisable_RenderCache_OperationalFlush:ivb */
|
|
|
|
I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* Apply the WaDisableRHWOOptimizationForRenderHang:ivb workaround. */
|
2012-04-18 18:29:25 +00:00
|
|
|
I915_WRITE(GEN7_COMMON_SLICE_CHICKEN1,
|
|
|
|
GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC);
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaApplyL3ControlAndL3ChickenMode:ivb */
|
2012-04-18 18:29:25 +00:00
|
|
|
I915_WRITE(GEN7_L3CNTLREG1,
|
|
|
|
GEN7_WA_FOR_GEN7_L3_CONTROL);
|
|
|
|
I915_WRITE(GEN7_L3_CHICKEN_MODE_REGISTER,
|
2012-10-25 19:15:42 +00:00
|
|
|
GEN7_WA_L3_CHICKEN_MODE);
|
2016-10-13 10:02:58 +00:00
|
|
|
if (IS_IVB_GT1(dev_priv))
|
2012-10-25 19:15:42 +00:00
|
|
|
I915_WRITE(GEN7_ROW_CHICKEN2,
|
|
|
|
_MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
|
2014-01-22 19:32:44 +00:00
|
|
|
else {
|
|
|
|
/* must write both registers */
|
|
|
|
I915_WRITE(GEN7_ROW_CHICKEN2,
|
|
|
|
_MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
|
2012-10-25 19:15:42 +00:00
|
|
|
I915_WRITE(GEN7_ROW_CHICKEN2_GT2,
|
|
|
|
_MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
|
2014-01-22 19:32:44 +00:00
|
|
|
}
|
2012-04-18 18:29:25 +00:00
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaForceL3Serialization:ivb */
|
2012-10-02 22:43:38 +00:00
|
|
|
I915_WRITE(GEN7_L3SQCREG4, I915_READ(GEN7_L3SQCREG4) &
|
|
|
|
~L3SQ_URB_READ_CAM_MATCH_DISABLE);
|
|
|
|
|
2014-01-22 19:32:53 +00:00
|
|
|
/*
|
2012-06-14 18:04:47 +00:00
|
|
|
* According to the spec, bit 13 (RCZUNIT) must be set on IVB.
|
2013-05-03 17:48:10 +00:00
|
|
|
* This implements the WaDisableRCZUnitClockGating:ivb workaround.
|
2012-06-14 18:04:47 +00:00
|
|
|
*/
|
|
|
|
I915_WRITE(GEN6_UCGCTL2,
|
2014-01-22 19:32:48 +00:00
|
|
|
GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
|
2012-06-14 18:04:47 +00:00
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* This is required by WaCatErrorRejectionIssue:ivb */
|
2012-04-18 18:29:25 +00:00
|
|
|
I915_WRITE(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
|
|
|
|
I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
|
|
|
|
GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
g4x_disable_trickle_feed(dev_priv);
|
2012-04-18 18:29:25 +00:00
|
|
|
|
|
|
|
gen7_setup_fixed_func_scheduler(dev_priv);
|
2012-04-24 14:00:21 +00:00
|
|
|
|
2014-03-04 09:41:43 +00:00
|
|
|
if (0) { /* causes HiZ corruption on ivb:gt1 */
|
|
|
|
/* enable HiZ Raw Stall Optimization */
|
|
|
|
I915_WRITE(CACHE_MODE_0_GEN7,
|
|
|
|
_MASKED_BIT_DISABLE(HIZ_RAW_STALL_OPT_DISABLE));
|
|
|
|
}
|
2014-01-28 05:29:34 +00:00
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisable4x2SubspanOptimization:ivb */
|
2012-04-24 14:00:21 +00:00
|
|
|
I915_WRITE(CACHE_MODE_1,
|
|
|
|
_MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE));
|
2012-05-05 01:58:59 +00:00
|
|
|
|
2014-02-04 19:59:19 +00:00
|
|
|
/*
|
|
|
|
* BSpec recommends 8x4 when MSAA is used,
|
|
|
|
* however in practice 16x4 seems fastest.
|
2014-02-05 10:43:47 +00:00
|
|
|
*
|
|
|
|
* Note that PS/WM thread counts depend on the WIZ hashing
|
|
|
|
* disable bit, which we don't touch here, but it's good
|
|
|
|
* to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
|
2014-02-04 19:59:19 +00:00
|
|
|
*/
|
|
|
|
I915_WRITE(GEN7_GT_MODE,
|
2014-12-08 17:33:51 +00:00
|
|
|
_MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4));
|
2014-02-04 19:59:19 +00:00
|
|
|
|
2012-05-05 01:58:59 +00:00
|
|
|
snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
|
|
|
|
snpcr &= ~GEN6_MBC_SNPCR_MASK;
|
|
|
|
snpcr |= GEN6_MBC_SNPCR_MED;
|
|
|
|
I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
|
2012-10-31 21:52:31 +00:00
|
|
|
|
2016-10-13 10:02:53 +00:00
|
|
|
if (!HAS_PCH_NOP(dev_priv))
|
2016-10-31 20:37:22 +00:00
|
|
|
cpt_init_clock_gating(dev_priv);
|
2013-02-09 20:03:42 +00:00
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
gen6_check_mch_setup(dev_priv);
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void vlv_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisableEarlyCull:vlv */
|
2012-10-02 22:43:41 +00:00
|
|
|
I915_WRITE(_3D_CHICKEN3,
|
|
|
|
_MASKED_BIT_ENABLE(_3D_CHICKEN_SF_DISABLE_OBJEND_CULL));
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisableBackToBackFlipFix:vlv */
|
2012-04-18 18:29:25 +00:00
|
|
|
I915_WRITE(IVB_CHICKEN3,
|
|
|
|
CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
|
|
|
|
CHICKEN3_DGMG_DONE_FIX_DISABLE);
|
|
|
|
|
2014-01-22 19:32:39 +00:00
|
|
|
/* WaPsdDispatchEnable:vlv */
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisablePSDDualDispatchEnable:vlv */
|
2012-10-25 19:15:45 +00:00
|
|
|
I915_WRITE(GEN7_HALF_SLICE_CHICKEN1,
|
2013-03-08 18:45:51 +00:00
|
|
|
_MASKED_BIT_ENABLE(GEN7_MAX_PS_THREAD_DEP |
|
|
|
|
GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE));
|
2012-10-25 19:15:45 +00:00
|
|
|
|
2014-04-04 11:44:38 +00:00
|
|
|
/* WaDisable_RenderCache_OperationalFlush:vlv */
|
|
|
|
I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaForceL3Serialization:vlv */
|
2012-10-02 22:43:38 +00:00
|
|
|
I915_WRITE(GEN7_L3SQCREG4, I915_READ(GEN7_L3SQCREG4) &
|
|
|
|
~L3SQ_URB_READ_CAM_MATCH_DISABLE);
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* WaDisableDopClockGating:vlv */
|
2012-10-25 19:15:42 +00:00
|
|
|
I915_WRITE(GEN7_ROW_CHICKEN2,
|
|
|
|
_MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
|
|
|
|
|
2013-05-03 17:48:10 +00:00
|
|
|
/* This is required by WaCatErrorRejectionIssue:vlv */
|
2012-04-18 18:29:25 +00:00
|
|
|
I915_WRITE(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
|
|
|
|
I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
|
|
|
|
GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
|
|
|
|
|
2014-01-22 19:33:01 +00:00
|
|
|
gen7_setup_fixed_func_scheduler(dev_priv);
|
|
|
|
|
2014-01-22 19:32:56 +00:00
|
|
|
/*
|
2012-06-14 18:04:47 +00:00
|
|
|
* According to the spec, bit 13 (RCZUNIT) must be set on IVB.
|
2013-05-03 17:48:10 +00:00
|
|
|
* This implements the WaDisableRCZUnitClockGating:vlv workaround.
|
2012-06-14 18:04:47 +00:00
|
|
|
*/
|
|
|
|
I915_WRITE(GEN6_UCGCTL2,
|
2014-01-22 19:32:56 +00:00
|
|
|
GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
|
2012-06-14 18:04:47 +00:00
|
|
|
|
2014-03-24 17:30:07 +00:00
|
|
|
/* WaDisableL3Bank2xClockGate:vlv
|
|
|
|
* Disabling L3 clock gating- MMIO 940c[25] = 1
|
|
|
|
* Set bit 25, to disable L3_BANK_2x_CLK_GATING */
|
|
|
|
I915_WRITE(GEN7_UCGCTL4,
|
|
|
|
I915_READ(GEN7_UCGCTL4) | GEN7_L3BANK2X_CLOCK_GATE_DISABLE);
|
2012-06-14 18:04:50 +00:00
|
|
|
|
2014-01-22 19:33:03 +00:00
|
|
|
/*
|
|
|
|
* BSpec says this must be set, even though
|
|
|
|
* WaDisable4x2SubspanOptimization isn't listed for VLV.
|
|
|
|
*/
|
2012-04-24 12:04:12 +00:00
|
|
|
I915_WRITE(CACHE_MODE_1,
|
|
|
|
_MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE));
|
2012-06-20 17:53:12 +00:00
|
|
|
|
2015-01-21 17:38:01 +00:00
|
|
|
/*
|
|
|
|
* BSpec recommends 8x4 when MSAA is used,
|
|
|
|
* however in practice 16x4 seems fastest.
|
|
|
|
*
|
|
|
|
* Note that PS/WM thread counts depend on the WIZ hashing
|
|
|
|
* disable bit, which we don't touch here, but it's good
|
|
|
|
* to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
|
|
|
|
*/
|
|
|
|
I915_WRITE(GEN7_GT_MODE,
|
|
|
|
_MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4));
|
|
|
|
|
2014-01-22 19:32:46 +00:00
|
|
|
/*
|
|
|
|
* WaIncreaseL3CreditsForVLVB0:vlv
|
|
|
|
* This is the hardware default actually.
|
|
|
|
*/
|
|
|
|
I915_WRITE(GEN7_L3SQCREG1, VLV_B0_WA_L3SQCREG1_VALUE);
|
|
|
|
|
2012-10-25 19:15:44 +00:00
|
|
|
/*
|
2013-05-03 17:48:10 +00:00
|
|
|
* WaDisableVLVClockGating_VBIIssue:vlv
|
2012-10-25 19:15:44 +00:00
|
|
|
* Disable clock gating on th GCFG unit to prevent a delay
|
|
|
|
* in the reporting of vblank events.
|
|
|
|
*/
|
2014-01-22 19:33:04 +00:00
|
|
|
I915_WRITE(VLV_GUNIT_CLOCK_GATE, GCFG_DIS);
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void chv_init_clock_gating(struct drm_i915_private *dev_priv)
|
2014-04-09 10:28:10 +00:00
|
|
|
{
|
2014-04-09 10:28:35 +00:00
|
|
|
/* WaVSRefCountFullforceMissDisable:chv */
|
|
|
|
/* WaDSRefCountFullforceMissDisable:chv */
|
|
|
|
I915_WRITE(GEN7_FF_THREAD_MODE,
|
|
|
|
I915_READ(GEN7_FF_THREAD_MODE) &
|
|
|
|
~(GEN8_FF_DS_REF_CNT_FFME | GEN7_FF_VS_REF_CNT_FFME));
|
2014-04-09 10:28:36 +00:00
|
|
|
|
|
|
|
/* WaDisableSemaphoreAndSyncFlipWait:chv */
|
|
|
|
I915_WRITE(GEN6_RC_SLEEP_PSMI_CONTROL,
|
|
|
|
_MASKED_BIT_ENABLE(GEN8_RC_SEMA_IDLE_MSG_DISABLE));
|
2014-04-09 10:28:37 +00:00
|
|
|
|
|
|
|
/* WaDisableCSUnitClockGating:chv */
|
|
|
|
I915_WRITE(GEN6_UCGCTL1, I915_READ(GEN6_UCGCTL1) |
|
|
|
|
GEN6_CSUNIT_CLOCK_GATE_DISABLE);
|
2014-04-09 10:28:38 +00:00
|
|
|
|
|
|
|
/* WaDisableSDEUnitClockGating:chv */
|
|
|
|
I915_WRITE(GEN8_UCGCTL6, I915_READ(GEN8_UCGCTL6) |
|
|
|
|
GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
|
2015-05-19 17:32:57 +00:00
|
|
|
|
2016-05-03 12:54:21 +00:00
|
|
|
/*
|
|
|
|
* WaProgramL3SqcReg1Default:chv
|
|
|
|
* See gfxspecs/Related Documents/Performance Guide/
|
|
|
|
* LSQC Setting Recommendations.
|
|
|
|
*/
|
|
|
|
gen8_set_l3sqc_credits(dev_priv, 38, 2);
|
2014-04-09 10:28:10 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
static void g4x_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
2019-01-18 12:01:20 +00:00
|
|
|
u32 dspclk_gate;
|
2012-04-18 18:29:25 +00:00
|
|
|
|
|
|
|
I915_WRITE(RENCLK_GATE_D1, 0);
|
|
|
|
I915_WRITE(RENCLK_GATE_D2, VF_UNIT_CLOCK_GATE_DISABLE |
|
|
|
|
GS_UNIT_CLOCK_GATE_DISABLE |
|
|
|
|
CL_UNIT_CLOCK_GATE_DISABLE);
|
|
|
|
I915_WRITE(RAMCLK_GATE_D, 0);
|
|
|
|
dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
OVRUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
OVCUNIT_CLOCK_GATE_DISABLE;
|
2016-10-13 10:02:58 +00:00
|
|
|
if (IS_GM45(dev_priv))
|
2012-04-18 18:29:25 +00:00
|
|
|
dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE;
|
|
|
|
I915_WRITE(DSPCLK_GATE_D, dspclk_gate);
|
2012-10-18 09:49:51 +00:00
|
|
|
|
|
|
|
/* WaDisableRenderCachePipelinedFlush */
|
|
|
|
I915_WRITE(CACHE_MODE_0,
|
|
|
|
_MASKED_BIT_ENABLE(CM0_PIPELINED_RENDER_FLUSH_DISABLE));
|
2013-06-07 07:47:01 +00:00
|
|
|
|
2014-04-04 11:44:38 +00:00
|
|
|
/* WaDisable_RenderCache_OperationalFlush:g4x */
|
|
|
|
I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
g4x_disable_trickle_feed(dev_priv);
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void i965gm_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
2019-06-11 10:45:48 +00:00
|
|
|
struct intel_uncore *uncore = &dev_priv->uncore;
|
|
|
|
|
|
|
|
intel_uncore_write(uncore, RENCLK_GATE_D1, I965_RCC_CLOCK_GATE_DISABLE);
|
|
|
|
intel_uncore_write(uncore, RENCLK_GATE_D2, 0);
|
|
|
|
intel_uncore_write(uncore, DSPCLK_GATE_D, 0);
|
|
|
|
intel_uncore_write(uncore, RAMCLK_GATE_D, 0);
|
|
|
|
intel_uncore_write16(uncore, DEUC, 0);
|
|
|
|
intel_uncore_write(uncore,
|
|
|
|
MI_ARB_STATE,
|
|
|
|
_MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
|
2014-04-04 11:44:38 +00:00
|
|
|
|
|
|
|
/* WaDisable_RenderCache_OperationalFlush:gen4 */
|
2019-06-11 10:45:48 +00:00
|
|
|
intel_uncore_write(uncore,
|
|
|
|
CACHE_MODE_0,
|
|
|
|
_MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 05:20:26 +00:00
|
|
|
static void i965g_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
|
|
|
I915_WRITE(RENCLK_GATE_D1, I965_RCZ_CLOCK_GATE_DISABLE |
|
|
|
|
I965_RCC_CLOCK_GATE_DISABLE |
|
|
|
|
I965_RCPB_CLOCK_GATE_DISABLE |
|
|
|
|
I965_ISC_CLOCK_GATE_DISABLE |
|
|
|
|
I965_FBC_CLOCK_GATE_DISABLE);
|
|
|
|
I915_WRITE(RENCLK_GATE_D2, 0);
|
2013-06-07 07:47:02 +00:00
|
|
|
I915_WRITE(MI_ARB_STATE,
|
|
|
|
_MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
|
2014-04-04 11:44:38 +00:00
|
|
|
|
|
|
|
/* WaDisable_RenderCache_OperationalFlush:gen4 */
|
|
|
|
I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
static void gen3_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
|
|
|
u32 dstate = I915_READ(D_STATE);
|
|
|
|
|
|
|
|
dstate |= DSTATE_PLL_D3_OFF | DSTATE_GFX_CLOCK_GATING |
|
|
|
|
DSTATE_DOT_CLOCK_GATING;
|
|
|
|
I915_WRITE(D_STATE, dstate);
|
2012-04-24 13:51:43 +00:00
|
|
|
|
2016-10-31 20:37:15 +00:00
|
|
|
if (IS_PINEVIEW(dev_priv))
|
2012-04-24 13:51:43 +00:00
|
|
|
I915_WRITE(ECOSKPD, _MASKED_BIT_ENABLE(ECO_GATING_CX_ONLY));
|
2012-09-09 09:54:16 +00:00
|
|
|
|
|
|
|
/* IIR "flip pending" means done if this bit is set */
|
|
|
|
I915_WRITE(ECOSKPD, _MASKED_BIT_DISABLE(ECO_FLIP_DONE));
|
2014-02-25 13:13:38 +00:00
|
|
|
|
|
|
|
/* interrupts should cause a wake up from C3 */
|
2014-02-25 13:13:39 +00:00
|
|
|
I915_WRITE(INSTPM, _MASKED_BIT_ENABLE(INSTPM_AGPBUSY_INT_EN));
|
2014-02-25 13:13:41 +00:00
|
|
|
|
|
|
|
/* On GEN3 we really need to make sure the ARB C3 LP bit is set */
|
|
|
|
I915_WRITE(MI_ARB_STATE, _MASKED_BIT_ENABLE(MI_ARB_C3_LP_WRITE_ENABLE));
|
2014-08-14 22:21:54 +00:00
|
|
|
|
|
|
|
I915_WRITE(MI_ARB_STATE,
|
|
|
|
_MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
static void i85x_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
|
|
|
I915_WRITE(RENCLK_GATE_D1, SV_CLOCK_GATE_DISABLE);
|
2014-02-25 13:13:40 +00:00
|
|
|
|
|
|
|
/* interrupts should cause a wake up from C3 */
|
|
|
|
I915_WRITE(MI_STATE, _MASKED_BIT_ENABLE(MI_AGPBUSY_INT_EN) |
|
|
|
|
_MASKED_BIT_DISABLE(MI_AGPBUSY_830_MODE));
|
2014-08-14 22:21:54 +00:00
|
|
|
|
|
|
|
I915_WRITE(MEM_MODE,
|
|
|
|
_MASKED_BIT_ENABLE(MEM_DISPLAY_TRICKLE_FEED_DISABLE));
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
static void i830_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
2014-08-14 22:21:54 +00:00
|
|
|
I915_WRITE(MEM_MODE,
|
|
|
|
_MASKED_BIT_ENABLE(MEM_DISPLAY_A_TRICKLE_FEED_DISABLE) |
|
|
|
|
_MASKED_BIT_ENABLE(MEM_DISPLAY_B_TRICKLE_FEED_DISABLE));
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
void intel_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:25 +00:00
|
|
|
{
|
2016-10-31 20:37:22 +00:00
|
|
|
dev_priv->display.init_clock_gating(dev_priv);
|
2012-04-18 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:23 +00:00
|
|
|
void intel_suspend_hw(struct drm_i915_private *dev_priv)
|
2013-04-17 11:04:50 +00:00
|
|
|
{
|
2016-10-31 20:37:23 +00:00
|
|
|
if (HAS_PCH_LPT(dev_priv))
|
|
|
|
lpt_suspend_hw(dev_priv);
|
2013-04-17 11:04:50 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 20:37:22 +00:00
|
|
|
static void nop_init_clock_gating(struct drm_i915_private *dev_priv)
|
2016-03-16 11:38:54 +00:00
|
|
|
{
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"No clock gating settings or workarounds applied.\n");
|
2016-03-16 11:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* intel_init_clock_gating_hooks - setup the clock gating hooks
|
|
|
|
* @dev_priv: device private
|
|
|
|
*
|
|
|
|
* Setup the hooks that configure which clocks of a given platform can be
|
|
|
|
* gated and also apply various GT and display specific workarounds for these
|
|
|
|
* platforms. Note that some GT specific workarounds are applied separately
|
|
|
|
* when GPU contexts or batchbuffers start their execution.
|
|
|
|
*/
|
|
|
|
void intel_init_clock_gating_hooks(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
2019-08-17 09:38:42 +00:00
|
|
|
if (IS_GEN(dev_priv, 12))
|
2019-08-23 08:20:34 +00:00
|
|
|
dev_priv->display.init_clock_gating = tgl_init_clock_gating;
|
2019-08-17 09:38:42 +00:00
|
|
|
else if (IS_GEN(dev_priv, 11))
|
2018-05-08 21:29:24 +00:00
|
|
|
dev_priv->display.init_clock_gating = icl_init_clock_gating;
|
2018-05-08 21:29:23 +00:00
|
|
|
else if (IS_CANNONLAKE(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = cnl_init_clock_gating;
|
2017-08-31 04:52:23 +00:00
|
|
|
else if (IS_COFFEELAKE(dev_priv))
|
|
|
|
dev_priv->display.init_clock_gating = cfl_init_clock_gating;
|
2017-08-15 23:16:48 +00:00
|
|
|
else if (IS_SKYLAKE(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = skl_init_clock_gating;
|
2017-08-31 04:52:23 +00:00
|
|
|
else if (IS_KABYLAKE(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = kbl_init_clock_gating;
|
2017-01-26 09:16:58 +00:00
|
|
|
else if (IS_BROXTON(dev_priv))
|
2016-03-16 11:38:54 +00:00
|
|
|
dev_priv->display.init_clock_gating = bxt_init_clock_gating;
|
2017-01-26 09:16:58 +00:00
|
|
|
else if (IS_GEMINILAKE(dev_priv))
|
|
|
|
dev_priv->display.init_clock_gating = glk_init_clock_gating;
|
2016-03-16 11:38:54 +00:00
|
|
|
else if (IS_BROADWELL(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = bdw_init_clock_gating;
|
2016-03-16 11:38:54 +00:00
|
|
|
else if (IS_CHERRYVIEW(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = chv_init_clock_gating;
|
2016-03-16 11:38:54 +00:00
|
|
|
else if (IS_HASWELL(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = hsw_init_clock_gating;
|
2016-03-16 11:38:54 +00:00
|
|
|
else if (IS_IVYBRIDGE(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = ivb_init_clock_gating;
|
2016-03-16 11:38:54 +00:00
|
|
|
else if (IS_VALLEYVIEW(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = vlv_init_clock_gating;
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
else if (IS_GEN(dev_priv, 6))
|
2016-03-16 11:38:54 +00:00
|
|
|
dev_priv->display.init_clock_gating = gen6_init_clock_gating;
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
else if (IS_GEN(dev_priv, 5))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = ilk_init_clock_gating;
|
2016-03-16 11:38:54 +00:00
|
|
|
else if (IS_G4X(dev_priv))
|
|
|
|
dev_priv->display.init_clock_gating = g4x_init_clock_gating;
|
2016-12-07 10:13:04 +00:00
|
|
|
else if (IS_I965GM(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = i965gm_init_clock_gating;
|
2016-12-07 10:13:04 +00:00
|
|
|
else if (IS_I965G(dev_priv))
|
2017-08-29 05:20:26 +00:00
|
|
|
dev_priv->display.init_clock_gating = i965g_init_clock_gating;
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
else if (IS_GEN(dev_priv, 3))
|
2016-03-16 11:38:54 +00:00
|
|
|
dev_priv->display.init_clock_gating = gen3_init_clock_gating;
|
|
|
|
else if (IS_I85X(dev_priv) || IS_I865G(dev_priv))
|
|
|
|
dev_priv->display.init_clock_gating = i85x_init_clock_gating;
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
else if (IS_GEN(dev_priv, 2))
|
2016-03-16 11:38:54 +00:00
|
|
|
dev_priv->display.init_clock_gating = i830_init_clock_gating;
|
|
|
|
else {
|
|
|
|
MISSING_CASE(INTEL_DEVID(dev_priv));
|
|
|
|
dev_priv->display.init_clock_gating = nop_init_clock_gating;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-18 18:29:26 +00:00
|
|
|
/* Set up chip specific power management-related functions */
|
2016-10-31 20:37:25 +00:00
|
|
|
void intel_init_pm(struct drm_i915_private *dev_priv)
|
2012-04-18 18:29:26 +00:00
|
|
|
{
|
2012-04-26 21:28:17 +00:00
|
|
|
/* For cxsr */
|
2016-10-31 20:37:15 +00:00
|
|
|
if (IS_PINEVIEW(dev_priv))
|
2019-12-24 08:40:04 +00:00
|
|
|
pnv_get_mem_freq(dev_priv);
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
else if (IS_GEN(dev_priv, 5))
|
2019-12-24 08:40:09 +00:00
|
|
|
ilk_get_mem_freq(dev_priv);
|
2012-04-26 21:28:17 +00:00
|
|
|
|
2019-10-09 17:23:14 +00:00
|
|
|
if (intel_has_sagv(dev_priv))
|
|
|
|
skl_setup_sagv_block_time(dev_priv);
|
|
|
|
|
2012-04-18 18:29:26 +00:00
|
|
|
/* For FIFO watermark updates */
|
2016-10-31 20:37:25 +00:00
|
|
|
if (INTEL_GEN(dev_priv) >= 9) {
|
2016-10-31 20:37:24 +00:00
|
|
|
skl_setup_wm_latency(dev_priv);
|
2016-11-08 12:55:33 +00:00
|
|
|
dev_priv->display.initial_watermarks = skl_initial_wm;
|
2016-11-08 12:55:32 +00:00
|
|
|
dev_priv->display.atomic_update_watermarks = skl_atomic_update_crtc_wm;
|
2016-05-12 14:06:03 +00:00
|
|
|
dev_priv->display.compute_global_watermarks = skl_compute_wm;
|
2016-10-13 10:02:53 +00:00
|
|
|
} else if (HAS_PCH_SPLIT(dev_priv)) {
|
2016-10-31 20:37:24 +00:00
|
|
|
ilk_setup_wm_latency(dev_priv);
|
2013-08-01 13:18:50 +00:00
|
|
|
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if ((IS_GEN(dev_priv, 5) && dev_priv->wm.pri_latency[1] &&
|
2014-01-07 14:14:10 +00:00
|
|
|
dev_priv->wm.spr_latency[1] && dev_priv->wm.cur_latency[1]) ||
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
(!IS_GEN(dev_priv, 5) && dev_priv->wm.pri_latency[0] &&
|
2014-01-07 14:14:10 +00:00
|
|
|
dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) {
|
2015-09-24 22:53:16 +00:00
|
|
|
dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm;
|
drm/i915: Add two-stage ILK-style watermark programming (v11)
In addition to calculating final watermarks, let's also pre-calculate a
set of intermediate watermark values at atomic check time. These
intermediate watermarks are a combination of the watermarks for the old
state and the new state; they should satisfy the requirements of both
states which means they can be programmed immediately when we commit the
atomic state (without waiting for a vblank). Once the vblank does
happen, we can then re-program watermarks to the more optimal final
value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity
(Maarten)
- Don't due async watermark optimization; just do it at the end of the
atomic transaction, after waiting for vblanks. We do want it to be
async eventually, but adding that now will cause more trouble for
Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on
platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit
now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the
need_postvbl_update flag. Since we don't have async yet it isn't
terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose
.initial_watermarks() and .optimize_watermarks() functions to do
watermark programming. These should lock wm_mutex, copy the
appropriate state values into intel_crtc->active, and then call
the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware
readout since we don't trust the existing HW values (and don't have
valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have
atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
v8:
- A few minor indentation and line length fixes
v9:
- Yet another rebase since Maarten's patches reworked a bunch of the
code (wm_pre, wm_post, etc.) that this was previously based on.
v10:
- Move wm_mutex to dev_priv to protect against racing commits against
disjoint CRTC sets. (Maarten)
- Drop unnecessary clearing of cstate->wm.need_postvbl_update (Maarten)
v11:
- Now that we've moved to atomic watermark updates, make sure we call
the proper function to program watermarks in
{ironlake,haswell}_crtc_enable(); the failure to do so on the
previous patch iteration led to us not actually programming the
watermarks before turning on the CRTC, which was the cause of the
underruns that the CI system was seeing.
- Fix inverted logic for determining when to optimize watermarks. We
were needlessly optimizing when the intermediate/optimal values were
the same (harmless), but not actually optimizing when they differed
(also harmless, but wasteful from a power/bandwidth perspective).
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1456276813-5689-1-git-send-email-matthew.d.roper@intel.com
2016-02-24 01:20:13 +00:00
|
|
|
dev_priv->display.compute_intermediate_wm =
|
|
|
|
ilk_compute_intermediate_wm;
|
|
|
|
dev_priv->display.initial_watermarks =
|
|
|
|
ilk_initial_watermarks;
|
|
|
|
dev_priv->display.optimize_watermarks =
|
|
|
|
ilk_optimize_watermarks;
|
2014-01-07 14:14:10 +00:00
|
|
|
} else {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Failed to read display plane latency. "
|
|
|
|
"Disable CxSR\n");
|
2014-01-07 14:14:10 +00:00
|
|
|
}
|
2016-11-28 17:37:07 +00:00
|
|
|
} else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
|
2016-10-31 20:37:24 +00:00
|
|
|
vlv_setup_wm_latency(dev_priv);
|
2017-03-02 17:14:57 +00:00
|
|
|
dev_priv->display.compute_pipe_wm = vlv_compute_pipe_wm;
|
2017-03-02 17:14:59 +00:00
|
|
|
dev_priv->display.compute_intermediate_wm = vlv_compute_intermediate_wm;
|
2017-03-02 17:14:57 +00:00
|
|
|
dev_priv->display.initial_watermarks = vlv_initial_watermarks;
|
2017-03-02 17:14:59 +00:00
|
|
|
dev_priv->display.optimize_watermarks = vlv_optimize_watermarks;
|
2017-03-02 17:14:57 +00:00
|
|
|
dev_priv->display.atomic_update_watermarks = vlv_atomic_update_fifo;
|
2017-04-21 18:14:29 +00:00
|
|
|
} else if (IS_G4X(dev_priv)) {
|
|
|
|
g4x_setup_wm_latency(dev_priv);
|
|
|
|
dev_priv->display.compute_pipe_wm = g4x_compute_pipe_wm;
|
|
|
|
dev_priv->display.compute_intermediate_wm = g4x_compute_intermediate_wm;
|
|
|
|
dev_priv->display.initial_watermarks = g4x_initial_watermarks;
|
|
|
|
dev_priv->display.optimize_watermarks = g4x_optimize_watermarks;
|
2016-10-31 20:37:15 +00:00
|
|
|
} else if (IS_PINEVIEW(dev_priv)) {
|
2019-03-26 07:40:54 +00:00
|
|
|
if (!intel_get_cxsr_latency(!IS_MOBILE(dev_priv),
|
2012-04-18 18:29:26 +00:00
|
|
|
dev_priv->is_ddr3,
|
|
|
|
dev_priv->fsb_freq,
|
|
|
|
dev_priv->mem_freq)) {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_info(&dev_priv->drm,
|
|
|
|
"failed to find known CxSR latency "
|
2012-04-18 18:29:26 +00:00
|
|
|
"(found ddr%s fsb freq %d, mem freq %d), "
|
|
|
|
"disabling CxSR\n",
|
|
|
|
(dev_priv->is_ddr3 == 1) ? "3" : "2",
|
|
|
|
dev_priv->fsb_freq, dev_priv->mem_freq);
|
|
|
|
/* Disable CxSR and never update its watermark again */
|
2014-07-01 09:36:17 +00:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-18 18:29:26 +00:00
|
|
|
dev_priv->display.update_wm = NULL;
|
|
|
|
} else
|
2019-12-24 08:40:04 +00:00
|
|
|
dev_priv->display.update_wm = pnv_update_wm;
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
} else if (IS_GEN(dev_priv, 4)) {
|
2012-04-18 18:29:26 +00:00
|
|
|
dev_priv->display.update_wm = i965_update_wm;
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
} else if (IS_GEN(dev_priv, 3)) {
|
2012-04-18 18:29:26 +00:00
|
|
|
dev_priv->display.update_wm = i9xx_update_wm;
|
|
|
|
dev_priv->display.get_fifo_size = i9xx_get_fifo_size;
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
} else if (IS_GEN(dev_priv, 2)) {
|
2019-09-11 09:26:08 +00:00
|
|
|
if (INTEL_NUM_PIPES(dev_priv) == 1) {
|
2013-12-14 22:38:30 +00:00
|
|
|
dev_priv->display.update_wm = i845_update_wm;
|
2012-04-18 18:29:26 +00:00
|
|
|
dev_priv->display.get_fifo_size = i845_get_fifo_size;
|
2013-12-14 22:38:30 +00:00
|
|
|
} else {
|
|
|
|
dev_priv->display.update_wm = i9xx_update_wm;
|
2012-04-18 18:29:26 +00:00
|
|
|
dev_priv->display.get_fifo_size = i830_get_fifo_size;
|
2013-12-14 22:38:30 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-01-07 15:13:30 +00:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"unexpected fall-through in %s\n", __func__);
|
2012-04-18 18:29:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 14:16:45 +00:00
|
|
|
void intel_pm_setup(struct drm_i915_private *dev_priv)
|
2013-07-19 19:36:52 +00:00
|
|
|
{
|
2017-10-10 21:30:04 +00:00
|
|
|
dev_priv->runtime_pm.suspended = false;
|
|
|
|
atomic_set(&dev_priv->runtime_pm.wakeref_count, 0);
|
2013-07-19 19:36:52 +00:00
|
|
|
}
|