2012-04-16 22:20:34 -03: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>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2021-04-30 17:39:44 +03:00
|
|
|
#include "display/intel_de.h"
|
2021-12-08 13:05:17 +02:00
|
|
|
#include "display/intel_display_trace.h"
|
2022-09-08 22:16:45 +03:00
|
|
|
#include "display/skl_watermark.h"
|
2019-06-13 11:44:16 +03:00
|
|
|
|
2022-01-10 21:15:56 -08:00
|
|
|
#include "gt/intel_engine_regs.h"
|
2022-01-27 15:43:33 -08:00
|
|
|
#include "gt/intel_gt_regs.h"
|
2019-10-20 19:41:39 +01:00
|
|
|
|
2012-04-16 22:20:34 -03:00
|
|
|
#include "i915_drv.h"
|
2022-02-14 22:13:42 -08:00
|
|
|
#include "intel_mchbar_regs.h"
|
2019-04-05 14:00:15 +03:00
|
|
|
#include "intel_pm.h"
|
2021-10-13 13:11:59 +03:00
|
|
|
#include "vlv_sideband.h"
|
2022-03-09 18:49:43 +02:00
|
|
|
|
2022-02-03 16:02:33 +02:00
|
|
|
struct drm_i915_clock_gating_funcs {
|
|
|
|
|
void (*init_clock_gating)(struct drm_i915_private *i915);
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-27 19:00:47 +02:00
|
|
|
/* used in computing the new watermarks state */
|
|
|
|
|
struct intel_wm_config {
|
|
|
|
|
unsigned int num_pipes_active;
|
|
|
|
|
bool sprites_enabled;
|
|
|
|
|
bool sprites_scaled;
|
|
|
|
|
};
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
static void gen9_init_clock_gating(struct drm_i915_private *dev_priv)
|
2015-03-27 14:00:04 +02:00
|
|
|
{
|
2017-08-24 22:10:51 +03:00
|
|
|
if (HAS_LLC(dev_priv)) {
|
|
|
|
|
/*
|
|
|
|
|
* WaCompressedResourceDisplayNewHashMode:skl,kbl
|
2017-12-05 11:01:17 -08:00
|
|
|
* Display WA #0390: skl,kbl
|
2017-08-24 22:10:51 +03:00
|
|
|
*
|
|
|
|
|
* Must match Sampler, Pixel Back End, and Media. See
|
|
|
|
|
* WaCompressedResourceSamplerPbeMediaNewHashMode.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, CHICKEN_PAR1_1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, CHICKEN_PAR1_1) |
|
2017-08-24 22:10:51 +03:00
|
|
|
SKL_DE_COMPRESSED_HASH_MODE);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-08 08:50:00 -07:00
|
|
|
/* See Bspec note for PSR2_CTL bit 31, Wa#828:skl,bxt,kbl,cfl */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, CHICKEN_PAR1_1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, CHICKEN_PAR1_1) | SKL_EDP_PSR_FIX_RDWRAP);
|
2016-05-19 09:14:20 +02:00
|
|
|
|
2017-06-08 08:50:00 -07:00
|
|
|
/* WaEnableChickenDCPR:skl,bxt,kbl,glk,cfl */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN8_CHICKEN_DCPR_1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN8_CHICKEN_DCPR_1) | MASK_WAKEMEM);
|
2016-06-07 17:19:16 +03:00
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcWakeMemOn:skl,bxt,kbl,glk,cfl
|
|
|
|
|
* Display WA #0859: skl,bxt,kbl,glk,cfl
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL, intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL) |
|
2016-06-07 17:19:17 +03:00
|
|
|
DISP_FBC_MEMORY_WAKE);
|
2016-06-07 17:19:04 +03:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
static void bxt_init_clock_gating(struct drm_i915_private *dev_priv)
|
2016-06-07 17:19:04 +03:00
|
|
|
{
|
2016-10-31 22:37:22 +02:00
|
|
|
gen9_init_clock_gating(dev_priv);
|
2016-06-07 17:19:04 +03:00
|
|
|
|
2015-06-29 14:07:32 +01:00
|
|
|
/* WaDisableSDEUnitClockGating:bxt */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN8_UCGCTL6, intel_uncore_read(&dev_priv->uncore, GEN8_UCGCTL6) |
|
2015-06-29 14:07:32 +01:00
|
|
|
GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
|
|
|
|
|
|
2015-03-11 11:10:27 +02:00
|
|
|
/*
|
|
|
|
|
* FIXME:
|
2015-03-11 10:49:32 +02:00
|
|
|
* GEN8_HDCUNIT_CLOCK_GATE_DISABLE_HDCREQ applies on 3x6 GT SKUs only.
|
2015-03-11 11:10:27 +02:00
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN8_UCGCTL6, intel_uncore_read(&dev_priv->uncore, GEN8_UCGCTL6) |
|
2015-03-11 10:49:32 +02:00
|
|
|
GEN8_HDCUNIT_CLOCK_GATE_DISABLE_HDCREQ);
|
2015-12-01 10:23:52 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Wa: Backlight PWM may stop in the asserted state, causing backlight
|
|
|
|
|
* to stay fully on.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN9_CLKGATE_DIS_0, intel_uncore_read(&dev_priv->uncore, GEN9_CLKGATE_DIS_0) |
|
2017-02-15 17:21:37 +02:00
|
|
|
PWM1_GATING_DIS | PWM2_GATING_DIS);
|
2018-08-07 21:15:35 +05:30
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, RM_TIMEOUT, MMIO_TIMEOUT_US(950));
|
2020-07-08 16:12:21 +03:00
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcTurnOffFbcWatermark:bxt
|
|
|
|
|
* Display WA #0562: bxt
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL, intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL) |
|
2020-07-08 16:12:21 +03:00
|
|
|
DISP_FBC_WM_DIS);
|
2020-07-08 16:12:22 +03:00
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcHighMemBwCorruptionAvoidance:bxt
|
|
|
|
|
* Display WA #0883: bxt
|
|
|
|
|
*/
|
2021-12-14 20:46:16 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A)) |
|
|
|
|
|
DPFC_DISABLE_DUMMY0);
|
2015-03-27 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
2017-01-26 11:16:58 +02: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.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN9_CLKGATE_DIS_0, intel_uncore_read(&dev_priv->uncore, GEN9_CLKGATE_DIS_0) |
|
2017-01-26 11:16:58 +02:00
|
|
|
PWM1_GATING_DIS | PWM2_GATING_DIS);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-24 00:40:04 -08:00
|
|
|
static void pnv_get_mem_freq(struct drm_i915_private *dev_priv)
|
2012-04-26 23:28:17 +02:00
|
|
|
{
|
|
|
|
|
u32 tmp;
|
|
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, CLKCFG);
|
2012-04-26 23:28:17 +02:00
|
|
|
|
|
|
|
|
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 */
|
2020-11-30 13:15:58 +02:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, CSHRDDR3CTL);
|
2012-04-26 23:28:17 +02:00
|
|
|
dev_priv->is_ddr3 = (tmp & CSHRDDR3CTL_DDR3) ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-24 00:40:09 -08:00
|
|
|
static void ilk_get_mem_freq(struct drm_i915_private *dev_priv)
|
2012-04-26 23:28:17 +02:00
|
|
|
{
|
|
|
|
|
u16 ddrpll, csipll;
|
|
|
|
|
|
2019-06-11 11:45:48 +01:00
|
|
|
ddrpll = intel_uncore_read16(&dev_priv->uncore, DDRMPLL1);
|
|
|
|
|
csipll = intel_uncore_read16(&dev_priv->uncore, CSIPLL0);
|
2012-04-26 23:28:17 +02: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 18:13:30 +03:00
|
|
|
drm_dbg(&dev_priv->drm, "unknown memory frequency 0x%02x\n",
|
|
|
|
|
ddrpll & 0xff);
|
2012-04-26 23:28:17 +02: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 18:13:30 +03:00
|
|
|
drm_dbg(&dev_priv->drm, "unknown fsb frequency 0x%04x\n",
|
|
|
|
|
csipll & 0x3ff);
|
2012-04-26 23:28:17 +02:00
|
|
|
dev_priv->fsb_freq = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-16 22:20:35 -03: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 11:09:23 +01:00
|
|
|
static const struct cxsr_latency *intel_get_cxsr_latency(bool is_desktop,
|
|
|
|
|
bool is_ddr3,
|
2012-04-16 22:20:35 -03: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 21:19:52 +02:00
|
|
|
static void chv_set_memory_dvfs(struct drm_i915_private *dev_priv, bool enable)
|
|
|
|
|
{
|
|
|
|
|
u32 val;
|
|
|
|
|
|
2019-04-26 09:17:20 +01:00
|
|
|
vlv_punit_get(dev_priv);
|
2015-03-05 21:19:52 +02: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 18:13:30 +03:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
|
"timed out waiting for Punit DDR DVFS request\n");
|
2015-03-05 21:19:52 +02:00
|
|
|
|
2019-04-26 09:17:20 +01:00
|
|
|
vlv_punit_put(dev_priv);
|
2015-03-05 21:19:52 +02:00
|
|
|
}
|
|
|
|
|
|
2015-03-05 21:19:51 +02:00
|
|
|
static void chv_set_memory_pm5(struct drm_i915_private *dev_priv, bool enable)
|
|
|
|
|
{
|
|
|
|
|
u32 val;
|
|
|
|
|
|
2019-04-26 09:17:20 +01:00
|
|
|
vlv_punit_get(dev_priv);
|
2015-03-05 21:19:51 +02:00
|
|
|
|
2018-11-29 19:55:03 +02:00
|
|
|
val = vlv_punit_read(dev_priv, PUNIT_REG_DSPSSPM);
|
2015-03-05 21:19:51 +02:00
|
|
|
if (enable)
|
|
|
|
|
val |= DSP_MAXFIFO_PM5_ENABLE;
|
|
|
|
|
else
|
|
|
|
|
val &= ~DSP_MAXFIFO_PM5_ENABLE;
|
2018-11-29 19:55:03 +02:00
|
|
|
vlv_punit_write(dev_priv, PUNIT_REG_DSPSSPM, val);
|
2015-03-05 21:19:51 +02:00
|
|
|
|
2019-04-26 09:17:20 +01:00
|
|
|
vlv_punit_put(dev_priv);
|
2015-03-05 21:19:51 +02:00
|
|
|
}
|
|
|
|
|
|
2015-03-10 17:02:21 +02:00
|
|
|
#define FW_WM(value, plane) \
|
|
|
|
|
(((value) << DSPFW_ ## plane ## _SHIFT) & DSPFW_ ## plane ## _MASK)
|
|
|
|
|
|
2016-11-28 19:37:12 +02:00
|
|
|
static bool _intel_set_memory_cxsr(struct drm_i915_private *dev_priv, bool enable)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2016-11-28 19:37:12 +02:00
|
|
|
bool was_enabled;
|
2014-07-01 12:36:17 +03:00
|
|
|
u32 val;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2016-10-14 10:13:44 +01:00
|
|
|
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
|
2020-11-30 13:15:58 +02:00
|
|
|
was_enabled = intel_uncore_read(&dev_priv->uncore, FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, FW_BLC_SELF_VLV, enable ? FW_CSPWRDWNEN : 0);
|
|
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, FW_BLC_SELF_VLV);
|
2016-12-07 12:13:04 +02:00
|
|
|
} else if (IS_G4X(dev_priv) || IS_I965GM(dev_priv)) {
|
2020-11-30 13:15:58 +02:00
|
|
|
was_enabled = intel_uncore_read(&dev_priv->uncore, FW_BLC_SELF) & FW_BLC_SELF_EN;
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, FW_BLC_SELF, enable ? FW_BLC_SELF_EN : 0);
|
|
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, FW_BLC_SELF);
|
2016-10-31 22:37:15 +02:00
|
|
|
} else if (IS_PINEVIEW(dev_priv)) {
|
2020-11-30 13:15:58 +02:00
|
|
|
val = intel_uncore_read(&dev_priv->uncore, DSPFW3);
|
2016-11-28 19:37:12 +02:00
|
|
|
was_enabled = val & PINEVIEW_SELF_REFRESH_EN;
|
|
|
|
|
if (enable)
|
|
|
|
|
val |= PINEVIEW_SELF_REFRESH_EN;
|
|
|
|
|
else
|
|
|
|
|
val &= ~PINEVIEW_SELF_REFRESH_EN;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW3, val);
|
|
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, DSPFW3);
|
2016-10-13 11:02:58 +01:00
|
|
|
} else if (IS_I945G(dev_priv) || IS_I945GM(dev_priv)) {
|
2020-11-30 13:15:58 +02:00
|
|
|
was_enabled = intel_uncore_read(&dev_priv->uncore, FW_BLC_SELF) & FW_BLC_SELF_EN;
|
2014-07-01 12:36:17 +03:00
|
|
|
val = enable ? _MASKED_BIT_ENABLE(FW_BLC_SELF_EN) :
|
|
|
|
|
_MASKED_BIT_DISABLE(FW_BLC_SELF_EN);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, FW_BLC_SELF, val);
|
|
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, FW_BLC_SELF);
|
2016-10-13 11:02:58 +01:00
|
|
|
} else if (IS_I915GM(dev_priv)) {
|
2016-07-29 17:57:02 +03: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?
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
was_enabled = intel_uncore_read(&dev_priv->uncore, INSTPM) & INSTPM_SELF_EN;
|
2014-07-01 12:36:17 +03:00
|
|
|
val = enable ? _MASKED_BIT_ENABLE(INSTPM_SELF_EN) :
|
|
|
|
|
_MASKED_BIT_DISABLE(INSTPM_SELF_EN);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, INSTPM, val);
|
|
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, INSTPM);
|
2014-07-01 12:36:17 +03:00
|
|
|
} else {
|
2016-11-28 19:37:12 +02:00
|
|
|
return false;
|
2014-07-01 12:36:17 +03:00
|
|
|
}
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2017-03-02 19:15:07 +02:00
|
|
|
trace_intel_memory_cxsr(dev_priv, was_enabled, enable);
|
|
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "memory self-refresh is %s (was %s)\n",
|
2022-02-25 15:46:30 -08:00
|
|
|
str_enabled_disabled(enable),
|
|
|
|
|
str_enabled_disabled(was_enabled));
|
2016-11-28 19:37:12 +02:00
|
|
|
|
|
|
|
|
return was_enabled;
|
2012-04-16 22:20:35 -03:00
|
|
|
}
|
|
|
|
|
|
2017-04-21 21:14:23 +03: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 19:37:12 +02:00
|
|
|
bool intel_set_memory_cxsr(struct drm_i915_private *dev_priv, bool enable)
|
2016-11-28 19:37:11 +02:00
|
|
|
{
|
2016-11-28 19:37:12 +02:00
|
|
|
bool ret;
|
|
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
2016-11-28 19:37:12 +02:00
|
|
|
ret = _intel_set_memory_cxsr(dev_priv, enable);
|
2017-04-21 21:14:29 +03:00
|
|
|
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.vlv.cxsr = enable;
|
2017-04-21 21:14:29 +03:00
|
|
|
else if (IS_G4X(dev_priv))
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.g4x.cxsr = enable;
|
|
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2016-11-28 19:37:12 +02:00
|
|
|
|
|
|
|
|
return ret;
|
2016-11-28 19:37:11 +02:00
|
|
|
}
|
2015-03-05 21:19:52 +02:00
|
|
|
|
2012-04-16 22:20:35 -03: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 11:56:07 +01:00
|
|
|
static const int pessimal_latency_ns = 5000;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2015-03-05 21:19:47 +02:00
|
|
|
#define VLV_FIFO_START(dsparb, dsparb2, lo_shift, hi_shift) \
|
|
|
|
|
((((dsparb) >> (lo_shift)) & 0xff) | ((((dsparb2) >> (hi_shift)) & 0x1) << 8))
|
|
|
|
|
|
2017-03-02 19:14:55 +02:00
|
|
|
static void vlv_get_fifo_size(struct intel_crtc_state *crtc_state)
|
2015-03-05 21:19:47 +02:00
|
|
|
{
|
2019-10-31 12:26:03 +01:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2017-03-02 19:14:52 +02:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2017-03-02 19:14:55 +02:00
|
|
|
struct vlv_fifo_state *fifo_state = &crtc_state->wm.vlv.fifo_state;
|
2017-03-02 19:14:52 +02:00
|
|
|
enum pipe pipe = crtc->pipe;
|
|
|
|
|
int sprite0_start, sprite1_start;
|
2020-02-20 16:05:17 -08:00
|
|
|
u32 dsparb, dsparb2, dsparb3;
|
2016-11-22 18:02:01 +02:00
|
|
|
|
2017-03-02 19:14:52 +02:00
|
|
|
switch (pipe) {
|
2015-03-05 21:19:47 +02:00
|
|
|
case PIPE_A:
|
2020-11-30 13:15:58 +02:00
|
|
|
dsparb = intel_uncore_read(&dev_priv->uncore, DSPARB);
|
|
|
|
|
dsparb2 = intel_uncore_read(&dev_priv->uncore, DSPARB2);
|
2015-03-05 21:19:47 +02:00
|
|
|
sprite0_start = VLV_FIFO_START(dsparb, dsparb2, 0, 0);
|
|
|
|
|
sprite1_start = VLV_FIFO_START(dsparb, dsparb2, 8, 4);
|
|
|
|
|
break;
|
|
|
|
|
case PIPE_B:
|
2020-11-30 13:15:58 +02:00
|
|
|
dsparb = intel_uncore_read(&dev_priv->uncore, DSPARB);
|
|
|
|
|
dsparb2 = intel_uncore_read(&dev_priv->uncore, DSPARB2);
|
2015-03-05 21:19:47 +02:00
|
|
|
sprite0_start = VLV_FIFO_START(dsparb, dsparb2, 16, 8);
|
|
|
|
|
sprite1_start = VLV_FIFO_START(dsparb, dsparb2, 24, 12);
|
|
|
|
|
break;
|
|
|
|
|
case PIPE_C:
|
2020-11-30 13:15:58 +02:00
|
|
|
dsparb2 = intel_uncore_read(&dev_priv->uncore, DSPARB2);
|
|
|
|
|
dsparb3 = intel_uncore_read(&dev_priv->uncore, DSPARB3);
|
2015-03-05 21:19:47 +02:00
|
|
|
sprite0_start = VLV_FIFO_START(dsparb3, dsparb2, 0, 16);
|
|
|
|
|
sprite1_start = VLV_FIFO_START(dsparb3, dsparb2, 8, 20);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2017-03-02 19:14:52 +02:00
|
|
|
MISSING_CASE(pipe);
|
|
|
|
|
return;
|
2015-03-05 21:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:14:52 +02: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 21:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-17 21:19:11 +02:00
|
|
|
static int i9xx_get_fifo_size(struct drm_i915_private *dev_priv,
|
|
|
|
|
enum i9xx_plane_id i9xx_plane)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2020-11-30 13:15:58 +02:00
|
|
|
u32 dsparb = intel_uncore_read(&dev_priv->uncore, DSPARB);
|
2012-04-16 22:20:35 -03:00
|
|
|
int size;
|
|
|
|
|
|
|
|
|
|
size = dsparb & 0x7f;
|
2017-11-17 21:19:11 +02:00
|
|
|
if (i9xx_plane == PLANE_B)
|
2012-04-16 22:20:35 -03:00
|
|
|
size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) - size;
|
|
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "FIFO size - (0x%08x) %c: %d\n",
|
|
|
|
|
dsparb, plane_name(i9xx_plane), size);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-17 21:19:11 +02:00
|
|
|
static int i830_get_fifo_size(struct drm_i915_private *dev_priv,
|
|
|
|
|
enum i9xx_plane_id i9xx_plane)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2020-11-30 13:15:58 +02:00
|
|
|
u32 dsparb = intel_uncore_read(&dev_priv->uncore, DSPARB);
|
2012-04-16 22:20:35 -03:00
|
|
|
int size;
|
|
|
|
|
|
|
|
|
|
size = dsparb & 0x1ff;
|
2017-11-17 21:19:11 +02:00
|
|
|
if (i9xx_plane == PLANE_B)
|
2012-04-16 22:20:35 -03:00
|
|
|
size = ((dsparb >> DSPARB_BEND_SHIFT) & 0x1ff) - size;
|
|
|
|
|
size >>= 1; /* Convert to cachelines */
|
|
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "FIFO size - (0x%08x) %c: %d\n",
|
|
|
|
|
dsparb, plane_name(i9xx_plane), size);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-17 21:19:11 +02:00
|
|
|
static int i845_get_fifo_size(struct drm_i915_private *dev_priv,
|
|
|
|
|
enum i9xx_plane_id i9xx_plane)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2020-11-30 13:15:58 +02:00
|
|
|
u32 dsparb = intel_uncore_read(&dev_priv->uncore, DSPARB);
|
2012-04-16 22:20:35 -03:00
|
|
|
int size;
|
|
|
|
|
|
|
|
|
|
size = dsparb & 0x7f;
|
|
|
|
|
size >>= 2; /* Convert to cachelines */
|
|
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "FIFO size - (0x%08x) %c: %d\n",
|
|
|
|
|
dsparb, plane_name(i9xx_plane), size);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pineview has different values for various configs */
|
2019-12-24 00:40:04 -08:00
|
|
|
static const struct intel_watermark_params pnv_display_wm = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
2019-12-24 00:40:04 -08:00
|
|
|
|
|
|
|
|
static const struct intel_watermark_params pnv_display_hplloff_wm = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
2019-12-24 00:40:04 -08:00
|
|
|
|
|
|
|
|
static const struct intel_watermark_params pnv_cursor_wm = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
2019-12-24 00:40:04 -08:00
|
|
|
|
|
|
|
|
static const struct intel_watermark_params pnv_cursor_hplloff_wm = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
2019-12-24 00:40:04 -08:00
|
|
|
|
2012-04-16 22:20:35 -03:00
|
|
|
static const struct intel_watermark_params i965_cursor_wm_info = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
2019-12-24 00:40:04 -08:00
|
|
|
|
2012-04-16 22:20:35 -03:00
|
|
|
static const struct intel_watermark_params i945_wm_info = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
2019-12-24 00:40:04 -08:00
|
|
|
|
2012-04-16 22:20:35 -03:00
|
|
|
static const struct intel_watermark_params i915_wm_info = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
2019-12-24 00:40:04 -08:00
|
|
|
|
2014-08-15 01:21:53 +03:00
|
|
|
static const struct intel_watermark_params i830_a_wm_info = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
2019-12-24 00:40:04 -08:00
|
|
|
|
2014-08-15 01:21:53 +03: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 00:40:04 -08:00
|
|
|
|
2013-12-14 20:38:30 -02:00
|
|
|
static const struct intel_watermark_params i845_wm_info = {
|
2014-06-05 19:15:50 +03: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-16 22:20:35 -03:00
|
|
|
};
|
|
|
|
|
|
2017-04-21 21:14:27 +03: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 14:01:20 +02:00
|
|
|
u64 ret;
|
2017-04-21 21:14:27 +03:00
|
|
|
|
2019-04-08 18:27:01 +03:00
|
|
|
ret = mul_u32_u32(pixel_rate, cpp * latency);
|
2017-04-21 21:14:27 +03: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-16 22:20:35 -03:00
|
|
|
/**
|
|
|
|
|
* intel_calculate_wm - calculate watermark level
|
2017-04-21 21:14:27 +03:00
|
|
|
* @pixel_rate: pixel clock
|
2012-04-16 22:20:35 -03:00
|
|
|
* @wm: chip FIFO params
|
2018-02-14 14:03:03 +00:00
|
|
|
* @fifo_size: size of the FIFO buffer
|
2016-01-20 21:05:26 +02:00
|
|
|
* @cpp: bytes per pixel
|
2012-04-16 22:20:35 -03: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 21:14:27 +03: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-16 22:20:35 -03:00
|
|
|
{
|
2017-04-21 21:14:27 +03:00
|
|
|
int entries, wm_size;
|
2012-04-16 22:20:35 -03: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 21:14:27 +03: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-16 22:20:35 -03:00
|
|
|
|
2017-04-21 21:14:27 +03:00
|
|
|
wm_size = fifo_size - entries;
|
|
|
|
|
DRM_DEBUG_KMS("FIFO watermark level: %d\n", wm_size);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
/* Don't promote wm_size to unsigned... */
|
2017-04-21 21:14:27 +03:00
|
|
|
if (wm_size > wm->max_wm)
|
2012-04-16 22:20:35 -03:00
|
|
|
wm_size = wm->max_wm;
|
|
|
|
|
if (wm_size <= 0)
|
|
|
|
|
wm_size = wm->default_wm;
|
2014-09-05 21:54:13 +03: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-16 22:20:35 -03:00
|
|
|
return wm_size;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 21:14:29 +03: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 21:14:20 +03:00
|
|
|
static int intel_wm_num_levels(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
return dev_priv->display.wm.max_level + 1;
|
2017-04-21 21:14:20 +03:00
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
bool intel_wm_plane_visible(const struct intel_crtc_state *crtc_state,
|
|
|
|
|
const struct intel_plane_state *plane_state)
|
2017-03-14 17:10:49 +02:00
|
|
|
{
|
2019-10-31 12:26:08 +01:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2017-03-14 17:10:49 +02:00
|
|
|
|
|
|
|
|
/* FIXME check the 'enable' instead */
|
2019-10-31 12:26:02 +01:00
|
|
|
if (!crtc_state->hw.active)
|
2017-03-14 17:10:49 +02: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 12:26:07 +01:00
|
|
|
return plane_state->hw.fb != NULL;
|
2017-03-14 17:10:49 +02:00
|
|
|
else
|
2019-10-31 12:26:08 +01:00
|
|
|
return plane_state->uapi.visible;
|
2017-03-14 17:10:49 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-27 22:12:11 +02: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.
|
|
|
|
|
*/
|
2021-12-17 08:02:55 -08:00
|
|
|
return crtc && crtc->active && crtc->base.primary->state->fb &&
|
2019-11-27 22:12:11 +02:00
|
|
|
crtc->config->hw.adjusted_mode.crtc_clock;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:21 +02:00
|
|
|
static struct intel_crtc *single_enabled_crtc(struct drm_i915_private *dev_priv)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2016-10-31 22:37:04 +02:00
|
|
|
struct intel_crtc *crtc, *enabled = NULL;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2016-10-31 22:37:21 +02:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2016-10-31 22:37:04 +02:00
|
|
|
if (intel_crtc_active(crtc)) {
|
2012-04-16 22:20:35 -03:00
|
|
|
if (enabled)
|
|
|
|
|
return NULL;
|
|
|
|
|
enabled = crtc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return enabled;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 01:57:47 +03:00
|
|
|
static void pnv_update_wm(struct drm_i915_private *dev_priv)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2016-10-31 22:37:04 +02:00
|
|
|
struct intel_crtc *crtc;
|
2012-04-16 22:20:35 -03:00
|
|
|
const struct cxsr_latency *latency;
|
|
|
|
|
u32 reg;
|
2017-04-21 21:14:27 +03:00
|
|
|
unsigned int wm;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2019-03-26 07:40:54 +00:00
|
|
|
latency = intel_get_cxsr_latency(!IS_MOBILE(dev_priv),
|
2016-10-13 11:02:58 +01:00
|
|
|
dev_priv->is_ddr3,
|
|
|
|
|
dev_priv->fsb_freq,
|
|
|
|
|
dev_priv->mem_freq);
|
2012-04-16 22:20:35 -03:00
|
|
|
if (!latency) {
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"Unknown FSB/MEM found, disable CxSR\n");
|
2014-07-01 12:36:17 +03:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-16 22:20:35 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:21 +02:00
|
|
|
crtc = single_enabled_crtc(dev_priv);
|
2012-04-16 22:20:35 -03:00
|
|
|
if (crtc) {
|
2016-10-31 22:37:04 +02:00
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
|
crtc->base.primary->state->fb;
|
2021-12-09 16:43:09 +02:00
|
|
|
int pixel_rate = crtc->config->pixel_rate;
|
2016-12-14 23:30:57 +02:00
|
|
|
int cpp = fb->format->cpp[0];
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
/* Display SR */
|
2021-12-09 16:43:09 +02:00
|
|
|
wm = intel_calculate_wm(pixel_rate, &pnv_display_wm,
|
2019-12-24 00:40:04 -08:00
|
|
|
pnv_display_wm.fifo_size,
|
2016-01-20 21:05:26 +02:00
|
|
|
cpp, latency->display_sr);
|
2020-11-30 13:15:58 +02:00
|
|
|
reg = intel_uncore_read(&dev_priv->uncore, DSPFW1);
|
2012-04-16 22:20:35 -03:00
|
|
|
reg &= ~DSPFW_SR_MASK;
|
2015-03-10 17:02:21 +02:00
|
|
|
reg |= FW_WM(wm, SR);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW1, reg);
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "DSPFW1 register is %x\n", reg);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
/* cursor SR */
|
2021-12-09 16:43:09 +02:00
|
|
|
wm = intel_calculate_wm(pixel_rate, &pnv_cursor_wm,
|
2019-12-24 00:40:04 -08:00
|
|
|
pnv_display_wm.fifo_size,
|
2017-04-21 21:14:24 +03:00
|
|
|
4, latency->cursor_sr);
|
2020-11-30 13:15:58 +02:00
|
|
|
reg = intel_uncore_read(&dev_priv->uncore, DSPFW3);
|
2012-04-16 22:20:35 -03:00
|
|
|
reg &= ~DSPFW_CURSOR_SR_MASK;
|
2015-03-10 17:02:21 +02:00
|
|
|
reg |= FW_WM(wm, CURSOR_SR);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW3, reg);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
/* Display HPLL off SR */
|
2021-12-09 16:43:09 +02:00
|
|
|
wm = intel_calculate_wm(pixel_rate, &pnv_display_hplloff_wm,
|
2019-12-24 00:40:04 -08:00
|
|
|
pnv_display_hplloff_wm.fifo_size,
|
2016-01-20 21:05:26 +02:00
|
|
|
cpp, latency->display_hpll_disable);
|
2020-11-30 13:15:58 +02:00
|
|
|
reg = intel_uncore_read(&dev_priv->uncore, DSPFW3);
|
2012-04-16 22:20:35 -03:00
|
|
|
reg &= ~DSPFW_HPLL_SR_MASK;
|
2015-03-10 17:02:21 +02:00
|
|
|
reg |= FW_WM(wm, HPLL_SR);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW3, reg);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
/* cursor HPLL off SR */
|
2021-12-09 16:43:09 +02:00
|
|
|
wm = intel_calculate_wm(pixel_rate, &pnv_cursor_hplloff_wm,
|
2019-12-24 00:40:04 -08:00
|
|
|
pnv_display_hplloff_wm.fifo_size,
|
2017-04-21 21:14:24 +03:00
|
|
|
4, latency->cursor_hpll_disable);
|
2020-11-30 13:15:58 +02:00
|
|
|
reg = intel_uncore_read(&dev_priv->uncore, DSPFW3);
|
2012-04-16 22:20:35 -03:00
|
|
|
reg &= ~DSPFW_HPLL_CURSOR_MASK;
|
2015-03-10 17:02:21 +02:00
|
|
|
reg |= FW_WM(wm, HPLL_CURSOR);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW3, reg);
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "DSPFW3 register is %x\n", reg);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2014-07-01 12:36:17 +03:00
|
|
|
intel_set_memory_cxsr(dev_priv, true);
|
2012-04-16 22:20:35 -03:00
|
|
|
} else {
|
2014-07-01 12:36:17 +03:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-16 22:20:35 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 21:14:26 +03: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 21:14:26 +03:00
|
|
|
{
|
|
|
|
|
int tlb_miss = fifo_size * 64 - width * cpp * 8;
|
|
|
|
|
|
|
|
|
|
return max(0, tlb_miss);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 21:14:29 +03:00
|
|
|
static void g4x_write_wm_values(struct drm_i915_private *dev_priv,
|
|
|
|
|
const struct g4x_wm_values *wm)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2017-04-21 21:14:31 +03:00
|
|
|
enum pipe pipe;
|
|
|
|
|
|
|
|
|
|
for_each_pipe(dev_priv, pipe)
|
2021-12-01 15:57:04 +02:00
|
|
|
trace_g4x_wm(intel_crtc_for_pipe(dev_priv, pipe), wm);
|
2017-04-21 21:14:31 +03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW1,
|
2017-04-21 21:14:29 +03:00
|
|
|
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));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW2,
|
2017-04-21 21:14:29 +03:00
|
|
|
(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));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW3,
|
2017-04-21 21:14:29 +03:00
|
|
|
(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-16 22:20:35 -03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, DSPFW1);
|
2012-04-16 22:20:35 -03:00
|
|
|
}
|
|
|
|
|
|
2015-03-10 16:16:28 +02:00
|
|
|
#define FW_WM_VLV(value, plane) \
|
|
|
|
|
(((value) << DSPFW_ ## plane ## _SHIFT) & DSPFW_ ## plane ## _MASK_VLV)
|
|
|
|
|
|
2016-11-28 19:37:15 +02:00
|
|
|
static void vlv_write_wm_values(struct drm_i915_private *dev_priv,
|
2015-03-05 21:19:45 +02:00
|
|
|
const struct vlv_wm_values *wm)
|
|
|
|
|
{
|
2016-11-28 19:37:15 +02:00
|
|
|
enum pipe pipe;
|
|
|
|
|
|
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2021-12-01 15:57:04 +02:00
|
|
|
trace_vlv_wm(intel_crtc_for_pipe(dev_priv, pipe), wm);
|
2017-03-02 19:15:06 +02:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, VLV_DDL(pipe),
|
2016-11-28 19:37:15 +02:00
|
|
|
(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 21:19:45 +02:00
|
|
|
|
2016-11-28 19:37:14 +02: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.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPHOWM, 0);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPHOWM1, 0);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW4, 0);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW5, 0);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW6, 0);
|
2016-11-28 19:37:14 +02:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW1,
|
2015-03-10 16:16:28 +02:00
|
|
|
FW_WM(wm->sr.plane, SR) |
|
2016-11-28 19:37:08 +02: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));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW2,
|
2016-11-28 19:37:08 +02: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));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW3,
|
2015-03-10 16:16:28 +02:00
|
|
|
FW_WM(wm->sr.cursor, CURSOR_SR));
|
2015-03-05 21:19:49 +02:00
|
|
|
|
|
|
|
|
if (IS_CHERRYVIEW(dev_priv)) {
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW7_CHV,
|
2016-11-28 19:37:08 +02:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_SPRITE1], SPRITED) |
|
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_SPRITE0], SPRITEC));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW8_CHV,
|
2016-11-28 19:37:08 +02:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_C].plane[PLANE_SPRITE1], SPRITEF) |
|
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_C].plane[PLANE_SPRITE0], SPRITEE));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW9_CHV,
|
2016-11-28 19:37:08 +02:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_C].plane[PLANE_PRIMARY], PLANEC) |
|
|
|
|
|
FW_WM(wm->pipe[PIPE_C].plane[PLANE_CURSOR], CURSORC));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPHOWM,
|
2015-03-10 16:16:28 +02:00
|
|
|
FW_WM(wm->sr.plane >> 9, SR_HI) |
|
2016-11-28 19:37:08 +02: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 21:19:49 +02:00
|
|
|
} else {
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW7,
|
2016-11-28 19:37:08 +02:00
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_SPRITE1], SPRITED) |
|
|
|
|
|
FW_WM_VLV(wm->pipe[PIPE_B].plane[PLANE_SPRITE0], SPRITEC));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPHOWM,
|
2015-03-10 16:16:28 +02:00
|
|
|
FW_WM(wm->sr.plane >> 9, SR_HI) |
|
2016-11-28 19:37:08 +02: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 21:19:49 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, DSPFW1);
|
2015-03-05 21:19:45 +02:00
|
|
|
}
|
|
|
|
|
|
2015-03-10 16:16:28 +02:00
|
|
|
#undef FW_WM_VLV
|
|
|
|
|
|
2017-04-21 21:14:29 +03:00
|
|
|
static void g4x_setup_wm_latency(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
|
|
|
|
/* all latencies in usec */
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.pri_latency[G4X_WM_LEVEL_NORMAL] = 5;
|
|
|
|
|
dev_priv->display.wm.pri_latency[G4X_WM_LEVEL_SR] = 12;
|
|
|
|
|
dev_priv->display.wm.pri_latency[G4X_WM_LEVEL_HPLL] = 35;
|
2017-04-21 21:14:29 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.max_level = G4X_WM_LEVEL_HPLL;
|
2017-04-21 21:14:29 +03: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 14:01:20 +02: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 21:14:29 +03:00
|
|
|
{
|
2019-10-31 12:26:08 +01:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2017-04-21 21:14:29 +03:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
|
2020-11-12 21:17:18 +02:00
|
|
|
const struct drm_display_mode *pipe_mode =
|
|
|
|
|
&crtc_state->hw.pipe_mode;
|
2022-08-24 16:15:40 +03:00
|
|
|
unsigned int latency = dev_priv->display.wm.pri_latency[level] * 10;
|
2021-12-09 16:43:09 +02:00
|
|
|
unsigned int pixel_rate, htotal, cpp, width, wm;
|
2017-04-21 21:14:29 +03:00
|
|
|
|
|
|
|
|
if (latency == 0)
|
|
|
|
|
return USHRT_MAX;
|
|
|
|
|
|
|
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2019-10-31 12:26:07 +01:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2019-07-03 23:08:22 +03:00
|
|
|
|
2017-04-21 21:14:29 +03:00
|
|
|
/*
|
2021-05-14 15:57:41 +03:00
|
|
|
* WaUse32BppForSRWM:ctg,elk
|
2017-04-21 21:14:29 +03:00
|
|
|
*
|
2021-05-14 15:57:41 +03:00
|
|
|
* The spec fails to list this restriction for the
|
|
|
|
|
* HPLL watermark, which seems a little strange.
|
2017-04-21 21:14:29 +03:00
|
|
|
* Let's use 32bpp for the HPLL watermark as well.
|
|
|
|
|
*/
|
2021-05-14 15:57:41 +03:00
|
|
|
if (plane->id == PLANE_PRIMARY &&
|
2017-04-21 21:14:29 +03:00
|
|
|
level != G4X_WM_LEVEL_NORMAL)
|
2019-07-03 23:08:22 +03:00
|
|
|
cpp = max(cpp, 4u);
|
2017-04-21 21:14:29 +03:00
|
|
|
|
2021-12-09 16:43:09 +02:00
|
|
|
pixel_rate = crtc_state->pixel_rate;
|
2020-11-12 21:17:18 +02:00
|
|
|
htotal = pipe_mode->crtc_htotal;
|
2021-12-09 16:43:10 +02:00
|
|
|
width = drm_rect_width(&plane_state->uapi.src) >> 16;
|
2017-04-21 21:14:29 +03:00
|
|
|
|
|
|
|
|
if (plane->id == PLANE_CURSOR) {
|
2021-12-09 16:43:09 +02:00
|
|
|
wm = intel_wm_method2(pixel_rate, htotal, width, cpp, latency);
|
2017-04-21 21:14:29 +03:00
|
|
|
} else if (plane->id == PLANE_PRIMARY &&
|
|
|
|
|
level == G4X_WM_LEVEL_NORMAL) {
|
2021-12-09 16:43:09 +02:00
|
|
|
wm = intel_wm_method1(pixel_rate, cpp, latency);
|
2017-04-21 21:14:29 +03:00
|
|
|
} else {
|
2017-11-07 14:03:38 +00:00
|
|
|
unsigned int small, large;
|
2017-04-21 21:14:29 +03:00
|
|
|
|
2021-12-09 16:43:09 +02:00
|
|
|
small = intel_wm_method1(pixel_rate, cpp, latency);
|
|
|
|
|
large = intel_wm_method2(pixel_rate, htotal, width, cpp, latency);
|
2017-04-21 21:14:29 +03:00
|
|
|
|
|
|
|
|
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 21:14:29 +03: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 12:26:03 +01:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 21:14:29 +03: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 12:26:03 +01:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 21:14:29 +03: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 10:55:17 +02:00
|
|
|
static u32 ilk_compute_fbc_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 pri_val);
|
2017-04-21 21:14:29 +03:00
|
|
|
|
|
|
|
|
static bool g4x_raw_plane_wm_compute(struct intel_crtc_state *crtc_state,
|
|
|
|
|
const struct intel_plane_state *plane_state)
|
|
|
|
|
{
|
2019-10-31 12:26:08 +01:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2020-01-07 18:13:30 +03:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 21:14:29 +03: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 18:13:30 +03: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 21:14:29 +03:00
|
|
|
|
|
|
|
|
if (plane_id == PLANE_PRIMARY)
|
2020-01-07 18:13:30 +03: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 21:14:29 +03: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 12:26:03 +01:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 21:14:29 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
if (level > dev_priv->display.wm.max_level)
|
2017-04-21 21:14:29 +03:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 13:10:33 +03:00
|
|
|
static bool g4x_compute_fbc_en(const struct g4x_wm_state *wm_state,
|
|
|
|
|
int level)
|
|
|
|
|
{
|
|
|
|
|
if (level < G4X_WM_LEVEL_SR)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (level >= G4X_WM_LEVEL_SR &&
|
|
|
|
|
wm_state->sr.fbc > g4x_fbc_fifo_size(G4X_WM_LEVEL_SR))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (level >= G4X_WM_LEVEL_HPLL &&
|
|
|
|
|
wm_state->hpll.fbc > g4x_fbc_fifo_size(G4X_WM_LEVEL_HPLL))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-09 11:56:30 +03:00
|
|
|
static int g4x_compute_pipe_wm(struct intel_atomic_state *state,
|
|
|
|
|
struct intel_crtc *crtc)
|
2017-04-21 21:14:29 +03:00
|
|
|
{
|
2021-06-09 11:56:30 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2017-04-21 21:14:29 +03:00
|
|
|
struct g4x_wm_state *wm_state = &crtc_state->wm.g4x.optimal;
|
2021-05-14 15:57:39 +03:00
|
|
|
u8 active_planes = crtc_state->active_planes & ~BIT(PLANE_CURSOR);
|
2017-04-21 21:14:29 +03:00
|
|
|
const struct g4x_pipe_wm *raw;
|
2017-08-23 18:22:22 +03:00
|
|
|
const struct intel_plane_state *old_plane_state;
|
|
|
|
|
const struct intel_plane_state *new_plane_state;
|
2017-04-21 21:14:29 +03:00
|
|
|
struct intel_plane *plane;
|
|
|
|
|
enum plane_id plane_id;
|
|
|
|
|
int i, level;
|
|
|
|
|
unsigned int dirty = 0;
|
|
|
|
|
|
2017-08-23 18:22:22 +03:00
|
|
|
for_each_oldnew_intel_plane_in_state(state, plane,
|
|
|
|
|
old_plane_state,
|
|
|
|
|
new_plane_state, i) {
|
2019-10-31 12:26:07 +01:00
|
|
|
if (new_plane_state->hw.crtc != &crtc->base &&
|
|
|
|
|
old_plane_state->hw.crtc != &crtc->base)
|
2017-04-21 21:14:29 +03:00
|
|
|
continue;
|
|
|
|
|
|
2017-08-23 18:22:22 +03:00
|
|
|
if (g4x_raw_plane_wm_compute(crtc_state, new_plane_state))
|
2017-04-21 21:14:29 +03: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;
|
|
|
|
|
|
2021-05-14 15:57:39 +03:00
|
|
|
wm_state->cxsr = active_planes == BIT(PLANE_PRIMARY);
|
2017-04-21 21:14:29 +03:00
|
|
|
|
|
|
|
|
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
|
2020-04-29 13:10:33 +03:00
|
|
|
* watermark(s) rather than disable the SR/HPLL
|
|
|
|
|
* level(s) entirely. 'level-1' is the highest valid
|
|
|
|
|
* level here.
|
2017-04-21 21:14:29 +03:00
|
|
|
*/
|
2020-04-29 13:10:33 +03:00
|
|
|
wm_state->fbc_en = g4x_compute_fbc_en(wm_state, level - 1);
|
2017-04-21 21:14:29 +03:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-09 11:56:30 +03:00
|
|
|
static int g4x_compute_intermediate_wm(struct intel_atomic_state *state,
|
|
|
|
|
struct intel_crtc *crtc)
|
2017-04-21 21:14:29 +03:00
|
|
|
{
|
2020-05-04 23:45:59 +05:30
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2021-06-09 11:56:30 +03:00
|
|
|
struct intel_crtc_state *new_crtc_state =
|
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
|
|
|
|
const struct intel_crtc_state *old_crtc_state =
|
|
|
|
|
intel_atomic_get_old_crtc_state(state, crtc);
|
2017-11-15 17:31:57 +01:00
|
|
|
struct g4x_wm_state *intermediate = &new_crtc_state->wm.g4x.intermediate;
|
|
|
|
|
const struct g4x_wm_state *optimal = &new_crtc_state->wm.g4x.optimal;
|
|
|
|
|
const struct g4x_wm_state *active = &old_crtc_state->wm.g4x.optimal;
|
2017-04-21 21:14:29 +03:00
|
|
|
enum plane_id plane_id;
|
|
|
|
|
|
2021-06-09 11:56:30 +03:00
|
|
|
if (!new_crtc_state->hw.active ||
|
|
|
|
|
drm_atomic_crtc_needs_modeset(&new_crtc_state->uapi)) {
|
2017-11-15 17:31:57 +01:00
|
|
|
*intermediate = *optimal;
|
|
|
|
|
|
|
|
|
|
intermediate->cxsr = false;
|
|
|
|
|
intermediate->hpll_en = false;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 21:14:29 +03:00
|
|
|
intermediate->cxsr = optimal->cxsr && active->cxsr &&
|
2017-11-15 17:31:57 +01:00
|
|
|
!new_crtc_state->disable_cxsr;
|
2017-04-21 21:14:29 +03:00
|
|
|
intermediate->hpll_en = optimal->hpll_en && active->hpll_en &&
|
2017-11-15 17:31:57 +01:00
|
|
|
!new_crtc_state->disable_cxsr;
|
2017-04-21 21:14:29 +03: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]);
|
|
|
|
|
|
2020-05-04 23:45:59 +05:30
|
|
|
drm_WARN_ON(&dev_priv->drm, intermediate->wm.plane[plane_id] >
|
|
|
|
|
g4x_plane_fifo_size(plane_id, G4X_WM_LEVEL_NORMAL));
|
2017-04-21 21:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2020-05-04 23:45:59 +05:30
|
|
|
drm_WARN_ON(&dev_priv->drm,
|
|
|
|
|
(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);
|
|
|
|
|
drm_WARN_ON(&dev_priv->drm,
|
|
|
|
|
(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);
|
|
|
|
|
|
|
|
|
|
drm_WARN_ON(&dev_priv->drm,
|
|
|
|
|
intermediate->sr.fbc > g4x_fbc_fifo_size(1) &&
|
|
|
|
|
intermediate->fbc_en && intermediate->cxsr);
|
|
|
|
|
drm_WARN_ON(&dev_priv->drm,
|
|
|
|
|
intermediate->hpll.fbc > g4x_fbc_fifo_size(2) &&
|
|
|
|
|
intermediate->fbc_en && intermediate->hpll_en);
|
2017-04-21 21:14:29 +03:00
|
|
|
|
2017-11-15 17:31:57 +01:00
|
|
|
out:
|
2017-04-21 21:14:29 +03: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 17:31:57 +01:00
|
|
|
new_crtc_state->wm.need_postvbl_update = true;
|
2017-04-21 21:14:29 +03: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 20:30:32 +03:00
|
|
|
int num_active_pipes = 0;
|
2017-04-21 21:14:29 +03: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 20:30:32 +03:00
|
|
|
num_active_pipes++;
|
2017-04-21 21:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
2019-08-21 20:30:32 +03:00
|
|
|
if (num_active_pipes != 1) {
|
2017-04-21 21:14:29 +03: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)
|
|
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
struct g4x_wm_values *old_wm = &dev_priv->display.wm.g4x;
|
2017-04-21 21:14:29 +03:00
|
|
|
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 18:44:26 +02:00
|
|
|
struct intel_crtc *crtc)
|
2017-04-21 21:14:29 +03:00
|
|
|
{
|
2019-11-18 18:44:26 +02: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 21:14:29 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
2017-04-21 21:14:29 +03:00
|
|
|
crtc->wm.active.g4x = crtc_state->wm.g4x.intermediate;
|
|
|
|
|
g4x_program_watermarks(dev_priv);
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2017-04-21 21:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void g4x_optimize_watermarks(struct intel_atomic_state *state,
|
2019-11-18 18:44:26 +02:00
|
|
|
struct intel_crtc *crtc)
|
2017-04-21 21:14:29 +03:00
|
|
|
{
|
2019-11-18 18:44:26 +02: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 21:14:29 +03:00
|
|
|
|
|
|
|
|
if (!crtc_state->wm.need_postvbl_update)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
2019-07-01 19:05:45 +03:00
|
|
|
crtc->wm.active.g4x = crtc_state->wm.g4x.optimal;
|
2017-04-21 21:14:29 +03:00
|
|
|
g4x_program_watermarks(dev_priv);
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2017-04-21 21:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
2015-06-24 22:00:04 +03:00
|
|
|
/* latency must be in 0.1us units. */
|
|
|
|
|
static unsigned int vlv_wm_method2(unsigned int pixel_rate,
|
2017-04-21 21:14:27 +03:00
|
|
|
unsigned int htotal,
|
|
|
|
|
unsigned int width,
|
2016-01-20 21:05:26 +02:00
|
|
|
unsigned int cpp,
|
2015-06-24 22:00:04 +03:00
|
|
|
unsigned int latency)
|
|
|
|
|
{
|
|
|
|
|
unsigned int ret;
|
|
|
|
|
|
2017-04-21 21:14:27 +03:00
|
|
|
ret = intel_wm_method2(pixel_rate, htotal,
|
|
|
|
|
width, cpp, latency);
|
2015-06-24 22:00:04 +03:00
|
|
|
ret = DIV_ROUND_UP(ret, 64);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:24 +02:00
|
|
|
static void vlv_setup_wm_latency(struct drm_i915_private *dev_priv)
|
2015-06-24 22:00:04 +03:00
|
|
|
{
|
|
|
|
|
/* all latencies in usec */
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.pri_latency[VLV_WM_LEVEL_PM2] = 3;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.max_level = VLV_WM_LEVEL_PM2;
|
2015-09-08 21:05:12 +03:00
|
|
|
|
2015-06-24 22:00:04 +03:00
|
|
|
if (IS_CHERRYVIEW(dev_priv)) {
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.pri_latency[VLV_WM_LEVEL_PM5] = 12;
|
|
|
|
|
dev_priv->display.wm.pri_latency[VLV_WM_LEVEL_DDR_DVFS] = 33;
|
2015-09-08 21:05:12 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.max_level = VLV_WM_LEVEL_DDR_DVFS;
|
2015-06-24 22:00:04 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 14:01:20 +02: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 22:00:04 +03:00
|
|
|
{
|
2019-10-31 12:26:08 +01:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2015-06-24 22:00:04 +03:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
|
2020-11-12 21:17:18 +02:00
|
|
|
const struct drm_display_mode *pipe_mode =
|
|
|
|
|
&crtc_state->hw.pipe_mode;
|
2021-12-09 16:43:09 +02:00
|
|
|
unsigned int pixel_rate, htotal, cpp, width, wm;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
if (dev_priv->display.wm.pri_latency[level] == 0)
|
2015-06-24 22:00:04 +03:00
|
|
|
return USHRT_MAX;
|
|
|
|
|
|
2017-03-03 17:19:27 +02:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2015-06-24 22:00:04 +03:00
|
|
|
return 0;
|
|
|
|
|
|
2019-10-31 12:26:07 +01:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2021-12-09 16:43:09 +02:00
|
|
|
pixel_rate = crtc_state->pixel_rate;
|
2020-11-12 21:17:18 +02:00
|
|
|
htotal = pipe_mode->crtc_htotal;
|
2021-12-09 16:43:10 +02:00
|
|
|
width = drm_rect_width(&plane_state->uapi.src) >> 16;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-03 17:19:26 +02:00
|
|
|
if (plane->id == PLANE_CURSOR) {
|
2015-06-24 22:00:04 +03: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 {
|
2021-12-09 16:43:09 +02:00
|
|
|
wm = vlv_wm_method2(pixel_rate, htotal, width, cpp,
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.pri_latency[level] * 10);
|
2015-06-24 22:00:04 +03:00
|
|
|
}
|
|
|
|
|
|
2017-11-07 14:03:38 +00:00
|
|
|
return min_t(unsigned int, wm, USHRT_MAX);
|
2015-06-24 22:00:04 +03:00
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:15:03 +02: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 19:14:56 +02:00
|
|
|
static int vlv_compute_fifo(struct intel_crtc_state *crtc_state)
|
2015-06-24 22:00:05 +03:00
|
|
|
{
|
2019-10-31 12:26:03 +01:00
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
2020-05-04 23:45:59 +05:30
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2017-04-21 21:14:21 +03:00
|
|
|
const struct g4x_pipe_wm *raw =
|
2017-03-02 19:14:56 +02:00
|
|
|
&crtc_state->wm.vlv.raw[VLV_WM_LEVEL_PM2];
|
2017-03-02 19:14:55 +02:00
|
|
|
struct vlv_fifo_state *fifo_state = &crtc_state->wm.vlv.fifo_state;
|
2021-05-14 15:57:40 +03:00
|
|
|
u8 active_planes = crtc_state->active_planes & ~BIT(PLANE_CURSOR);
|
2019-08-21 20:30:33 +03:00
|
|
|
int num_active_planes = hweight8(active_planes);
|
2017-03-02 19:14:56 +02:00
|
|
|
const int fifo_size = 511;
|
2015-06-24 22:00:05 +03:00
|
|
|
int fifo_extra, fifo_left = fifo_size;
|
2017-03-02 19:15:03 +02:00
|
|
|
int sprite0_fifo_extra = 0;
|
2017-03-02 19:14:56 +02:00
|
|
|
unsigned int total_rate;
|
|
|
|
|
enum plane_id plane_id;
|
2015-06-24 22:00:05 +03:00
|
|
|
|
2017-03-02 19:15:03 +02: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 19:14:56 +02:00
|
|
|
total_rate = raw->plane[PLANE_PRIMARY] +
|
|
|
|
|
raw->plane[PLANE_SPRITE0] +
|
2017-03-02 19:15:03 +02:00
|
|
|
raw->plane[PLANE_SPRITE1] +
|
|
|
|
|
sprite0_fifo_extra;
|
2015-06-24 22:00:05 +03:00
|
|
|
|
2017-03-02 19:14:56 +02:00
|
|
|
if (total_rate > fifo_size)
|
|
|
|
|
return -EINVAL;
|
2015-06-24 22:00:05 +03:00
|
|
|
|
2017-03-02 19:14:56 +02:00
|
|
|
if (total_rate == 0)
|
|
|
|
|
total_rate = 1;
|
2015-06-24 22:00:05 +03:00
|
|
|
|
2017-03-02 19:14:56 +02:00
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
2015-06-24 22:00:05 +03:00
|
|
|
unsigned int rate;
|
|
|
|
|
|
2017-03-02 19:14:56 +02:00
|
|
|
if ((active_planes & BIT(plane_id)) == 0) {
|
|
|
|
|
fifo_state->plane[plane_id] = 0;
|
2015-06-24 22:00:05 +03:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:14:56 +02: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 22:00:05 +03:00
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:15:03 +02:00
|
|
|
fifo_state->plane[PLANE_SPRITE0] += sprite0_fifo_extra;
|
|
|
|
|
fifo_left -= sprite0_fifo_extra;
|
|
|
|
|
|
2017-03-02 19:14:56 +02:00
|
|
|
fifo_state->plane[PLANE_CURSOR] = 63;
|
|
|
|
|
|
|
|
|
|
fifo_extra = DIV_ROUND_UP(fifo_left, num_active_planes ?: 1);
|
2015-06-24 22:00:05 +03:00
|
|
|
|
|
|
|
|
/* spread the remainder evenly */
|
2017-03-02 19:14:56 +02:00
|
|
|
for_each_plane_id_on_crtc(crtc, plane_id) {
|
2015-06-24 22:00:05 +03:00
|
|
|
int plane_extra;
|
|
|
|
|
|
|
|
|
|
if (fifo_left == 0)
|
|
|
|
|
break;
|
|
|
|
|
|
2017-03-02 19:14:56 +02:00
|
|
|
if ((active_planes & BIT(plane_id)) == 0)
|
2015-06-24 22:00:05 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
plane_extra = min(fifo_extra, fifo_left);
|
2017-03-02 19:14:56 +02:00
|
|
|
fifo_state->plane[plane_id] += plane_extra;
|
2015-06-24 22:00:05 +03:00
|
|
|
fifo_left -= plane_extra;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 23:45:59 +05:30
|
|
|
drm_WARN_ON(&dev_priv->drm, active_planes != 0 && fifo_left != 0);
|
2017-03-02 19:14:56 +02:00
|
|
|
|
|
|
|
|
/* give it all to the first plane if none are active */
|
|
|
|
|
if (active_planes == 0) {
|
2020-05-04 23:45:59 +05:30
|
|
|
drm_WARN_ON(&dev_priv->drm, fifo_left != fifo_size);
|
2017-03-02 19:14:56 +02:00
|
|
|
fifo_state->plane[PLANE_PRIMARY] = fifo_left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2015-06-24 22:00:05 +03:00
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:14:57 +02: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 21:14:20 +03:00
|
|
|
for (; level < intel_wm_num_levels(dev_priv); level++) {
|
2017-03-02 19:14:57 +02: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 19:37:09 +02: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 19:14:57 +02:00
|
|
|
/*
|
|
|
|
|
* Starting from 'level' set all higher
|
|
|
|
|
* levels to 'value' in the "raw" watermarks.
|
|
|
|
|
*/
|
2017-03-02 19:14:58 +02:00
|
|
|
static bool vlv_raw_plane_wm_set(struct intel_crtc_state *crtc_state,
|
2017-03-02 19:14:57 +02:00
|
|
|
int level, enum plane_id plane_id, u16 value)
|
2015-06-24 22:00:04 +03:00
|
|
|
{
|
2019-10-31 12:26:03 +01:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-04-21 21:14:20 +03:00
|
|
|
int num_levels = intel_wm_num_levels(dev_priv);
|
2017-03-02 19:14:58 +02:00
|
|
|
bool dirty = false;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
for (; level < num_levels; level++) {
|
2017-04-21 21:14:21 +03:00
|
|
|
struct g4x_pipe_wm *raw = &crtc_state->wm.vlv.raw[level];
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:58 +02:00
|
|
|
dirty |= raw->plane[plane_id] != value;
|
2017-03-02 19:14:57 +02:00
|
|
|
raw->plane[plane_id] = value;
|
2015-06-24 22:00:04 +03:00
|
|
|
}
|
2017-03-02 19:14:58 +02:00
|
|
|
|
|
|
|
|
return dirty;
|
2015-06-24 22:00:04 +03:00
|
|
|
}
|
|
|
|
|
|
2017-04-21 21:14:18 +03:00
|
|
|
static bool vlv_raw_plane_wm_compute(struct intel_crtc_state *crtc_state,
|
|
|
|
|
const struct intel_plane_state *plane_state)
|
2015-06-24 22:00:04 +03:00
|
|
|
{
|
2019-10-31 12:26:08 +01:00
|
|
|
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
2020-01-07 18:13:30 +03:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
|
2017-03-02 19:14:57 +02:00
|
|
|
enum plane_id plane_id = plane->id;
|
2017-04-21 21:14:20 +03:00
|
|
|
int num_levels = intel_wm_num_levels(to_i915(plane->base.dev));
|
2015-06-24 22:00:04 +03:00
|
|
|
int level;
|
2017-03-02 19:14:58 +02:00
|
|
|
bool dirty = false;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-03 17:19:27 +02:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state)) {
|
2017-03-02 19:14:58 +02:00
|
|
|
dirty |= vlv_raw_plane_wm_set(crtc_state, 0, plane_id, 0);
|
|
|
|
|
goto out;
|
2017-03-02 19:14:57 +02:00
|
|
|
}
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
for (level = 0; level < num_levels; level++) {
|
2017-04-21 21:14:21 +03:00
|
|
|
struct g4x_pipe_wm *raw = &crtc_state->wm.vlv.raw[level];
|
2017-03-02 19:14:57 +02:00
|
|
|
int wm = vlv_compute_wm_level(crtc_state, plane_state, level);
|
|
|
|
|
int max_wm = plane_id == PLANE_CURSOR ? 63 : 511;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
if (wm > max_wm)
|
|
|
|
|
break;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:58 +02:00
|
|
|
dirty |= raw->plane[plane_id] != wm;
|
2017-03-02 19:14:57 +02:00
|
|
|
raw->plane[plane_id] = wm;
|
|
|
|
|
}
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
/* mark all higher levels as invalid */
|
2017-03-02 19:14:58 +02:00
|
|
|
dirty |= vlv_raw_plane_wm_set(crtc_state, level, plane_id, USHRT_MAX);
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:58 +02:00
|
|
|
out:
|
|
|
|
|
if (dirty)
|
2020-01-07 18:13:30 +03: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 19:14:58 +02:00
|
|
|
|
|
|
|
|
return dirty;
|
2017-03-02 19:14:57 +02:00
|
|
|
}
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-04-21 21:14:18 +03: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 19:14:57 +02:00
|
|
|
{
|
2017-04-21 21:14:21 +03:00
|
|
|
const struct g4x_pipe_wm *raw =
|
2017-03-02 19:14:57 +02:00
|
|
|
&crtc_state->wm.vlv.raw[level];
|
|
|
|
|
const struct vlv_fifo_state *fifo_state =
|
|
|
|
|
&crtc_state->wm.vlv.fifo_state;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
return raw->plane[plane_id] <= fifo_state->plane[plane_id];
|
|
|
|
|
}
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-04-21 21:14:18 +03:00
|
|
|
static bool vlv_raw_crtc_wm_is_valid(const struct intel_crtc_state *crtc_state, int level)
|
2017-03-02 19:14:57 +02:00
|
|
|
{
|
2017-04-21 21:14:18 +03: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 19:14:57 +02:00
|
|
|
}
|
|
|
|
|
|
2021-06-09 11:56:30 +03:00
|
|
|
static int vlv_compute_pipe_wm(struct intel_atomic_state *state,
|
|
|
|
|
struct intel_crtc *crtc)
|
2017-03-02 19:14:57 +02:00
|
|
|
{
|
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2021-06-09 11:56:30 +03:00
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2017-03-02 19:14:57 +02: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;
|
2021-05-14 15:57:40 +03:00
|
|
|
u8 active_planes = crtc_state->active_planes & ~BIT(PLANE_CURSOR);
|
|
|
|
|
int num_active_planes = hweight8(active_planes);
|
2019-10-31 12:26:03 +01:00
|
|
|
bool needs_modeset = drm_atomic_crtc_needs_modeset(&crtc_state->uapi);
|
2017-08-23 18:22:22 +03:00
|
|
|
const struct intel_plane_state *old_plane_state;
|
|
|
|
|
const struct intel_plane_state *new_plane_state;
|
2017-03-02 19:14:57 +02:00
|
|
|
struct intel_plane *plane;
|
|
|
|
|
enum plane_id plane_id;
|
|
|
|
|
int level, ret, i;
|
2017-03-02 19:14:58 +02:00
|
|
|
unsigned int dirty = 0;
|
2017-03-02 19:14:57 +02:00
|
|
|
|
2017-08-23 18:22:22 +03:00
|
|
|
for_each_oldnew_intel_plane_in_state(state, plane,
|
|
|
|
|
old_plane_state,
|
|
|
|
|
new_plane_state, i) {
|
2019-10-31 12:26:07 +01:00
|
|
|
if (new_plane_state->hw.crtc != &crtc->base &&
|
|
|
|
|
old_plane_state->hw.crtc != &crtc->base)
|
2017-03-02 19:14:57 +02:00
|
|
|
continue;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-08-23 18:22:22 +03:00
|
|
|
if (vlv_raw_plane_wm_compute(crtc_state, new_plane_state))
|
2017-03-02 19:14:58 +02: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 18:22:22 +03:00
|
|
|
intel_atomic_get_old_crtc_state(state, crtc);
|
2017-03-02 19:14:58 +02: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 19:14:56 +02:00
|
|
|
}
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
/* initially allow all levels */
|
2017-04-21 21:14:20 +03:00
|
|
|
wm_state->num_levels = intel_wm_num_levels(dev_priv);
|
2017-03-02 19:14:57 +02: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 19:15:00 +02:00
|
|
|
wm_state->cxsr = crtc->pipe != PIPE_C && num_active_planes == 1;
|
2017-03-02 19:14:57 +02:00
|
|
|
|
2017-03-02 19:14:56 +02:00
|
|
|
for (level = 0; level < wm_state->num_levels; level++) {
|
2017-04-21 21:14:21 +03:00
|
|
|
const struct g4x_pipe_wm *raw = &crtc_state->wm.vlv.raw[level];
|
2019-09-11 12:26:08 +03:00
|
|
|
const int sr_fifo_size = INTEL_NUM_PIPES(dev_priv) * 512 - 1;
|
2017-03-02 19:14:56 +02:00
|
|
|
|
2017-04-21 21:14:18 +03:00
|
|
|
if (!vlv_raw_crtc_wm_is_valid(crtc_state, level))
|
2017-03-02 19:14:57 +02:00
|
|
|
break;
|
2017-03-02 19:14:56 +02:00
|
|
|
|
2017-03-02 19:14:57 +02: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 19:14:56 +02:00
|
|
|
raw->plane[PLANE_SPRITE0],
|
2017-03-02 19:14:57 +02:00
|
|
|
raw->plane[PLANE_SPRITE1]),
|
|
|
|
|
sr_fifo_size);
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
wm_state->sr[level].cursor =
|
|
|
|
|
vlv_invert_wm_value(raw->plane[PLANE_CURSOR],
|
|
|
|
|
63);
|
2015-06-24 22:00:04 +03:00
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:14:57 +02: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 22:00:04 +03:00
|
|
|
}
|
|
|
|
|
|
2015-06-24 22:00:05 +03:00
|
|
|
#define VLV_FIFO(plane, value) \
|
|
|
|
|
(((value) << DSPARB_ ## plane ## _SHIFT_VLV) & DSPARB_ ## plane ## _MASK_VLV)
|
|
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
static void vlv_atomic_update_fifo(struct intel_atomic_state *state,
|
2019-11-18 18:44:26 +02:00
|
|
|
struct intel_crtc *crtc)
|
2015-06-24 22:00:05 +03:00
|
|
|
{
|
2017-03-02 19:14:52 +02:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2019-06-11 11:45:44 +01:00
|
|
|
struct intel_uncore *uncore = &dev_priv->uncore;
|
2019-11-18 18:44:26 +02:00
|
|
|
const struct intel_crtc_state *crtc_state =
|
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2017-03-02 19:14:55 +02:00
|
|
|
const struct vlv_fifo_state *fifo_state =
|
|
|
|
|
&crtc_state->wm.vlv.fifo_state;
|
2017-03-02 19:14:52 +02:00
|
|
|
int sprite0_start, sprite1_start, fifo_size;
|
2020-02-20 16:05:17 -08:00
|
|
|
u32 dsparb, dsparb2, dsparb3;
|
2015-06-24 22:00:05 +03:00
|
|
|
|
2017-03-02 19:14:58 +02:00
|
|
|
if (!crtc_state->fifo_changed)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-03-02 19:14:52 +02: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 22:00:05 +03:00
|
|
|
|
drm/i915: Make WARN* drm specific where drm_priv ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_i915_private struct pointer is readily
available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
command: ls drivers/gpu/drm/i915/*.c | xargs spatch --sp-file \
<script> --linux-spacing --in-place
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200115034455.17658-10-pankaj.laxminarayan.bharadiya@intel.com
2020-01-15 09:14:53 +05:30
|
|
|
drm_WARN_ON(&dev_priv->drm, fifo_state->plane[PLANE_CURSOR] != 63);
|
|
|
|
|
drm_WARN_ON(&dev_priv->drm, fifo_size != 511);
|
2015-06-24 22:00:05 +03:00
|
|
|
|
2017-03-02 19:15:06 +02:00
|
|
|
trace_vlv_fifo_size(crtc, sprite0_start, sprite1_start, fifo_size);
|
|
|
|
|
|
2017-03-09 17:44:34 +02: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 11:45:44 +01:00
|
|
|
spin_lock(&uncore->lock);
|
2016-12-05 16:13:28 +02:00
|
|
|
|
2015-06-24 22:00:05 +03:00
|
|
|
switch (crtc->pipe) {
|
|
|
|
|
case PIPE_A:
|
2019-06-11 11:45:44 +01:00
|
|
|
dsparb = intel_uncore_read_fw(uncore, DSPARB);
|
|
|
|
|
dsparb2 = intel_uncore_read_fw(uncore, DSPARB2);
|
2015-06-24 22:00:05 +03: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 11:45:44 +01:00
|
|
|
intel_uncore_write_fw(uncore, DSPARB, dsparb);
|
|
|
|
|
intel_uncore_write_fw(uncore, DSPARB2, dsparb2);
|
2015-06-24 22:00:05 +03:00
|
|
|
break;
|
|
|
|
|
case PIPE_B:
|
2019-06-11 11:45:44 +01:00
|
|
|
dsparb = intel_uncore_read_fw(uncore, DSPARB);
|
|
|
|
|
dsparb2 = intel_uncore_read_fw(uncore, DSPARB2);
|
2015-06-24 22:00:05 +03: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 11:45:44 +01:00
|
|
|
intel_uncore_write_fw(uncore, DSPARB, dsparb);
|
|
|
|
|
intel_uncore_write_fw(uncore, DSPARB2, dsparb2);
|
2015-06-24 22:00:05 +03:00
|
|
|
break;
|
|
|
|
|
case PIPE_C:
|
2019-06-11 11:45:44 +01:00
|
|
|
dsparb3 = intel_uncore_read_fw(uncore, DSPARB3);
|
|
|
|
|
dsparb2 = intel_uncore_read_fw(uncore, DSPARB2);
|
2015-06-24 22:00:05 +03: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 11:45:44 +01:00
|
|
|
intel_uncore_write_fw(uncore, DSPARB3, dsparb3);
|
|
|
|
|
intel_uncore_write_fw(uncore, DSPARB2, dsparb2);
|
2015-06-24 22:00:05 +03:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-12-05 16:13:28 +02:00
|
|
|
|
2019-06-11 11:45:44 +01:00
|
|
|
intel_uncore_posting_read_fw(uncore, DSPARB);
|
2016-12-05 16:13:28 +02:00
|
|
|
|
2019-06-11 11:45:44 +01:00
|
|
|
spin_unlock(&uncore->lock);
|
2015-06-24 22:00:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef VLV_FIFO
|
|
|
|
|
|
2021-06-09 11:56:30 +03:00
|
|
|
static int vlv_compute_intermediate_wm(struct intel_atomic_state *state,
|
|
|
|
|
struct intel_crtc *crtc)
|
2017-03-02 19:14:59 +02:00
|
|
|
{
|
2021-06-09 11:56:30 +03:00
|
|
|
struct intel_crtc_state *new_crtc_state =
|
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
|
|
|
|
const struct intel_crtc_state *old_crtc_state =
|
|
|
|
|
intel_atomic_get_old_crtc_state(state, crtc);
|
2017-11-15 17:31:56 +01:00
|
|
|
struct vlv_wm_state *intermediate = &new_crtc_state->wm.vlv.intermediate;
|
|
|
|
|
const struct vlv_wm_state *optimal = &new_crtc_state->wm.vlv.optimal;
|
|
|
|
|
const struct vlv_wm_state *active = &old_crtc_state->wm.vlv.optimal;
|
2017-03-02 19:14:59 +02:00
|
|
|
int level;
|
|
|
|
|
|
2021-06-09 11:56:30 +03:00
|
|
|
if (!new_crtc_state->hw.active ||
|
|
|
|
|
drm_atomic_crtc_needs_modeset(&new_crtc_state->uapi)) {
|
2017-11-15 17:31:56 +01:00
|
|
|
*intermediate = *optimal;
|
|
|
|
|
|
|
|
|
|
intermediate->cxsr = false;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:14:59 +02:00
|
|
|
intermediate->num_levels = min(optimal->num_levels, active->num_levels);
|
2017-03-02 19:15:00 +02:00
|
|
|
intermediate->cxsr = optimal->cxsr && active->cxsr &&
|
2017-11-15 17:31:56 +01:00
|
|
|
!new_crtc_state->disable_cxsr;
|
2017-03-02 19:14:59 +02: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 17:31:56 +01:00
|
|
|
out:
|
2017-03-02 19:14:59 +02: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 19:15:00 +02:00
|
|
|
if (memcmp(intermediate, optimal, sizeof(*intermediate)) != 0)
|
2017-11-15 17:31:56 +01:00
|
|
|
new_crtc_state->wm.need_postvbl_update = true;
|
2017-03-02 19:14:59 +02:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 19:37:10 +02:00
|
|
|
static void vlv_merge_wm(struct drm_i915_private *dev_priv,
|
2015-06-24 22:00:04 +03:00
|
|
|
struct vlv_wm_values *wm)
|
|
|
|
|
{
|
|
|
|
|
struct intel_crtc *crtc;
|
2019-08-21 20:30:32 +03:00
|
|
|
int num_active_pipes = 0;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
wm->level = dev_priv->display.wm.max_level;
|
2015-06-24 22:00:04 +03:00
|
|
|
wm->cxsr = true;
|
|
|
|
|
|
2016-11-28 19:37:10 +02:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2017-03-02 19:14:53 +02:00
|
|
|
const struct vlv_wm_state *wm_state = &crtc->wm.active.vlv;
|
2015-06-24 22:00:04 +03:00
|
|
|
|
|
|
|
|
if (!crtc->active)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!wm_state->cxsr)
|
|
|
|
|
wm->cxsr = false;
|
|
|
|
|
|
2019-08-21 20:30:32 +03:00
|
|
|
num_active_pipes++;
|
2015-06-24 22:00:04 +03:00
|
|
|
wm->level = min_t(int, wm->level, wm_state->num_levels - 1);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-21 20:30:32 +03:00
|
|
|
if (num_active_pipes != 1)
|
2015-06-24 22:00:04 +03:00
|
|
|
wm->cxsr = false;
|
|
|
|
|
|
2019-08-21 20:30:32 +03:00
|
|
|
if (num_active_pipes > 1)
|
2015-06-24 22:00:08 +03:00
|
|
|
wm->level = VLV_WM_LEVEL_PM2;
|
|
|
|
|
|
2016-11-28 19:37:10 +02:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2017-03-02 19:14:53 +02:00
|
|
|
const struct vlv_wm_state *wm_state = &crtc->wm.active.vlv;
|
2015-06-24 22:00:04 +03:00
|
|
|
enum pipe pipe = crtc->pipe;
|
|
|
|
|
|
|
|
|
|
wm->pipe[pipe] = wm_state->wm[wm->level];
|
2017-03-02 19:14:57 +02:00
|
|
|
if (crtc->active && wm->cxsr)
|
2015-06-24 22:00:04 +03:00
|
|
|
wm->sr = wm_state->sr[wm->level];
|
|
|
|
|
|
2016-11-28 19:37:08 +02: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 22:00:04 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
static void vlv_program_watermarks(struct drm_i915_private *dev_priv)
|
2015-06-24 22:00:04 +03:00
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
struct vlv_wm_values *old_wm = &dev_priv->display.wm.vlv;
|
2016-11-28 19:37:16 +02:00
|
|
|
struct vlv_wm_values new_wm = {};
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
vlv_merge_wm(dev_priv, &new_wm);
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
if (memcmp(old_wm, &new_wm, sizeof(new_wm)) == 0)
|
2015-06-24 22:00:04 +03:00
|
|
|
return;
|
|
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
if (is_disabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_DDR_DVFS))
|
2015-06-24 22:00:04 +03:00
|
|
|
chv_set_memory_dvfs(dev_priv, false);
|
|
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
if (is_disabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_PM5))
|
2015-06-24 22:00:04 +03:00
|
|
|
chv_set_memory_pm5(dev_priv, false);
|
|
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
if (is_disabling(old_wm->cxsr, new_wm.cxsr, true))
|
2016-11-28 19:37:11 +02:00
|
|
|
_intel_set_memory_cxsr(dev_priv, false);
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
vlv_write_wm_values(dev_priv, &new_wm);
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
if (is_enabling(old_wm->cxsr, new_wm.cxsr, true))
|
2016-11-28 19:37:11 +02:00
|
|
|
_intel_set_memory_cxsr(dev_priv, true);
|
2015-06-24 22:00:04 +03:00
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
if (is_enabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_PM5))
|
2015-06-24 22:00:04 +03:00
|
|
|
chv_set_memory_pm5(dev_priv, true);
|
|
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
if (is_enabling(old_wm->level, new_wm.level, VLV_WM_LEVEL_DDR_DVFS))
|
2015-06-24 22:00:04 +03:00
|
|
|
chv_set_memory_dvfs(dev_priv, true);
|
|
|
|
|
|
2016-11-28 19:37:16 +02:00
|
|
|
*old_wm = new_wm;
|
2014-06-26 17:03:06 +03:00
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:14:57 +02:00
|
|
|
static void vlv_initial_watermarks(struct intel_atomic_state *state,
|
2019-11-18 18:44:26 +02:00
|
|
|
struct intel_crtc *crtc)
|
2017-03-02 19:14:57 +02:00
|
|
|
{
|
2019-11-18 18:44:26 +02: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 19:14:57 +02:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
2017-03-02 19:14:59 +02:00
|
|
|
crtc->wm.active.vlv = crtc_state->wm.vlv.intermediate;
|
|
|
|
|
vlv_program_watermarks(dev_priv);
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2017-03-02 19:14:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void vlv_optimize_watermarks(struct intel_atomic_state *state,
|
2019-11-18 18:44:26 +02:00
|
|
|
struct intel_crtc *crtc)
|
2017-03-02 19:14:59 +02:00
|
|
|
{
|
2019-11-18 18:44:26 +02: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 19:14:59 +02:00
|
|
|
|
|
|
|
|
if (!crtc_state->wm.need_postvbl_update)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
2019-07-01 19:05:45 +03:00
|
|
|
crtc->wm.active.vlv = crtc_state->wm.vlv.optimal;
|
2017-03-02 19:14:57 +02:00
|
|
|
vlv_program_watermarks(dev_priv);
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2017-03-02 19:14:57 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-29 01:57:47 +03:00
|
|
|
static void i965_update_wm(struct drm_i915_private *dev_priv)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2016-10-31 22:37:04 +02:00
|
|
|
struct intel_crtc *crtc;
|
2012-04-16 22:20:35 -03:00
|
|
|
int srwm = 1;
|
|
|
|
|
int cursor_sr = 16;
|
2014-06-13 14:54:20 +03:00
|
|
|
bool cxsr_enabled;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
/* Calc sr entries for one plane configs */
|
2016-10-31 22:37:21 +02:00
|
|
|
crtc = single_enabled_crtc(dev_priv);
|
2012-04-16 22:20:35 -03:00
|
|
|
if (crtc) {
|
|
|
|
|
/* self-refresh has much higher latency */
|
|
|
|
|
static const int sr_latency_ns = 12000;
|
2020-11-12 21:17:18 +02:00
|
|
|
const struct drm_display_mode *pipe_mode =
|
|
|
|
|
&crtc->config->hw.pipe_mode;
|
2016-10-31 22:37:04 +02:00
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
|
crtc->base.primary->state->fb;
|
2021-12-09 16:43:09 +02:00
|
|
|
int pixel_rate = crtc->config->pixel_rate;
|
2020-11-12 21:17:18 +02:00
|
|
|
int htotal = pipe_mode->crtc_htotal;
|
2021-12-09 16:43:10 +02:00
|
|
|
int width = drm_rect_width(&crtc->base.primary->state->src) >> 16;
|
2016-12-14 23:30:57 +02:00
|
|
|
int cpp = fb->format->cpp[0];
|
2012-04-16 22:20:35 -03:00
|
|
|
int entries;
|
|
|
|
|
|
2021-12-09 16:43:09 +02:00
|
|
|
entries = intel_wm_method2(pixel_rate, htotal,
|
2021-12-09 16:43:10 +02:00
|
|
|
width, cpp, sr_latency_ns / 100);
|
2012-04-16 22:20:35 -03: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 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"self-refresh entries: %d, wm: %d\n",
|
|
|
|
|
entries, srwm);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2021-12-09 16:43:09 +02:00
|
|
|
entries = intel_wm_method2(pixel_rate, htotal,
|
2017-04-21 21:14:27 +03:00
|
|
|
crtc->base.cursor->state->crtc_w, 4,
|
|
|
|
|
sr_latency_ns / 100);
|
2012-04-16 22:20:35 -03:00
|
|
|
entries = DIV_ROUND_UP(entries,
|
2017-04-21 21:14:27 +03:00
|
|
|
i965_cursor_wm_info.cacheline_size) +
|
|
|
|
|
i965_cursor_wm_info.guard_size;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2017-04-21 21:14:27 +03:00
|
|
|
cursor_sr = i965_cursor_wm_info.fifo_size - entries;
|
2012-04-16 22:20:35 -03:00
|
|
|
if (cursor_sr > i965_cursor_wm_info.max_wm)
|
|
|
|
|
cursor_sr = i965_cursor_wm_info.max_wm;
|
|
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"self-refresh watermark: display plane %d "
|
|
|
|
|
"cursor %d\n", srwm, cursor_sr);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2014-06-13 14:54:20 +03:00
|
|
|
cxsr_enabled = true;
|
2012-04-16 22:20:35 -03:00
|
|
|
} else {
|
2014-06-13 14:54:20 +03:00
|
|
|
cxsr_enabled = false;
|
2012-04-16 22:20:35 -03:00
|
|
|
/* Turn off self refresh if both pipes are enabled */
|
2014-07-01 12:36:17 +03:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-16 22:20:35 -03:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"Setting FIFO watermarks - A: 8, B: 8, C: 8, SR %d\n",
|
|
|
|
|
srwm);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
/* 965 has limitations... */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW1, FW_WM(srwm, SR) |
|
2015-03-10 17:02:21 +02:00
|
|
|
FW_WM(8, CURSORB) |
|
|
|
|
|
FW_WM(8, PLANEB) |
|
|
|
|
|
FW_WM(8, PLANEA));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW2, FW_WM(8, CURSORA) |
|
2015-03-10 17:02:21 +02:00
|
|
|
FW_WM(8, PLANEC_OLD));
|
2012-04-16 22:20:35 -03:00
|
|
|
/* update cursor SR watermark */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPFW3, FW_WM(cursor_sr, CURSOR_SR));
|
2014-06-13 14:54:20 +03:00
|
|
|
|
|
|
|
|
if (cxsr_enabled)
|
|
|
|
|
intel_set_memory_cxsr(dev_priv, true);
|
2012-04-16 22:20:35 -03:00
|
|
|
}
|
|
|
|
|
|
2015-03-10 17:02:21 +02:00
|
|
|
#undef FW_WM
|
|
|
|
|
|
2021-12-03 13:20:28 +02:00
|
|
|
static struct intel_crtc *intel_crtc_for_plane(struct drm_i915_private *i915,
|
|
|
|
|
enum i9xx_plane_id i9xx_plane)
|
|
|
|
|
{
|
|
|
|
|
struct intel_plane *plane;
|
|
|
|
|
|
|
|
|
|
for_each_intel_plane(&i915->drm, plane) {
|
|
|
|
|
if (plane->id == PLANE_PRIMARY &&
|
|
|
|
|
plane->i9xx_plane == i9xx_plane)
|
|
|
|
|
return intel_crtc_for_pipe(i915, plane->pipe);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 01:57:47 +03:00
|
|
|
static void i9xx_update_wm(struct drm_i915_private *dev_priv)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
|
|
|
|
const struct intel_watermark_params *wm_info;
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 fwater_lo;
|
|
|
|
|
u32 fwater_hi;
|
2012-04-16 22:20:35 -03:00
|
|
|
int cwm, srwm = 1;
|
|
|
|
|
int fifo_size;
|
|
|
|
|
int planea_wm, planeb_wm;
|
2021-12-09 16:43:11 +02:00
|
|
|
struct intel_crtc *crtc;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2016-10-31 22:37:20 +02:00
|
|
|
if (IS_I945GM(dev_priv))
|
2012-04-16 22:20:35 -03:00
|
|
|
wm_info = &i945_wm_info;
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
else if (DISPLAY_VER(dev_priv) != 2)
|
2012-04-16 22:20:35 -03:00
|
|
|
wm_info = &i915_wm_info;
|
|
|
|
|
else
|
2014-08-15 01:21:53 +03:00
|
|
|
wm_info = &i830_a_wm_info;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2021-09-29 01:57:46 +03:00
|
|
|
if (DISPLAY_VER(dev_priv) == 2)
|
|
|
|
|
fifo_size = i830_get_fifo_size(dev_priv, PLANE_A);
|
|
|
|
|
else
|
|
|
|
|
fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_A);
|
2021-12-01 15:57:05 +02:00
|
|
|
crtc = intel_crtc_for_plane(dev_priv, PLANE_A);
|
2016-10-31 22:37:04 +02:00
|
|
|
if (intel_crtc_active(crtc)) {
|
|
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
|
crtc->base.primary->state->fb;
|
|
|
|
|
int cpp;
|
|
|
|
|
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) == 2)
|
2012-10-22 12:32:15 +01:00
|
|
|
cpp = 4;
|
2016-10-31 22:37:04 +02:00
|
|
|
else
|
2016-12-14 23:30:57 +02:00
|
|
|
cpp = fb->format->cpp[0];
|
2012-10-22 12:32:15 +01:00
|
|
|
|
2021-12-09 16:43:09 +02:00
|
|
|
planea_wm = intel_calculate_wm(crtc->config->pixel_rate,
|
2012-10-22 12:32:15 +01:00
|
|
|
wm_info, fifo_size, cpp,
|
2014-09-03 11:56:07 +01:00
|
|
|
pessimal_latency_ns);
|
2014-08-15 01:21:53 +03:00
|
|
|
} else {
|
2012-04-16 22:20:35 -03:00
|
|
|
planea_wm = fifo_size - wm_info->guard_size;
|
2014-08-15 01:21:53 +03:00
|
|
|
if (planea_wm > (long)wm_info->max_wm)
|
|
|
|
|
planea_wm = wm_info->max_wm;
|
|
|
|
|
}
|
|
|
|
|
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) == 2)
|
2014-08-15 01:21:53 +03:00
|
|
|
wm_info = &i830_bc_wm_info;
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2021-09-29 01:57:46 +03:00
|
|
|
if (DISPLAY_VER(dev_priv) == 2)
|
|
|
|
|
fifo_size = i830_get_fifo_size(dev_priv, PLANE_B);
|
|
|
|
|
else
|
|
|
|
|
fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_B);
|
2021-12-01 15:57:05 +02:00
|
|
|
crtc = intel_crtc_for_plane(dev_priv, PLANE_B);
|
2016-10-31 22:37:04 +02:00
|
|
|
if (intel_crtc_active(crtc)) {
|
|
|
|
|
const struct drm_framebuffer *fb =
|
|
|
|
|
crtc->base.primary->state->fb;
|
|
|
|
|
int cpp;
|
|
|
|
|
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) == 2)
|
2012-10-22 12:32:15 +01:00
|
|
|
cpp = 4;
|
2016-10-31 22:37:04 +02:00
|
|
|
else
|
2016-12-14 23:30:57 +02:00
|
|
|
cpp = fb->format->cpp[0];
|
2012-10-22 12:32:15 +01:00
|
|
|
|
2021-12-09 16:43:09 +02:00
|
|
|
planeb_wm = intel_calculate_wm(crtc->config->pixel_rate,
|
2012-10-22 12:32:15 +01:00
|
|
|
wm_info, fifo_size, cpp,
|
2014-09-03 11:56:07 +01:00
|
|
|
pessimal_latency_ns);
|
2014-08-15 01:21:53 +03:00
|
|
|
} else {
|
2012-04-16 22:20:35 -03:00
|
|
|
planeb_wm = fifo_size - wm_info->guard_size;
|
2014-08-15 01:21:53 +03:00
|
|
|
if (planeb_wm > (long)wm_info->max_wm)
|
|
|
|
|
planeb_wm = wm_info->max_wm;
|
|
|
|
|
}
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"FIFO watermarks - A: %d, B: %d\n", planea_wm, planeb_wm);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2021-12-09 16:43:11 +02:00
|
|
|
crtc = single_enabled_crtc(dev_priv);
|
|
|
|
|
if (IS_I915GM(dev_priv) && crtc) {
|
2014-07-08 07:50:07 -07:00
|
|
|
struct drm_i915_gem_object *obj;
|
2014-04-07 08:54:21 +02:00
|
|
|
|
2021-12-09 16:43:11 +02:00
|
|
|
obj = intel_fb_obj(crtc->base.primary->state->fb);
|
2014-04-07 08:54:21 +02:00
|
|
|
|
|
|
|
|
/* self-refresh seems busted with untiled */
|
2016-08-05 10:14:23 +01:00
|
|
|
if (!i915_gem_object_is_tiled(obj))
|
2021-12-09 16:43:11 +02:00
|
|
|
crtc = NULL;
|
2014-04-07 08:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-16 22:20:35 -03: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 12:36:17 +03:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
|
|
|
|
/* Calc sr entries for one plane configs */
|
2021-12-09 16:43:11 +02:00
|
|
|
if (HAS_FW_BLC(dev_priv) && crtc) {
|
2012-04-16 22:20:35 -03:00
|
|
|
/* self-refresh has much higher latency */
|
|
|
|
|
static const int sr_latency_ns = 6000;
|
2020-11-12 21:17:18 +02:00
|
|
|
const struct drm_display_mode *pipe_mode =
|
2021-12-09 16:43:11 +02:00
|
|
|
&crtc->config->hw.pipe_mode;
|
2016-10-31 22:37:04 +02:00
|
|
|
const struct drm_framebuffer *fb =
|
2021-12-09 16:43:11 +02:00
|
|
|
crtc->base.primary->state->fb;
|
|
|
|
|
int pixel_rate = crtc->config->pixel_rate;
|
2020-11-12 21:17:18 +02:00
|
|
|
int htotal = pipe_mode->crtc_htotal;
|
2021-12-09 16:43:11 +02:00
|
|
|
int width = drm_rect_width(&crtc->base.primary->state->src) >> 16;
|
2016-10-31 22:37:04 +02:00
|
|
|
int cpp;
|
2012-04-16 22:20:35 -03:00
|
|
|
int entries;
|
|
|
|
|
|
2016-10-13 11:02:58 +01:00
|
|
|
if (IS_I915GM(dev_priv) || IS_I945GM(dev_priv))
|
2016-07-29 17:57:01 +03:00
|
|
|
cpp = 4;
|
2016-10-31 22:37:04 +02:00
|
|
|
else
|
2016-12-14 23:30:57 +02:00
|
|
|
cpp = fb->format->cpp[0];
|
2016-07-29 17:57:01 +03:00
|
|
|
|
2021-12-09 16:43:10 +02:00
|
|
|
entries = intel_wm_method2(pixel_rate, htotal, width, cpp,
|
2017-04-21 21:14:27 +03:00
|
|
|
sr_latency_ns / 100);
|
2012-04-16 22:20:35 -03:00
|
|
|
entries = DIV_ROUND_UP(entries, wm_info->cacheline_size);
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"self-refresh entries: %d\n", entries);
|
2012-04-16 22:20:35 -03:00
|
|
|
srwm = wm_info->fifo_size - entries;
|
|
|
|
|
if (srwm < 0)
|
|
|
|
|
srwm = 1;
|
|
|
|
|
|
2016-10-13 11:02:58 +01:00
|
|
|
if (IS_I945G(dev_priv) || IS_I945GM(dev_priv))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, FW_BLC_SELF,
|
2012-04-16 22:20:35 -03:00
|
|
|
FW_BLC_SELF_FIFO_MASK | (srwm & 0xff));
|
2016-07-29 17:57:02 +03:00
|
|
|
else
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, FW_BLC_SELF, srwm & 0x3f);
|
2012-04-16 22:20:35 -03:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 18:13:30 +03: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-16 22:20:35 -03: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);
|
|
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, FW_BLC, fwater_lo);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, FW_BLC2, fwater_hi);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2021-12-09 16:43:11 +02:00
|
|
|
if (crtc)
|
2014-07-01 12:36:17 +03:00
|
|
|
intel_set_memory_cxsr(dev_priv, true);
|
2012-04-16 22:20:35 -03:00
|
|
|
}
|
|
|
|
|
|
2021-09-29 01:57:47 +03:00
|
|
|
static void i845_update_wm(struct drm_i915_private *dev_priv)
|
2012-04-16 22:20:35 -03:00
|
|
|
{
|
2016-10-31 22:37:04 +02:00
|
|
|
struct intel_crtc *crtc;
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 fwater_lo;
|
2012-04-16 22:20:35 -03:00
|
|
|
int planea_wm;
|
|
|
|
|
|
2016-10-31 22:37:21 +02:00
|
|
|
crtc = single_enabled_crtc(dev_priv);
|
2012-04-16 22:20:35 -03:00
|
|
|
if (crtc == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-12-09 16:43:09 +02:00
|
|
|
planea_wm = intel_calculate_wm(crtc->config->pixel_rate,
|
2013-12-14 20:38:30 -02:00
|
|
|
&i845_wm_info,
|
2021-09-29 01:57:46 +03:00
|
|
|
i845_get_fifo_size(dev_priv, PLANE_A),
|
2014-09-03 11:56:07 +01:00
|
|
|
4, pessimal_latency_ns);
|
2020-11-30 13:15:58 +02:00
|
|
|
fwater_lo = intel_uncore_read(&dev_priv->uncore, FW_BLC) & ~0xfff;
|
2012-04-16 22:20:35 -03:00
|
|
|
fwater_lo |= (3<<8) | planea_wm;
|
|
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"Setting FIFO watermarks - A: %d\n", planea_wm);
|
2012-04-16 22:20:35 -03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, FW_BLC, fwater_lo);
|
2012-04-16 22:20:35 -03:00
|
|
|
}
|
|
|
|
|
|
2013-08-01 16:18:55 +03:00
|
|
|
/* latency must be in 0.1us units. */
|
2017-04-21 21:14:27 +03:00
|
|
|
static unsigned int ilk_wm_method1(unsigned int pixel_rate,
|
|
|
|
|
unsigned int cpp,
|
|
|
|
|
unsigned int latency)
|
2013-05-31 10:08:35 -03:00
|
|
|
{
|
2017-04-21 21:14:27 +03:00
|
|
|
unsigned int ret;
|
2013-08-01 16:18:53 +03:00
|
|
|
|
2017-04-21 21:14:27 +03:00
|
|
|
ret = intel_wm_method1(pixel_rate, cpp, latency);
|
|
|
|
|
ret = DIV_ROUND_UP(ret, 64) + 2;
|
2013-05-31 10:08:35 -03:00
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-01 16:18:55 +03:00
|
|
|
/* latency must be in 0.1us units. */
|
2017-04-21 21:14:27 +03: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 10:08:35 -03:00
|
|
|
{
|
2017-04-21 21:14:27 +03:00
|
|
|
unsigned int ret;
|
2013-08-01 16:18:53 +03:00
|
|
|
|
2017-04-21 21:14:27 +03:00
|
|
|
ret = intel_wm_method2(pixel_rate, htotal,
|
|
|
|
|
width, cpp, latency);
|
2013-05-31 10:08:35 -03:00
|
|
|
ret = DIV_ROUND_UP(ret, 64) + 2;
|
2017-04-21 21:14:27 +03:00
|
|
|
|
2013-05-31 10:08:35 -03:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 14:01:20 +02:00
|
|
|
static u32 ilk_wm_fbc(u32 pri_val, u32 horiz_pixels, u8 cpp)
|
2013-05-31 11:45:06 -03:00
|
|
|
{
|
2015-12-03 11:37:40 -08: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 21:05:26 +02:00
|
|
|
if (WARN_ON(!cpp))
|
2015-12-03 11:37:40 -08:00
|
|
|
return 0;
|
|
|
|
|
if (WARN_ON(!horiz_pixels))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2016-01-20 21:05:26 +02:00
|
|
|
return DIV_ROUND_UP(pri_val * 64, horiz_pixels * cpp) + 2;
|
2013-05-31 11:45:06 -03:00
|
|
|
}
|
|
|
|
|
|
2013-12-17 14:46:36 +02:00
|
|
|
struct ilk_wm_maximums {
|
2019-01-18 14:01:20 +02:00
|
|
|
u16 pri;
|
|
|
|
|
u16 spr;
|
|
|
|
|
u16 cur;
|
|
|
|
|
u16 fbc;
|
2013-05-31 11:45:06 -03:00
|
|
|
};
|
|
|
|
|
|
2013-08-01 16:18:55 +03:00
|
|
|
/*
|
|
|
|
|
* For both WM_PIPE and WM_LP.
|
|
|
|
|
* mem_value must be in 0.1us units.
|
|
|
|
|
*/
|
2019-06-28 10:55:17 +02:00
|
|
|
static u32 ilk_compute_pri_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 mem_value, bool is_lp)
|
2013-05-31 10:08:35 -03:00
|
|
|
{
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 method1, method2;
|
2016-11-18 21:53:00 +02:00
|
|
|
int cpp;
|
2013-05-31 11:45:06 -03:00
|
|
|
|
2018-11-14 19:34:40 +02:00
|
|
|
if (mem_value == 0)
|
|
|
|
|
return U32_MAX;
|
|
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2013-05-31 10:08:35 -03:00
|
|
|
return 0;
|
|
|
|
|
|
2019-10-31 12:26:07 +01:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2016-11-18 21:53:00 +02:00
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
method1 = ilk_wm_method1(crtc_state->pixel_rate, cpp, mem_value);
|
2013-05-31 11:45:06 -03:00
|
|
|
|
|
|
|
|
if (!is_lp)
|
|
|
|
|
return method1;
|
|
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
method2 = ilk_wm_method2(crtc_state->pixel_rate,
|
2020-11-12 21:17:18 +02:00
|
|
|
crtc_state->hw.pipe_mode.crtc_htotal,
|
2021-12-09 16:43:10 +02:00
|
|
|
drm_rect_width(&plane_state->uapi.src) >> 16,
|
2016-01-20 21:05:26 +02:00
|
|
|
cpp, mem_value);
|
2013-05-31 11:45:06 -03:00
|
|
|
|
|
|
|
|
return min(method1, method2);
|
2013-05-31 10:08:35 -03:00
|
|
|
}
|
|
|
|
|
|
2013-08-01 16:18:55 +03:00
|
|
|
/*
|
|
|
|
|
* For both WM_PIPE and WM_LP.
|
|
|
|
|
* mem_value must be in 0.1us units.
|
|
|
|
|
*/
|
2019-06-28 10:55:17 +02:00
|
|
|
static u32 ilk_compute_spr_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 mem_value)
|
2013-05-31 10:08:35 -03:00
|
|
|
{
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 method1, method2;
|
2016-11-18 21:53:00 +02:00
|
|
|
int cpp;
|
2013-05-31 10:08:35 -03:00
|
|
|
|
2018-11-14 19:34:40 +02:00
|
|
|
if (mem_value == 0)
|
|
|
|
|
return U32_MAX;
|
|
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2013-05-31 10:08:35 -03:00
|
|
|
return 0;
|
|
|
|
|
|
2019-10-31 12:26:07 +01:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2016-11-18 21:53:00 +02:00
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
method1 = ilk_wm_method1(crtc_state->pixel_rate, cpp, mem_value);
|
|
|
|
|
method2 = ilk_wm_method2(crtc_state->pixel_rate,
|
2020-11-12 21:17:18 +02:00
|
|
|
crtc_state->hw.pipe_mode.crtc_htotal,
|
2021-12-09 16:43:10 +02:00
|
|
|
drm_rect_width(&plane_state->uapi.src) >> 16,
|
2016-01-20 21:05:26 +02:00
|
|
|
cpp, mem_value);
|
2013-05-31 10:08:35 -03:00
|
|
|
return min(method1, method2);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-01 16:18:55 +03:00
|
|
|
/*
|
|
|
|
|
* For both WM_PIPE and WM_LP.
|
|
|
|
|
* mem_value must be in 0.1us units.
|
|
|
|
|
*/
|
2019-06-28 10:55:17 +02:00
|
|
|
static u32 ilk_compute_cur_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 mem_value)
|
2013-05-31 10:08:35 -03:00
|
|
|
{
|
2017-02-17 17:01:59 +02:00
|
|
|
int cpp;
|
|
|
|
|
|
2018-11-14 19:34:40 +02:00
|
|
|
if (mem_value == 0)
|
|
|
|
|
return U32_MAX;
|
|
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2013-05-31 10:08:35 -03:00
|
|
|
return 0;
|
|
|
|
|
|
2019-10-31 12:26:07 +01:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2017-02-17 17:01:59 +02:00
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
return ilk_wm_method2(crtc_state->pixel_rate,
|
2020-11-12 21:17:18 +02:00
|
|
|
crtc_state->hw.pipe_mode.crtc_htotal,
|
2021-12-09 16:43:10 +02:00
|
|
|
drm_rect_width(&plane_state->uapi.src) >> 16,
|
2019-10-04 13:34:54 +02:00
|
|
|
cpp, mem_value);
|
2013-05-31 10:08:35 -03:00
|
|
|
}
|
|
|
|
|
|
2013-05-31 11:45:06 -03:00
|
|
|
/* Only for WM_LP. */
|
2019-06-28 10:55:17 +02:00
|
|
|
static u32 ilk_compute_fbc_wm(const struct intel_crtc_state *crtc_state,
|
|
|
|
|
const struct intel_plane_state *plane_state,
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 pri_val)
|
2013-05-31 11:45:06 -03:00
|
|
|
{
|
2016-11-18 21:53:00 +02:00
|
|
|
int cpp;
|
2015-09-24 15:53:07 -07:00
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
if (!intel_wm_plane_visible(crtc_state, plane_state))
|
2013-05-31 11:45:06 -03:00
|
|
|
return 0;
|
|
|
|
|
|
2019-10-31 12:26:07 +01:00
|
|
|
cpp = plane_state->hw.fb->format->cpp[0];
|
2016-11-18 21:53:00 +02:00
|
|
|
|
2021-12-09 16:43:10 +02:00
|
|
|
return ilk_wm_fbc(pri_val, drm_rect_width(&plane_state->uapi.src) >> 16,
|
2019-10-31 12:26:08 +01:00
|
|
|
cpp);
|
2013-05-31 11:45:06 -03: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 13:28:19 +03:00
|
|
|
{
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 8)
|
2013-11-02 21:07:46 -07:00
|
|
|
return 3072;
|
2021-03-19 21:42:43 -07:00
|
|
|
else if (DISPLAY_VER(dev_priv) >= 7)
|
2013-08-07 13:28:19 +03: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 18:32:11 +02:00
|
|
|
{
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 8)
|
2014-03-07 18:32:11 +02:00
|
|
|
/* BDW primary/sprite plane watermarks */
|
|
|
|
|
return level == 0 ? 255 : 2047;
|
2021-03-19 21:42:43 -07:00
|
|
|
else if (DISPLAY_VER(dev_priv) >= 7)
|
2014-03-07 18:32:11 +02: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 18:32:11 +02:00
|
|
|
{
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 7)
|
2014-03-07 18:32:11 +02: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 18:32:11 +02:00
|
|
|
{
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 8)
|
2014-03-07 18:32:11 +02:00
|
|
|
return 31;
|
|
|
|
|
else
|
|
|
|
|
return 15;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-07 13:28:19 +03:00
|
|
|
/* Calculate the maximum primary/sprite plane watermark */
|
2018-12-10 13:54:14 -08:00
|
|
|
static unsigned int ilk_plane_wm_max(const struct drm_i915_private *dev_priv,
|
2013-08-07 13:28:19 +03:00
|
|
|
int level,
|
2013-08-07 13:29:12 +03:00
|
|
|
const struct intel_wm_config *config,
|
2013-08-07 13:28:19 +03: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 13:28:19 +03:00
|
|
|
|
|
|
|
|
/* if sprites aren't enabled, sprites get nothing */
|
2013-08-07 13:29:12 +03:00
|
|
|
if (is_sprite && !config->sprites_enabled)
|
2013-08-07 13:28:19 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* HSW allows LP1+ watermarks even with multiple pipes */
|
2013-08-07 13:29:12 +03:00
|
|
|
if (level == 0 || config->num_pipes_active > 1) {
|
2019-09-11 12:26:08 +03:00
|
|
|
fifo_size /= INTEL_NUM_PIPES(dev_priv);
|
2013-08-07 13:28:19 +03:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* For some reason the non self refresh
|
|
|
|
|
* FIFO size is only half of the self
|
|
|
|
|
* refresh FIFO size on ILK/SNB.
|
|
|
|
|
*/
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) <= 6)
|
2013-08-07 13:28:19 +03:00
|
|
|
fifo_size /= 2;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-07 13:29:12 +03:00
|
|
|
if (config->sprites_enabled) {
|
2013-08-07 13:28:19 +03: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 13:28:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Calculate the maximum cursor plane watermark */
|
2018-12-10 13:54:14 -08:00
|
|
|
static unsigned int ilk_cursor_wm_max(const struct drm_i915_private *dev_priv,
|
2013-08-07 13:29:12 +03:00
|
|
|
int level,
|
|
|
|
|
const struct intel_wm_config *config)
|
2013-08-07 13:28:19 +03:00
|
|
|
{
|
|
|
|
|
/* HSW LP1+ watermarks w/ multiple pipes */
|
2013-08-07 13:29:12 +03:00
|
|
|
if (level > 0 && config->num_pipes_active > 1)
|
2013-08-07 13:28:19 +03:00
|
|
|
return 64;
|
|
|
|
|
|
|
|
|
|
/* otherwise just report max that registers can hold */
|
2018-12-10 13:54:14 -08:00
|
|
|
return ilk_cursor_wm_reg_max(dev_priv, level);
|
2013-08-07 13:28:19 +03:00
|
|
|
}
|
|
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
static void ilk_compute_wm_maximums(const struct drm_i915_private *dev_priv,
|
2013-10-09 19:18:09 +03:00
|
|
|
int level,
|
|
|
|
|
const struct intel_wm_config *config,
|
|
|
|
|
enum intel_ddb_partitioning ddb_partitioning,
|
2013-12-17 14:46:36 +02:00
|
|
|
struct ilk_wm_maximums *max)
|
2013-08-07 13:28:19 +03:00
|
|
|
{
|
2018-12-10 13:54:14 -08: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 13:28:19 +03: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 15:44:56 +03: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 15:44:56 +03:00
|
|
|
}
|
|
|
|
|
|
2013-10-09 19:18:10 +03:00
|
|
|
static bool ilk_validate_wm_level(int level,
|
2013-12-17 14:46:36 +02:00
|
|
|
const struct ilk_wm_maximums *max,
|
2013-10-09 19:18:10 +03:00
|
|
|
struct intel_wm_level *result)
|
2013-08-07 13:24:47 +03: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 14:01:20 +02: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 13:24:47 +03: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,
|
2020-02-25 19:11:06 +02:00
|
|
|
const struct intel_crtc *crtc,
|
2013-08-06 22:24:02 +03:00
|
|
|
int level,
|
2019-06-28 10:55:17 +02:00
|
|
|
struct intel_crtc_state *crtc_state,
|
2017-10-19 17:13:40 +02:00
|
|
|
const struct intel_plane_state *pristate,
|
|
|
|
|
const struct intel_plane_state *sprstate,
|
|
|
|
|
const struct intel_plane_state *curstate,
|
2013-08-06 22:24:05 +03:00
|
|
|
struct intel_wm_level *result)
|
2013-08-06 22:24:02 +03:00
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
u16 pri_latency = dev_priv->display.wm.pri_latency[level];
|
|
|
|
|
u16 spr_latency = dev_priv->display.wm.spr_latency[level];
|
|
|
|
|
u16 cur_latency = dev_priv->display.wm.cur_latency[level];
|
2013-08-06 22:24:02 +03:00
|
|
|
|
|
|
|
|
/* WM1+ latency values stored in 0.5us units */
|
|
|
|
|
if (level > 0) {
|
|
|
|
|
pri_latency *= 5;
|
|
|
|
|
spr_latency *= 5;
|
|
|
|
|
cur_latency *= 5;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-01 11:07:22 +01:00
|
|
|
if (pristate) {
|
2019-06-28 10:55:17 +02:00
|
|
|
result->pri_val = ilk_compute_pri_wm(crtc_state, pristate,
|
2016-03-01 11:07:22 +01:00
|
|
|
pri_latency, level);
|
2019-06-28 10:55:17 +02:00
|
|
|
result->fbc_val = ilk_compute_fbc_wm(crtc_state, pristate, result->pri_val);
|
2016-03-01 11:07:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sprstate)
|
2019-06-28 10:55:17 +02:00
|
|
|
result->spr_val = ilk_compute_spr_wm(crtc_state, sprstate, spr_latency);
|
2016-03-01 11:07:22 +01:00
|
|
|
|
|
|
|
|
if (curstate)
|
2019-06-28 10:55:17 +02:00
|
|
|
result->cur_val = ilk_compute_cur_wm(crtc_state, curstate, cur_latency);
|
2016-03-01 11:07:22 +01:00
|
|
|
|
2013-08-06 22:24:02 +03:00
|
|
|
result->enable = true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:44 +03:00
|
|
|
static void hsw_read_wm_latency(struct drm_i915_private *i915, u16 wm[])
|
2022-08-18 16:41:54 -07:00
|
|
|
{
|
2022-09-08 22:16:44 +03:00
|
|
|
u64 sskpd;
|
2022-08-18 16:41:54 -07:00
|
|
|
|
2022-09-08 22:16:44 +03:00
|
|
|
sskpd = intel_uncore_read64(&i915->uncore, MCH_SSKPD);
|
2022-08-18 16:41:54 -07:00
|
|
|
|
2022-09-08 22:16:44 +03:00
|
|
|
wm[0] = REG_FIELD_GET64(SSKPD_NEW_WM0_MASK_HSW, sskpd);
|
|
|
|
|
if (wm[0] == 0)
|
|
|
|
|
wm[0] = REG_FIELD_GET64(SSKPD_OLD_WM0_MASK_HSW, sskpd);
|
|
|
|
|
wm[1] = REG_FIELD_GET64(SSKPD_WM1_MASK_HSW, sskpd);
|
|
|
|
|
wm[2] = REG_FIELD_GET64(SSKPD_WM2_MASK_HSW, sskpd);
|
|
|
|
|
wm[3] = REG_FIELD_GET64(SSKPD_WM3_MASK_HSW, sskpd);
|
|
|
|
|
wm[4] = REG_FIELD_GET64(SSKPD_WM4_MASK_HSW, sskpd);
|
|
|
|
|
}
|
2022-08-18 16:41:54 -07:00
|
|
|
|
2022-09-08 22:16:44 +03:00
|
|
|
static void snb_read_wm_latency(struct drm_i915_private *i915, u16 wm[])
|
|
|
|
|
{
|
|
|
|
|
u32 sskpd;
|
2022-08-18 16:41:54 -07:00
|
|
|
|
2022-09-08 22:16:44 +03:00
|
|
|
sskpd = intel_uncore_read(&i915->uncore, MCH_SSKPD);
|
|
|
|
|
|
|
|
|
|
wm[0] = REG_FIELD_GET(SSKPD_WM0_MASK_SNB, sskpd);
|
|
|
|
|
wm[1] = REG_FIELD_GET(SSKPD_WM1_MASK_SNB, sskpd);
|
|
|
|
|
wm[2] = REG_FIELD_GET(SSKPD_WM2_MASK_SNB, sskpd);
|
|
|
|
|
wm[3] = REG_FIELD_GET(SSKPD_WM3_MASK_SNB, sskpd);
|
2022-08-18 16:41:54 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:44 +03:00
|
|
|
static void ilk_read_wm_latency(struct drm_i915_private *i915, u16 wm[])
|
2013-07-05 11:57:21 +03:00
|
|
|
{
|
2022-09-08 22:16:44 +03:00
|
|
|
u32 mltr;
|
2014-11-04 17:06:38 +00:00
|
|
|
|
2022-09-08 22:16:44 +03:00
|
|
|
mltr = intel_uncore_read(&i915->uncore, MLTR_ILK);
|
2014-11-04 17:06:38 +00:00
|
|
|
|
2022-09-08 22:16:44 +03:00
|
|
|
/* ILK primary LP0 latency is 700 ns */
|
|
|
|
|
wm[0] = 7;
|
|
|
|
|
wm[1] = REG_FIELD_GET(MLTR_WM1_MASK, mltr);
|
|
|
|
|
wm[2] = REG_FIELD_GET(MLTR_WM2_MASK, mltr);
|
2013-07-05 11:57:21 +03:00
|
|
|
}
|
|
|
|
|
|
2016-10-13 11:03:10 +01:00
|
|
|
static void intel_fixup_spr_wm_latency(struct drm_i915_private *dev_priv,
|
2019-01-18 14:01:20 +02:00
|
|
|
u16 wm[5])
|
2013-08-01 16:18:50 +03:00
|
|
|
{
|
|
|
|
|
/* ILK sprite LP0 latency is 1300 ns */
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) == 5)
|
2013-08-01 16:18:50 +03:00
|
|
|
wm[0] = 13;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-14 10:13:06 +01:00
|
|
|
static void intel_fixup_cur_wm_latency(struct drm_i915_private *dev_priv,
|
2019-01-18 14:01:20 +02:00
|
|
|
u16 wm[5])
|
2013-08-01 16:18:50 +03:00
|
|
|
{
|
|
|
|
|
/* ILK cursor LP0 latency is 1300 ns */
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) == 5)
|
2013-08-01 16:18:50 +03:00
|
|
|
wm[0] = 13;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 11:03:10 +01:00
|
|
|
int ilk_wm_max_level(const struct drm_i915_private *dev_priv)
|
2013-08-01 16:18:52 +03:00
|
|
|
{
|
|
|
|
|
/* how many WM levels are we expecting */
|
2021-05-18 17:06:11 -07:00
|
|
|
if (HAS_HW_SAGV_WM(dev_priv))
|
|
|
|
|
return 5;
|
|
|
|
|
else if (DISPLAY_VER(dev_priv) >= 9)
|
2014-11-04 17:06:38 +00:00
|
|
|
return 7;
|
2016-10-13 11:03:00 +01:00
|
|
|
else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
|
2013-08-30 14:30:25 +03:00
|
|
|
return 4;
|
2021-03-19 21:42:43 -07:00
|
|
|
else if (DISPLAY_VER(dev_priv) >= 6)
|
2013-08-30 14:30:25 +03:00
|
|
|
return 3;
|
2013-08-01 16:18:52 +03:00
|
|
|
else
|
2013-08-30 14:30:25 +03:00
|
|
|
return 2;
|
|
|
|
|
}
|
2014-09-29 15:07:19 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
void intel_print_wm_latency(struct drm_i915_private *dev_priv,
|
|
|
|
|
const char *name, const u16 wm[])
|
2013-08-30 14:30:25 +03:00
|
|
|
{
|
2016-10-13 11:03:10 +01:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2013-08-01 16:18:52 +03:00
|
|
|
|
|
|
|
|
for (level = 0; level <= max_level; level++) {
|
|
|
|
|
unsigned int latency = wm[level];
|
|
|
|
|
|
|
|
|
|
if (latency == 0) {
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"%s WM%d latency not provided\n",
|
|
|
|
|
name, level);
|
2013-08-01 16:18:52 +03: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
|
|
|
|
|
*/
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 9)
|
2014-11-04 17:06:38 +00:00
|
|
|
latency *= 10;
|
|
|
|
|
else if (level > 0)
|
2013-08-01 16:18:52 +03:00
|
|
|
latency *= 5;
|
|
|
|
|
|
2020-01-07 18:13:30 +03: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 16:18:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 15:09:19 +03:00
|
|
|
static bool ilk_increase_wm_latency(struct drm_i915_private *dev_priv,
|
2019-01-18 14:01:20 +02:00
|
|
|
u16 wm[5], u16 min)
|
2014-05-08 15:09:19 +03:00
|
|
|
{
|
2016-10-13 11:03:10 +01:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2014-05-08 15:09:19 +03:00
|
|
|
|
|
|
|
|
if (wm[0] >= min)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
wm[0] = max(wm[0], min);
|
|
|
|
|
for (level = 1; level <= max_level; level++)
|
2019-01-18 14:01:20 +02:00
|
|
|
wm[level] = max_t(u16, wm[level], DIV_ROUND_UP(min, 5));
|
2014-05-08 15:09:19 +03:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:24 +02:00
|
|
|
static void snb_wm_latency_quirk(struct drm_i915_private *dev_priv)
|
2014-05-08 15:09:19 +03:00
|
|
|
{
|
|
|
|
|
bool changed;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The BIOS provided WM memory latency values are often
|
|
|
|
|
* inadequate for high resolution displays. Adjust them.
|
|
|
|
|
*/
|
2022-08-24 16:15:40 +03:00
|
|
|
changed = ilk_increase_wm_latency(dev_priv, dev_priv->display.wm.pri_latency, 12);
|
|
|
|
|
changed |= ilk_increase_wm_latency(dev_priv, dev_priv->display.wm.spr_latency, 12);
|
|
|
|
|
changed |= ilk_increase_wm_latency(dev_priv, dev_priv->display.wm.cur_latency, 12);
|
2014-05-08 15:09:19 +03:00
|
|
|
|
|
|
|
|
if (!changed)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"WM latency values increased to avoid potential underruns\n");
|
2022-08-24 16:15:40 +03:00
|
|
|
intel_print_wm_latency(dev_priv, "Primary", dev_priv->display.wm.pri_latency);
|
|
|
|
|
intel_print_wm_latency(dev_priv, "Sprite", dev_priv->display.wm.spr_latency);
|
|
|
|
|
intel_print_wm_latency(dev_priv, "Cursor", dev_priv->display.wm.cur_latency);
|
2014-05-08 15:09:19 +03:00
|
|
|
}
|
|
|
|
|
|
2018-11-14 19:34:40 +02: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.
|
|
|
|
|
*/
|
2022-08-24 16:15:40 +03:00
|
|
|
if (dev_priv->display.wm.pri_latency[3] == 0 &&
|
|
|
|
|
dev_priv->display.wm.spr_latency[3] == 0 &&
|
|
|
|
|
dev_priv->display.wm.cur_latency[3] == 0)
|
2018-11-14 19:34:40 +02:00
|
|
|
return;
|
|
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.pri_latency[3] = 0;
|
|
|
|
|
dev_priv->display.wm.spr_latency[3] = 0;
|
|
|
|
|
dev_priv->display.wm.cur_latency[3] = 0;
|
2018-11-14 19:34:40 +02:00
|
|
|
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"LP3 watermarks disabled due to potential for lost interrupts\n");
|
2022-08-24 16:15:40 +03:00
|
|
|
intel_print_wm_latency(dev_priv, "Primary", dev_priv->display.wm.pri_latency);
|
|
|
|
|
intel_print_wm_latency(dev_priv, "Sprite", dev_priv->display.wm.spr_latency);
|
|
|
|
|
intel_print_wm_latency(dev_priv, "Cursor", dev_priv->display.wm.cur_latency);
|
2018-11-14 19:34:40 +02:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:24 +02:00
|
|
|
static void ilk_setup_wm_latency(struct drm_i915_private *dev_priv)
|
2013-08-01 16:18:50 +03:00
|
|
|
{
|
2022-09-08 22:16:44 +03:00
|
|
|
if (IS_BROADWELL(dev_priv) || IS_HASWELL(dev_priv))
|
|
|
|
|
hsw_read_wm_latency(dev_priv, dev_priv->display.wm.pri_latency);
|
|
|
|
|
else if (DISPLAY_VER(dev_priv) >= 6)
|
|
|
|
|
snb_read_wm_latency(dev_priv, dev_priv->display.wm.pri_latency);
|
|
|
|
|
else
|
|
|
|
|
ilk_read_wm_latency(dev_priv, dev_priv->display.wm.pri_latency);
|
2013-08-01 16:18:50 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
memcpy(dev_priv->display.wm.spr_latency, dev_priv->display.wm.pri_latency,
|
|
|
|
|
sizeof(dev_priv->display.wm.pri_latency));
|
|
|
|
|
memcpy(dev_priv->display.wm.cur_latency, dev_priv->display.wm.pri_latency,
|
|
|
|
|
sizeof(dev_priv->display.wm.pri_latency));
|
2013-08-01 16:18:50 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
intel_fixup_spr_wm_latency(dev_priv, dev_priv->display.wm.spr_latency);
|
|
|
|
|
intel_fixup_cur_wm_latency(dev_priv, dev_priv->display.wm.cur_latency);
|
2013-08-01 16:18:52 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
intel_print_wm_latency(dev_priv, "Primary", dev_priv->display.wm.pri_latency);
|
|
|
|
|
intel_print_wm_latency(dev_priv, "Sprite", dev_priv->display.wm.spr_latency);
|
|
|
|
|
intel_print_wm_latency(dev_priv, "Cursor", dev_priv->display.wm.cur_latency);
|
2014-05-08 15:09:19 +03:00
|
|
|
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) == 6) {
|
2016-10-31 22:37:24 +02:00
|
|
|
snb_wm_latency_quirk(dev_priv);
|
2018-11-14 19:34:40 +02:00
|
|
|
snb_wm_lp3_irq_quirk(dev_priv);
|
|
|
|
|
}
|
2013-08-01 16:18:50 +03:00
|
|
|
}
|
|
|
|
|
|
2018-12-10 13:54:14 -08: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-23 17:20:13 -08: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 13:54:14 -08: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-23 17:20:13 -08:00
|
|
|
|
|
|
|
|
/* At least LP0 must be valid */
|
|
|
|
|
if (!ilk_validate_wm_level(0, &max, &pipe_wm->wm[0])) {
|
2020-01-07 18:13:30 +03: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-23 17:20:13 -08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-09 19:17:55 +03:00
|
|
|
/* Compute new watermarks for the pipe */
|
2021-06-09 11:56:30 +03:00
|
|
|
static int ilk_compute_pipe_wm(struct intel_atomic_state *state,
|
|
|
|
|
struct intel_crtc *crtc)
|
2013-10-09 19:17:55 +03:00
|
|
|
{
|
2021-06-09 11:56:30 +03:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(state->base.dev);
|
|
|
|
|
struct intel_crtc_state *crtc_state =
|
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
2015-09-24 15:53:16 -07:00
|
|
|
struct intel_pipe_wm *pipe_wm;
|
2019-10-04 13:34:53 +02:00
|
|
|
struct intel_plane *plane;
|
|
|
|
|
const struct intel_plane_state *plane_state;
|
2017-10-19 17:13:40 +02: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 11:03:10 +01:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv), usable_level;
|
2013-12-17 14:46:36 +02:00
|
|
|
struct ilk_wm_maximums max;
|
2013-10-09 19:17:55 +03:00
|
|
|
|
2019-06-28 10:55:17 +02:00
|
|
|
pipe_wm = &crtc_state->wm.ilk.optimal;
|
2015-09-24 15:53:16 -07:00
|
|
|
|
2019-10-04 13:34:53 +02: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 15:53:07 -07:00
|
|
|
}
|
|
|
|
|
|
2019-10-31 12:26:02 +01:00
|
|
|
pipe_wm->pipe_enabled = crtc_state->hw.active;
|
2022-02-11 11:06:25 +02:00
|
|
|
pipe_wm->sprites_enabled = crtc_state->active_planes & BIT(PLANE_SPRITE0);
|
|
|
|
|
pipe_wm->sprites_scaled = crtc_state->scaled_planes & BIT(PLANE_SPRITE0);
|
2016-03-01 11:07:22 +01:00
|
|
|
|
2016-03-02 12:38:06 +01:00
|
|
|
usable_level = max_level;
|
|
|
|
|
|
2013-12-05 15:51:30 +02:00
|
|
|
/* ILK/SNB: LP2+ watermarks only w/o sprites */
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) <= 6 && pipe_wm->sprites_enabled)
|
2016-03-02 12:38:06 +01:00
|
|
|
usable_level = 1;
|
2013-12-05 15:51:30 +02: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-23 17:20:13 -08:00
|
|
|
if (pipe_wm->sprites_scaled)
|
2016-03-02 12:38:06 +01:00
|
|
|
usable_level = 0;
|
2013-12-05 15:51:30 +02:00
|
|
|
|
2016-03-08 10:57:16 +01:00
|
|
|
memset(&pipe_wm->wm, 0, sizeof(pipe_wm->wm));
|
2020-02-25 19:11:06 +02:00
|
|
|
ilk_compute_wm_level(dev_priv, crtc, 0, crtc_state,
|
2017-10-19 17:13:40 +02:00
|
|
|
pristate, sprstate, curstate, &pipe_wm->wm[0]);
|
2013-10-09 19:17:55 +03:00
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
if (!ilk_validate_pipe_wm(dev_priv, pipe_wm))
|
2016-03-02 12:36:03 +01:00
|
|
|
return -EINVAL;
|
2014-04-28 15:44:56 +03:00
|
|
|
|
2016-11-16 08:55:42 +00:00
|
|
|
ilk_compute_wm_reg_maximums(dev_priv, 1, &max);
|
2014-04-28 15:44:56 +03:00
|
|
|
|
2017-10-19 17:13:40 +02:00
|
|
|
for (level = 1; level <= usable_level; level++) {
|
|
|
|
|
struct intel_wm_level *wm = &pipe_wm->wm[level];
|
2014-04-28 15:44:56 +03:00
|
|
|
|
2020-02-25 19:11:06 +02:00
|
|
|
ilk_compute_wm_level(dev_priv, crtc, level, crtc_state,
|
2016-03-02 12:38:06 +01:00
|
|
|
pristate, sprstate, curstate, wm);
|
2014-04-28 15:44:56 +03:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Disable any watermark level that exceeds the
|
|
|
|
|
* register maximums since such watermarks are
|
|
|
|
|
* always invalid.
|
|
|
|
|
*/
|
2017-10-19 17:13:40 +02:00
|
|
|
if (!ilk_validate_wm_level(level, &max, wm)) {
|
|
|
|
|
memset(wm, 0, sizeof(*wm));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-04-28 15:44:56 +03:00
|
|
|
}
|
|
|
|
|
|
2015-09-24 15:53:16 -07:00
|
|
|
return 0;
|
2013-10-09 19:17:55 +03: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-23 17:20:13 -08: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.
|
|
|
|
|
*/
|
2021-06-09 11:56:30 +03:00
|
|
|
static int ilk_compute_intermediate_wm(struct intel_atomic_state *state,
|
|
|
|
|
struct intel_crtc *crtc)
|
|
|
|
|
{
|
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
|
struct intel_crtc_state *new_crtc_state =
|
|
|
|
|
intel_atomic_get_new_crtc_state(state, crtc);
|
|
|
|
|
const struct intel_crtc_state *old_crtc_state =
|
|
|
|
|
intel_atomic_get_old_crtc_state(state, crtc);
|
|
|
|
|
struct intel_pipe_wm *a = &new_crtc_state->wm.ilk.intermediate;
|
|
|
|
|
const struct intel_pipe_wm *b = &old_crtc_state->wm.ilk.optimal;
|
2018-12-10 13:54:14 -08: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-23 17:20:13 -08: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.
|
|
|
|
|
*/
|
2021-06-09 11:56:30 +03:00
|
|
|
*a = new_crtc_state->wm.ilk.optimal;
|
|
|
|
|
if (!new_crtc_state->hw.active ||
|
|
|
|
|
drm_atomic_crtc_needs_modeset(&new_crtc_state->uapi) ||
|
|
|
|
|
state->skip_intermediate_wm)
|
2017-10-19 17:13:41 +02: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-23 17:20:13 -08: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 13:54:14 -08: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-23 17:20:13 -08: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.
|
|
|
|
|
*/
|
2021-06-09 11:56:30 +03:00
|
|
|
if (memcmp(a, &new_crtc_state->wm.ilk.optimal, sizeof(*a)) != 0)
|
|
|
|
|
new_crtc_state->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-23 17:20:13 -08:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-09 19:17:55 +03:00
|
|
|
/*
|
|
|
|
|
* Merge the watermarks from all active pipes for a specific level.
|
|
|
|
|
*/
|
2018-12-10 13:54:14 -08:00
|
|
|
static void ilk_merge_wm_level(struct drm_i915_private *dev_priv,
|
2013-10-09 19:17:55 +03:00
|
|
|
int level,
|
|
|
|
|
struct intel_wm_level *ret_wm)
|
|
|
|
|
{
|
2021-06-09 11:56:30 +03:00
|
|
|
const struct intel_crtc *crtc;
|
2013-10-09 19:17:55 +03:00
|
|
|
|
2014-04-28 15:44:57 +03:00
|
|
|
ret_wm->enable = true;
|
|
|
|
|
|
2021-06-09 11:56:30 +03:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
|
|
|
|
const struct intel_pipe_wm *active = &crtc->wm.active.ilk;
|
2014-03-07 18:32:10 +02:00
|
|
|
const struct intel_wm_level *wm = &active->wm[level];
|
|
|
|
|
|
|
|
|
|
if (!active->pipe_enabled)
|
|
|
|
|
continue;
|
2013-10-09 19:17:55 +03:00
|
|
|
|
2014-04-28 15:44:57 +03: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 19:17:55 +03:00
|
|
|
if (!wm->enable)
|
2014-04-28 15:44:57 +03:00
|
|
|
ret_wm->enable = false;
|
2013-10-09 19:17:55 +03: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 13:54:14 -08:00
|
|
|
static void ilk_wm_merge(struct drm_i915_private *dev_priv,
|
2013-12-05 15:51:34 +02:00
|
|
|
const struct intel_wm_config *config,
|
2013-12-17 14:46:36 +02:00
|
|
|
const struct ilk_wm_maximums *max,
|
2013-10-09 19:17:55 +03:00
|
|
|
struct intel_pipe_wm *merged)
|
|
|
|
|
{
|
2016-10-13 11:03:10 +01:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2014-04-28 15:44:57 +03:00
|
|
|
int last_enabled_level = max_level;
|
2013-10-09 19:17:55 +03:00
|
|
|
|
2013-12-05 15:51:34 +02:00
|
|
|
/* ILK/SNB/IVB: LP1+ watermarks only w/ single pipe */
|
2021-03-19 21:42:43 -07:00
|
|
|
if ((DISPLAY_VER(dev_priv) <= 6 || IS_IVYBRIDGE(dev_priv)) &&
|
2013-12-05 15:51:34 +02:00
|
|
|
config->num_pipes_active > 1)
|
2016-04-01 21:53:18 +03:00
|
|
|
last_enabled_level = 0;
|
2013-12-05 15:51:34 +02:00
|
|
|
|
2013-12-05 15:51:35 +02:00
|
|
|
/* ILK: FBC WM must be disabled always */
|
2021-03-19 21:42:43 -07:00
|
|
|
merged->fbc_wm_enabled = DISPLAY_VER(dev_priv) >= 6;
|
2013-10-09 19:17:55 +03:00
|
|
|
|
|
|
|
|
/* merge each WM1+ level */
|
|
|
|
|
for (level = 1; level <= max_level; level++) {
|
|
|
|
|
struct intel_wm_level *wm = &merged->wm[level];
|
|
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
ilk_merge_wm_level(dev_priv, level, wm);
|
2013-10-09 19:17:55 +03:00
|
|
|
|
2014-04-28 15:44:57 +03: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 19:17:55 +03: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 15:44:57 +03:00
|
|
|
if (wm->enable)
|
|
|
|
|
merged->fbc_wm_enabled = false;
|
2013-10-09 19:17:55 +03:00
|
|
|
wm->fbc_val = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-05 15:51:35 +02:00
|
|
|
|
|
|
|
|
/* ILK: LP2+ must be disabled when FBC WM is disabled but FBC enabled */
|
2021-11-24 13:36:33 +02:00
|
|
|
if (DISPLAY_VER(dev_priv) == 5 && HAS_FBC(dev_priv) &&
|
|
|
|
|
dev_priv->params.enable_fbc && !merged->fbc_wm_enabled) {
|
2013-12-05 15:51:35 +02:00
|
|
|
for (level = 2; level <= max_level; level++) {
|
|
|
|
|
struct intel_wm_level *wm = &merged->wm[level];
|
|
|
|
|
|
|
|
|
|
wm->enable = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-09 19:17:55 +03:00
|
|
|
}
|
|
|
|
|
|
2013-10-09 19:18:01 +03: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 15:51:29 +02:00
|
|
|
/* The value we need to program into the WM_LPx latency field */
|
2018-12-10 13:54:14 -08:00
|
|
|
static unsigned int ilk_wm_lp_latency(struct drm_i915_private *dev_priv,
|
|
|
|
|
int level)
|
2013-12-05 15:51:29 +02:00
|
|
|
{
|
2016-10-13 11:03:00 +01:00
|
|
|
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
|
2013-12-05 15:51:29 +02:00
|
|
|
return 2 * level;
|
|
|
|
|
else
|
2022-08-24 16:15:40 +03:00
|
|
|
return dev_priv->display.wm.pri_latency[level];
|
2013-12-05 15:51:29 +02:00
|
|
|
}
|
|
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
static void ilk_compute_wm_results(struct drm_i915_private *dev_priv,
|
2013-10-09 19:17:57 +03:00
|
|
|
const struct intel_pipe_wm *merged,
|
2013-10-09 19:18:03 +03:00
|
|
|
enum intel_ddb_partitioning partitioning,
|
2013-12-17 14:46:36 +02:00
|
|
|
struct ilk_wm_values *results)
|
2013-05-31 10:08:35 -03:00
|
|
|
{
|
2021-06-09 11:56:30 +03:00
|
|
|
struct intel_crtc *crtc;
|
2013-10-09 19:17:55 +03:00
|
|
|
int level, wm_lp;
|
2013-05-31 11:45:06 -03:00
|
|
|
|
2013-10-09 19:17:57 +03:00
|
|
|
results->enable_fbc_wm = merged->fbc_wm_enabled;
|
2013-10-09 19:18:03 +03:00
|
|
|
results->partitioning = partitioning;
|
2013-05-31 11:45:06 -03:00
|
|
|
|
2013-10-09 19:17:55 +03:00
|
|
|
/* LP1+ register values */
|
2013-05-31 11:45:06 -03:00
|
|
|
for (wm_lp = 1; wm_lp <= 3; wm_lp++) {
|
2013-08-06 22:24:05 +03:00
|
|
|
const struct intel_wm_level *r;
|
2013-05-31 10:08:35 -03:00
|
|
|
|
2013-10-09 19:18:01 +03:00
|
|
|
level = ilk_wm_lp_to_level(wm_lp, merged);
|
2013-10-09 19:17:55 +03:00
|
|
|
|
2013-10-09 19:17:57 +03:00
|
|
|
r = &merged->wm[level];
|
2013-05-31 11:45:06 -03:00
|
|
|
|
2014-04-28 15:44:57 +03:00
|
|
|
/*
|
|
|
|
|
* Maintain the watermark values even if the level is
|
|
|
|
|
* disabled. Doing otherwise could cause underruns.
|
|
|
|
|
*/
|
|
|
|
|
results->wm_lp[wm_lp - 1] =
|
2022-02-17 01:28:06 +02:00
|
|
|
WM_LP_LATENCY(ilk_wm_lp_latency(dev_priv, level)) |
|
|
|
|
|
WM_LP_PRIMARY(r->pri_val) |
|
|
|
|
|
WM_LP_CURSOR(r->cur_val);
|
2013-11-02 21:07:46 -07:00
|
|
|
|
2014-04-28 15:44:57 +03:00
|
|
|
if (r->enable)
|
2022-02-17 01:28:06 +02:00
|
|
|
results->wm_lp[wm_lp - 1] |= WM_LP_ENABLE;
|
2014-04-28 15:44:57 +03:00
|
|
|
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 8)
|
2022-02-17 01:28:06 +02:00
|
|
|
results->wm_lp[wm_lp - 1] |= WM_LP_FBC_BDW(r->fbc_val);
|
2013-11-02 21:07:46 -07:00
|
|
|
else
|
2022-02-17 01:28:06 +02:00
|
|
|
results->wm_lp[wm_lp - 1] |= WM_LP_FBC_ILK(r->fbc_val);
|
|
|
|
|
|
|
|
|
|
results->wm_lp_spr[wm_lp - 1] = WM_LP_SPRITE(r->spr_val);
|
2013-11-02 21:07:46 -07:00
|
|
|
|
2014-04-28 15:44:57 +03:00
|
|
|
/*
|
2022-02-17 01:28:06 +02:00
|
|
|
* Always set WM_LP_SPRITE_EN when spr_val != 0, even if the
|
2014-04-28 15:44:57 +03:00
|
|
|
* level is disabled. Doing otherwise could cause underruns.
|
|
|
|
|
*/
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) <= 6 && r->spr_val) {
|
drm/i915: Make WARN* drm specific where drm_priv ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_i915_private struct pointer is readily
available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
command: ls drivers/gpu/drm/i915/*.c | xargs spatch --sp-file \
<script> --linux-spacing --in-place
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200115034455.17658-10-pankaj.laxminarayan.bharadiya@intel.com
2020-01-15 09:14:53 +05:30
|
|
|
drm_WARN_ON(&dev_priv->drm, wm_lp != 1);
|
2022-02-17 01:28:06 +02:00
|
|
|
results->wm_lp_spr[wm_lp - 1] |= WM_LP_SPRITE_ENABLE;
|
|
|
|
|
}
|
2013-05-31 11:45:06 -03:00
|
|
|
}
|
2013-05-31 10:08:35 -03:00
|
|
|
|
2013-10-09 19:17:55 +03:00
|
|
|
/* LP0 register values */
|
2021-06-09 11:56:30 +03:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
|
|
|
|
enum pipe pipe = crtc->pipe;
|
|
|
|
|
const struct intel_pipe_wm *pipe_wm = &crtc->wm.active.ilk;
|
2020-01-20 19:47:11 +02:00
|
|
|
const struct intel_wm_level *r = &pipe_wm->wm[0];
|
2013-10-09 19:17:55 +03:00
|
|
|
|
drm/i915: Make WARN* drm specific where drm_priv ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_i915_private struct pointer is readily
available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
command: ls drivers/gpu/drm/i915/*.c | xargs spatch --sp-file \
<script> --linux-spacing --in-place
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200115034455.17658-10-pankaj.laxminarayan.bharadiya@intel.com
2020-01-15 09:14:53 +05:30
|
|
|
if (drm_WARN_ON(&dev_priv->drm, !r->enable))
|
2013-10-09 19:17:55 +03:00
|
|
|
continue;
|
2013-05-09 16:55:50 -03:00
|
|
|
|
2013-10-09 19:17:55 +03:00
|
|
|
results->wm_pipe[pipe] =
|
2022-02-17 01:28:06 +02:00
|
|
|
WM0_PIPE_PRIMARY(r->pri_val) |
|
|
|
|
|
WM0_PIPE_SPRITE(r->spr_val) |
|
|
|
|
|
WM0_PIPE_CURSOR(r->cur_val);
|
2013-05-31 10:08:35 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-31 10:19:21 -03: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 13:54:14 -08: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 10:19:21 -03:00
|
|
|
{
|
2018-12-10 13:54:14 -08:00
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2013-10-09 19:17:58 +03:00
|
|
|
int level1 = 0, level2 = 0;
|
2013-05-31 10:19:21 -03:00
|
|
|
|
2013-10-09 19:17:58 +03: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 10:19:21 -03:00
|
|
|
}
|
|
|
|
|
|
2013-10-09 19:17:58 +03:00
|
|
|
if (level1 == level2) {
|
|
|
|
|
if (r2->fbc_wm_enabled && !r1->fbc_wm_enabled)
|
2013-05-31 10:19:21 -03:00
|
|
|
return r2;
|
|
|
|
|
else
|
|
|
|
|
return r1;
|
2013-10-09 19:17:58 +03:00
|
|
|
} else if (level1 > level2) {
|
2013-05-31 10:19:21 -03:00
|
|
|
return r1;
|
|
|
|
|
} else {
|
|
|
|
|
return r2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-11 19:39:52 +03:00
|
|
|
/* dirty bits used to track which watermarks need changes */
|
|
|
|
|
#define WM_DIRTY_PIPE(pipe) (1 << (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 13:49:10 +01:00
|
|
|
static unsigned int ilk_compute_wm_dirty(struct drm_i915_private *dev_priv,
|
2013-12-17 14:46:36 +02:00
|
|
|
const struct ilk_wm_values *old,
|
|
|
|
|
const struct ilk_wm_values *new)
|
2013-10-11 19:39:52 +03:00
|
|
|
{
|
|
|
|
|
unsigned int dirty = 0;
|
|
|
|
|
enum pipe pipe;
|
|
|
|
|
int wm_lp;
|
|
|
|
|
|
2014-08-18 13:49:10 +01:00
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2013-10-11 19:39:52 +03:00
|
|
|
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 15:51:39 +02:00
|
|
|
static bool _ilk_disable_lp_wm(struct drm_i915_private *dev_priv,
|
|
|
|
|
unsigned int dirty)
|
2013-05-31 10:08:35 -03:00
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
struct ilk_wm_values *previous = &dev_priv->display.wm.hw;
|
2013-12-05 15:51:39 +02:00
|
|
|
bool changed = false;
|
2013-05-31 10:08:35 -03:00
|
|
|
|
2022-02-17 01:28:06 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(3) && previous->wm_lp[2] & WM_LP_ENABLE) {
|
|
|
|
|
previous->wm_lp[2] &= ~WM_LP_ENABLE;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM3_LP_ILK, previous->wm_lp[2]);
|
2013-12-05 15:51:39 +02:00
|
|
|
changed = true;
|
2013-12-05 15:51:33 +02:00
|
|
|
}
|
2022-02-17 01:28:06 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(2) && previous->wm_lp[1] & WM_LP_ENABLE) {
|
|
|
|
|
previous->wm_lp[1] &= ~WM_LP_ENABLE;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM2_LP_ILK, previous->wm_lp[1]);
|
2013-12-05 15:51:39 +02:00
|
|
|
changed = true;
|
2013-12-05 15:51:33 +02:00
|
|
|
}
|
2022-02-17 01:28:06 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(1) && previous->wm_lp[0] & WM_LP_ENABLE) {
|
|
|
|
|
previous->wm_lp[0] &= ~WM_LP_ENABLE;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM1_LP_ILK, previous->wm_lp[0]);
|
2013-12-05 15:51:39 +02:00
|
|
|
changed = true;
|
2013-12-05 15:51:33 +02:00
|
|
|
}
|
2013-05-31 10:08:35 -03:00
|
|
|
|
2013-12-05 15:51:33 +02:00
|
|
|
/*
|
2022-02-17 01:28:06 +02:00
|
|
|
* Don't touch WM_LP_SPRITE_ENABLE here.
|
2013-12-05 15:51:33 +02:00
|
|
|
* Doing so could cause underruns.
|
|
|
|
|
*/
|
2013-12-05 15:51:32 +02:00
|
|
|
|
2013-12-05 15:51:39 +02: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 14:46:36 +02:00
|
|
|
static void ilk_write_wm_values(struct drm_i915_private *dev_priv,
|
|
|
|
|
struct ilk_wm_values *results)
|
2013-12-05 15:51:39 +02:00
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
struct ilk_wm_values *previous = &dev_priv->display.wm.hw;
|
2013-12-05 15:51:39 +02:00
|
|
|
unsigned int dirty;
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 val;
|
2013-12-05 15:51:39 +02:00
|
|
|
|
2014-08-18 13:49:10 +01:00
|
|
|
dirty = ilk_compute_wm_dirty(dev_priv, previous, results);
|
2013-12-05 15:51:39 +02:00
|
|
|
if (!dirty)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_ilk_disable_lp_wm(dev_priv, dirty);
|
|
|
|
|
|
2013-10-11 19:39:52 +03:00
|
|
|
if (dirty & WM_DIRTY_PIPE(PIPE_A))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM0_PIPE_ILK(PIPE_A), results->wm_pipe[0]);
|
2013-10-11 19:39:52 +03:00
|
|
|
if (dirty & WM_DIRTY_PIPE(PIPE_B))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM0_PIPE_ILK(PIPE_B), results->wm_pipe[1]);
|
2013-10-11 19:39:52 +03:00
|
|
|
if (dirty & WM_DIRTY_PIPE(PIPE_C))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM0_PIPE_ILK(PIPE_C), results->wm_pipe[2]);
|
2013-05-31 10:08:35 -03:00
|
|
|
|
2013-10-11 19:39:52 +03:00
|
|
|
if (dirty & WM_DIRTY_DDB) {
|
2016-10-13 11:03:00 +01:00
|
|
|
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
|
2020-11-30 13:15:58 +02:00
|
|
|
val = intel_uncore_read(&dev_priv->uncore, WM_MISC);
|
2013-12-05 15:51:28 +02:00
|
|
|
if (results->partitioning == INTEL_DDB_PART_1_2)
|
|
|
|
|
val &= ~WM_MISC_DATA_PARTITION_5_6;
|
|
|
|
|
else
|
|
|
|
|
val |= WM_MISC_DATA_PARTITION_5_6;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM_MISC, val);
|
2013-12-05 15:51:28 +02:00
|
|
|
} else {
|
2020-11-30 13:15:58 +02:00
|
|
|
val = intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL2);
|
2013-12-05 15:51:28 +02:00
|
|
|
if (results->partitioning == INTEL_DDB_PART_1_2)
|
|
|
|
|
val &= ~DISP_DATA_PARTITION_5_6;
|
|
|
|
|
else
|
|
|
|
|
val |= DISP_DATA_PARTITION_5_6;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL2, val);
|
2013-12-05 15:51:28 +02:00
|
|
|
}
|
2013-05-09 16:55:50 -03:00
|
|
|
}
|
|
|
|
|
|
2013-10-11 19:39:52 +03:00
|
|
|
if (dirty & WM_DIRTY_FBC) {
|
2020-11-30 13:15:58 +02:00
|
|
|
val = intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL);
|
2013-05-31 11:45:06 -03:00
|
|
|
if (results->enable_fbc_wm)
|
|
|
|
|
val &= ~DISP_FBC_WM_DIS;
|
|
|
|
|
else
|
|
|
|
|
val |= DISP_FBC_WM_DIS;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL, val);
|
2013-05-31 11:45:06 -03:00
|
|
|
}
|
|
|
|
|
|
2013-12-17 14:46:34 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(1) &&
|
|
|
|
|
previous->wm_lp_spr[0] != results->wm_lp_spr[0])
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM1S_LP_ILK, results->wm_lp_spr[0]);
|
2013-12-17 14:46:34 +02:00
|
|
|
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 7) {
|
2013-12-05 15:51:32 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(2) && previous->wm_lp_spr[1] != results->wm_lp_spr[1])
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM2S_LP_IVB, results->wm_lp_spr[1]);
|
2013-12-05 15:51:32 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(3) && previous->wm_lp_spr[2] != results->wm_lp_spr[2])
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM3S_LP_IVB, results->wm_lp_spr[2]);
|
2013-12-05 15:51:32 +02:00
|
|
|
}
|
2013-05-31 10:08:35 -03:00
|
|
|
|
2013-12-05 15:51:33 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(1) && previous->wm_lp[0] != results->wm_lp[0])
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM1_LP_ILK, results->wm_lp[0]);
|
2013-12-05 15:51:33 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(2) && previous->wm_lp[1] != results->wm_lp[1])
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM2_LP_ILK, results->wm_lp[1]);
|
2013-12-05 15:51:33 +02:00
|
|
|
if (dirty & WM_DIRTY_LP(3) && previous->wm_lp[2] != results->wm_lp[2])
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM3_LP_ILK, results->wm_lp[2]);
|
2013-10-09 19:18:03 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.hw = *results;
|
2013-05-31 10:08:35 -03:00
|
|
|
}
|
|
|
|
|
|
2019-11-27 21:05:51 +02:00
|
|
|
bool ilk_disable_lp_wm(struct drm_i915_private *dev_priv)
|
2013-12-05 15:51:39 +02:00
|
|
|
{
|
|
|
|
|
return _ilk_disable_lp_wm(dev_priv, WM_DIRTY_LP_ALL);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
static void ilk_compute_wm_config(struct drm_i915_private *dev_priv,
|
|
|
|
|
struct intel_wm_config *config)
|
2016-09-22 18:00:28 -03:00
|
|
|
{
|
2022-09-08 22:16:45 +03:00
|
|
|
struct intel_crtc *crtc;
|
2016-09-22 18:00:28 -03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
/* Compute the currently _active_ config */
|
|
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
|
|
|
|
const struct intel_pipe_wm *wm = &crtc->wm.active.ilk;
|
2019-10-09 10:23:15 -07:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
if (!wm->pipe_enabled)
|
|
|
|
|
continue;
|
2019-10-09 10:23:15 -07:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
config->sprites_enabled |= wm->sprites_enabled;
|
|
|
|
|
config->sprites_scaled |= wm->sprites_scaled;
|
|
|
|
|
config->num_pipes_active++;
|
2019-10-09 10:23:14 -07:00
|
|
|
}
|
2022-03-09 18:49:42 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
static void ilk_program_watermarks(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 15:55:54 -04:00
|
|
|
{
|
2022-09-08 22:16:45 +03:00
|
|
|
struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;
|
|
|
|
|
struct ilk_wm_maximums max;
|
|
|
|
|
struct intel_wm_config config = {};
|
|
|
|
|
struct ilk_wm_values results = {};
|
|
|
|
|
enum intel_ddb_partitioning partitioning;
|
2016-09-22 18:00:28 -03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
ilk_compute_wm_config(dev_priv, &config);
|
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 15:55:54 -04:00
|
|
|
|
2022-09-08 22:16:45 +03: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);
|
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 15:55:54 -04:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
/* 5/6 split only in single pipe config on IVB+ */
|
|
|
|
|
if (DISPLAY_VER(dev_priv) >= 7 &&
|
|
|
|
|
config.num_pipes_active == 1 && config.sprites_enabled) {
|
|
|
|
|
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);
|
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 15:55:54 -04:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
best_lp_wm = ilk_find_best_result(dev_priv, &lp_wm_1_2, &lp_wm_5_6);
|
2019-10-09 10:23:14 -07:00
|
|
|
} else {
|
2022-09-08 22:16:45 +03:00
|
|
|
best_lp_wm = &lp_wm_1_2;
|
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 15:55:54 -04:00
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
partitioning = (best_lp_wm == &lp_wm_1_2) ?
|
|
|
|
|
INTEL_DDB_PART_1_2 : INTEL_DDB_PART_5_6;
|
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 15:55:54 -04:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
ilk_compute_wm_results(dev_priv, best_lp_wm, partitioning, &results);
|
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 15:55:54 -04:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
ilk_write_wm_values(dev_priv, &results);
|
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 15:55:54 -04:00
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
static void ilk_initial_watermarks(struct intel_atomic_state *state,
|
|
|
|
|
struct intel_crtc *crtc)
|
2020-04-15 17:39:04 +03:00
|
|
|
{
|
2022-09-08 22:16:45 +03: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);
|
2020-04-30 22:17:57 +03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
|
|
|
|
crtc->wm.active.ilk = crtc_state->wm.ilk.intermediate;
|
|
|
|
|
ilk_program_watermarks(dev_priv);
|
|
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2022-02-18 08:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
static void ilk_optimize_watermarks(struct intel_atomic_state *state,
|
|
|
|
|
struct intel_crtc *crtc)
|
2022-02-18 08:40:36 +02:00
|
|
|
{
|
2022-09-08 22:16:45 +03: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);
|
2022-02-18 08:40:36 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
if (!crtc_state->wm.need_postvbl_update)
|
2020-04-30 22:17:57 +03:00
|
|
|
return;
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
|
|
|
|
crtc->wm.active.ilk = crtc_state->wm.ilk.optimal;
|
|
|
|
|
ilk_program_watermarks(dev_priv);
|
|
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2022-02-18 08:40:36 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
static void ilk_pipe_wm_get_hw_state(struct intel_crtc *crtc)
|
2022-02-18 08:40:36 +02:00
|
|
|
{
|
2022-09-08 22:16:45 +03:00
|
|
|
struct drm_device *dev = crtc->base.dev;
|
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
|
|
|
|
struct ilk_wm_values *hw = &dev_priv->display.wm.hw;
|
|
|
|
|
struct intel_crtc_state *crtc_state = to_intel_crtc_state(crtc->base.state);
|
|
|
|
|
struct intel_pipe_wm *active = &crtc_state->wm.ilk.optimal;
|
|
|
|
|
enum pipe pipe = crtc->pipe;
|
drm/i915: Restrict qgv points which don't have enough bandwidth.
According to BSpec 53998, we should try to
restrict qgv points, which can't provide
enough bandwidth for desired display configuration.
Currently we are just comparing against all of
those and take minimum(worst case).
v2: Fixed wrong PCode reply mask, removed hardcoded
values.
v3: Forbid simultaneous legacy SAGV PCode requests and
restricting qgv points. Put the actual restriction
to commit function, added serialization(thanks to Ville)
to prevent commit being applied out of order in case of
nonblocking and/or nomodeset commits.
v4:
- Minor code refactoring, fixed few typos(thanks to James Ausmus)
- Change the naming of qgv point
masking/unmasking functions(James Ausmus).
- Simplify the masking/unmasking operation itself,
as we don't need to mask only single point per request(James Ausmus)
- Reject and stick to highest bandwidth point if SAGV
can't be enabled(BSpec)
v5:
- Add new mailbox reply codes, which seems to happen during boot
time for TGL and indicate that QGV setting is not yet available.
v6:
- Increase number of supported QGV points to be in sync with BSpec.
v7: - Rebased and resolved conflict to fix build failure.
- Fix NUM_QGV_POINTS to 8 and moved that to header file(James Ausmus)
v8: - Don't report an error if we can't restrict qgv points, as SAGV
can be disabled by BIOS, which is completely legal. So don't
make CI panic. Instead if we detect that there is only 1 QGV
point accessible just analyze if we can fit the required bandwidth
requirements, but no need in restricting.
v9: - Fix wrong QGV transition if we have 0 planes and no SAGV
simultaneously.
v10: - Fix CDCLK corruption, because of global state getting serialized
without modeset, which caused copying of non-calculated cdclk
to be copied to dev_priv(thanks to Ville for the hint).
v11: - Remove unneeded headers and spaces(Matthew Roper)
- Remove unneeded intel_qgv_info qi struct from bw check and zero
out the needed one(Matthew Roper)
- Changed QGV error message to have more clear meaning(Matthew Roper)
- Use state->modeset_set instead of any_ms(Matthew Roper)
- Moved NUM_SAGV_POINTS from i915_reg.h to i915_drv.h where it's used
- Keep using crtc_state->hw.active instead of .enable(Matthew Roper)
- Moved unrelated changes to other patch(using latency as parameter
for plane wm calculation, moved to SAGV refactoring patch)
v12: - Fix rebase conflict with own temporary SAGV/QGV fix.
- Remove unnecessary mask being zero check when unmasking
qgv points as this is completely legal(Matt Roper)
- Check if we are setting the same mask as already being set
in hardware to prevent error from PCode.
- Fix error message when restricting/unrestricting qgv points
to "mask/unmask" which sounds more accurate(Matt Roper)
- Move sagv status setting to icl_get_bw_info from atomic check
as this should be calculated only once.(Matt Roper)
- Edited comments for the case when we can't enable SAGV and
use only 1 QGV point with highest bandwidth to be more
understandable.(Matt Roper)
v13: - Moved max_data_rate in bw check to closer scope(Ville Syrjälä)
- Changed comment for zero new_mask in qgv points masking function
to better reflect reality(Ville Syrjälä)
- Simplified bit mask operation in qgv points masking function
(Ville Syrjälä)
- Moved intel_qgv_points_mask closer to gen11 SAGV disabling,
however this still can't be under modeset condition(Ville Syrjälä)
- Packed qgv_points_mask as u8 and moved closer to pipe_sagv_mask
(Ville Syrjälä)
- Extracted PCode changes to separate patch.(Ville Syrjälä)
- Now treat num_planes 0 same as 1 to avoid confusion and
returning max_bw as 0, which would prevent choosing QGV
point having max bandwidth in case if SAGV is not allowed,
as per BSpec(Ville Syrjälä)
- Do the actual qgv_points_mask swap in the same place as
all other global state parts like cdclk are swapped.
In the next patch, this all will be moved to bw state as
global state, once new global state patch series from Ville
lands
v14: - Now using global state to serialize access to qgv points
- Added global state locking back, otherwise we seem to read
bw state in a wrong way.
v15: - Added TODO comment for near atomic global state locking in
bw code.
v16: - Fixed intel_atomic_bw_* functions to be intel_bw_* as discussed
with Jani Nikula.
- Take bw_state_changed flag into use.
v17: - Moved qgv point related manipulations next to SAGV code, as
those are semantically related(Ville Syrjälä)
- Renamed those into intel_sagv_(pre)|(post)_plane_update
(Ville Syrjälä)
v18: - Move sagv related calls from commit tail into
intel_sagv_(pre)|(post)_plane_update(Ville Syrjälä)
v19: - Use intel_atomic_get_bw_(old)|(new)_state which is intended
for commit tail stage.
v20: - Return max bandwidth for 0 planes(Ville)
- Constify old_bw_state in bw_atomic_check(Ville)
- Removed some debugs(Ville)
- Added data rate to debug print when no QGV points(Ville)
- Removed some comments(Ville)
v21, v22, v23: - Fixed rebase conflict
v24: - Changed PCode mask to use ICL_ prefix
v25: - Resolved rebase conflict
v26: - Removed redundant NULL checks(Ville)
- Removed redundant error prints(Ville)
v27: - Use device specific drm_err(Ville)
- Fixed parenthesis ident reported by checkpatch
Line over 100 warns to be fixed together with
existing code style.
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Cc: Ville Syrjälä <ville.syrjala@intel.com>
Cc: James Ausmus <james.ausmus@intel.com>
[vsyrjala: Drop duplicate intel_sagv_{pre,post}_plane_update() prototypes
and drop unused NUM_SAGV_POINTS define]
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200514074853.9508-3-stanislav.lisovskiy@intel.com
2020-05-14 10:48:52 +03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
hw->wm_pipe[pipe] = intel_uncore_read(&dev_priv->uncore, WM0_PIPE_ILK(pipe));
|
drm/i915: Restrict qgv points which don't have enough bandwidth.
According to BSpec 53998, we should try to
restrict qgv points, which can't provide
enough bandwidth for desired display configuration.
Currently we are just comparing against all of
those and take minimum(worst case).
v2: Fixed wrong PCode reply mask, removed hardcoded
values.
v3: Forbid simultaneous legacy SAGV PCode requests and
restricting qgv points. Put the actual restriction
to commit function, added serialization(thanks to Ville)
to prevent commit being applied out of order in case of
nonblocking and/or nomodeset commits.
v4:
- Minor code refactoring, fixed few typos(thanks to James Ausmus)
- Change the naming of qgv point
masking/unmasking functions(James Ausmus).
- Simplify the masking/unmasking operation itself,
as we don't need to mask only single point per request(James Ausmus)
- Reject and stick to highest bandwidth point if SAGV
can't be enabled(BSpec)
v5:
- Add new mailbox reply codes, which seems to happen during boot
time for TGL and indicate that QGV setting is not yet available.
v6:
- Increase number of supported QGV points to be in sync with BSpec.
v7: - Rebased and resolved conflict to fix build failure.
- Fix NUM_QGV_POINTS to 8 and moved that to header file(James Ausmus)
v8: - Don't report an error if we can't restrict qgv points, as SAGV
can be disabled by BIOS, which is completely legal. So don't
make CI panic. Instead if we detect that there is only 1 QGV
point accessible just analyze if we can fit the required bandwidth
requirements, but no need in restricting.
v9: - Fix wrong QGV transition if we have 0 planes and no SAGV
simultaneously.
v10: - Fix CDCLK corruption, because of global state getting serialized
without modeset, which caused copying of non-calculated cdclk
to be copied to dev_priv(thanks to Ville for the hint).
v11: - Remove unneeded headers and spaces(Matthew Roper)
- Remove unneeded intel_qgv_info qi struct from bw check and zero
out the needed one(Matthew Roper)
- Changed QGV error message to have more clear meaning(Matthew Roper)
- Use state->modeset_set instead of any_ms(Matthew Roper)
- Moved NUM_SAGV_POINTS from i915_reg.h to i915_drv.h where it's used
- Keep using crtc_state->hw.active instead of .enable(Matthew Roper)
- Moved unrelated changes to other patch(using latency as parameter
for plane wm calculation, moved to SAGV refactoring patch)
v12: - Fix rebase conflict with own temporary SAGV/QGV fix.
- Remove unnecessary mask being zero check when unmasking
qgv points as this is completely legal(Matt Roper)
- Check if we are setting the same mask as already being set
in hardware to prevent error from PCode.
- Fix error message when restricting/unrestricting qgv points
to "mask/unmask" which sounds more accurate(Matt Roper)
- Move sagv status setting to icl_get_bw_info from atomic check
as this should be calculated only once.(Matt Roper)
- Edited comments for the case when we can't enable SAGV and
use only 1 QGV point with highest bandwidth to be more
understandable.(Matt Roper)
v13: - Moved max_data_rate in bw check to closer scope(Ville Syrjälä)
- Changed comment for zero new_mask in qgv points masking function
to better reflect reality(Ville Syrjälä)
- Simplified bit mask operation in qgv points masking function
(Ville Syrjälä)
- Moved intel_qgv_points_mask closer to gen11 SAGV disabling,
however this still can't be under modeset condition(Ville Syrjälä)
- Packed qgv_points_mask as u8 and moved closer to pipe_sagv_mask
(Ville Syrjälä)
- Extracted PCode changes to separate patch.(Ville Syrjälä)
- Now treat num_planes 0 same as 1 to avoid confusion and
returning max_bw as 0, which would prevent choosing QGV
point having max bandwidth in case if SAGV is not allowed,
as per BSpec(Ville Syrjälä)
- Do the actual qgv_points_mask swap in the same place as
all other global state parts like cdclk are swapped.
In the next patch, this all will be moved to bw state as
global state, once new global state patch series from Ville
lands
v14: - Now using global state to serialize access to qgv points
- Added global state locking back, otherwise we seem to read
bw state in a wrong way.
v15: - Added TODO comment for near atomic global state locking in
bw code.
v16: - Fixed intel_atomic_bw_* functions to be intel_bw_* as discussed
with Jani Nikula.
- Take bw_state_changed flag into use.
v17: - Moved qgv point related manipulations next to SAGV code, as
those are semantically related(Ville Syrjälä)
- Renamed those into intel_sagv_(pre)|(post)_plane_update
(Ville Syrjälä)
v18: - Move sagv related calls from commit tail into
intel_sagv_(pre)|(post)_plane_update(Ville Syrjälä)
v19: - Use intel_atomic_get_bw_(old)|(new)_state which is intended
for commit tail stage.
v20: - Return max bandwidth for 0 planes(Ville)
- Constify old_bw_state in bw_atomic_check(Ville)
- Removed some debugs(Ville)
- Added data rate to debug print when no QGV points(Ville)
- Removed some comments(Ville)
v21, v22, v23: - Fixed rebase conflict
v24: - Changed PCode mask to use ICL_ prefix
v25: - Resolved rebase conflict
v26: - Removed redundant NULL checks(Ville)
- Removed redundant error prints(Ville)
v27: - Use device specific drm_err(Ville)
- Fixed parenthesis ident reported by checkpatch
Line over 100 warns to be fixed together with
existing code style.
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Cc: Ville Syrjälä <ville.syrjala@intel.com>
Cc: James Ausmus <james.ausmus@intel.com>
[vsyrjala: Drop duplicate intel_sagv_{pre,post}_plane_update() prototypes
and drop unused NUM_SAGV_POINTS define]
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200514074853.9508-3-stanislav.lisovskiy@intel.com
2020-05-14 10:48:52 +03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
memset(active, 0, sizeof(*active));
|
drm/i915: Restrict qgv points which don't have enough bandwidth.
According to BSpec 53998, we should try to
restrict qgv points, which can't provide
enough bandwidth for desired display configuration.
Currently we are just comparing against all of
those and take minimum(worst case).
v2: Fixed wrong PCode reply mask, removed hardcoded
values.
v3: Forbid simultaneous legacy SAGV PCode requests and
restricting qgv points. Put the actual restriction
to commit function, added serialization(thanks to Ville)
to prevent commit being applied out of order in case of
nonblocking and/or nomodeset commits.
v4:
- Minor code refactoring, fixed few typos(thanks to James Ausmus)
- Change the naming of qgv point
masking/unmasking functions(James Ausmus).
- Simplify the masking/unmasking operation itself,
as we don't need to mask only single point per request(James Ausmus)
- Reject and stick to highest bandwidth point if SAGV
can't be enabled(BSpec)
v5:
- Add new mailbox reply codes, which seems to happen during boot
time for TGL and indicate that QGV setting is not yet available.
v6:
- Increase number of supported QGV points to be in sync with BSpec.
v7: - Rebased and resolved conflict to fix build failure.
- Fix NUM_QGV_POINTS to 8 and moved that to header file(James Ausmus)
v8: - Don't report an error if we can't restrict qgv points, as SAGV
can be disabled by BIOS, which is completely legal. So don't
make CI panic. Instead if we detect that there is only 1 QGV
point accessible just analyze if we can fit the required bandwidth
requirements, but no need in restricting.
v9: - Fix wrong QGV transition if we have 0 planes and no SAGV
simultaneously.
v10: - Fix CDCLK corruption, because of global state getting serialized
without modeset, which caused copying of non-calculated cdclk
to be copied to dev_priv(thanks to Ville for the hint).
v11: - Remove unneeded headers and spaces(Matthew Roper)
- Remove unneeded intel_qgv_info qi struct from bw check and zero
out the needed one(Matthew Roper)
- Changed QGV error message to have more clear meaning(Matthew Roper)
- Use state->modeset_set instead of any_ms(Matthew Roper)
- Moved NUM_SAGV_POINTS from i915_reg.h to i915_drv.h where it's used
- Keep using crtc_state->hw.active instead of .enable(Matthew Roper)
- Moved unrelated changes to other patch(using latency as parameter
for plane wm calculation, moved to SAGV refactoring patch)
v12: - Fix rebase conflict with own temporary SAGV/QGV fix.
- Remove unnecessary mask being zero check when unmasking
qgv points as this is completely legal(Matt Roper)
- Check if we are setting the same mask as already being set
in hardware to prevent error from PCode.
- Fix error message when restricting/unrestricting qgv points
to "mask/unmask" which sounds more accurate(Matt Roper)
- Move sagv status setting to icl_get_bw_info from atomic check
as this should be calculated only once.(Matt Roper)
- Edited comments for the case when we can't enable SAGV and
use only 1 QGV point with highest bandwidth to be more
understandable.(Matt Roper)
v13: - Moved max_data_rate in bw check to closer scope(Ville Syrjälä)
- Changed comment for zero new_mask in qgv points masking function
to better reflect reality(Ville Syrjälä)
- Simplified bit mask operation in qgv points masking function
(Ville Syrjälä)
- Moved intel_qgv_points_mask closer to gen11 SAGV disabling,
however this still can't be under modeset condition(Ville Syrjälä)
- Packed qgv_points_mask as u8 and moved closer to pipe_sagv_mask
(Ville Syrjälä)
- Extracted PCode changes to separate patch.(Ville Syrjälä)
- Now treat num_planes 0 same as 1 to avoid confusion and
returning max_bw as 0, which would prevent choosing QGV
point having max bandwidth in case if SAGV is not allowed,
as per BSpec(Ville Syrjälä)
- Do the actual qgv_points_mask swap in the same place as
all other global state parts like cdclk are swapped.
In the next patch, this all will be moved to bw state as
global state, once new global state patch series from Ville
lands
v14: - Now using global state to serialize access to qgv points
- Added global state locking back, otherwise we seem to read
bw state in a wrong way.
v15: - Added TODO comment for near atomic global state locking in
bw code.
v16: - Fixed intel_atomic_bw_* functions to be intel_bw_* as discussed
with Jani Nikula.
- Take bw_state_changed flag into use.
v17: - Moved qgv point related manipulations next to SAGV code, as
those are semantically related(Ville Syrjälä)
- Renamed those into intel_sagv_(pre)|(post)_plane_update
(Ville Syrjälä)
v18: - Move sagv related calls from commit tail into
intel_sagv_(pre)|(post)_plane_update(Ville Syrjälä)
v19: - Use intel_atomic_get_bw_(old)|(new)_state which is intended
for commit tail stage.
v20: - Return max bandwidth for 0 planes(Ville)
- Constify old_bw_state in bw_atomic_check(Ville)
- Removed some debugs(Ville)
- Added data rate to debug print when no QGV points(Ville)
- Removed some comments(Ville)
v21, v22, v23: - Fixed rebase conflict
v24: - Changed PCode mask to use ICL_ prefix
v25: - Resolved rebase conflict
v26: - Removed redundant NULL checks(Ville)
- Removed redundant error prints(Ville)
v27: - Use device specific drm_err(Ville)
- Fixed parenthesis ident reported by checkpatch
Line over 100 warns to be fixed together with
existing code style.
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Cc: Ville Syrjälä <ville.syrjala@intel.com>
Cc: James Ausmus <james.ausmus@intel.com>
[vsyrjala: Drop duplicate intel_sagv_{pre,post}_plane_update() prototypes
and drop unused NUM_SAGV_POINTS define]
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200514074853.9508-3-stanislav.lisovskiy@intel.com
2020-05-14 10:48:52 +03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
active->pipe_enabled = crtc->active;
|
2022-02-18 08:40:37 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
if (active->pipe_enabled) {
|
|
|
|
|
u32 tmp = hw->wm_pipe[pipe];
|
2022-02-18 08:40:37 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
/*
|
|
|
|
|
* 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 = REG_FIELD_GET(WM0_PIPE_PRIMARY_MASK, tmp);
|
|
|
|
|
active->wm[0].spr_val = REG_FIELD_GET(WM0_PIPE_SPRITE_MASK, tmp);
|
|
|
|
|
active->wm[0].cur_val = REG_FIELD_GET(WM0_PIPE_CURSOR_MASK, tmp);
|
|
|
|
|
} else {
|
|
|
|
|
int level, max_level = ilk_wm_max_level(dev_priv);
|
2020-04-15 17:39:04 +03:00
|
|
|
|
2022-09-08 22:16:45 +03: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;
|
|
|
|
|
}
|
2020-04-30 22:17:57 +03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
crtc->wm.active.ilk = *active;
|
|
|
|
|
}
|
2020-04-30 22:17:57 +03:00
|
|
|
|
2022-09-08 22:16:45 +03: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)
|
2022-02-18 08:40:37 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
static void g4x_read_wm_values(struct drm_i915_private *dev_priv,
|
|
|
|
|
struct g4x_wm_values *wm)
|
|
|
|
|
{
|
|
|
|
|
u32 tmp;
|
drm/i915: Restrict qgv points which don't have enough bandwidth.
According to BSpec 53998, we should try to
restrict qgv points, which can't provide
enough bandwidth for desired display configuration.
Currently we are just comparing against all of
those and take minimum(worst case).
v2: Fixed wrong PCode reply mask, removed hardcoded
values.
v3: Forbid simultaneous legacy SAGV PCode requests and
restricting qgv points. Put the actual restriction
to commit function, added serialization(thanks to Ville)
to prevent commit being applied out of order in case of
nonblocking and/or nomodeset commits.
v4:
- Minor code refactoring, fixed few typos(thanks to James Ausmus)
- Change the naming of qgv point
masking/unmasking functions(James Ausmus).
- Simplify the masking/unmasking operation itself,
as we don't need to mask only single point per request(James Ausmus)
- Reject and stick to highest bandwidth point if SAGV
can't be enabled(BSpec)
v5:
- Add new mailbox reply codes, which seems to happen during boot
time for TGL and indicate that QGV setting is not yet available.
v6:
- Increase number of supported QGV points to be in sync with BSpec.
v7: - Rebased and resolved conflict to fix build failure.
- Fix NUM_QGV_POINTS to 8 and moved that to header file(James Ausmus)
v8: - Don't report an error if we can't restrict qgv points, as SAGV
can be disabled by BIOS, which is completely legal. So don't
make CI panic. Instead if we detect that there is only 1 QGV
point accessible just analyze if we can fit the required bandwidth
requirements, but no need in restricting.
v9: - Fix wrong QGV transition if we have 0 planes and no SAGV
simultaneously.
v10: - Fix CDCLK corruption, because of global state getting serialized
without modeset, which caused copying of non-calculated cdclk
to be copied to dev_priv(thanks to Ville for the hint).
v11: - Remove unneeded headers and spaces(Matthew Roper)
- Remove unneeded intel_qgv_info qi struct from bw check and zero
out the needed one(Matthew Roper)
- Changed QGV error message to have more clear meaning(Matthew Roper)
- Use state->modeset_set instead of any_ms(Matthew Roper)
- Moved NUM_SAGV_POINTS from i915_reg.h to i915_drv.h where it's used
- Keep using crtc_state->hw.active instead of .enable(Matthew Roper)
- Moved unrelated changes to other patch(using latency as parameter
for plane wm calculation, moved to SAGV refactoring patch)
v12: - Fix rebase conflict with own temporary SAGV/QGV fix.
- Remove unnecessary mask being zero check when unmasking
qgv points as this is completely legal(Matt Roper)
- Check if we are setting the same mask as already being set
in hardware to prevent error from PCode.
- Fix error message when restricting/unrestricting qgv points
to "mask/unmask" which sounds more accurate(Matt Roper)
- Move sagv status setting to icl_get_bw_info from atomic check
as this should be calculated only once.(Matt Roper)
- Edited comments for the case when we can't enable SAGV and
use only 1 QGV point with highest bandwidth to be more
understandable.(Matt Roper)
v13: - Moved max_data_rate in bw check to closer scope(Ville Syrjälä)
- Changed comment for zero new_mask in qgv points masking function
to better reflect reality(Ville Syrjälä)
- Simplified bit mask operation in qgv points masking function
(Ville Syrjälä)
- Moved intel_qgv_points_mask closer to gen11 SAGV disabling,
however this still can't be under modeset condition(Ville Syrjälä)
- Packed qgv_points_mask as u8 and moved closer to pipe_sagv_mask
(Ville Syrjälä)
- Extracted PCode changes to separate patch.(Ville Syrjälä)
- Now treat num_planes 0 same as 1 to avoid confusion and
returning max_bw as 0, which would prevent choosing QGV
point having max bandwidth in case if SAGV is not allowed,
as per BSpec(Ville Syrjälä)
- Do the actual qgv_points_mask swap in the same place as
all other global state parts like cdclk are swapped.
In the next patch, this all will be moved to bw state as
global state, once new global state patch series from Ville
lands
v14: - Now using global state to serialize access to qgv points
- Added global state locking back, otherwise we seem to read
bw state in a wrong way.
v15: - Added TODO comment for near atomic global state locking in
bw code.
v16: - Fixed intel_atomic_bw_* functions to be intel_bw_* as discussed
with Jani Nikula.
- Take bw_state_changed flag into use.
v17: - Moved qgv point related manipulations next to SAGV code, as
those are semantically related(Ville Syrjälä)
- Renamed those into intel_sagv_(pre)|(post)_plane_update
(Ville Syrjälä)
v18: - Move sagv related calls from commit tail into
intel_sagv_(pre)|(post)_plane_update(Ville Syrjälä)
v19: - Use intel_atomic_get_bw_(old)|(new)_state which is intended
for commit tail stage.
v20: - Return max bandwidth for 0 planes(Ville)
- Constify old_bw_state in bw_atomic_check(Ville)
- Removed some debugs(Ville)
- Added data rate to debug print when no QGV points(Ville)
- Removed some comments(Ville)
v21, v22, v23: - Fixed rebase conflict
v24: - Changed PCode mask to use ICL_ prefix
v25: - Resolved rebase conflict
v26: - Removed redundant NULL checks(Ville)
- Removed redundant error prints(Ville)
v27: - Use device specific drm_err(Ville)
- Fixed parenthesis ident reported by checkpatch
Line over 100 warns to be fixed together with
existing code style.
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Cc: Ville Syrjälä <ville.syrjala@intel.com>
Cc: James Ausmus <james.ausmus@intel.com>
[vsyrjala: Drop duplicate intel_sagv_{pre,post}_plane_update() prototypes
and drop unused NUM_SAGV_POINTS define]
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200514074853.9508-3-stanislav.lisovskiy@intel.com
2020-05-14 10:48:52 +03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, 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);
|
2022-02-18 08:40:37 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, 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);
|
drm/i915: Restrict qgv points which don't have enough bandwidth.
According to BSpec 53998, we should try to
restrict qgv points, which can't provide
enough bandwidth for desired display configuration.
Currently we are just comparing against all of
those and take minimum(worst case).
v2: Fixed wrong PCode reply mask, removed hardcoded
values.
v3: Forbid simultaneous legacy SAGV PCode requests and
restricting qgv points. Put the actual restriction
to commit function, added serialization(thanks to Ville)
to prevent commit being applied out of order in case of
nonblocking and/or nomodeset commits.
v4:
- Minor code refactoring, fixed few typos(thanks to James Ausmus)
- Change the naming of qgv point
masking/unmasking functions(James Ausmus).
- Simplify the masking/unmasking operation itself,
as we don't need to mask only single point per request(James Ausmus)
- Reject and stick to highest bandwidth point if SAGV
can't be enabled(BSpec)
v5:
- Add new mailbox reply codes, which seems to happen during boot
time for TGL and indicate that QGV setting is not yet available.
v6:
- Increase number of supported QGV points to be in sync with BSpec.
v7: - Rebased and resolved conflict to fix build failure.
- Fix NUM_QGV_POINTS to 8 and moved that to header file(James Ausmus)
v8: - Don't report an error if we can't restrict qgv points, as SAGV
can be disabled by BIOS, which is completely legal. So don't
make CI panic. Instead if we detect that there is only 1 QGV
point accessible just analyze if we can fit the required bandwidth
requirements, but no need in restricting.
v9: - Fix wrong QGV transition if we have 0 planes and no SAGV
simultaneously.
v10: - Fix CDCLK corruption, because of global state getting serialized
without modeset, which caused copying of non-calculated cdclk
to be copied to dev_priv(thanks to Ville for the hint).
v11: - Remove unneeded headers and spaces(Matthew Roper)
- Remove unneeded intel_qgv_info qi struct from bw check and zero
out the needed one(Matthew Roper)
- Changed QGV error message to have more clear meaning(Matthew Roper)
- Use state->modeset_set instead of any_ms(Matthew Roper)
- Moved NUM_SAGV_POINTS from i915_reg.h to i915_drv.h where it's used
- Keep using crtc_state->hw.active instead of .enable(Matthew Roper)
- Moved unrelated changes to other patch(using latency as parameter
for plane wm calculation, moved to SAGV refactoring patch)
v12: - Fix rebase conflict with own temporary SAGV/QGV fix.
- Remove unnecessary mask being zero check when unmasking
qgv points as this is completely legal(Matt Roper)
- Check if we are setting the same mask as already being set
in hardware to prevent error from PCode.
- Fix error message when restricting/unrestricting qgv points
to "mask/unmask" which sounds more accurate(Matt Roper)
- Move sagv status setting to icl_get_bw_info from atomic check
as this should be calculated only once.(Matt Roper)
- Edited comments for the case when we can't enable SAGV and
use only 1 QGV point with highest bandwidth to be more
understandable.(Matt Roper)
v13: - Moved max_data_rate in bw check to closer scope(Ville Syrjälä)
- Changed comment for zero new_mask in qgv points masking function
to better reflect reality(Ville Syrjälä)
- Simplified bit mask operation in qgv points masking function
(Ville Syrjälä)
- Moved intel_qgv_points_mask closer to gen11 SAGV disabling,
however this still can't be under modeset condition(Ville Syrjälä)
- Packed qgv_points_mask as u8 and moved closer to pipe_sagv_mask
(Ville Syrjälä)
- Extracted PCode changes to separate patch.(Ville Syrjälä)
- Now treat num_planes 0 same as 1 to avoid confusion and
returning max_bw as 0, which would prevent choosing QGV
point having max bandwidth in case if SAGV is not allowed,
as per BSpec(Ville Syrjälä)
- Do the actual qgv_points_mask swap in the same place as
all other global state parts like cdclk are swapped.
In the next patch, this all will be moved to bw state as
global state, once new global state patch series from Ville
lands
v14: - Now using global state to serialize access to qgv points
- Added global state locking back, otherwise we seem to read
bw state in a wrong way.
v15: - Added TODO comment for near atomic global state locking in
bw code.
v16: - Fixed intel_atomic_bw_* functions to be intel_bw_* as discussed
with Jani Nikula.
- Take bw_state_changed flag into use.
v17: - Moved qgv point related manipulations next to SAGV code, as
those are semantically related(Ville Syrjälä)
- Renamed those into intel_sagv_(pre)|(post)_plane_update
(Ville Syrjälä)
v18: - Move sagv related calls from commit tail into
intel_sagv_(pre)|(post)_plane_update(Ville Syrjälä)
v19: - Use intel_atomic_get_bw_(old)|(new)_state which is intended
for commit tail stage.
v20: - Return max bandwidth for 0 planes(Ville)
- Constify old_bw_state in bw_atomic_check(Ville)
- Removed some debugs(Ville)
- Added data rate to debug print when no QGV points(Ville)
- Removed some comments(Ville)
v21, v22, v23: - Fixed rebase conflict
v24: - Changed PCode mask to use ICL_ prefix
v25: - Resolved rebase conflict
v26: - Removed redundant NULL checks(Ville)
- Removed redundant error prints(Ville)
v27: - Use device specific drm_err(Ville)
- Fixed parenthesis ident reported by checkpatch
Line over 100 warns to be fixed together with
existing code style.
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Cc: Ville Syrjälä <ville.syrjala@intel.com>
Cc: James Ausmus <james.ausmus@intel.com>
[vsyrjala: Drop duplicate intel_sagv_{pre,post}_plane_update() prototypes
and drop unused NUM_SAGV_POINTS define]
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200514074853.9508-3-stanislav.lisovskiy@intel.com
2020-05-14 10:48:52 +03:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, 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);
|
2020-04-15 17:39:04 +03:00
|
|
|
}
|
|
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
static void vlv_read_wm_values(struct drm_i915_private *dev_priv,
|
|
|
|
|
struct vlv_wm_values *wm)
|
2022-02-18 08:40:36 +02:00
|
|
|
{
|
2022-09-08 22:16:45 +03:00
|
|
|
enum pipe pipe;
|
|
|
|
|
u32 tmp;
|
2022-02-18 08:40:36 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
for_each_pipe(dev_priv, pipe) {
|
|
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, VLV_DDL(pipe));
|
2022-02-18 08:40:36 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
wm->ddl[pipe].plane[PLANE_PRIMARY] =
|
|
|
|
|
(tmp >> DDL_PLANE_SHIFT) & (DDL_PRECISION_HIGH | DRAIN_LATENCY_MASK);
|
|
|
|
|
wm->ddl[pipe].plane[PLANE_CURSOR] =
|
|
|
|
|
(tmp >> DDL_CURSOR_SHIFT) & (DDL_PRECISION_HIGH | DRAIN_LATENCY_MASK);
|
|
|
|
|
wm->ddl[pipe].plane[PLANE_SPRITE0] =
|
|
|
|
|
(tmp >> DDL_SPRITE_SHIFT(0)) & (DDL_PRECISION_HIGH | DRAIN_LATENCY_MASK);
|
|
|
|
|
wm->ddl[pipe].plane[PLANE_SPRITE1] =
|
|
|
|
|
(tmp >> DDL_SPRITE_SHIFT(1)) & (DDL_PRECISION_HIGH | DRAIN_LATENCY_MASK);
|
|
|
|
|
}
|
2022-02-18 08:40:36 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, 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_VLV(tmp, PLANEB);
|
|
|
|
|
wm->pipe[PIPE_A].plane[PLANE_PRIMARY] = _FW_WM_VLV(tmp, PLANEA);
|
2022-02-18 08:40:36 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, DSPFW2);
|
|
|
|
|
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);
|
2022-02-18 08:40:36 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, DSPFW3);
|
|
|
|
|
wm->sr.cursor = _FW_WM(tmp, CURSOR_SR);
|
2022-02-18 08:40:36 +02:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
if (IS_CHERRYVIEW(dev_priv)) {
|
|
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, DSPFW7_CHV);
|
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE1] = _FW_WM_VLV(tmp, SPRITED);
|
|
|
|
|
wm->pipe[PIPE_B].plane[PLANE_SPRITE0] = _FW_WM_VLV(tmp, SPRITEC);
|
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 15:55:54 -04:00
|
|
|
|
2022-09-08 22:16:45 +03:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, DSPFW8_CHV);
|
|
|
|
|
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 22:00:03 +03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, DSPFW9_CHV);
|
2016-11-28 19:37:08 +02: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 22:00:03 +03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, DSPHOWM);
|
2015-06-24 22:00:03 +03:00
|
|
|
wm->sr.plane |= _FW_WM(tmp, SR_HI) << 9;
|
2016-11-28 19:37:08 +02: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 22:00:03 +03:00
|
|
|
} else {
|
2020-11-30 13:15:58 +02:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, DSPFW7);
|
2016-11-28 19:37:08 +02: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 22:00:03 +03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, DSPHOWM);
|
2015-06-24 22:00:03 +03:00
|
|
|
wm->sr.plane |= _FW_WM(tmp, SR_HI) << 9;
|
2016-11-28 19:37:08 +02: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 22:00:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef _FW_WM
|
|
|
|
|
#undef _FW_WM_VLV
|
|
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
void g4x_wm_get_hw_state(struct drm_i915_private *dev_priv)
|
2017-04-21 21:14:29 +03:00
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
struct g4x_wm_values *wm = &dev_priv->display.wm.g4x;
|
2017-04-21 21:14:29 +03:00
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
|
|
g4x_read_wm_values(dev_priv, wm);
|
|
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
wm->cxsr = intel_uncore_read(&dev_priv->uncore, FW_BLC_SELF) & FW_BLC_SELF_EN;
|
2017-04-21 21:14:29 +03:00
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2017-04-21 21:14:29 +03: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];
|
|
|
|
|
|
2021-05-14 15:57:42 +03:00
|
|
|
level = G4X_WM_LEVEL_SR;
|
|
|
|
|
if (level > max_level)
|
2017-04-21 21:14:29 +03:00
|
|
|
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;
|
|
|
|
|
|
2021-05-14 15:57:42 +03:00
|
|
|
level = G4X_WM_LEVEL_HPLL;
|
|
|
|
|
if (level > max_level)
|
2017-04-21 21:14:29 +03:00
|
|
|
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;
|
|
|
|
|
|
2021-05-14 15:57:42 +03:00
|
|
|
level++;
|
2017-04-21 21:14:29 +03:00
|
|
|
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 18:13:30 +03: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 21:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 18:13:30 +03: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",
|
2022-02-25 15:46:28 -08:00
|
|
|
str_yes_no(wm->cxsr), str_yes_no(wm->hpll_en),
|
|
|
|
|
str_yes_no(wm->fbc_en));
|
2017-04-21 21:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void g4x_wm_sanitize(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
|
|
|
|
struct intel_plane *plane;
|
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
2017-04-21 21:14:29 +03:00
|
|
|
|
|
|
|
|
for_each_intel_plane(&dev_priv->drm, plane) {
|
|
|
|
|
struct intel_crtc *crtc =
|
2021-12-01 15:57:04 +02:00
|
|
|
intel_crtc_for_pipe(dev_priv, plane->pipe);
|
2017-04-21 21:14:29 +03:00
|
|
|
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 12:26:08 +01:00
|
|
|
if (plane_state->uapi.visible)
|
2017-04-21 21:14:29 +03: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);
|
|
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2017-04-21 21:14:29 +03:00
|
|
|
}
|
|
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
void vlv_wm_get_hw_state(struct drm_i915_private *dev_priv)
|
2015-06-24 22:00:03 +03:00
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
struct vlv_wm_values *wm = &dev_priv->display.wm.vlv;
|
2017-03-02 19:14:52 +02:00
|
|
|
struct intel_crtc *crtc;
|
2015-06-24 22:00:03 +03:00
|
|
|
u32 val;
|
|
|
|
|
|
|
|
|
|
vlv_read_wm_values(dev_priv, wm);
|
|
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
wm->cxsr = intel_uncore_read(&dev_priv->uncore, FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
|
2015-06-24 22:00:03 +03:00
|
|
|
wm->level = VLV_WM_LEVEL_PM2;
|
|
|
|
|
|
|
|
|
|
if (IS_CHERRYVIEW(dev_priv)) {
|
2019-04-26 09:17:20 +01:00
|
|
|
vlv_punit_get(dev_priv);
|
2015-06-24 22:00:03 +03:00
|
|
|
|
2018-11-29 19:55:03 +02:00
|
|
|
val = vlv_punit_read(dev_priv, PUNIT_REG_DSPSSPM);
|
2015-06-24 22:00:03 +03:00
|
|
|
if (val & DSP_MAXFIFO_PM5_ENABLE)
|
|
|
|
|
wm->level = VLV_WM_LEVEL_PM5;
|
|
|
|
|
|
2015-09-08 21:05:12 +03: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 22:00:03 +03:00
|
|
|
val = vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2);
|
2015-09-08 21:05:12 +03: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 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"Punit not acking DDR DVFS request, "
|
|
|
|
|
"assuming DDR DVFS is disabled\n");
|
2022-08-24 16:15:40 +03:00
|
|
|
dev_priv->display.wm.max_level = VLV_WM_LEVEL_PM5;
|
2015-09-08 21:05:12 +03:00
|
|
|
} 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 22:00:03 +03:00
|
|
|
|
2019-04-26 09:17:20 +01:00
|
|
|
vlv_punit_put(dev_priv);
|
2015-06-24 22:00:03 +03:00
|
|
|
}
|
|
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2017-03-02 19:14:57 +02: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 21:14:21 +03:00
|
|
|
struct g4x_pipe_wm *raw =
|
2017-03-02 19:14:57 +02: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 19:14:59 +02:00
|
|
|
crtc_state->wm.vlv.intermediate = *active;
|
2017-03-02 19:14:57 +02:00
|
|
|
|
2020-01-07 18:13:30 +03: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 19:14:57 +02:00
|
|
|
}
|
2015-06-24 22:00:03 +03:00
|
|
|
|
2020-01-07 18:13:30 +03: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 22:00:03 +03:00
|
|
|
}
|
|
|
|
|
|
2017-03-02 19:15:02 +02:00
|
|
|
void vlv_wm_sanitize(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
|
|
|
|
struct intel_plane *plane;
|
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_lock(&dev_priv->display.wm.wm_mutex);
|
2017-03-02 19:15:02 +02:00
|
|
|
|
|
|
|
|
for_each_intel_plane(&dev_priv->drm, plane) {
|
|
|
|
|
struct intel_crtc *crtc =
|
2021-12-01 15:57:04 +02:00
|
|
|
intel_crtc_for_pipe(dev_priv, plane->pipe);
|
2017-03-02 19:15:02 +02:00
|
|
|
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 12:26:08 +01:00
|
|
|
if (plane_state->uapi.visible)
|
2017-03-02 19:15:02 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for (level = 0; level < wm_state->num_levels; level++) {
|
2017-04-21 21:14:21 +03:00
|
|
|
struct g4x_pipe_wm *raw =
|
2017-03-02 19:15:02 +02: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);
|
|
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
mutex_unlock(&dev_priv->display.wm.wm_mutex);
|
2017-03-02 19:15:02 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-08 15:35:55 +02: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)
|
|
|
|
|
{
|
2022-02-17 01:28:06 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, WM3_LP_ILK, intel_uncore_read(&dev_priv->uncore, WM3_LP_ILK) & ~WM_LP_ENABLE);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, WM2_LP_ILK, intel_uncore_read(&dev_priv->uncore, WM2_LP_ILK) & ~WM_LP_ENABLE);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, WM1_LP_ILK, intel_uncore_read(&dev_priv->uncore, WM1_LP_ILK) & ~WM_LP_ENABLE);
|
2017-11-08 15:35:55 +02:00
|
|
|
|
|
|
|
|
/*
|
2022-02-17 01:28:06 +02:00
|
|
|
* Don't touch WM_LP_SPRITE_ENABLE here.
|
2017-11-08 15:35:55 +02:00
|
|
|
* Doing so could cause underruns.
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
void ilk_wm_get_hw_state(struct drm_i915_private *dev_priv)
|
2013-10-14 14:55:24 +03:00
|
|
|
{
|
2022-08-24 16:15:40 +03:00
|
|
|
struct ilk_wm_values *hw = &dev_priv->display.wm.hw;
|
2018-12-10 13:54:14 -08:00
|
|
|
struct intel_crtc *crtc;
|
2013-10-14 14:55:24 +03:00
|
|
|
|
2017-11-08 15:35:55 +02:00
|
|
|
ilk_init_lp_watermarks(dev_priv);
|
|
|
|
|
|
2018-12-10 13:54:14 -08:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc)
|
2013-10-14 14:55:24 +03:00
|
|
|
ilk_pipe_wm_get_hw_state(crtc);
|
|
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
hw->wm_lp[0] = intel_uncore_read(&dev_priv->uncore, WM1_LP_ILK);
|
|
|
|
|
hw->wm_lp[1] = intel_uncore_read(&dev_priv->uncore, WM2_LP_ILK);
|
|
|
|
|
hw->wm_lp[2] = intel_uncore_read(&dev_priv->uncore, WM3_LP_ILK);
|
2013-10-14 14:55:24 +03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
hw->wm_lp_spr[0] = intel_uncore_read(&dev_priv->uncore, WM1S_LP_ILK);
|
2021-03-19 21:42:43 -07:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 7) {
|
2020-11-30 13:15:58 +02:00
|
|
|
hw->wm_lp_spr[1] = intel_uncore_read(&dev_priv->uncore, WM2S_LP_IVB);
|
|
|
|
|
hw->wm_lp_spr[2] = intel_uncore_read(&dev_priv->uncore, WM3S_LP_IVB);
|
2014-03-07 18:32:08 +02:00
|
|
|
}
|
2013-10-14 14:55:24 +03:00
|
|
|
|
2016-10-13 11:03:00 +01:00
|
|
|
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
|
2020-11-30 13:15:58 +02:00
|
|
|
hw->partitioning = (intel_uncore_read(&dev_priv->uncore, WM_MISC) & WM_MISC_DATA_PARTITION_5_6) ?
|
2013-12-05 15:51:28 +02:00
|
|
|
INTEL_DDB_PART_5_6 : INTEL_DDB_PART_1_2;
|
2016-10-14 10:13:06 +01:00
|
|
|
else if (IS_IVYBRIDGE(dev_priv))
|
2020-11-30 13:15:58 +02:00
|
|
|
hw->partitioning = (intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL2) & DISP_DATA_PARTITION_5_6) ?
|
2013-12-05 15:51:28 +02:00
|
|
|
INTEL_DDB_PART_5_6 : INTEL_DDB_PART_1_2;
|
2013-10-14 14:55:24 +03:00
|
|
|
|
|
|
|
|
hw->enable_fbc_wm =
|
2020-11-30 13:15:58 +02:00
|
|
|
!(intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL) & DISP_FBC_WM_DIS);
|
2013-10-14 14:55:24 +03:00
|
|
|
}
|
|
|
|
|
|
2019-10-24 22:16:41 +01: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.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
|
2019-10-24 22:16:41 +01:00
|
|
|
}
|
2012-08-09 16:46:01 +02:00
|
|
|
|
2019-10-24 22:16:41 +01:00
|
|
|
static void g4x_disable_trickle_feed(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:23 -03:00
|
|
|
{
|
2019-10-24 22:16:41 +01:00
|
|
|
enum pipe pipe;
|
2012-04-18 15:29:23 -03:00
|
|
|
|
2019-10-24 22:16:41 +01:00
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPCNTR(pipe),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, DSPCNTR(pipe)) |
|
2022-01-21 13:30:31 +02:00
|
|
|
DISP_TRICKLE_FEED_DISABLE);
|
2012-08-09 16:46:01 +02:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPSURF(pipe), intel_uncore_read(&dev_priv->uncore, DSPSURF(pipe)));
|
|
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, DSPSURF(pipe));
|
2012-04-18 15:29:23 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-24 22:16:41 +01:00
|
|
|
static void ilk_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:23 -03:00
|
|
|
{
|
2019-10-24 22:16:41 +01:00
|
|
|
u32 dspclk_gate = ILK_VRHUNIT_CLOCK_GATE_DISABLE;
|
2012-04-18 15:29:23 -03:00
|
|
|
|
2019-10-24 22:16:41 +01: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 15:29:23 -03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, PCH_3DCGDIS0,
|
2019-10-24 22:16:41 +01:00
|
|
|
MARIUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
|
SVSMUNIT_CLOCK_GATE_DISABLE);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, PCH_3DCGDIS1,
|
2019-10-24 22:16:41 +01:00
|
|
|
VFMUNIT_CLOCK_GATE_DISABLE);
|
2012-04-18 15:29:23 -03:00
|
|
|
|
2019-10-24 22:16:41 +01: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
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2,
|
|
|
|
|
(intel_uncore_read(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2) |
|
2019-10-24 22:16:41 +01:00
|
|
|
ILK_DPARB_GATE | ILK_VSDPFD_FULL));
|
|
|
|
|
dspclk_gate |= ILK_DPARBUNIT_CLOCK_GATE_ENABLE;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL,
|
|
|
|
|
(intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL) |
|
2019-10-24 22:16:41 +01:00
|
|
|
DISP_FBC_WM_DIS));
|
2012-04-18 15:29:23 -03:00
|
|
|
|
|
|
|
|
/*
|
2019-10-24 22:16:41 +01: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 15:29:23 -03:00
|
|
|
*/
|
2019-10-24 22:16:41 +01:00
|
|
|
if (IS_IRONLAKE_M(dev_priv)) {
|
|
|
|
|
/* WaFbcAsynchFlipDisableFbcQueue:ilk */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DISPLAY_CHICKEN1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DISPLAY_CHICKEN1) |
|
2019-10-24 22:16:41 +01:00
|
|
|
ILK_FBCQ_DIS);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2) |
|
2019-10-24 22:16:41 +01:00
|
|
|
ILK_DPARB_GATE);
|
|
|
|
|
}
|
2012-04-18 15:29:23 -03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DSPCLK_GATE_D, dspclk_gate);
|
2012-04-18 15:29:23 -03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2) |
|
2019-10-24 22:16:41 +01:00
|
|
|
ILK_ELPIN_409_SELECT);
|
2012-04-18 15:29:23 -03:00
|
|
|
|
2019-10-24 22:16:41 +01:00
|
|
|
g4x_disable_trickle_feed(dev_priv);
|
2012-08-09 16:46:01 +02:00
|
|
|
|
2019-10-24 22:16:41 +01:00
|
|
|
ibx_init_clock_gating(dev_priv);
|
2012-04-18 15:29:23 -03:00
|
|
|
}
|
|
|
|
|
|
2019-10-24 22:16:41 +01:00
|
|
|
static void cpt_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:23 -03:00
|
|
|
{
|
2019-10-24 22:16:41 +01:00
|
|
|
enum pipe pipe;
|
|
|
|
|
u32 val;
|
2012-04-18 15:29:23 -03:00
|
|
|
|
2019-10-24 22:16:41 +01: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.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE |
|
2019-10-24 22:16:41 +01:00
|
|
|
PCH_DPLUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
|
PCH_CPUNIT_CLOCK_GATE_DISABLE);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, SOUTH_CHICKEN2, intel_uncore_read(&dev_priv->uncore, SOUTH_CHICKEN2) |
|
2019-10-24 22:16:41 +01:00
|
|
|
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) {
|
2020-11-30 13:15:58 +02:00
|
|
|
val = intel_uncore_read(&dev_priv->uncore, TRANS_CHICKEN2(pipe));
|
2019-10-24 22:16:41 +01:00
|
|
|
val |= TRANS_CHICKEN2_TIMING_OVERRIDE;
|
|
|
|
|
val &= ~TRANS_CHICKEN2_FDI_POLARITY_REVERSED;
|
2022-08-29 16:18:14 +03:00
|
|
|
if (dev_priv->display.vbt.fdi_rx_polarity_inverted)
|
2019-10-24 22:16:41 +01:00
|
|
|
val |= TRANS_CHICKEN2_FDI_POLARITY_REVERSED;
|
|
|
|
|
val &= ~TRANS_CHICKEN2_DISABLE_DEEP_COLOR_COUNTER;
|
|
|
|
|
val &= ~TRANS_CHICKEN2_DISABLE_DEEP_COLOR_MODESWITCH;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, TRANS_CHICKEN2(pipe), val);
|
2019-10-24 22:16:41 +01:00
|
|
|
}
|
|
|
|
|
/* WADP0ClockGatingDisable */
|
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, TRANS_CHICKEN1(pipe),
|
2019-10-24 22:16:41 +01:00
|
|
|
TRANS_CHICKEN1_DP0UNIT_GC_DISABLE);
|
|
|
|
|
}
|
2012-04-18 15:29:23 -03:00
|
|
|
}
|
|
|
|
|
|
2019-10-24 22:16:41 +01:00
|
|
|
static void gen6_check_mch_setup(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:23 -03:00
|
|
|
{
|
2019-10-24 22:16:41 +01:00
|
|
|
u32 tmp;
|
2012-07-26 11:16:14 +02:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
tmp = intel_uncore_read(&dev_priv->uncore, MCH_SSKPD);
|
2022-02-17 01:28:05 +02:00
|
|
|
if (REG_FIELD_GET(SSKPD_WM0_MASK_SNB, tmp) != 12)
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"Wrong MCH_SSKPD value: 0x%08x This can cause underruns.\n",
|
|
|
|
|
tmp);
|
2012-07-26 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-24 22:16:41 +01: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 17:34:57 +01:00
|
|
|
{
|
2019-10-24 22:16:41 +01: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 17:34:57 +01:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, 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 17:34:57 +01:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2) |
|
2019-10-24 22:16:41 +01:00
|
|
|
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 17:34:57 +01:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN6_UCGCTL1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN6_UCGCTL1) |
|
2019-10-24 22:16:41 +01:00
|
|
|
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 17:34:57 +01:00
|
|
|
|
2019-10-24 22:16:41 +01: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 15:52:59 +02:00
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN6_UCGCTL2,
|
2019-10-24 22:16:41 +01:00
|
|
|
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 14:26:29 +01:00
|
|
|
|
2019-10-24 22:16:41 +01: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
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DISPLAY_CHICKEN1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DISPLAY_CHICKEN1) |
|
2019-10-24 22:16:41 +01:00
|
|
|
ILK_FBCQ_DIS | ILK_PABSTRETCH_DIS);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DISPLAY_CHICKEN2) |
|
2019-10-24 22:16:41 +01:00
|
|
|
ILK_DPARB_GATE | ILK_VSDPFD_FULL);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DSPCLK_GATE_D,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DSPCLK_GATE_D) |
|
2019-10-24 22:16:41 +01:00
|
|
|
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 17:34:57 +01:00
|
|
|
|
2019-10-24 22:16:41 +01: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 14:26:29 +01:00
|
|
|
|
2019-10-24 22:16:41 +01: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 14:26:29 +01:00
|
|
|
|
2019-10-24 22:16:41 +01: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 14:26:29 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-24 22:16:41 +01:00
|
|
|
static void lpt_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-07-26 11:16:14 +02:00
|
|
|
{
|
2019-10-24 22:16:41 +01: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 15:12:07 -02:00
|
|
|
*/
|
2016-10-13 11:02:52 +01:00
|
|
|
if (HAS_PCH_LPT_LP(dev_priv))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, SOUTH_DSPCLK_GATE_D,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, SOUTH_DSPCLK_GATE_D) |
|
2012-11-20 15:12:07 -02:00
|
|
|
PCH_LP_PARTITION_LEVEL_DISABLE);
|
2013-04-17 18:15:49 -03:00
|
|
|
|
|
|
|
|
/* WADPOClockGatingDisable:hsw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, TRANS_CHICKEN1(PIPE_A),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, TRANS_CHICKEN1(PIPE_A)) |
|
2013-04-17 18:15:49 -03:00
|
|
|
TRANS_CHICKEN1_DP0UNIT_GC_DISABLE);
|
2012-11-20 15:12:07 -02:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:23 +02:00
|
|
|
static void lpt_suspend_hw(struct drm_i915_private *dev_priv)
|
2013-04-17 14:04:50 +03:00
|
|
|
{
|
2016-10-13 11:02:52 +01:00
|
|
|
if (HAS_PCH_LPT_LP(dev_priv)) {
|
2020-11-30 13:15:58 +02:00
|
|
|
u32 val = intel_uncore_read(&dev_priv->uncore, SOUTH_DSPCLK_GATE_D);
|
2013-04-17 14:04:50 +03:00
|
|
|
|
|
|
|
|
val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, SOUTH_DSPCLK_GATE_D, val);
|
2013-04-17 14:04:50 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-03 15:54:21 +03: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 13:25:45 -07:00
|
|
|
u32 val;
|
2016-05-03 15:54:21 +03:00
|
|
|
|
|
|
|
|
/* WaTempDisableDOPClkGating:bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
misccpctl = intel_uncore_read(&dev_priv->uncore, GEN7_MISCCPCTL);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE);
|
2016-05-03 15:54:21 +03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
val = intel_uncore_read(&dev_priv->uncore, GEN8_L3SQCREG1);
|
2017-10-17 13:25:45 -07:00
|
|
|
val &= ~L3_PRIO_CREDITS_MASK;
|
|
|
|
|
val |= L3_GENERAL_PRIO_CREDITS(general_prio_credits);
|
|
|
|
|
val |= L3_HIGH_PRIO_CREDITS(high_prio_credits);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN8_L3SQCREG1, val);
|
2016-05-03 15:54:21 +03:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Wait at least 100 clocks before re-enabling clock gating.
|
|
|
|
|
* See the definition of L3SQCREG1 in BSpec.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_posting_read(&dev_priv->uncore, GEN8_L3SQCREG1);
|
2016-05-03 15:54:21 +03:00
|
|
|
udelay(1);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_MISCCPCTL, misccpctl);
|
2016-05-03 15:54:21 +03:00
|
|
|
}
|
|
|
|
|
|
2018-05-08 14:29:24 -07:00
|
|
|
static void icl_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
2020-07-08 16:12:20 +03:00
|
|
|
/* Wa_1409120013:icl,ehl */
|
2021-12-14 20:46:16 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
|
|
|
|
|
DPFC_CHICKEN_COMP_DUMMY_PIXEL);
|
2020-07-08 16:12:20 +03:00
|
|
|
|
2020-01-13 23:11:28 -05:00
|
|
|
/*Wa_14010594013:icl, ehl */
|
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, GEN8_CHICKEN_DCPR_1,
|
2021-07-28 14:59:38 -07:00
|
|
|
0, ICL_DELAY_PMRSP);
|
2018-05-08 14:29:24 -07:00
|
|
|
}
|
|
|
|
|
|
2021-01-13 05:37:59 -08:00
|
|
|
static void gen12lp_init_clock_gating(struct drm_i915_private *dev_priv)
|
2020-10-14 12:19:34 -07:00
|
|
|
{
|
2022-09-07 16:25:42 -07:00
|
|
|
/* Wa_1409120013 */
|
|
|
|
|
if (DISPLAY_VER(dev_priv) == 12)
|
2021-12-14 20:46:16 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
|
2021-11-04 16:45:15 +02:00
|
|
|
DPFC_CHICKEN_COMP_DUMMY_PIXEL);
|
2020-07-08 16:12:20 +03:00
|
|
|
|
2020-01-09 14:37:27 -08:00
|
|
|
/* Wa_1409825376:tgl (pre-prod)*/
|
2021-07-16 22:14:26 -07:00
|
|
|
if (IS_TGL_DISPLAY_STEP(dev_priv, STEP_A0, STEP_C0))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN9_CLKGATE_DIS_3, intel_uncore_read(&dev_priv->uncore, GEN9_CLKGATE_DIS_3) |
|
2020-01-09 14:37:27 -08:00
|
|
|
TGL_VRH_GATING_DIS);
|
2020-04-15 15:35:35 -04:00
|
|
|
|
2021-04-08 13:49:16 -07:00
|
|
|
/* Wa_14013723622:tgl,rkl,dg1,adl-s */
|
|
|
|
|
if (DISPLAY_VER(dev_priv) == 12)
|
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, CLKREQ_POLICY,
|
|
|
|
|
CLKREQ_POLICY_MEM_UP_OVRD, 0);
|
2019-08-23 01:20:34 -07:00
|
|
|
}
|
|
|
|
|
|
2021-05-14 08:37:09 -07:00
|
|
|
static void adlp_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
|
|
|
|
gen12lp_init_clock_gating(dev_priv);
|
|
|
|
|
|
|
|
|
|
/* Wa_22011091694:adlp */
|
|
|
|
|
intel_de_rmw(dev_priv, GEN9_CLKGATE_DIS_5, 0, DPCE_GATING_DIS);
|
2022-03-23 22:17:49 +02:00
|
|
|
|
|
|
|
|
/* Bspec/49189 Initialize Sequence */
|
|
|
|
|
intel_de_rmw(dev_priv, GEN8_CHICKEN_DCPR_1, DDI_CLOCK_REG_ACCESS, 0);
|
2021-05-14 08:37:09 -07:00
|
|
|
}
|
|
|
|
|
|
2020-10-14 12:19:34 -07:00
|
|
|
static void dg1_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
2021-01-13 05:37:59 -08:00
|
|
|
gen12lp_init_clock_gating(dev_priv);
|
|
|
|
|
|
2020-10-14 12:19:34 -07:00
|
|
|
/* Wa_1409836686:dg1[a0] */
|
2021-10-19 17:23:53 -07:00
|
|
|
if (IS_DG1_GRAPHICS_STEP(dev_priv, STEP_A0, STEP_B0))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN9_CLKGATE_DIS_3, intel_uncore_read(&dev_priv->uncore, GEN9_CLKGATE_DIS_3) |
|
2020-10-14 12:19:34 -07:00
|
|
|
DPT_GATING_DIS);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-02 15:25:09 -07:00
|
|
|
static void xehpsdv_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
|
|
|
|
/* Wa_22010146351:xehpsdv */
|
|
|
|
|
if (IS_XEHPSDV_GRAPHICS_STEP(dev_priv, STEP_A0, STEP_B0))
|
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, XEHP_CLOCK_GATE_DIS, 0, SGR_DIS);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-02 15:25:10 -07:00
|
|
|
static void dg2_init_clock_gating(struct drm_i915_private *i915)
|
|
|
|
|
{
|
2022-05-17 13:13:38 -07:00
|
|
|
/* Wa_22010954014:dg2 */
|
|
|
|
|
intel_uncore_rmw(&i915->uncore, XEHP_CLOCK_GATE_DIS, 0,
|
|
|
|
|
SGSI_SIDECLK_DIS);
|
2021-11-02 15:25:10 -07:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Wa_14010733611:dg2_g10
|
|
|
|
|
* Wa_22010146351:dg2_g10
|
|
|
|
|
*/
|
|
|
|
|
if (IS_DG2_GRAPHICS_STEP(i915, G10, STEP_A0, STEP_B0))
|
|
|
|
|
intel_uncore_rmw(&i915->uncore, XEHP_CLOCK_GATE_DIS, 0,
|
|
|
|
|
SGR_DIS | SGGI_DIS);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-27 09:33:48 -07:00
|
|
|
static void pvc_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
|
|
|
|
/* Wa_14012385139:pvc */
|
|
|
|
|
if (IS_PVC_BD_STEP(dev_priv, STEP_A0, STEP_B0))
|
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, XEHP_CLOCK_GATE_DIS, 0, SGR_DIS);
|
|
|
|
|
|
|
|
|
|
/* Wa_22010954014:pvc */
|
|
|
|
|
if (IS_PVC_BD_STEP(dev_priv, STEP_A0, STEP_B0))
|
|
|
|
|
intel_uncore_rmw(&dev_priv->uncore, XEHP_CLOCK_GATE_DIS, 0, SGSI_SIDECLK_DIS);
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-30 21:52:23 -07:00
|
|
|
static void cnp_init_clock_gating(struct drm_i915_private *dev_priv)
|
|
|
|
|
{
|
|
|
|
|
if (!HAS_PCH_CNP(dev_priv))
|
|
|
|
|
return;
|
|
|
|
|
|
2018-03-05 17:28:12 -08:00
|
|
|
/* Display WA #1181 WaSouthDisplayDisablePWMCGEGating: cnp */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, SOUTH_DSPCLK_GATE_D, intel_uncore_read(&dev_priv->uncore, SOUTH_DSPCLK_GATE_D) |
|
2017-09-08 16:45:33 -07:00
|
|
|
CNP_PWM_CGE_GATING_DISABLE);
|
2017-08-30 21:52:23 -07: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);
|
|
|
|
|
|
2020-07-16 22:04:26 +03:00
|
|
|
/* WAC6entrylatency:cfl */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, FBC_LLC_READ_CTRL, intel_uncore_read(&dev_priv->uncore, FBC_LLC_READ_CTRL) |
|
2020-07-16 22:04:26 +03:00
|
|
|
FBC_LLC_FULLY_OPEN);
|
|
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcTurnOffFbcWatermark:cfl
|
|
|
|
|
* Display WA #0562: cfl
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL, intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL) |
|
2020-07-08 16:12:21 +03:00
|
|
|
DISP_FBC_WM_DIS);
|
|
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcNukeOnHostModify:cfl
|
|
|
|
|
* Display WA #0873: cfl
|
|
|
|
|
*/
|
2021-12-14 20:46:16 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A)) |
|
|
|
|
|
DPFC_NUKE_ON_ANY_MODIFICATION);
|
2017-08-30 21:52:23 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void kbl_init_clock_gating(struct drm_i915_private *dev_priv)
|
2016-06-07 17:19:01 +03:00
|
|
|
{
|
2016-10-31 22:37:22 +02:00
|
|
|
gen9_init_clock_gating(dev_priv);
|
2016-06-07 17:19:01 +03:00
|
|
|
|
2020-07-16 22:04:26 +03:00
|
|
|
/* WAC6entrylatency:kbl */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, FBC_LLC_READ_CTRL, intel_uncore_read(&dev_priv->uncore, FBC_LLC_READ_CTRL) |
|
2020-07-16 22:04:26 +03:00
|
|
|
FBC_LLC_FULLY_OPEN);
|
|
|
|
|
|
2016-06-07 17:19:01 +03:00
|
|
|
/* WaDisableSDEUnitClockGating:kbl */
|
2021-10-19 17:23:53 -07:00
|
|
|
if (IS_KBL_GRAPHICS_STEP(dev_priv, 0, STEP_C0))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN8_UCGCTL6, intel_uncore_read(&dev_priv->uncore, GEN8_UCGCTL6) |
|
2016-06-07 17:19:01 +03:00
|
|
|
GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
|
2016-06-07 17:19:05 +03:00
|
|
|
|
|
|
|
|
/* WaDisableGamClockGating:kbl */
|
2021-10-19 17:23:53 -07:00
|
|
|
if (IS_KBL_GRAPHICS_STEP(dev_priv, 0, STEP_C0))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN6_UCGCTL1, intel_uncore_read(&dev_priv->uncore, GEN6_UCGCTL1) |
|
2016-06-07 17:19:05 +03:00
|
|
|
GEN6_GAMUNIT_CLOCK_GATE_DISABLE);
|
2016-06-07 17:19:18 +03:00
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcTurnOffFbcWatermark:kbl
|
|
|
|
|
* Display WA #0562: kbl
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL, intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL) |
|
2020-07-08 16:12:21 +03:00
|
|
|
DISP_FBC_WM_DIS);
|
|
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcNukeOnHostModify:kbl
|
|
|
|
|
* Display WA #0873: kbl
|
|
|
|
|
*/
|
2021-12-14 20:46:16 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A)) |
|
|
|
|
|
DPFC_NUKE_ON_ANY_MODIFICATION);
|
2016-06-07 17:19:01 +03:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void skl_init_clock_gating(struct drm_i915_private *dev_priv)
|
2016-05-19 09:14:20 +02:00
|
|
|
{
|
2016-10-31 22:37:22 +02:00
|
|
|
gen9_init_clock_gating(dev_priv);
|
2016-06-07 17:19:09 +03:00
|
|
|
|
2020-07-16 22:04:25 +03:00
|
|
|
/* WaDisableDopClockGating:skl */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_MISCCPCTL, intel_uncore_read(&dev_priv->uncore, GEN7_MISCCPCTL) &
|
2020-07-16 22:04:25 +03:00
|
|
|
~GEN7_DOP_CLOCK_GATE_ENABLE);
|
|
|
|
|
|
2016-06-07 17:19:09 +03:00
|
|
|
/* WAC6entrylatency:skl */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, FBC_LLC_READ_CTRL, intel_uncore_read(&dev_priv->uncore, FBC_LLC_READ_CTRL) |
|
2016-06-07 17:19:09 +03:00
|
|
|
FBC_LLC_FULLY_OPEN);
|
2016-06-07 17:19:18 +03:00
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcTurnOffFbcWatermark:skl
|
|
|
|
|
* Display WA #0562: skl
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DISP_ARB_CTL, intel_uncore_read(&dev_priv->uncore, DISP_ARB_CTL) |
|
2020-07-08 16:12:21 +03:00
|
|
|
DISP_FBC_WM_DIS);
|
|
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcNukeOnHostModify:skl
|
|
|
|
|
* Display WA #0873: skl
|
|
|
|
|
*/
|
2021-12-14 20:46:16 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A)) |
|
|
|
|
|
DPFC_NUKE_ON_ANY_MODIFICATION);
|
2020-07-08 16:12:22 +03:00
|
|
|
|
2020-07-08 16:12:23 +03:00
|
|
|
/*
|
|
|
|
|
* WaFbcHighMemBwCorruptionAvoidance:skl
|
|
|
|
|
* Display WA #0883: skl
|
|
|
|
|
*/
|
2021-12-14 20:46:16 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DPFC_CHICKEN(INTEL_FBC_A)) |
|
|
|
|
|
DPFC_DISABLE_DUMMY0);
|
2016-05-19 09:14:20 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void bdw_init_clock_gating(struct drm_i915_private *dev_priv)
|
2013-11-02 21:07:06 -07:00
|
|
|
{
|
2014-03-03 17:31:46 +00:00
|
|
|
enum pipe pipe;
|
2013-11-02 21:07:06 -07:00
|
|
|
|
2020-07-08 16:12:20 +03:00
|
|
|
/* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, CHICKEN_PIPESL_1(PIPE_A),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, CHICKEN_PIPESL_1(PIPE_A)) |
|
2020-07-08 16:12:20 +03:00
|
|
|
HSW_FBCQ_DIS);
|
|
|
|
|
|
2013-12-12 15:28:04 -08:00
|
|
|
/* WaSwitchSolVfFArbitrationPriority:bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GAM_ECOCHK, intel_uncore_read(&dev_priv->uncore, GAM_ECOCHK) | HSW_ECOCHK_ARB_PRIO_SOL);
|
2013-11-02 21:07:54 -07:00
|
|
|
|
2013-12-12 15:28:04 -08:00
|
|
|
/* WaPsrDPAMaskVBlankInSRD:bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, CHICKEN_PAR1_1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, CHICKEN_PAR1_1) | DPA_MASK_VBLANK_SRD);
|
2013-11-02 21:07:54 -07:00
|
|
|
|
2014-08-18 13:49:10 +01:00
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2021-02-20 12:33:03 +02:00
|
|
|
/* WaPsrDPRSUnmaskVBlankInSRD:bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, CHICKEN_PIPESL_1(pipe),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, CHICKEN_PIPESL_1(pipe)) |
|
2014-03-05 13:05:47 +02:00
|
|
|
BDW_DPRS_MASK_VBLANK_SRD);
|
2013-11-02 21:07:54 -07:00
|
|
|
}
|
2013-12-12 17:26:03 -08:00
|
|
|
|
2013-12-12 15:28:04 -08:00
|
|
|
/* WaVSRefCountFullforceMissDisable:bdw */
|
|
|
|
|
/* WaDSRefCountFullforceMissDisable:bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_FF_THREAD_MODE,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN7_FF_THREAD_MODE) &
|
2013-12-12 15:28:04 -08:00
|
|
|
~(GEN8_FF_DS_REF_CNT_FFME | GEN7_FF_VS_REF_CNT_FFME));
|
2014-02-04 21:59:21 +02:00
|
|
|
|
2022-01-10 21:15:53 -08:00
|
|
|
intel_uncore_write(&dev_priv->uncore, RING_PSMI_CTL(RENDER_RING_BASE),
|
2014-02-27 21:59:01 +02:00
|
|
|
_MASKED_BIT_ENABLE(GEN8_RC_SEMA_IDLE_MSG_DISABLE));
|
2014-02-27 21:59:02 +02:00
|
|
|
|
|
|
|
|
/* WaDisableSDEUnitClockGating:bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN8_UCGCTL6, intel_uncore_read(&dev_priv->uncore, GEN8_UCGCTL6) |
|
2014-02-27 21:59:02 +02:00
|
|
|
GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
|
2014-03-26 18:41:51 +00:00
|
|
|
|
2016-05-03 15:54:21 +03:00
|
|
|
/* WaProgramL3SqcReg1Default:bdw */
|
|
|
|
|
gen8_set_l3sqc_credits(dev_priv, 30, 2);
|
2015-05-19 20:32:56 +03:00
|
|
|
|
2016-06-07 17:19:02 +03:00
|
|
|
/* WaKVMNotificationOnConfigChange:bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, CHICKEN_PAR2_1, intel_uncore_read(&dev_priv->uncore, CHICKEN_PAR2_1)
|
2016-06-07 17:19:02 +03:00
|
|
|
| KVM_CONFIG_CHANGE_NOTIFICATION_SELECT);
|
|
|
|
|
|
2016-10-31 22:37:22 +02: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.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN6_UCGCTL1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN6_UCGCTL1) | GEN6_EU_TCUNIT_CLOCK_GATE_DISABLE);
|
2013-11-02 21:07:06 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void hsw_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-07-02 11:51:09 -03:00
|
|
|
{
|
2020-07-08 16:12:20 +03:00
|
|
|
/* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, CHICKEN_PIPESL_1(PIPE_A),
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, CHICKEN_PIPESL_1(PIPE_A)) |
|
2020-07-08 16:12:20 +03:00
|
|
|
HSW_FBCQ_DIS);
|
|
|
|
|
|
2013-05-03 18:48:10 +01:00
|
|
|
/* This is required by WaCatErrorRejectionIssue:hsw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
|
2020-06-11 10:30:15 +01:00
|
|
|
GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
|
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>
2014-12-31 16:23:00 -08:00
|
|
|
|
2013-05-03 18:48:10 +01:00
|
|
|
/* WaSwitchSolVfFArbitrationPriority:hsw */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GAM_ECOCHK, intel_uncore_read(&dev_priv->uncore, GAM_ECOCHK) | HSW_ECOCHK_ARB_PRIO_SOL);
|
2013-03-20 14:49:14 -07:00
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
lpt_init_clock_gating(dev_priv);
|
2012-07-02 11:51:09 -03:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void ivb_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 snpcr;
|
2012-04-18 15:29:25 -03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DSPCLK_GATE_D, ILK_VRHUNIT_CLOCK_GATE_DISABLE);
|
2012-04-18 15:29:25 -03:00
|
|
|
|
2020-07-08 16:12:20 +03:00
|
|
|
/* WaFbcAsynchFlipDisableFbcQueue:ivb */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ILK_DISPLAY_CHICKEN1,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, ILK_DISPLAY_CHICKEN1) |
|
2020-07-08 16:12:20 +03:00
|
|
|
ILK_FBCQ_DIS);
|
|
|
|
|
|
2013-05-03 18:48:10 +01:00
|
|
|
/* WaDisableBackToBackFlipFix:ivb */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, IVB_CHICKEN3,
|
2012-04-18 15:29:25 -03:00
|
|
|
CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
|
|
|
|
|
CHICKEN3_DGMG_DONE_FIX_DISABLE);
|
|
|
|
|
|
2016-10-13 11:02:58 +01:00
|
|
|
if (IS_IVB_GT1(dev_priv))
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_ROW_CHICKEN2,
|
2012-10-25 12:15:42 -07:00
|
|
|
_MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
|
2014-01-22 21:32:44 +02:00
|
|
|
else {
|
|
|
|
|
/* must write both registers */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_ROW_CHICKEN2,
|
2014-01-22 21:32:44 +02:00
|
|
|
_MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_ROW_CHICKEN2_GT2,
|
2012-10-25 12:15:42 -07:00
|
|
|
_MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
|
2014-01-22 21:32:44 +02:00
|
|
|
}
|
2012-04-18 15:29:25 -03:00
|
|
|
|
2014-01-22 21:32:53 +02:00
|
|
|
/*
|
2012-06-14 11:04:47 -07:00
|
|
|
* According to the spec, bit 13 (RCZUNIT) must be set on IVB.
|
2013-05-03 18:48:10 +01:00
|
|
|
* This implements the WaDisableRCZUnitClockGating:ivb workaround.
|
2012-06-14 11:04:47 -07:00
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN6_UCGCTL2,
|
2014-01-22 21:32:48 +02:00
|
|
|
GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
|
2012-06-14 11:04:47 -07:00
|
|
|
|
2013-05-03 18:48:10 +01:00
|
|
|
/* This is required by WaCatErrorRejectionIssue:ivb */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
|
2012-04-18 15:29:25 -03:00
|
|
|
GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
g4x_disable_trickle_feed(dev_priv);
|
2012-04-18 15:29:25 -03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
snpcr = intel_uncore_read(&dev_priv->uncore, GEN6_MBCUNIT_SNPCR);
|
2012-05-04 18:58:59 -07:00
|
|
|
snpcr &= ~GEN6_MBC_SNPCR_MASK;
|
|
|
|
|
snpcr |= GEN6_MBC_SNPCR_MED;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN6_MBCUNIT_SNPCR, snpcr);
|
2012-10-31 22:52:31 +01:00
|
|
|
|
2016-10-13 11:02:53 +01:00
|
|
|
if (!HAS_PCH_NOP(dev_priv))
|
2016-10-31 22:37:22 +02:00
|
|
|
cpt_init_clock_gating(dev_priv);
|
2013-02-09 21:03:42 +01:00
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
gen6_check_mch_setup(dev_priv);
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void vlv_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2013-05-03 18:48:10 +01:00
|
|
|
/* WaDisableBackToBackFlipFix:vlv */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, IVB_CHICKEN3,
|
2012-04-18 15:29:25 -03:00
|
|
|
CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
|
|
|
|
|
CHICKEN3_DGMG_DONE_FIX_DISABLE);
|
|
|
|
|
|
2013-05-03 18:48:10 +01:00
|
|
|
/* WaDisableDopClockGating:vlv */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_ROW_CHICKEN2,
|
2012-10-25 12:15:42 -07:00
|
|
|
_MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
|
|
|
|
|
|
2013-05-03 18:48:10 +01:00
|
|
|
/* This is required by WaCatErrorRejectionIssue:vlv */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
|
2012-04-18 15:29:25 -03:00
|
|
|
GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
|
|
|
|
|
|
2014-01-22 21:32:56 +02:00
|
|
|
/*
|
2012-06-14 11:04:47 -07:00
|
|
|
* According to the spec, bit 13 (RCZUNIT) must be set on IVB.
|
2013-05-03 18:48:10 +01:00
|
|
|
* This implements the WaDisableRCZUnitClockGating:vlv workaround.
|
2012-06-14 11:04:47 -07:00
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN6_UCGCTL2,
|
2014-01-22 21:32:56 +02:00
|
|
|
GEN6_RCZUNIT_CLOCK_GATE_DISABLE);
|
2012-06-14 11:04:47 -07:00
|
|
|
|
2014-03-24 23:00:07 +05:30
|
|
|
/* WaDisableL3Bank2xClockGate:vlv
|
|
|
|
|
* Disabling L3 clock gating- MMIO 940c[25] = 1
|
|
|
|
|
* Set bit 25, to disable L3_BANK_2x_CLK_GATING */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_UCGCTL4,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN7_UCGCTL4) | GEN7_L3BANK2X_CLOCK_GATE_DISABLE);
|
2012-06-14 11:04:50 -07:00
|
|
|
|
2012-10-25 12:15:44 -07:00
|
|
|
/*
|
2013-05-03 18:48:10 +01:00
|
|
|
* WaDisableVLVClockGating_VBIIssue:vlv
|
2012-10-25 12:15:44 -07:00
|
|
|
* Disable clock gating on th GCFG unit to prevent a delay
|
|
|
|
|
* in the reporting of vblank events.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, VLV_GUNIT_CLOCK_GATE, GCFG_DIS);
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void chv_init_clock_gating(struct drm_i915_private *dev_priv)
|
2014-04-09 13:28:10 +03:00
|
|
|
{
|
2014-04-09 13:28:35 +03:00
|
|
|
/* WaVSRefCountFullforceMissDisable:chv */
|
|
|
|
|
/* WaDSRefCountFullforceMissDisable:chv */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN7_FF_THREAD_MODE,
|
|
|
|
|
intel_uncore_read(&dev_priv->uncore, GEN7_FF_THREAD_MODE) &
|
2014-04-09 13:28:35 +03:00
|
|
|
~(GEN8_FF_DS_REF_CNT_FFME | GEN7_FF_VS_REF_CNT_FFME));
|
2014-04-09 13:28:36 +03:00
|
|
|
|
|
|
|
|
/* WaDisableSemaphoreAndSyncFlipWait:chv */
|
2022-01-10 21:15:53 -08:00
|
|
|
intel_uncore_write(&dev_priv->uncore, RING_PSMI_CTL(RENDER_RING_BASE),
|
2014-04-09 13:28:36 +03:00
|
|
|
_MASKED_BIT_ENABLE(GEN8_RC_SEMA_IDLE_MSG_DISABLE));
|
2014-04-09 13:28:37 +03:00
|
|
|
|
|
|
|
|
/* WaDisableCSUnitClockGating:chv */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN6_UCGCTL1, intel_uncore_read(&dev_priv->uncore, GEN6_UCGCTL1) |
|
2014-04-09 13:28:37 +03:00
|
|
|
GEN6_CSUNIT_CLOCK_GATE_DISABLE);
|
2014-04-09 13:28:38 +03:00
|
|
|
|
|
|
|
|
/* WaDisableSDEUnitClockGating:chv */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, GEN8_UCGCTL6, intel_uncore_read(&dev_priv->uncore, GEN8_UCGCTL6) |
|
2014-04-09 13:28:38 +03:00
|
|
|
GEN8_SDEUNIT_CLOCK_GATE_DISABLE);
|
2015-05-19 20:32:57 +03:00
|
|
|
|
2016-05-03 15:54:21 +03:00
|
|
|
/*
|
|
|
|
|
* WaProgramL3SqcReg1Default:chv
|
|
|
|
|
* See gfxspecs/Related Documents/Performance Guide/
|
|
|
|
|
* LSQC Setting Recommendations.
|
|
|
|
|
*/
|
|
|
|
|
gen8_set_l3sqc_credits(dev_priv, 38, 2);
|
2014-04-09 13:28:10 +03:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
static void g4x_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2019-01-18 14:01:20 +02:00
|
|
|
u32 dspclk_gate;
|
2012-04-18 15:29:25 -03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, RENCLK_GATE_D1, 0);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, RENCLK_GATE_D2, VF_UNIT_CLOCK_GATE_DISABLE |
|
2012-04-18 15:29:25 -03:00
|
|
|
GS_UNIT_CLOCK_GATE_DISABLE |
|
|
|
|
|
CL_UNIT_CLOCK_GATE_DISABLE);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, RAMCLK_GATE_D, 0);
|
2012-04-18 15:29:25 -03:00
|
|
|
dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
|
OVRUNIT_CLOCK_GATE_DISABLE |
|
|
|
|
|
OVCUNIT_CLOCK_GATE_DISABLE;
|
2016-10-13 11:02:58 +01:00
|
|
|
if (IS_GM45(dev_priv))
|
2012-04-18 15:29:25 -03:00
|
|
|
dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE;
|
2022-08-30 13:28:01 +03:00
|
|
|
intel_uncore_write(&dev_priv->uncore, DSPCLK_GATE_D(dev_priv), dspclk_gate);
|
2012-10-18 11:49:51 +02:00
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
g4x_disable_trickle_feed(dev_priv);
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void i965gm_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2019-06-11 11:45:48 +01: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);
|
2022-08-30 13:28:01 +03:00
|
|
|
intel_uncore_write(uncore, DSPCLK_GATE_D(dev_priv), 0);
|
2019-06-11 11:45:48 +01:00
|
|
|
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));
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2017-08-28 22:20:26 -07:00
|
|
|
static void i965g_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, RENCLK_GATE_D1, I965_RCZ_CLOCK_GATE_DISABLE |
|
2012-04-18 15:29:25 -03:00
|
|
|
I965_RCC_CLOCK_GATE_DISABLE |
|
|
|
|
|
I965_RCPB_CLOCK_GATE_DISABLE |
|
|
|
|
|
I965_ISC_CLOCK_GATE_DISABLE |
|
|
|
|
|
I965_FBC_CLOCK_GATE_DISABLE);
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, RENCLK_GATE_D2, 0);
|
|
|
|
|
intel_uncore_write(&dev_priv->uncore, MI_ARB_STATE,
|
2013-06-07 10:47:02 +03:00
|
|
|
_MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
static void gen3_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2020-11-30 13:15:58 +02:00
|
|
|
u32 dstate = intel_uncore_read(&dev_priv->uncore, D_STATE);
|
2012-04-18 15:29:25 -03:00
|
|
|
|
|
|
|
|
dstate |= DSTATE_PLL_D3_OFF | DSTATE_GFX_CLOCK_GATING |
|
|
|
|
|
DSTATE_DOT_CLOCK_GATING;
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, D_STATE, dstate);
|
2012-04-24 14:51:43 +01:00
|
|
|
|
2016-10-31 22:37:15 +02:00
|
|
|
if (IS_PINEVIEW(dev_priv))
|
2022-01-10 21:15:52 -08:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ECOSKPD(RENDER_RING_BASE),
|
|
|
|
|
_MASKED_BIT_ENABLE(ECO_GATING_CX_ONLY));
|
2012-09-09 11:54:16 +02:00
|
|
|
|
|
|
|
|
/* IIR "flip pending" means done if this bit is set */
|
2022-01-10 21:15:52 -08:00
|
|
|
intel_uncore_write(&dev_priv->uncore, ECOSKPD(RENDER_RING_BASE),
|
|
|
|
|
_MASKED_BIT_DISABLE(ECO_FLIP_DONE));
|
2014-02-25 15:13:38 +02:00
|
|
|
|
|
|
|
|
/* interrupts should cause a wake up from C3 */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, INSTPM, _MASKED_BIT_ENABLE(INSTPM_AGPBUSY_INT_EN));
|
2014-02-25 15:13:41 +02:00
|
|
|
|
|
|
|
|
/* On GEN3 we really need to make sure the ARB C3 LP bit is set */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, MI_ARB_STATE, _MASKED_BIT_ENABLE(MI_ARB_C3_LP_WRITE_ENABLE));
|
2014-08-15 01:21:54 +03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, MI_ARB_STATE,
|
2014-08-15 01:21:54 +03:00
|
|
|
_MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
static void i85x_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, RENCLK_GATE_D1, SV_CLOCK_GATE_DISABLE);
|
2014-02-25 15:13:40 +02:00
|
|
|
|
|
|
|
|
/* interrupts should cause a wake up from C3 */
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, MI_STATE, _MASKED_BIT_ENABLE(MI_AGPBUSY_INT_EN) |
|
2014-02-25 15:13:40 +02:00
|
|
|
_MASKED_BIT_DISABLE(MI_AGPBUSY_830_MODE));
|
2014-08-15 01:21:54 +03:00
|
|
|
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, MEM_MODE,
|
2014-08-15 01:21:54 +03:00
|
|
|
_MASKED_BIT_ENABLE(MEM_DISPLAY_TRICKLE_FEED_DISABLE));
|
2020-07-02 18:37:23 +03:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Have FBC ignore 3D activity since we use software
|
|
|
|
|
* render tracking, and otherwise a pure 3D workload
|
|
|
|
|
* (even if it just renders a single frame and then does
|
|
|
|
|
* abosultely nothing) would not allow FBC to recompress
|
|
|
|
|
* until a 2D blit occurs.
|
|
|
|
|
*/
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, SCPD0,
|
2020-07-02 18:37:23 +03:00
|
|
|
_MASKED_BIT_ENABLE(SCPD_FBC_IGNORE_3D));
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
static void i830_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2020-11-30 13:15:58 +02:00
|
|
|
intel_uncore_write(&dev_priv->uncore, MEM_MODE,
|
2014-08-15 01:21:54 +03:00
|
|
|
_MASKED_BIT_ENABLE(MEM_DISPLAY_A_TRICKLE_FEED_DISABLE) |
|
|
|
|
|
_MASKED_BIT_ENABLE(MEM_DISPLAY_B_TRICKLE_FEED_DISABLE));
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
void intel_init_clock_gating(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:25 -03:00
|
|
|
{
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs->init_clock_gating(dev_priv);
|
2012-04-18 15:29:25 -03:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:23 +02:00
|
|
|
void intel_suspend_hw(struct drm_i915_private *dev_priv)
|
2013-04-17 14:04:50 +03:00
|
|
|
{
|
2016-10-31 22:37:23 +02:00
|
|
|
if (HAS_PCH_LPT(dev_priv))
|
|
|
|
|
lpt_suspend_hw(dev_priv);
|
2013-04-17 14:04:50 +03:00
|
|
|
}
|
|
|
|
|
|
2016-10-31 22:37:22 +02:00
|
|
|
static void nop_init_clock_gating(struct drm_i915_private *dev_priv)
|
2016-03-16 13:38:54 +02:00
|
|
|
{
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"No clock gating settings or workarounds applied.\n");
|
2016-03-16 13:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-29 01:58:07 +03:00
|
|
|
#define CG_FUNCS(platform) \
|
|
|
|
|
static const struct drm_i915_clock_gating_funcs platform##_clock_gating_funcs = { \
|
|
|
|
|
.init_clock_gating = platform##_init_clock_gating, \
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-27 09:33:48 -07:00
|
|
|
CG_FUNCS(pvc);
|
2021-11-02 15:25:10 -07:00
|
|
|
CG_FUNCS(dg2);
|
2021-11-02 15:25:09 -07:00
|
|
|
CG_FUNCS(xehpsdv);
|
2021-09-29 01:58:07 +03:00
|
|
|
CG_FUNCS(adlp);
|
|
|
|
|
CG_FUNCS(dg1);
|
|
|
|
|
CG_FUNCS(gen12lp);
|
|
|
|
|
CG_FUNCS(icl);
|
|
|
|
|
CG_FUNCS(cfl);
|
|
|
|
|
CG_FUNCS(skl);
|
|
|
|
|
CG_FUNCS(kbl);
|
|
|
|
|
CG_FUNCS(bxt);
|
|
|
|
|
CG_FUNCS(glk);
|
|
|
|
|
CG_FUNCS(bdw);
|
|
|
|
|
CG_FUNCS(chv);
|
|
|
|
|
CG_FUNCS(hsw);
|
|
|
|
|
CG_FUNCS(ivb);
|
|
|
|
|
CG_FUNCS(vlv);
|
|
|
|
|
CG_FUNCS(gen6);
|
|
|
|
|
CG_FUNCS(ilk);
|
|
|
|
|
CG_FUNCS(g4x);
|
|
|
|
|
CG_FUNCS(i965gm);
|
|
|
|
|
CG_FUNCS(i965g);
|
|
|
|
|
CG_FUNCS(gen3);
|
|
|
|
|
CG_FUNCS(i85x);
|
|
|
|
|
CG_FUNCS(i830);
|
|
|
|
|
CG_FUNCS(nop);
|
|
|
|
|
#undef CG_FUNCS
|
|
|
|
|
|
2016-03-16 13:38:54 +02: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)
|
|
|
|
|
{
|
2022-05-27 09:33:48 -07:00
|
|
|
if (IS_PONTEVECCHIO(dev_priv))
|
|
|
|
|
dev_priv->clock_gating_funcs = &pvc_clock_gating_funcs;
|
|
|
|
|
else if (IS_DG2(dev_priv))
|
2021-11-02 15:25:10 -07:00
|
|
|
dev_priv->clock_gating_funcs = &dg2_clock_gating_funcs;
|
|
|
|
|
else if (IS_XEHPSDV(dev_priv))
|
2021-11-02 15:25:09 -07:00
|
|
|
dev_priv->clock_gating_funcs = &xehpsdv_clock_gating_funcs;
|
|
|
|
|
else if (IS_ALDERLAKE_P(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &adlp_clock_gating_funcs;
|
2021-05-14 08:37:09 -07:00
|
|
|
else if (IS_DG1(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &dg1_clock_gating_funcs;
|
2021-06-05 21:50:49 -07:00
|
|
|
else if (GRAPHICS_VER(dev_priv) == 12)
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &gen12lp_clock_gating_funcs;
|
2021-06-05 21:50:49 -07:00
|
|
|
else if (GRAPHICS_VER(dev_priv) == 11)
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &icl_clock_gating_funcs;
|
2020-06-02 15:05:40 +01:00
|
|
|
else if (IS_COFFEELAKE(dev_priv) || IS_COMETLAKE(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &cfl_clock_gating_funcs;
|
2017-08-15 16:16:48 -07:00
|
|
|
else if (IS_SKYLAKE(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &skl_clock_gating_funcs;
|
2017-08-30 21:52:23 -07:00
|
|
|
else if (IS_KABYLAKE(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &kbl_clock_gating_funcs;
|
2017-01-26 11:16:58 +02:00
|
|
|
else if (IS_BROXTON(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &bxt_clock_gating_funcs;
|
2017-01-26 11:16:58 +02:00
|
|
|
else if (IS_GEMINILAKE(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &glk_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
else if (IS_BROADWELL(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &bdw_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
else if (IS_CHERRYVIEW(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &chv_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
else if (IS_HASWELL(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &hsw_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
else if (IS_IVYBRIDGE(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &ivb_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
else if (IS_VALLEYVIEW(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &vlv_clock_gating_funcs;
|
2021-06-05 21:50:49 -07:00
|
|
|
else if (GRAPHICS_VER(dev_priv) == 6)
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &gen6_clock_gating_funcs;
|
2021-06-05 21:50:49 -07:00
|
|
|
else if (GRAPHICS_VER(dev_priv) == 5)
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &ilk_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
else if (IS_G4X(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &g4x_clock_gating_funcs;
|
2016-12-07 12:13:04 +02:00
|
|
|
else if (IS_I965GM(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &i965gm_clock_gating_funcs;
|
2016-12-07 12:13:04 +02:00
|
|
|
else if (IS_I965G(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &i965g_clock_gating_funcs;
|
2021-06-05 21:50:49 -07:00
|
|
|
else if (GRAPHICS_VER(dev_priv) == 3)
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &gen3_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
else if (IS_I85X(dev_priv) || IS_I865G(dev_priv))
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &i85x_clock_gating_funcs;
|
2021-06-05 21:50:49 -07:00
|
|
|
else if (GRAPHICS_VER(dev_priv) == 2)
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &i830_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
else {
|
|
|
|
|
MISSING_CASE(INTEL_DEVID(dev_priv));
|
2021-09-29 01:58:07 +03:00
|
|
|
dev_priv->clock_gating_funcs = &nop_clock_gating_funcs;
|
2016-03-16 13:38:54 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-24 16:15:31 +03:00
|
|
|
static const struct intel_wm_funcs ilk_wm_funcs = {
|
2021-09-29 01:58:08 +03:00
|
|
|
.compute_pipe_wm = ilk_compute_pipe_wm,
|
|
|
|
|
.compute_intermediate_wm = ilk_compute_intermediate_wm,
|
|
|
|
|
.initial_watermarks = ilk_initial_watermarks,
|
|
|
|
|
.optimize_watermarks = ilk_optimize_watermarks,
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-24 16:15:31 +03:00
|
|
|
static const struct intel_wm_funcs vlv_wm_funcs = {
|
2021-09-29 01:58:08 +03:00
|
|
|
.compute_pipe_wm = vlv_compute_pipe_wm,
|
|
|
|
|
.compute_intermediate_wm = vlv_compute_intermediate_wm,
|
|
|
|
|
.initial_watermarks = vlv_initial_watermarks,
|
|
|
|
|
.optimize_watermarks = vlv_optimize_watermarks,
|
|
|
|
|
.atomic_update_watermarks = vlv_atomic_update_fifo,
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-24 16:15:31 +03:00
|
|
|
static const struct intel_wm_funcs g4x_wm_funcs = {
|
2021-09-29 01:58:08 +03:00
|
|
|
.compute_pipe_wm = g4x_compute_pipe_wm,
|
|
|
|
|
.compute_intermediate_wm = g4x_compute_intermediate_wm,
|
|
|
|
|
.initial_watermarks = g4x_initial_watermarks,
|
|
|
|
|
.optimize_watermarks = g4x_optimize_watermarks,
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-24 16:15:31 +03:00
|
|
|
static const struct intel_wm_funcs pnv_wm_funcs = {
|
2021-09-29 01:58:08 +03:00
|
|
|
.update_wm = pnv_update_wm,
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-24 16:15:31 +03:00
|
|
|
static const struct intel_wm_funcs i965_wm_funcs = {
|
2021-09-29 01:58:08 +03:00
|
|
|
.update_wm = i965_update_wm,
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-24 16:15:31 +03:00
|
|
|
static const struct intel_wm_funcs i9xx_wm_funcs = {
|
2021-09-29 01:58:08 +03:00
|
|
|
.update_wm = i9xx_update_wm,
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-24 16:15:31 +03:00
|
|
|
static const struct intel_wm_funcs i845_wm_funcs = {
|
2021-09-29 01:58:08 +03:00
|
|
|
.update_wm = i845_update_wm,
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-24 16:15:31 +03:00
|
|
|
static const struct intel_wm_funcs nop_funcs = {
|
2021-09-29 01:58:08 +03:00
|
|
|
};
|
|
|
|
|
|
2012-04-18 15:29:26 -03:00
|
|
|
/* Set up chip specific power management-related functions */
|
2016-10-31 22:37:25 +02:00
|
|
|
void intel_init_pm(struct drm_i915_private *dev_priv)
|
2012-04-18 15:29:26 -03:00
|
|
|
{
|
2022-09-08 22:16:45 +03:00
|
|
|
if (DISPLAY_VER(dev_priv) >= 9) {
|
|
|
|
|
skl_wm_init(dev_priv);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-26 23:28:17 +02:00
|
|
|
/* For cxsr */
|
2016-10-31 22:37:15 +02:00
|
|
|
if (IS_PINEVIEW(dev_priv))
|
2019-12-24 00:40:04 -08:00
|
|
|
pnv_get_mem_freq(dev_priv);
|
2021-06-05 21:50:49 -07:00
|
|
|
else if (GRAPHICS_VER(dev_priv) == 5)
|
2019-12-24 00:40:09 -08:00
|
|
|
ilk_get_mem_freq(dev_priv);
|
2012-04-26 23:28:17 +02:00
|
|
|
|
2012-04-18 15:29:26 -03:00
|
|
|
/* For FIFO watermark updates */
|
2022-09-08 22:16:45 +03:00
|
|
|
if (HAS_PCH_SPLIT(dev_priv)) {
|
2016-10-31 22:37:24 +02:00
|
|
|
ilk_setup_wm_latency(dev_priv);
|
2013-08-01 16:18:50 +03:00
|
|
|
|
2022-08-24 16:15:40 +03:00
|
|
|
if ((DISPLAY_VER(dev_priv) == 5 && dev_priv->display.wm.pri_latency[1] &&
|
|
|
|
|
dev_priv->display.wm.spr_latency[1] && dev_priv->display.wm.cur_latency[1]) ||
|
|
|
|
|
(DISPLAY_VER(dev_priv) != 5 && dev_priv->display.wm.pri_latency[0] &&
|
|
|
|
|
dev_priv->display.wm.spr_latency[0] && dev_priv->display.wm.cur_latency[0])) {
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &ilk_wm_funcs;
|
2014-01-07 16:14:10 +02:00
|
|
|
} else {
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
|
"Failed to read display plane latency. "
|
|
|
|
|
"Disable CxSR\n");
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &nop_funcs;
|
2014-01-07 16:14:10 +02:00
|
|
|
}
|
2016-11-28 19:37:07 +02:00
|
|
|
} else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
|
2016-10-31 22:37:24 +02:00
|
|
|
vlv_setup_wm_latency(dev_priv);
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &vlv_wm_funcs;
|
2017-04-21 21:14:29 +03:00
|
|
|
} else if (IS_G4X(dev_priv)) {
|
|
|
|
|
g4x_setup_wm_latency(dev_priv);
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &g4x_wm_funcs;
|
2016-10-31 22:37:15 +02: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 15:29:26 -03:00
|
|
|
dev_priv->is_ddr3,
|
|
|
|
|
dev_priv->fsb_freq,
|
|
|
|
|
dev_priv->mem_freq)) {
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_info(&dev_priv->drm,
|
|
|
|
|
"failed to find known CxSR latency "
|
2012-04-18 15:29:26 -03: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 12:36:17 +03:00
|
|
|
intel_set_memory_cxsr(dev_priv, false);
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &nop_funcs;
|
2012-04-18 15:29:26 -03:00
|
|
|
} else
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &pnv_wm_funcs;
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
} else if (DISPLAY_VER(dev_priv) == 4) {
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &i965_wm_funcs;
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
} else if (DISPLAY_VER(dev_priv) == 3) {
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &i9xx_wm_funcs;
|
drm/i915/display: rename display version macros
While converting the rest of the driver to use GRAPHICS_VER() and
MEDIA_VER(), following what was done for display, some discussions went
back on what we did for display:
1) Why is the == comparison special that deserves a separate
macro instead of just getting the version and comparing directly
like is done for >, >=, <=?
2) IS_DISPLAY_RANGE() is weird in that it omits the "_VER" for
brevity. If we remove the current users of IS_DISPLAY_VER(), we
could actually repurpose it for a range check
With (1) there could be an advantage if we used gen_mask since multiple
conditionals be combined by the compiler in a single and instruction and
check the result. However a) INTEL_GEN() doesn't use the mask since it
would make the code bigger everywhere else and b) in the cases it made
sense, it also made sense to convert to the _RANGE() variant.
So here we repurpose IS_DISPLAY_VER() to work with a [ from, to ] range
like was the IS_DISPLAY_RANGE() and convert the current IS_DISPLAY_VER()
users to use == and != operators. Aside from the definition changes,
this was done by the following semantic patch:
@@ expression dev_priv, E1; @@
- !IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) != E1
@@ expression dev_priv, E1; @@
- IS_DISPLAY_VER(dev_priv, E1)
+ DISPLAY_VER(dev_priv) == E1
@@ expression dev_priv, from, until; @@
- IS_DISPLAY_RANGE(dev_priv, from, until)
+ IS_DISPLAY_VER(dev_priv, from, until)
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
[Jani: Minor conflict resolve while applying.]
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210413051002.92589-4-lucas.demarchi@intel.com
2021-04-12 22:09:53 -07:00
|
|
|
} else if (DISPLAY_VER(dev_priv) == 2) {
|
2021-09-29 01:57:46 +03:00
|
|
|
if (INTEL_NUM_PIPES(dev_priv) == 1)
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &i845_wm_funcs;
|
2021-09-29 01:57:46 +03:00
|
|
|
else
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &i9xx_wm_funcs;
|
2013-12-14 20:38:30 -02:00
|
|
|
} else {
|
2020-01-07 18:13:30 +03:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
|
"unexpected fall-through in %s\n", __func__);
|
2022-08-24 16:15:31 +03:00
|
|
|
dev_priv->display.funcs.wm = &nop_funcs;
|
2012-04-18 15:29:26 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-01 14:16:45 +00:00
|
|
|
void intel_pm_setup(struct drm_i915_private *dev_priv)
|
2013-07-19 20:36:52 +01:00
|
|
|
{
|
2017-10-10 22:30:04 +01:00
|
|
|
dev_priv->runtime_pm.suspended = false;
|
|
|
|
|
atomic_set(&dev_priv->runtime_pm.wakeref_count, 0);
|
2013-07-19 20:36:52 +01:00
|
|
|
}
|