2015-07-11 00:13:11 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
*/
|
|
|
|
|
2019-04-25 00:48:39 +07:00
|
|
|
#include "i915_drv.h"
|
|
|
|
|
|
|
|
#include "intel_engine.h"
|
2019-06-21 14:07:50 +07:00
|
|
|
#include "intel_gt.h"
|
2015-07-11 00:13:11 +07:00
|
|
|
#include "intel_mocs.h"
|
|
|
|
#include "intel_lrc.h"
|
|
|
|
|
|
|
|
/* structures required */
|
|
|
|
struct drm_i915_mocs_entry {
|
|
|
|
u32 control_value;
|
|
|
|
u16 l3cc_value;
|
2019-01-24 07:06:02 +07:00
|
|
|
u16 used;
|
2015-07-11 00:13:11 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_i915_mocs_table {
|
2019-01-24 07:06:03 +07:00
|
|
|
unsigned int size;
|
|
|
|
unsigned int n_entries;
|
2015-07-11 00:13:11 +07:00
|
|
|
const struct drm_i915_mocs_entry *table;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Defines for the tables (XXX_MOCS_0 - XXX_MOCS_63) */
|
2019-01-24 07:05:59 +07:00
|
|
|
#define _LE_CACHEABILITY(value) ((value) << 0)
|
|
|
|
#define _LE_TGT_CACHE(value) ((value) << 2)
|
2015-07-11 00:13:11 +07:00
|
|
|
#define LE_LRUM(value) ((value) << 4)
|
|
|
|
#define LE_AOM(value) ((value) << 6)
|
|
|
|
#define LE_RSC(value) ((value) << 7)
|
|
|
|
#define LE_SCC(value) ((value) << 8)
|
|
|
|
#define LE_PFM(value) ((value) << 11)
|
|
|
|
#define LE_SCF(value) ((value) << 14)
|
2019-01-24 07:06:04 +07:00
|
|
|
#define LE_COS(value) ((value) << 15)
|
|
|
|
#define LE_SSE(value) ((value) << 17)
|
2015-07-11 00:13:11 +07:00
|
|
|
|
|
|
|
/* Defines for the tables (LNCFMOCS0 - LNCFMOCS31) - two entries per word */
|
|
|
|
#define L3_ESC(value) ((value) << 0)
|
|
|
|
#define L3_SCC(value) ((value) << 1)
|
2019-01-24 07:05:59 +07:00
|
|
|
#define _L3_CACHEABILITY(value) ((value) << 4)
|
2015-07-11 00:13:11 +07:00
|
|
|
|
|
|
|
/* Helper defines */
|
|
|
|
#define GEN9_NUM_MOCS_ENTRIES 62 /* 62 out of 64 - 63 & 64 are reserved. */
|
2019-01-24 07:06:04 +07:00
|
|
|
#define GEN11_NUM_MOCS_ENTRIES 64 /* 63-64 are reserved, but configured. */
|
2015-07-11 00:13:11 +07:00
|
|
|
|
|
|
|
/* (e)LLC caching options */
|
2019-07-31 01:04:05 +07:00
|
|
|
/*
|
|
|
|
* Note: LE_0_PAGETABLE works only up to Gen11; for newer gens it means
|
|
|
|
* the same as LE_UC
|
|
|
|
*/
|
2019-01-24 07:05:59 +07:00
|
|
|
#define LE_0_PAGETABLE _LE_CACHEABILITY(0)
|
|
|
|
#define LE_1_UC _LE_CACHEABILITY(1)
|
|
|
|
#define LE_2_WT _LE_CACHEABILITY(2)
|
|
|
|
#define LE_3_WB _LE_CACHEABILITY(3)
|
2015-07-11 00:13:11 +07:00
|
|
|
|
|
|
|
/* Target cache */
|
2019-01-24 07:05:59 +07:00
|
|
|
#define LE_TC_0_PAGETABLE _LE_TGT_CACHE(0)
|
|
|
|
#define LE_TC_1_LLC _LE_TGT_CACHE(1)
|
|
|
|
#define LE_TC_2_LLC_ELLC _LE_TGT_CACHE(2)
|
|
|
|
#define LE_TC_3_LLC_ELLC_ALT _LE_TGT_CACHE(3)
|
|
|
|
|
|
|
|
/* L3 caching options */
|
|
|
|
#define L3_0_DIRECT _L3_CACHEABILITY(0)
|
|
|
|
#define L3_1_UC _L3_CACHEABILITY(1)
|
|
|
|
#define L3_2_RESERVED _L3_CACHEABILITY(2)
|
|
|
|
#define L3_3_WB _L3_CACHEABILITY(3)
|
2015-07-11 00:13:11 +07:00
|
|
|
|
2019-01-24 07:06:01 +07:00
|
|
|
#define MOCS_ENTRY(__idx, __control_value, __l3cc_value) \
|
|
|
|
[__idx] = { \
|
|
|
|
.control_value = __control_value, \
|
|
|
|
.l3cc_value = __l3cc_value, \
|
2019-01-24 07:06:02 +07:00
|
|
|
.used = 1, \
|
2019-01-24 07:06:01 +07:00
|
|
|
}
|
|
|
|
|
2015-07-11 00:13:11 +07:00
|
|
|
/*
|
|
|
|
* MOCS tables
|
|
|
|
*
|
|
|
|
* These are the MOCS tables that are programmed across all the rings.
|
|
|
|
* The control value is programmed to all the rings that support the
|
|
|
|
* MOCS registers. While the l3cc_values are only programmed to the
|
|
|
|
* LNCFCMOCS0 - LNCFCMOCS32 registers.
|
|
|
|
*
|
|
|
|
* These tables are intended to be kept reasonably consistent across
|
2019-01-24 07:06:04 +07:00
|
|
|
* HW platforms, and for ICL+, be identical across OSes. To achieve
|
|
|
|
* that, for Icelake and above, list of entries is published as part
|
|
|
|
* of bspec.
|
2015-07-11 00:13:11 +07:00
|
|
|
*
|
|
|
|
* Entries not part of the following tables are undefined as far as
|
2019-07-31 01:04:05 +07:00
|
|
|
* userspace is concerned and shouldn't be relied upon. For Gen < 12
|
|
|
|
* they will be initialized to PTE. Gen >= 12 onwards don't have a setting for
|
|
|
|
* PTE and will be initialized to an invalid value.
|
2015-07-11 00:13:11 +07:00
|
|
|
*
|
2019-01-24 07:06:04 +07:00
|
|
|
* The last two entries are reserved by the hardware. For ICL+ they
|
|
|
|
* should be initialized according to bspec and never used, for older
|
|
|
|
* platforms they should never be written to.
|
|
|
|
*
|
|
|
|
* NOTE: These tables are part of bspec and defined as part of hardware
|
|
|
|
* interface for ICL+. For older platforms, they are part of kernel
|
|
|
|
* ABI. It is expected that, for specific hardware platform, existing
|
|
|
|
* entries will remain constant and the table will only be updated by
|
|
|
|
* adding new entries, filling unused positions.
|
2015-07-11 00:13:11 +07:00
|
|
|
*/
|
2019-01-24 07:06:00 +07:00
|
|
|
#define GEN9_MOCS_ENTRIES \
|
2019-01-24 07:06:01 +07:00
|
|
|
MOCS_ENTRY(I915_MOCS_UNCACHED, \
|
|
|
|
LE_1_UC | LE_TC_2_LLC_ELLC, \
|
|
|
|
L3_1_UC), \
|
|
|
|
MOCS_ENTRY(I915_MOCS_PTE, \
|
|
|
|
LE_0_PAGETABLE | LE_TC_2_LLC_ELLC | LE_LRUM(3), \
|
|
|
|
L3_3_WB)
|
2019-01-24 07:06:00 +07:00
|
|
|
|
2015-07-11 00:13:11 +07:00
|
|
|
static const struct drm_i915_mocs_entry skylake_mocs_table[] = {
|
2019-01-24 07:06:00 +07:00
|
|
|
GEN9_MOCS_ENTRIES,
|
2019-01-24 07:06:01 +07:00
|
|
|
MOCS_ENTRY(I915_MOCS_CACHED,
|
|
|
|
LE_3_WB | LE_TC_2_LLC_ELLC | LE_LRUM(3),
|
|
|
|
L3_3_WB)
|
2015-07-11 00:13:11 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* NOTE: the LE_TGT_CACHE is not used on Broxton */
|
|
|
|
static const struct drm_i915_mocs_entry broxton_mocs_table[] = {
|
2019-01-24 07:06:00 +07:00
|
|
|
GEN9_MOCS_ENTRIES,
|
2019-01-24 07:06:01 +07:00
|
|
|
MOCS_ENTRY(I915_MOCS_CACHED,
|
|
|
|
LE_1_UC | LE_TC_2_LLC_ELLC | LE_LRUM(3),
|
|
|
|
L3_3_WB)
|
2015-07-11 00:13:11 +07:00
|
|
|
};
|
|
|
|
|
2019-01-24 07:06:04 +07:00
|
|
|
#define GEN11_MOCS_ENTRIES \
|
2019-07-31 01:04:05 +07:00
|
|
|
/* Entries 0 and 1 are defined per-platform */ \
|
2019-01-24 07:06:04 +07:00
|
|
|
/* Base - L3 + LLC */ \
|
|
|
|
MOCS_ENTRY(2, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* Base - Uncached */ \
|
|
|
|
MOCS_ENTRY(3, \
|
|
|
|
LE_1_UC | LE_TC_1_LLC, \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* Base - L3 */ \
|
|
|
|
MOCS_ENTRY(4, \
|
|
|
|
LE_1_UC | LE_TC_1_LLC, \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* Base - LLC */ \
|
|
|
|
MOCS_ENTRY(5, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3), \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* Age 0 - LLC */ \
|
|
|
|
MOCS_ENTRY(6, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(1), \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* Age 0 - L3 + LLC */ \
|
|
|
|
MOCS_ENTRY(7, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(1), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* Age: Don't Chg. - LLC */ \
|
|
|
|
MOCS_ENTRY(8, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(2), \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* Age: Don't Chg. - L3 + LLC */ \
|
|
|
|
MOCS_ENTRY(9, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(2), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* No AOM - LLC */ \
|
|
|
|
MOCS_ENTRY(10, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3) | LE_AOM(1), \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* No AOM - L3 + LLC */ \
|
|
|
|
MOCS_ENTRY(11, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3) | LE_AOM(1), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* No AOM; Age 0 - LLC */ \
|
|
|
|
MOCS_ENTRY(12, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(1) | LE_AOM(1), \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* No AOM; Age 0 - L3 + LLC */ \
|
|
|
|
MOCS_ENTRY(13, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(1) | LE_AOM(1), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* No AOM; Age:DC - LLC */ \
|
|
|
|
MOCS_ENTRY(14, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(2) | LE_AOM(1), \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* No AOM; Age:DC - L3 + LLC */ \
|
|
|
|
MOCS_ENTRY(15, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(2) | LE_AOM(1), \
|
|
|
|
L3_3_WB), \
|
2019-05-31 06:40:14 +07:00
|
|
|
/* Bypass LLC - Uncached (EHL+) */ \
|
|
|
|
MOCS_ENTRY(16, \
|
|
|
|
LE_1_UC | LE_TC_1_LLC | LE_SCF(1), \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* Bypass LLC - L3 (Read-Only) (EHL+) */ \
|
|
|
|
MOCS_ENTRY(17, \
|
|
|
|
LE_1_UC | LE_TC_1_LLC | LE_SCF(1), \
|
|
|
|
L3_3_WB), \
|
2019-01-24 07:06:04 +07:00
|
|
|
/* Self-Snoop - L3 + LLC */ \
|
|
|
|
MOCS_ENTRY(18, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3) | LE_SSE(3), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* Skip Caching - L3 + LLC(12.5%) */ \
|
|
|
|
MOCS_ENTRY(19, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3) | LE_SCC(7), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* Skip Caching - L3 + LLC(25%) */ \
|
|
|
|
MOCS_ENTRY(20, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3) | LE_SCC(3), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* Skip Caching - L3 + LLC(50%) */ \
|
|
|
|
MOCS_ENTRY(21, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3) | LE_SCC(1), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* Skip Caching - L3 + LLC(75%) */ \
|
|
|
|
MOCS_ENTRY(22, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3) | LE_RSC(1) | LE_SCC(3), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* Skip Caching - L3 + LLC(87.5%) */ \
|
|
|
|
MOCS_ENTRY(23, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3) | LE_RSC(1) | LE_SCC(7), \
|
|
|
|
L3_3_WB), \
|
|
|
|
/* HW Reserved - SW program but never use */ \
|
|
|
|
MOCS_ENTRY(62, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3), \
|
|
|
|
L3_1_UC), \
|
|
|
|
/* HW Reserved - SW program but never use */ \
|
|
|
|
MOCS_ENTRY(63, \
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3), \
|
|
|
|
L3_1_UC)
|
|
|
|
|
2019-07-31 01:04:05 +07:00
|
|
|
static const struct drm_i915_mocs_entry tigerlake_mocs_table[] = {
|
|
|
|
/* Base - Error (Reserved for Non-Use) */
|
|
|
|
MOCS_ENTRY(0, 0x0, 0x0),
|
|
|
|
/* Base - Reserved */
|
|
|
|
MOCS_ENTRY(1, 0x0, 0x0),
|
|
|
|
|
|
|
|
GEN11_MOCS_ENTRIES,
|
|
|
|
|
|
|
|
/* Implicitly enable L1 - HDC:L1 + L3 + LLC */
|
|
|
|
MOCS_ENTRY(48,
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3),
|
|
|
|
L3_3_WB),
|
|
|
|
/* Implicitly enable L1 - HDC:L1 + L3 */
|
|
|
|
MOCS_ENTRY(49,
|
|
|
|
LE_1_UC | LE_TC_1_LLC,
|
|
|
|
L3_3_WB),
|
|
|
|
/* Implicitly enable L1 - HDC:L1 + LLC */
|
|
|
|
MOCS_ENTRY(50,
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3),
|
|
|
|
L3_1_UC),
|
|
|
|
/* Implicitly enable L1 - HDC:L1 */
|
|
|
|
MOCS_ENTRY(51,
|
|
|
|
LE_1_UC | LE_TC_1_LLC,
|
|
|
|
L3_1_UC),
|
|
|
|
/* HW Special Case (CCS) */
|
|
|
|
MOCS_ENTRY(60,
|
|
|
|
LE_3_WB | LE_TC_1_LLC | LE_LRUM(3),
|
|
|
|
L3_1_UC),
|
|
|
|
/* HW Special Case (Displayable) */
|
|
|
|
MOCS_ENTRY(61,
|
|
|
|
LE_1_UC | LE_TC_1_LLC | LE_SCF(1),
|
|
|
|
L3_3_WB),
|
|
|
|
};
|
|
|
|
|
2019-01-24 07:06:04 +07:00
|
|
|
static const struct drm_i915_mocs_entry icelake_mocs_table[] = {
|
2019-07-31 01:04:05 +07:00
|
|
|
/* Base - Uncached (Deprecated) */
|
|
|
|
MOCS_ENTRY(I915_MOCS_UNCACHED,
|
|
|
|
LE_1_UC | LE_TC_1_LLC,
|
|
|
|
L3_1_UC),
|
|
|
|
/* Base - L3 + LeCC:PAT (Deprecated) */
|
|
|
|
MOCS_ENTRY(I915_MOCS_PTE,
|
|
|
|
LE_0_PAGETABLE | LE_TC_1_LLC,
|
|
|
|
L3_3_WB),
|
|
|
|
|
2019-01-24 07:06:04 +07:00
|
|
|
GEN11_MOCS_ENTRIES
|
|
|
|
};
|
|
|
|
|
2019-06-21 14:07:50 +07:00
|
|
|
static bool get_mocs_settings(struct intel_gt *gt,
|
2015-07-11 00:13:11 +07:00
|
|
|
struct drm_i915_mocs_table *table)
|
|
|
|
{
|
2019-06-21 14:07:50 +07:00
|
|
|
struct drm_i915_private *i915 = gt->i915;
|
2015-07-11 00:13:11 +07:00
|
|
|
bool result = false;
|
|
|
|
|
2019-07-31 01:04:05 +07:00
|
|
|
if (INTEL_GEN(i915) >= 12) {
|
|
|
|
table->size = ARRAY_SIZE(tigerlake_mocs_table);
|
|
|
|
table->table = tigerlake_mocs_table;
|
|
|
|
table->n_entries = GEN11_NUM_MOCS_ENTRIES;
|
|
|
|
result = true;
|
|
|
|
} else if (IS_GEN(i915, 11)) {
|
2019-01-24 07:06:04 +07:00
|
|
|
table->size = ARRAY_SIZE(icelake_mocs_table);
|
|
|
|
table->table = icelake_mocs_table;
|
|
|
|
table->n_entries = GEN11_NUM_MOCS_ENTRIES;
|
|
|
|
result = true;
|
2019-06-21 14:07:50 +07:00
|
|
|
} else if (IS_GEN9_BC(i915) || IS_CANNONLAKE(i915)) {
|
2015-07-11 00:13:11 +07:00
|
|
|
table->size = ARRAY_SIZE(skylake_mocs_table);
|
2019-01-24 07:06:03 +07:00
|
|
|
table->n_entries = GEN9_NUM_MOCS_ENTRIES;
|
2015-07-11 00:13:11 +07:00
|
|
|
table->table = skylake_mocs_table;
|
|
|
|
result = true;
|
2019-06-21 14:07:50 +07:00
|
|
|
} else if (IS_GEN9_LP(i915)) {
|
2015-07-11 00:13:11 +07:00
|
|
|
table->size = ARRAY_SIZE(broxton_mocs_table);
|
2019-01-24 07:06:03 +07:00
|
|
|
table->n_entries = GEN9_NUM_MOCS_ENTRIES;
|
2015-07-11 00:13:11 +07:00
|
|
|
table->table = broxton_mocs_table;
|
|
|
|
result = true;
|
|
|
|
} else {
|
2019-06-21 14:07:50 +07:00
|
|
|
WARN_ONCE(INTEL_GEN(i915) >= 9,
|
2015-07-11 00:13:11 +07:00
|
|
|
"Platform that should have a MOCS table does not.\n");
|
|
|
|
}
|
|
|
|
|
2017-01-26 16:16:58 +07:00
|
|
|
/* WaDisableSkipCaching:skl,bxt,kbl,glk */
|
2019-06-21 14:07:50 +07:00
|
|
|
if (IS_GEN(i915, 9)) {
|
2016-06-07 21:19:08 +07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < table->size; i++)
|
|
|
|
if (WARN_ON(table->table[i].l3cc_value &
|
2016-06-13 13:54:22 +07:00
|
|
|
(L3_ESC(1) | L3_SCC(0x7))))
|
2016-06-07 21:19:08 +07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-11 00:13:11 +07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-07-21 00:16:06 +07:00
|
|
|
static i915_reg_t mocs_register(enum intel_engine_id engine_id, int index)
|
2015-11-05 19:13:53 +07:00
|
|
|
{
|
2016-07-21 00:16:06 +07:00
|
|
|
switch (engine_id) {
|
2019-03-06 01:03:30 +07:00
|
|
|
case RCS0:
|
2015-11-05 19:13:53 +07:00
|
|
|
return GEN9_GFX_MOCS(index);
|
2019-03-06 01:03:30 +07:00
|
|
|
case VCS0:
|
2015-11-05 19:13:53 +07:00
|
|
|
return GEN9_MFX0_MOCS(index);
|
2019-03-06 01:03:30 +07:00
|
|
|
case BCS0:
|
2015-11-05 19:13:53 +07:00
|
|
|
return GEN9_BLT_MOCS(index);
|
2019-03-06 01:03:30 +07:00
|
|
|
case VECS0:
|
2015-11-05 19:13:53 +07:00
|
|
|
return GEN9_VEBOX_MOCS(index);
|
2019-03-06 01:03:30 +07:00
|
|
|
case VCS1:
|
2015-11-05 19:13:53 +07:00
|
|
|
return GEN9_MFX1_MOCS(index);
|
2019-03-06 01:03:30 +07:00
|
|
|
case VCS2:
|
2018-05-03 05:31:42 +07:00
|
|
|
return GEN11_MFX2_MOCS(index);
|
2015-11-05 19:13:53 +07:00
|
|
|
default:
|
2016-07-21 00:16:06 +07:00
|
|
|
MISSING_CASE(engine_id);
|
drm/i915: Type safe register read/write
Make I915_READ and I915_WRITE more type safe by wrapping the register
offset in a struct. This should eliminate most of the fumbles we've had
with misplaced parens.
This only takes care of normal mmio registers. We could extend the idea
to other register types and define each with its own struct. That way
you wouldn't be able to accidentally pass the wrong thing to a specific
register access function.
The gpio_reg setup is probably the ugliest thing left. But I figure I'd
just leave it for now, and wait for some divine inspiration to strike
before making it nice.
As for the generated code, it's actually a bit better sometimes. Eg.
looking at i915_irq_handler(), we can see the following change:
lea 0x70024(%rdx,%rax,1),%r9d
mov $0x1,%edx
- movslq %r9d,%r9
- mov %r9,%rsi
- mov %r9,-0x58(%rbp)
- callq *0xd8(%rbx)
+ mov %r9d,%esi
+ mov %r9d,-0x48(%rbp)
callq *0xd8(%rbx)
So previously gcc thought the register offset might be signed and
decided to sign extend it, just in case. The rest appears to be
mostly just minor shuffling of instructions.
v2: i915_mmio_reg_{offset,equal,valid}() helpers added
s/_REG/_MMIO/ in the register defines
mo more switch statements left to worry about
ring_emit stuff got sorted in a prep patch
cmd parser, lrc context and w/a batch buildup also in prep patch
vgpu stuff cleaned up and moved to a prep patch
all other unrelated changes split out
v3: Rebased due to BXT DSI/BLC, MOCS, etc.
v4: Rebased due to churn, s/i915_mmio_reg_t/i915_reg_t/
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1447853606-2751-1-git-send-email-ville.syrjala@linux.intel.com
2015-11-18 20:33:26 +07:00
|
|
|
return INVALID_MMIO_REG;
|
2015-11-05 19:13:53 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/*
|
|
|
|
* Get control_value from MOCS entry taking into account when it's not used:
|
|
|
|
* I915_MOCS_PTE's value is returned in this case.
|
|
|
|
*/
|
|
|
|
static u32 get_entry_control(const struct drm_i915_mocs_table *table,
|
|
|
|
unsigned int index)
|
|
|
|
{
|
|
|
|
if (table->table[index].used)
|
|
|
|
return table->table[index].control_value;
|
|
|
|
|
|
|
|
return table->table[I915_MOCS_PTE].control_value;
|
|
|
|
}
|
|
|
|
|
2016-04-13 21:03:25 +07:00
|
|
|
/**
|
|
|
|
* intel_mocs_init_engine() - emit the mocs control table
|
|
|
|
* @engine: The engine for whom to emit the registers.
|
|
|
|
*
|
|
|
|
* This function simply emits a MI_LOAD_REGISTER_IMM command for the
|
|
|
|
* given table starting at the given address.
|
|
|
|
*/
|
2018-08-16 01:42:51 +07:00
|
|
|
void intel_mocs_init_engine(struct intel_engine_cs *engine)
|
2016-04-13 21:03:25 +07:00
|
|
|
{
|
2019-06-21 14:07:50 +07:00
|
|
|
struct intel_gt *gt = engine->gt;
|
|
|
|
struct intel_uncore *uncore = gt->uncore;
|
2016-04-13 21:03:25 +07:00
|
|
|
struct drm_i915_mocs_table table;
|
|
|
|
unsigned int index;
|
2019-01-24 07:06:02 +07:00
|
|
|
u32 unused_value;
|
2016-04-13 21:03:25 +07:00
|
|
|
|
2019-07-31 01:04:06 +07:00
|
|
|
/* Platforms with global MOCS do not need per-engine initialization. */
|
|
|
|
if (HAS_GLOBAL_MOCS_REGISTERS(gt->i915))
|
|
|
|
return;
|
|
|
|
|
2019-07-03 22:52:23 +07:00
|
|
|
/* Called under a blanket forcewake */
|
|
|
|
assert_forcewakes_active(uncore, FORCEWAKE_ALL);
|
|
|
|
|
2019-06-21 14:07:50 +07:00
|
|
|
if (!get_mocs_settings(gt, &table))
|
2018-08-16 01:42:51 +07:00
|
|
|
return;
|
2016-04-13 21:03:25 +07:00
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/* Set unused values to PTE */
|
|
|
|
unused_value = table.table[I915_MOCS_PTE].control_value;
|
|
|
|
|
|
|
|
for (index = 0; index < table.size; index++) {
|
|
|
|
u32 value = get_entry_control(&table, index);
|
2016-04-13 21:03:25 +07:00
|
|
|
|
2019-07-03 22:52:23 +07:00
|
|
|
intel_uncore_write_fw(uncore,
|
|
|
|
mocs_register(engine->id, index),
|
|
|
|
value);
|
2019-01-24 07:06:02 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All remaining entries are also unused */
|
2019-01-24 07:06:03 +07:00
|
|
|
for (; index < table.n_entries; index++)
|
2019-07-03 22:52:23 +07:00
|
|
|
intel_uncore_write_fw(uncore,
|
|
|
|
mocs_register(engine->id, index),
|
|
|
|
unused_value);
|
2016-04-13 21:03:25 +07:00
|
|
|
}
|
|
|
|
|
2019-07-31 01:04:07 +07:00
|
|
|
static void intel_mocs_init_global(struct intel_gt *gt)
|
2019-07-31 01:04:06 +07:00
|
|
|
{
|
|
|
|
struct intel_uncore *uncore = gt->uncore;
|
|
|
|
struct drm_i915_mocs_table table;
|
|
|
|
unsigned int index;
|
|
|
|
|
2019-07-31 01:04:07 +07:00
|
|
|
GEM_BUG_ON(!HAS_GLOBAL_MOCS_REGISTERS(gt->i915));
|
2019-07-31 01:04:06 +07:00
|
|
|
|
|
|
|
if (!get_mocs_settings(gt, &table))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (GEM_DEBUG_WARN_ON(table.size > table.n_entries))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (index = 0; index < table.size; index++)
|
|
|
|
intel_uncore_write(uncore,
|
|
|
|
GEN12_GLOBAL_MOCS(index),
|
|
|
|
table.table[index].control_value);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ok, now set the unused entries to the invalid entry (index 0). These
|
|
|
|
* entries are officially undefined and no contract for the contents and
|
|
|
|
* settings is given for these entries.
|
|
|
|
*/
|
|
|
|
for (; index < table.n_entries; index++)
|
|
|
|
intel_uncore_write(uncore,
|
|
|
|
GEN12_GLOBAL_MOCS(index),
|
|
|
|
table.table[0].control_value);
|
|
|
|
}
|
|
|
|
|
2018-02-21 16:56:36 +07:00
|
|
|
static int emit_mocs_control_table(struct i915_request *rq,
|
2016-04-13 21:03:25 +07:00
|
|
|
const struct drm_i915_mocs_table *table)
|
2015-07-11 00:13:11 +07:00
|
|
|
{
|
2018-02-21 16:56:36 +07:00
|
|
|
enum intel_engine_id engine = rq->engine->id;
|
2015-07-11 00:13:11 +07:00
|
|
|
unsigned int index;
|
2019-01-24 07:06:02 +07:00
|
|
|
u32 unused_value;
|
2017-02-14 18:32:42 +07:00
|
|
|
u32 *cs;
|
2015-07-11 00:13:11 +07:00
|
|
|
|
2019-01-24 07:06:03 +07:00
|
|
|
if (GEM_WARN_ON(table->size > table->n_entries))
|
2015-07-11 00:13:11 +07:00
|
|
|
return -ENODEV;
|
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/* Set unused values to PTE */
|
|
|
|
unused_value = table->table[I915_MOCS_PTE].control_value;
|
|
|
|
|
2019-01-24 07:06:03 +07:00
|
|
|
cs = intel_ring_begin(rq, 2 + 2 * table->n_entries);
|
2017-02-14 18:32:42 +07:00
|
|
|
if (IS_ERR(cs))
|
|
|
|
return PTR_ERR(cs);
|
2015-07-11 00:13:11 +07:00
|
|
|
|
2019-01-24 07:06:03 +07:00
|
|
|
*cs++ = MI_LOAD_REGISTER_IMM(table->n_entries);
|
2015-07-11 00:13:11 +07:00
|
|
|
|
|
|
|
for (index = 0; index < table->size; index++) {
|
2019-01-24 07:06:02 +07:00
|
|
|
u32 value = get_entry_control(table, index);
|
|
|
|
|
2017-02-14 18:32:42 +07:00
|
|
|
*cs++ = i915_mmio_reg_offset(mocs_register(engine, index));
|
2019-01-24 07:06:02 +07:00
|
|
|
*cs++ = value;
|
2015-07-11 00:13:11 +07:00
|
|
|
}
|
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/* All remaining entries are also unused */
|
2019-01-24 07:06:03 +07:00
|
|
|
for (; index < table->n_entries; index++) {
|
2017-02-14 18:32:42 +07:00
|
|
|
*cs++ = i915_mmio_reg_offset(mocs_register(engine, index));
|
2019-01-24 07:06:02 +07:00
|
|
|
*cs++ = unused_value;
|
2015-07-11 00:13:11 +07:00
|
|
|
}
|
|
|
|
|
2017-02-14 18:32:42 +07:00
|
|
|
*cs++ = MI_NOOP;
|
2018-02-21 16:56:36 +07:00
|
|
|
intel_ring_advance(rq, cs);
|
2015-07-11 00:13:11 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/*
|
|
|
|
* Get l3cc_value from MOCS entry taking into account when it's not used:
|
|
|
|
* I915_MOCS_PTE's value is returned in this case.
|
|
|
|
*/
|
|
|
|
static u16 get_entry_l3cc(const struct drm_i915_mocs_table *table,
|
|
|
|
unsigned int index)
|
|
|
|
{
|
|
|
|
if (table->table[index].used)
|
|
|
|
return table->table[index].l3cc_value;
|
|
|
|
|
|
|
|
return table->table[I915_MOCS_PTE].l3cc_value;
|
|
|
|
}
|
|
|
|
|
2016-04-13 21:03:25 +07:00
|
|
|
static inline u32 l3cc_combine(const struct drm_i915_mocs_table *table,
|
|
|
|
u16 low,
|
|
|
|
u16 high)
|
|
|
|
{
|
2019-01-24 07:06:02 +07:00
|
|
|
return low | high << 16;
|
2016-04-13 21:03:25 +07:00
|
|
|
}
|
|
|
|
|
2018-02-21 16:56:36 +07:00
|
|
|
static int emit_mocs_l3cc_table(struct i915_request *rq,
|
2015-07-11 00:13:11 +07:00
|
|
|
const struct drm_i915_mocs_table *table)
|
|
|
|
{
|
2019-01-24 07:06:02 +07:00
|
|
|
u16 unused_value;
|
2015-07-11 00:13:11 +07:00
|
|
|
unsigned int i;
|
2017-02-14 18:32:42 +07:00
|
|
|
u32 *cs;
|
2015-07-11 00:13:11 +07:00
|
|
|
|
2019-01-24 07:06:03 +07:00
|
|
|
if (GEM_WARN_ON(table->size > table->n_entries))
|
2015-07-11 00:13:11 +07:00
|
|
|
return -ENODEV;
|
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/* Set unused values to PTE */
|
|
|
|
unused_value = table->table[I915_MOCS_PTE].l3cc_value;
|
|
|
|
|
2019-01-24 07:06:03 +07:00
|
|
|
cs = intel_ring_begin(rq, 2 + table->n_entries);
|
2017-02-14 18:32:42 +07:00
|
|
|
if (IS_ERR(cs))
|
|
|
|
return PTR_ERR(cs);
|
2015-07-11 00:13:11 +07:00
|
|
|
|
2019-01-24 07:06:03 +07:00
|
|
|
*cs++ = MI_LOAD_REGISTER_IMM(table->n_entries / 2);
|
2015-07-11 00:13:11 +07:00
|
|
|
|
2019-01-24 07:05:58 +07:00
|
|
|
for (i = 0; i < table->size / 2; i++) {
|
2019-01-24 07:06:02 +07:00
|
|
|
u16 low = get_entry_l3cc(table, 2 * i);
|
|
|
|
u16 high = get_entry_l3cc(table, 2 * i + 1);
|
|
|
|
|
2017-02-14 18:32:42 +07:00
|
|
|
*cs++ = i915_mmio_reg_offset(GEN9_LNCFCMOCS(i));
|
2019-01-24 07:06:02 +07:00
|
|
|
*cs++ = l3cc_combine(table, low, high);
|
2015-07-11 00:13:11 +07:00
|
|
|
}
|
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/* Odd table size - 1 left over */
|
2015-07-11 00:13:11 +07:00
|
|
|
if (table->size & 0x01) {
|
2019-01-24 07:06:02 +07:00
|
|
|
u16 low = get_entry_l3cc(table, 2 * i);
|
|
|
|
|
2017-02-14 18:32:42 +07:00
|
|
|
*cs++ = i915_mmio_reg_offset(GEN9_LNCFCMOCS(i));
|
2019-01-24 07:06:02 +07:00
|
|
|
*cs++ = l3cc_combine(table, low, unused_value);
|
2016-04-13 21:03:25 +07:00
|
|
|
i++;
|
|
|
|
}
|
2015-07-11 00:13:11 +07:00
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/* All remaining entries are also unused */
|
2019-01-24 07:06:03 +07:00
|
|
|
for (; i < table->n_entries / 2; i++) {
|
2017-02-14 18:32:42 +07:00
|
|
|
*cs++ = i915_mmio_reg_offset(GEN9_LNCFCMOCS(i));
|
2019-01-24 07:06:02 +07:00
|
|
|
*cs++ = l3cc_combine(table, unused_value, unused_value);
|
2015-07-11 00:13:11 +07:00
|
|
|
}
|
|
|
|
|
2017-02-14 18:32:42 +07:00
|
|
|
*cs++ = MI_NOOP;
|
2018-02-21 16:56:36 +07:00
|
|
|
intel_ring_advance(rq, cs);
|
2015-07-11 00:13:11 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-07-31 01:04:07 +07:00
|
|
|
static void intel_mocs_init_l3cc_table(struct intel_gt *gt)
|
2016-04-13 21:03:25 +07:00
|
|
|
{
|
2019-06-21 14:07:50 +07:00
|
|
|
struct intel_uncore *uncore = gt->uncore;
|
2016-04-13 21:03:25 +07:00
|
|
|
struct drm_i915_mocs_table table;
|
|
|
|
unsigned int i;
|
2019-01-24 07:06:02 +07:00
|
|
|
u16 unused_value;
|
2016-04-13 21:03:25 +07:00
|
|
|
|
2019-06-21 14:07:50 +07:00
|
|
|
if (!get_mocs_settings(gt, &table))
|
2016-04-13 21:03:25 +07:00
|
|
|
return;
|
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/* Set unused values to PTE */
|
|
|
|
unused_value = table.table[I915_MOCS_PTE].l3cc_value;
|
|
|
|
|
|
|
|
for (i = 0; i < table.size / 2; i++) {
|
|
|
|
u16 low = get_entry_l3cc(&table, 2 * i);
|
|
|
|
u16 high = get_entry_l3cc(&table, 2 * i + 1);
|
|
|
|
|
2019-06-21 14:07:50 +07:00
|
|
|
intel_uncore_write(uncore,
|
|
|
|
GEN9_LNCFCMOCS(i),
|
|
|
|
l3cc_combine(&table, low, high));
|
2019-01-24 07:06:02 +07:00
|
|
|
}
|
2016-04-13 21:03:25 +07:00
|
|
|
|
|
|
|
/* Odd table size - 1 left over */
|
|
|
|
if (table.size & 0x01) {
|
2019-01-24 07:06:02 +07:00
|
|
|
u16 low = get_entry_l3cc(&table, 2 * i);
|
|
|
|
|
2019-06-21 14:07:50 +07:00
|
|
|
intel_uncore_write(uncore,
|
|
|
|
GEN9_LNCFCMOCS(i),
|
|
|
|
l3cc_combine(&table, low, unused_value));
|
2016-04-13 21:03:25 +07:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2019-01-24 07:06:02 +07:00
|
|
|
/* All remaining entries are also unused */
|
2019-01-24 07:06:03 +07:00
|
|
|
for (; i < table.n_entries / 2; i++)
|
2019-06-21 14:07:50 +07:00
|
|
|
intel_uncore_write(uncore,
|
|
|
|
GEN9_LNCFCMOCS(i),
|
|
|
|
l3cc_combine(&table, unused_value,
|
|
|
|
unused_value));
|
2016-04-13 21:03:25 +07:00
|
|
|
}
|
|
|
|
|
2015-07-11 00:13:11 +07:00
|
|
|
/**
|
2019-08-03 17:22:21 +07:00
|
|
|
* intel_mocs_emit() - program the MOCS register.
|
|
|
|
* @rq: Request to use to set up the MOCS tables.
|
2015-07-11 00:13:11 +07:00
|
|
|
*
|
|
|
|
* This function will emit a batch buffer with the values required for
|
|
|
|
* programming the MOCS register values for all the currently supported
|
|
|
|
* rings.
|
|
|
|
*
|
|
|
|
* These registers are partially stored in the RCS context, so they are
|
|
|
|
* emitted at the same time so that when a context is created these registers
|
|
|
|
* are set up. These registers have to be emitted into the start of the
|
|
|
|
* context as setting the ELSP will re-init some of these registers back
|
|
|
|
* to the hw values.
|
|
|
|
*
|
|
|
|
* Return: 0 on success, otherwise the error status.
|
|
|
|
*/
|
2019-07-29 18:37:20 +07:00
|
|
|
int intel_mocs_emit(struct i915_request *rq)
|
2015-07-11 00:13:11 +07:00
|
|
|
{
|
|
|
|
struct drm_i915_mocs_table t;
|
|
|
|
int ret;
|
|
|
|
|
2019-07-31 01:04:06 +07:00
|
|
|
if (HAS_GLOBAL_MOCS_REGISTERS(rq->i915) ||
|
|
|
|
rq->engine->class != RENDER_CLASS)
|
2019-07-29 18:37:20 +07:00
|
|
|
return 0;
|
|
|
|
|
2019-06-21 14:07:50 +07:00
|
|
|
if (get_mocs_settings(rq->engine->gt, &t)) {
|
2016-04-13 21:03:25 +07:00
|
|
|
/* Program the RCS control registers */
|
2018-02-21 16:56:36 +07:00
|
|
|
ret = emit_mocs_control_table(rq, &t);
|
2016-04-13 21:03:25 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2015-07-11 00:13:11 +07:00
|
|
|
|
|
|
|
/* Now program the l3cc registers */
|
2018-02-21 16:56:36 +07:00
|
|
|
ret = emit_mocs_l3cc_table(rq, &t);
|
2015-07-11 00:13:11 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-07-31 01:04:07 +07:00
|
|
|
|
|
|
|
void intel_mocs_init(struct intel_gt *gt)
|
|
|
|
{
|
|
|
|
intel_mocs_init_l3cc_table(gt);
|
|
|
|
|
|
|
|
if (HAS_GLOBAL_MOCS_REGISTERS(gt->i915))
|
|
|
|
intel_mocs_init_global(gt);
|
|
|
|
}
|