18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright(c) 2011-2016 Intel Corporation. All rights reserved. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next 128c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 138c2ecf20Sopenharmony_ci * Software. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 188c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 198c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 208c2ecf20Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 218c2ecf20Sopenharmony_ci * SOFTWARE. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Authors: 248c2ecf20Sopenharmony_ci * Eddie Dong <eddie.dong@intel.com> 258c2ecf20Sopenharmony_ci * Kevin Tian <kevin.tian@intel.com> 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * Contributors: 288c2ecf20Sopenharmony_ci * Zhi Wang <zhi.a.wang@intel.com> 298c2ecf20Sopenharmony_ci * Changbin Du <changbin.du@intel.com> 308c2ecf20Sopenharmony_ci * Zhenyu Wang <zhenyuw@linux.intel.com> 318c2ecf20Sopenharmony_ci * Tina Zhang <tina.zhang@intel.com> 328c2ecf20Sopenharmony_ci * Bing Niu <bing.niu@intel.com> 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#include "i915_drv.h" 378c2ecf20Sopenharmony_ci#include "gt/intel_context.h" 388c2ecf20Sopenharmony_ci#include "gt/intel_ring.h" 398c2ecf20Sopenharmony_ci#include "gvt.h" 408c2ecf20Sopenharmony_ci#include "trace.h" 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define GEN9_MOCS_SIZE 64 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* Raw offset is appened to each line for convenience. */ 458c2ecf20Sopenharmony_cistatic struct engine_mmio gen8_engine_mmio_list[] __cacheline_aligned = { 468c2ecf20Sopenharmony_ci {RCS0, GFX_MODE_GEN7, 0xffff, false}, /* 0x229c */ 478c2ecf20Sopenharmony_ci {RCS0, GEN9_CTX_PREEMPT_REG, 0x0, false}, /* 0x2248 */ 488c2ecf20Sopenharmony_ci {RCS0, HWSTAM, 0x0, false}, /* 0x2098 */ 498c2ecf20Sopenharmony_ci {RCS0, INSTPM, 0xffff, true}, /* 0x20c0 */ 508c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 0), 0, false}, /* 0x24d0 */ 518c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 1), 0, false}, /* 0x24d4 */ 528c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 2), 0, false}, /* 0x24d8 */ 538c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 3), 0, false}, /* 0x24dc */ 548c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 4), 0, false}, /* 0x24e0 */ 558c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 5), 0, false}, /* 0x24e4 */ 568c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 6), 0, false}, /* 0x24e8 */ 578c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 7), 0, false}, /* 0x24ec */ 588c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 8), 0, false}, /* 0x24f0 */ 598c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 9), 0, false}, /* 0x24f4 */ 608c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 10), 0, false}, /* 0x24f8 */ 618c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 11), 0, false}, /* 0x24fc */ 628c2ecf20Sopenharmony_ci {RCS0, CACHE_MODE_1, 0xffff, true}, /* 0x7004 */ 638c2ecf20Sopenharmony_ci {RCS0, GEN7_GT_MODE, 0xffff, true}, /* 0x7008 */ 648c2ecf20Sopenharmony_ci {RCS0, CACHE_MODE_0_GEN7, 0xffff, true}, /* 0x7000 */ 658c2ecf20Sopenharmony_ci {RCS0, GEN7_COMMON_SLICE_CHICKEN1, 0xffff, true}, /* 0x7010 */ 668c2ecf20Sopenharmony_ci {RCS0, HDC_CHICKEN0, 0xffff, true}, /* 0x7300 */ 678c2ecf20Sopenharmony_ci {RCS0, VF_GUARDBAND, 0xffff, true}, /* 0x83a4 */ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci {BCS0, RING_GFX_MODE(BLT_RING_BASE), 0xffff, false}, /* 0x2229c */ 708c2ecf20Sopenharmony_ci {BCS0, RING_MI_MODE(BLT_RING_BASE), 0xffff, false}, /* 0x2209c */ 718c2ecf20Sopenharmony_ci {BCS0, RING_INSTPM(BLT_RING_BASE), 0xffff, false}, /* 0x220c0 */ 728c2ecf20Sopenharmony_ci {BCS0, RING_HWSTAM(BLT_RING_BASE), 0x0, false}, /* 0x22098 */ 738c2ecf20Sopenharmony_ci {BCS0, RING_EXCC(BLT_RING_BASE), 0xffff, false}, /* 0x22028 */ 748c2ecf20Sopenharmony_ci {RCS0, INVALID_MMIO_REG, 0, false } /* Terminated */ 758c2ecf20Sopenharmony_ci}; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cistatic struct engine_mmio gen9_engine_mmio_list[] __cacheline_aligned = { 788c2ecf20Sopenharmony_ci {RCS0, GFX_MODE_GEN7, 0xffff, false}, /* 0x229c */ 798c2ecf20Sopenharmony_ci {RCS0, GEN9_CTX_PREEMPT_REG, 0x0, false}, /* 0x2248 */ 808c2ecf20Sopenharmony_ci {RCS0, HWSTAM, 0x0, false}, /* 0x2098 */ 818c2ecf20Sopenharmony_ci {RCS0, INSTPM, 0xffff, true}, /* 0x20c0 */ 828c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 0), 0, false}, /* 0x24d0 */ 838c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 1), 0, false}, /* 0x24d4 */ 848c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 2), 0, false}, /* 0x24d8 */ 858c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 3), 0, false}, /* 0x24dc */ 868c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 4), 0, false}, /* 0x24e0 */ 878c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 5), 0, false}, /* 0x24e4 */ 888c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 6), 0, false}, /* 0x24e8 */ 898c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 7), 0, false}, /* 0x24ec */ 908c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 8), 0, false}, /* 0x24f0 */ 918c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 9), 0, false}, /* 0x24f4 */ 928c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 10), 0, false}, /* 0x24f8 */ 938c2ecf20Sopenharmony_ci {RCS0, RING_FORCE_TO_NONPRIV(RENDER_RING_BASE, 11), 0, false}, /* 0x24fc */ 948c2ecf20Sopenharmony_ci {RCS0, CACHE_MODE_1, 0xffff, true}, /* 0x7004 */ 958c2ecf20Sopenharmony_ci {RCS0, GEN7_GT_MODE, 0xffff, true}, /* 0x7008 */ 968c2ecf20Sopenharmony_ci {RCS0, CACHE_MODE_0_GEN7, 0xffff, true}, /* 0x7000 */ 978c2ecf20Sopenharmony_ci {RCS0, GEN7_COMMON_SLICE_CHICKEN1, 0xffff, true}, /* 0x7010 */ 988c2ecf20Sopenharmony_ci {RCS0, HDC_CHICKEN0, 0xffff, true}, /* 0x7300 */ 998c2ecf20Sopenharmony_ci {RCS0, VF_GUARDBAND, 0xffff, true}, /* 0x83a4 */ 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci {RCS0, GEN8_PRIVATE_PAT_LO, 0, false}, /* 0x40e0 */ 1028c2ecf20Sopenharmony_ci {RCS0, GEN8_PRIVATE_PAT_HI, 0, false}, /* 0x40e4 */ 1038c2ecf20Sopenharmony_ci {RCS0, GEN8_CS_CHICKEN1, 0xffff, true}, /* 0x2580 */ 1048c2ecf20Sopenharmony_ci {RCS0, COMMON_SLICE_CHICKEN2, 0xffff, true}, /* 0x7014 */ 1058c2ecf20Sopenharmony_ci {RCS0, GEN9_CS_DEBUG_MODE1, 0xffff, false}, /* 0x20ec */ 1068c2ecf20Sopenharmony_ci {RCS0, GEN8_L3SQCREG4, 0, false}, /* 0xb118 */ 1078c2ecf20Sopenharmony_ci {RCS0, GEN7_HALF_SLICE_CHICKEN1, 0xffff, true}, /* 0xe100 */ 1088c2ecf20Sopenharmony_ci {RCS0, HALF_SLICE_CHICKEN2, 0xffff, true}, /* 0xe180 */ 1098c2ecf20Sopenharmony_ci {RCS0, HALF_SLICE_CHICKEN3, 0xffff, true}, /* 0xe184 */ 1108c2ecf20Sopenharmony_ci {RCS0, GEN9_HALF_SLICE_CHICKEN5, 0xffff, true}, /* 0xe188 */ 1118c2ecf20Sopenharmony_ci {RCS0, GEN9_HALF_SLICE_CHICKEN7, 0xffff, true}, /* 0xe194 */ 1128c2ecf20Sopenharmony_ci {RCS0, GEN8_ROW_CHICKEN, 0xffff, true}, /* 0xe4f0 */ 1138c2ecf20Sopenharmony_ci {RCS0, TRVATTL3PTRDW(0), 0, true}, /* 0x4de0 */ 1148c2ecf20Sopenharmony_ci {RCS0, TRVATTL3PTRDW(1), 0, true}, /* 0x4de4 */ 1158c2ecf20Sopenharmony_ci {RCS0, TRNULLDETCT, 0, true}, /* 0x4de8 */ 1168c2ecf20Sopenharmony_ci {RCS0, TRINVTILEDETCT, 0, true}, /* 0x4dec */ 1178c2ecf20Sopenharmony_ci {RCS0, TRVADR, 0, true}, /* 0x4df0 */ 1188c2ecf20Sopenharmony_ci {RCS0, TRTTE, 0, true}, /* 0x4df4 */ 1198c2ecf20Sopenharmony_ci {RCS0, _MMIO(0x4dfc), 0, true}, 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci {BCS0, RING_GFX_MODE(BLT_RING_BASE), 0xffff, false}, /* 0x2229c */ 1228c2ecf20Sopenharmony_ci {BCS0, RING_MI_MODE(BLT_RING_BASE), 0xffff, false}, /* 0x2209c */ 1238c2ecf20Sopenharmony_ci {BCS0, RING_INSTPM(BLT_RING_BASE), 0xffff, false}, /* 0x220c0 */ 1248c2ecf20Sopenharmony_ci {BCS0, RING_HWSTAM(BLT_RING_BASE), 0x0, false}, /* 0x22098 */ 1258c2ecf20Sopenharmony_ci {BCS0, RING_EXCC(BLT_RING_BASE), 0xffff, false}, /* 0x22028 */ 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci {VCS1, RING_EXCC(GEN8_BSD2_RING_BASE), 0xffff, false}, /* 0x1c028 */ 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci {VECS0, RING_EXCC(VEBOX_RING_BASE), 0xffff, false}, /* 0x1a028 */ 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci {RCS0, GEN8_HDC_CHICKEN1, 0xffff, true}, /* 0x7304 */ 1328c2ecf20Sopenharmony_ci {RCS0, GEN9_CTX_PREEMPT_REG, 0x0, false}, /* 0x2248 */ 1338c2ecf20Sopenharmony_ci {RCS0, GEN7_UCGCTL4, 0x0, false}, /* 0x940c */ 1348c2ecf20Sopenharmony_ci {RCS0, GAMT_CHKN_BIT_REG, 0x0, false}, /* 0x4ab8 */ 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci {RCS0, GEN9_GAMT_ECO_REG_RW_IA, 0x0, false}, /* 0x4ab0 */ 1378c2ecf20Sopenharmony_ci {RCS0, GEN9_CSFE_CHICKEN1_RCS, 0xffff, false}, /* 0x20d4 */ 1388c2ecf20Sopenharmony_ci {RCS0, _MMIO(0x20D8), 0xffff, true}, /* 0x20d8 */ 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci {RCS0, GEN8_GARBCNTL, 0x0, false}, /* 0xb004 */ 1418c2ecf20Sopenharmony_ci {RCS0, GEN7_FF_THREAD_MODE, 0x0, false}, /* 0x20a0 */ 1428c2ecf20Sopenharmony_ci {RCS0, FF_SLICE_CS_CHICKEN2, 0xffff, false}, /* 0x20e4 */ 1438c2ecf20Sopenharmony_ci {RCS0, INVALID_MMIO_REG, 0, false } /* Terminated */ 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistatic struct { 1478c2ecf20Sopenharmony_ci bool initialized; 1488c2ecf20Sopenharmony_ci u32 control_table[I915_NUM_ENGINES][GEN9_MOCS_SIZE]; 1498c2ecf20Sopenharmony_ci u32 l3cc_table[GEN9_MOCS_SIZE / 2]; 1508c2ecf20Sopenharmony_ci} gen9_render_mocs; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cistatic u32 gen9_mocs_mmio_offset_list[] = { 1538c2ecf20Sopenharmony_ci [RCS0] = 0xc800, 1548c2ecf20Sopenharmony_ci [VCS0] = 0xc900, 1558c2ecf20Sopenharmony_ci [VCS1] = 0xca00, 1568c2ecf20Sopenharmony_ci [BCS0] = 0xcc00, 1578c2ecf20Sopenharmony_ci [VECS0] = 0xcb00, 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistatic void load_render_mocs(const struct intel_engine_cs *engine) 1618c2ecf20Sopenharmony_ci{ 1628c2ecf20Sopenharmony_ci struct intel_gvt *gvt = engine->i915->gvt; 1638c2ecf20Sopenharmony_ci struct intel_uncore *uncore = engine->uncore; 1648c2ecf20Sopenharmony_ci u32 cnt = gvt->engine_mmio_list.mocs_mmio_offset_list_cnt; 1658c2ecf20Sopenharmony_ci u32 *regs = gvt->engine_mmio_list.mocs_mmio_offset_list; 1668c2ecf20Sopenharmony_ci i915_reg_t offset; 1678c2ecf20Sopenharmony_ci int ring_id, i; 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci /* Platform doesn't have mocs mmios. */ 1708c2ecf20Sopenharmony_ci if (!regs) 1718c2ecf20Sopenharmony_ci return; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci for (ring_id = 0; ring_id < cnt; ring_id++) { 1748c2ecf20Sopenharmony_ci if (!HAS_ENGINE(engine->gt, ring_id)) 1758c2ecf20Sopenharmony_ci continue; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci offset.reg = regs[ring_id]; 1788c2ecf20Sopenharmony_ci for (i = 0; i < GEN9_MOCS_SIZE; i++) { 1798c2ecf20Sopenharmony_ci gen9_render_mocs.control_table[ring_id][i] = 1808c2ecf20Sopenharmony_ci intel_uncore_read_fw(uncore, offset); 1818c2ecf20Sopenharmony_ci offset.reg += 4; 1828c2ecf20Sopenharmony_ci } 1838c2ecf20Sopenharmony_ci } 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci offset.reg = 0xb020; 1868c2ecf20Sopenharmony_ci for (i = 0; i < GEN9_MOCS_SIZE / 2; i++) { 1878c2ecf20Sopenharmony_ci gen9_render_mocs.l3cc_table[i] = 1888c2ecf20Sopenharmony_ci intel_uncore_read_fw(uncore, offset); 1898c2ecf20Sopenharmony_ci offset.reg += 4; 1908c2ecf20Sopenharmony_ci } 1918c2ecf20Sopenharmony_ci gen9_render_mocs.initialized = true; 1928c2ecf20Sopenharmony_ci} 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistatic int 1958c2ecf20Sopenharmony_cirestore_context_mmio_for_inhibit(struct intel_vgpu *vgpu, 1968c2ecf20Sopenharmony_ci struct i915_request *req) 1978c2ecf20Sopenharmony_ci{ 1988c2ecf20Sopenharmony_ci u32 *cs; 1998c2ecf20Sopenharmony_ci int ret; 2008c2ecf20Sopenharmony_ci struct engine_mmio *mmio; 2018c2ecf20Sopenharmony_ci struct intel_gvt *gvt = vgpu->gvt; 2028c2ecf20Sopenharmony_ci int ring_id = req->engine->id; 2038c2ecf20Sopenharmony_ci int count = gvt->engine_mmio_list.ctx_mmio_count[ring_id]; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci if (count == 0) 2068c2ecf20Sopenharmony_ci return 0; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci ret = req->engine->emit_flush(req, EMIT_BARRIER); 2098c2ecf20Sopenharmony_ci if (ret) 2108c2ecf20Sopenharmony_ci return ret; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci cs = intel_ring_begin(req, count * 2 + 2); 2138c2ecf20Sopenharmony_ci if (IS_ERR(cs)) 2148c2ecf20Sopenharmony_ci return PTR_ERR(cs); 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci *cs++ = MI_LOAD_REGISTER_IMM(count); 2178c2ecf20Sopenharmony_ci for (mmio = gvt->engine_mmio_list.mmio; 2188c2ecf20Sopenharmony_ci i915_mmio_reg_valid(mmio->reg); mmio++) { 2198c2ecf20Sopenharmony_ci if (mmio->id != ring_id || !mmio->in_context) 2208c2ecf20Sopenharmony_ci continue; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci *cs++ = i915_mmio_reg_offset(mmio->reg); 2238c2ecf20Sopenharmony_ci *cs++ = vgpu_vreg_t(vgpu, mmio->reg) | (mmio->mask << 16); 2248c2ecf20Sopenharmony_ci gvt_dbg_core("add lri reg pair 0x%x:0x%x in inhibit ctx, vgpu:%d, rind_id:%d\n", 2258c2ecf20Sopenharmony_ci *(cs-2), *(cs-1), vgpu->id, ring_id); 2268c2ecf20Sopenharmony_ci } 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci *cs++ = MI_NOOP; 2298c2ecf20Sopenharmony_ci intel_ring_advance(req, cs); 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci ret = req->engine->emit_flush(req, EMIT_BARRIER); 2328c2ecf20Sopenharmony_ci if (ret) 2338c2ecf20Sopenharmony_ci return ret; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci return 0; 2368c2ecf20Sopenharmony_ci} 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_cistatic int 2398c2ecf20Sopenharmony_cirestore_render_mocs_control_for_inhibit(struct intel_vgpu *vgpu, 2408c2ecf20Sopenharmony_ci struct i915_request *req) 2418c2ecf20Sopenharmony_ci{ 2428c2ecf20Sopenharmony_ci unsigned int index; 2438c2ecf20Sopenharmony_ci u32 *cs; 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci cs = intel_ring_begin(req, 2 * GEN9_MOCS_SIZE + 2); 2468c2ecf20Sopenharmony_ci if (IS_ERR(cs)) 2478c2ecf20Sopenharmony_ci return PTR_ERR(cs); 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci *cs++ = MI_LOAD_REGISTER_IMM(GEN9_MOCS_SIZE); 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci for (index = 0; index < GEN9_MOCS_SIZE; index++) { 2528c2ecf20Sopenharmony_ci *cs++ = i915_mmio_reg_offset(GEN9_GFX_MOCS(index)); 2538c2ecf20Sopenharmony_ci *cs++ = vgpu_vreg_t(vgpu, GEN9_GFX_MOCS(index)); 2548c2ecf20Sopenharmony_ci gvt_dbg_core("add lri reg pair 0x%x:0x%x in inhibit ctx, vgpu:%d, rind_id:%d\n", 2558c2ecf20Sopenharmony_ci *(cs-2), *(cs-1), vgpu->id, req->engine->id); 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci } 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci *cs++ = MI_NOOP; 2608c2ecf20Sopenharmony_ci intel_ring_advance(req, cs); 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci return 0; 2638c2ecf20Sopenharmony_ci} 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_cistatic int 2668c2ecf20Sopenharmony_cirestore_render_mocs_l3cc_for_inhibit(struct intel_vgpu *vgpu, 2678c2ecf20Sopenharmony_ci struct i915_request *req) 2688c2ecf20Sopenharmony_ci{ 2698c2ecf20Sopenharmony_ci unsigned int index; 2708c2ecf20Sopenharmony_ci u32 *cs; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci cs = intel_ring_begin(req, 2 * GEN9_MOCS_SIZE / 2 + 2); 2738c2ecf20Sopenharmony_ci if (IS_ERR(cs)) 2748c2ecf20Sopenharmony_ci return PTR_ERR(cs); 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci *cs++ = MI_LOAD_REGISTER_IMM(GEN9_MOCS_SIZE / 2); 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci for (index = 0; index < GEN9_MOCS_SIZE / 2; index++) { 2798c2ecf20Sopenharmony_ci *cs++ = i915_mmio_reg_offset(GEN9_LNCFCMOCS(index)); 2808c2ecf20Sopenharmony_ci *cs++ = vgpu_vreg_t(vgpu, GEN9_LNCFCMOCS(index)); 2818c2ecf20Sopenharmony_ci gvt_dbg_core("add lri reg pair 0x%x:0x%x in inhibit ctx, vgpu:%d, rind_id:%d\n", 2828c2ecf20Sopenharmony_ci *(cs-2), *(cs-1), vgpu->id, req->engine->id); 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci } 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci *cs++ = MI_NOOP; 2878c2ecf20Sopenharmony_ci intel_ring_advance(req, cs); 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci return 0; 2908c2ecf20Sopenharmony_ci} 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci/* 2938c2ecf20Sopenharmony_ci * Use lri command to initialize the mmio which is in context state image for 2948c2ecf20Sopenharmony_ci * inhibit context, it contains tracked engine mmio, render_mocs and 2958c2ecf20Sopenharmony_ci * render_mocs_l3cc. 2968c2ecf20Sopenharmony_ci */ 2978c2ecf20Sopenharmony_ciint intel_vgpu_restore_inhibit_context(struct intel_vgpu *vgpu, 2988c2ecf20Sopenharmony_ci struct i915_request *req) 2998c2ecf20Sopenharmony_ci{ 3008c2ecf20Sopenharmony_ci int ret; 3018c2ecf20Sopenharmony_ci u32 *cs; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci cs = intel_ring_begin(req, 2); 3048c2ecf20Sopenharmony_ci if (IS_ERR(cs)) 3058c2ecf20Sopenharmony_ci return PTR_ERR(cs); 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci *cs++ = MI_ARB_ON_OFF | MI_ARB_DISABLE; 3088c2ecf20Sopenharmony_ci *cs++ = MI_NOOP; 3098c2ecf20Sopenharmony_ci intel_ring_advance(req, cs); 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci ret = restore_context_mmio_for_inhibit(vgpu, req); 3128c2ecf20Sopenharmony_ci if (ret) 3138c2ecf20Sopenharmony_ci goto out; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci /* no MOCS register in context except render engine */ 3168c2ecf20Sopenharmony_ci if (req->engine->id != RCS0) 3178c2ecf20Sopenharmony_ci goto out; 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci ret = restore_render_mocs_control_for_inhibit(vgpu, req); 3208c2ecf20Sopenharmony_ci if (ret) 3218c2ecf20Sopenharmony_ci goto out; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci ret = restore_render_mocs_l3cc_for_inhibit(vgpu, req); 3248c2ecf20Sopenharmony_ci if (ret) 3258c2ecf20Sopenharmony_ci goto out; 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ciout: 3288c2ecf20Sopenharmony_ci cs = intel_ring_begin(req, 2); 3298c2ecf20Sopenharmony_ci if (IS_ERR(cs)) 3308c2ecf20Sopenharmony_ci return PTR_ERR(cs); 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci *cs++ = MI_ARB_ON_OFF | MI_ARB_ENABLE; 3338c2ecf20Sopenharmony_ci *cs++ = MI_NOOP; 3348c2ecf20Sopenharmony_ci intel_ring_advance(req, cs); 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci return ret; 3378c2ecf20Sopenharmony_ci} 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistatic u32 gen8_tlb_mmio_offset_list[] = { 3408c2ecf20Sopenharmony_ci [RCS0] = 0x4260, 3418c2ecf20Sopenharmony_ci [VCS0] = 0x4264, 3428c2ecf20Sopenharmony_ci [VCS1] = 0x4268, 3438c2ecf20Sopenharmony_ci [BCS0] = 0x426c, 3448c2ecf20Sopenharmony_ci [VECS0] = 0x4270, 3458c2ecf20Sopenharmony_ci}; 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_cistatic void handle_tlb_pending_event(struct intel_vgpu *vgpu, 3488c2ecf20Sopenharmony_ci const struct intel_engine_cs *engine) 3498c2ecf20Sopenharmony_ci{ 3508c2ecf20Sopenharmony_ci struct intel_uncore *uncore = engine->uncore; 3518c2ecf20Sopenharmony_ci struct intel_vgpu_submission *s = &vgpu->submission; 3528c2ecf20Sopenharmony_ci u32 *regs = vgpu->gvt->engine_mmio_list.tlb_mmio_offset_list; 3538c2ecf20Sopenharmony_ci u32 cnt = vgpu->gvt->engine_mmio_list.tlb_mmio_offset_list_cnt; 3548c2ecf20Sopenharmony_ci enum forcewake_domains fw; 3558c2ecf20Sopenharmony_ci i915_reg_t reg; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci if (!regs) 3588c2ecf20Sopenharmony_ci return; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci if (drm_WARN_ON(&engine->i915->drm, engine->id >= cnt)) 3618c2ecf20Sopenharmony_ci return; 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci if (!test_and_clear_bit(engine->id, (void *)s->tlb_handle_pending)) 3648c2ecf20Sopenharmony_ci return; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci reg = _MMIO(regs[engine->id]); 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci /* WaForceWakeRenderDuringMmioTLBInvalidate:skl 3698c2ecf20Sopenharmony_ci * we need to put a forcewake when invalidating RCS TLB caches, 3708c2ecf20Sopenharmony_ci * otherwise device can go to RC6 state and interrupt invalidation 3718c2ecf20Sopenharmony_ci * process 3728c2ecf20Sopenharmony_ci */ 3738c2ecf20Sopenharmony_ci fw = intel_uncore_forcewake_for_reg(uncore, reg, 3748c2ecf20Sopenharmony_ci FW_REG_READ | FW_REG_WRITE); 3758c2ecf20Sopenharmony_ci if (engine->id == RCS0 && INTEL_GEN(engine->i915) >= 9) 3768c2ecf20Sopenharmony_ci fw |= FORCEWAKE_RENDER; 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_ci intel_uncore_forcewake_get(uncore, fw); 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci intel_uncore_write_fw(uncore, reg, 0x1); 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci if (wait_for_atomic(intel_uncore_read_fw(uncore, reg) == 0, 50)) 3838c2ecf20Sopenharmony_ci gvt_vgpu_err("timeout in invalidate ring %s tlb\n", 3848c2ecf20Sopenharmony_ci engine->name); 3858c2ecf20Sopenharmony_ci else 3868c2ecf20Sopenharmony_ci vgpu_vreg_t(vgpu, reg) = 0; 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci intel_uncore_forcewake_put(uncore, fw); 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci gvt_dbg_core("invalidate TLB for ring %s\n", engine->name); 3918c2ecf20Sopenharmony_ci} 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_cistatic void switch_mocs(struct intel_vgpu *pre, struct intel_vgpu *next, 3948c2ecf20Sopenharmony_ci const struct intel_engine_cs *engine) 3958c2ecf20Sopenharmony_ci{ 3968c2ecf20Sopenharmony_ci u32 regs[] = { 3978c2ecf20Sopenharmony_ci [RCS0] = 0xc800, 3988c2ecf20Sopenharmony_ci [VCS0] = 0xc900, 3998c2ecf20Sopenharmony_ci [VCS1] = 0xca00, 4008c2ecf20Sopenharmony_ci [BCS0] = 0xcc00, 4018c2ecf20Sopenharmony_ci [VECS0] = 0xcb00, 4028c2ecf20Sopenharmony_ci }; 4038c2ecf20Sopenharmony_ci struct intel_uncore *uncore = engine->uncore; 4048c2ecf20Sopenharmony_ci i915_reg_t offset, l3_offset; 4058c2ecf20Sopenharmony_ci u32 old_v, new_v; 4068c2ecf20Sopenharmony_ci int i; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci if (drm_WARN_ON(&engine->i915->drm, engine->id >= ARRAY_SIZE(regs))) 4098c2ecf20Sopenharmony_ci return; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci if (engine->id == RCS0 && IS_GEN(engine->i915, 9)) 4128c2ecf20Sopenharmony_ci return; 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci if (!pre && !gen9_render_mocs.initialized) 4158c2ecf20Sopenharmony_ci load_render_mocs(engine); 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci offset.reg = regs[engine->id]; 4188c2ecf20Sopenharmony_ci for (i = 0; i < GEN9_MOCS_SIZE; i++) { 4198c2ecf20Sopenharmony_ci if (pre) 4208c2ecf20Sopenharmony_ci old_v = vgpu_vreg_t(pre, offset); 4218c2ecf20Sopenharmony_ci else 4228c2ecf20Sopenharmony_ci old_v = gen9_render_mocs.control_table[engine->id][i]; 4238c2ecf20Sopenharmony_ci if (next) 4248c2ecf20Sopenharmony_ci new_v = vgpu_vreg_t(next, offset); 4258c2ecf20Sopenharmony_ci else 4268c2ecf20Sopenharmony_ci new_v = gen9_render_mocs.control_table[engine->id][i]; 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci if (old_v != new_v) 4298c2ecf20Sopenharmony_ci intel_uncore_write_fw(uncore, offset, new_v); 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci offset.reg += 4; 4328c2ecf20Sopenharmony_ci } 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci if (engine->id == RCS0) { 4358c2ecf20Sopenharmony_ci l3_offset.reg = 0xb020; 4368c2ecf20Sopenharmony_ci for (i = 0; i < GEN9_MOCS_SIZE / 2; i++) { 4378c2ecf20Sopenharmony_ci if (pre) 4388c2ecf20Sopenharmony_ci old_v = vgpu_vreg_t(pre, l3_offset); 4398c2ecf20Sopenharmony_ci else 4408c2ecf20Sopenharmony_ci old_v = gen9_render_mocs.l3cc_table[i]; 4418c2ecf20Sopenharmony_ci if (next) 4428c2ecf20Sopenharmony_ci new_v = vgpu_vreg_t(next, l3_offset); 4438c2ecf20Sopenharmony_ci else 4448c2ecf20Sopenharmony_ci new_v = gen9_render_mocs.l3cc_table[i]; 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci if (old_v != new_v) 4478c2ecf20Sopenharmony_ci intel_uncore_write_fw(uncore, l3_offset, new_v); 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci l3_offset.reg += 4; 4508c2ecf20Sopenharmony_ci } 4518c2ecf20Sopenharmony_ci } 4528c2ecf20Sopenharmony_ci} 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci#define CTX_CONTEXT_CONTROL_VAL 0x03 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_cibool is_inhibit_context(struct intel_context *ce) 4578c2ecf20Sopenharmony_ci{ 4588c2ecf20Sopenharmony_ci const u32 *reg_state = ce->lrc_reg_state; 4598c2ecf20Sopenharmony_ci u32 inhibit_mask = 4608c2ecf20Sopenharmony_ci _MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT); 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci return inhibit_mask == 4638c2ecf20Sopenharmony_ci (reg_state[CTX_CONTEXT_CONTROL_VAL] & inhibit_mask); 4648c2ecf20Sopenharmony_ci} 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_ci/* Switch ring mmio values (context). */ 4678c2ecf20Sopenharmony_cistatic void switch_mmio(struct intel_vgpu *pre, 4688c2ecf20Sopenharmony_ci struct intel_vgpu *next, 4698c2ecf20Sopenharmony_ci const struct intel_engine_cs *engine) 4708c2ecf20Sopenharmony_ci{ 4718c2ecf20Sopenharmony_ci struct intel_uncore *uncore = engine->uncore; 4728c2ecf20Sopenharmony_ci struct intel_vgpu_submission *s; 4738c2ecf20Sopenharmony_ci struct engine_mmio *mmio; 4748c2ecf20Sopenharmony_ci u32 old_v, new_v; 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_ci if (INTEL_GEN(engine->i915) >= 9) 4778c2ecf20Sopenharmony_ci switch_mocs(pre, next, engine); 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci for (mmio = engine->i915->gvt->engine_mmio_list.mmio; 4808c2ecf20Sopenharmony_ci i915_mmio_reg_valid(mmio->reg); mmio++) { 4818c2ecf20Sopenharmony_ci if (mmio->id != engine->id) 4828c2ecf20Sopenharmony_ci continue; 4838c2ecf20Sopenharmony_ci /* 4848c2ecf20Sopenharmony_ci * No need to do save or restore of the mmio which is in context 4858c2ecf20Sopenharmony_ci * state image on gen9, it's initialized by lri command and 4868c2ecf20Sopenharmony_ci * save or restore with context together. 4878c2ecf20Sopenharmony_ci */ 4888c2ecf20Sopenharmony_ci if (IS_GEN(engine->i915, 9) && mmio->in_context) 4898c2ecf20Sopenharmony_ci continue; 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci // save 4928c2ecf20Sopenharmony_ci if (pre) { 4938c2ecf20Sopenharmony_ci vgpu_vreg_t(pre, mmio->reg) = 4948c2ecf20Sopenharmony_ci intel_uncore_read_fw(uncore, mmio->reg); 4958c2ecf20Sopenharmony_ci if (mmio->mask) 4968c2ecf20Sopenharmony_ci vgpu_vreg_t(pre, mmio->reg) &= 4978c2ecf20Sopenharmony_ci ~(mmio->mask << 16); 4988c2ecf20Sopenharmony_ci old_v = vgpu_vreg_t(pre, mmio->reg); 4998c2ecf20Sopenharmony_ci } else { 5008c2ecf20Sopenharmony_ci old_v = mmio->value = 5018c2ecf20Sopenharmony_ci intel_uncore_read_fw(uncore, mmio->reg); 5028c2ecf20Sopenharmony_ci } 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci // restore 5058c2ecf20Sopenharmony_ci if (next) { 5068c2ecf20Sopenharmony_ci s = &next->submission; 5078c2ecf20Sopenharmony_ci /* 5088c2ecf20Sopenharmony_ci * No need to restore the mmio which is in context state 5098c2ecf20Sopenharmony_ci * image if it's not inhibit context, it will restore 5108c2ecf20Sopenharmony_ci * itself. 5118c2ecf20Sopenharmony_ci */ 5128c2ecf20Sopenharmony_ci if (mmio->in_context && 5138c2ecf20Sopenharmony_ci !is_inhibit_context(s->shadow[engine->id])) 5148c2ecf20Sopenharmony_ci continue; 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci if (mmio->mask) 5178c2ecf20Sopenharmony_ci new_v = vgpu_vreg_t(next, mmio->reg) | 5188c2ecf20Sopenharmony_ci (mmio->mask << 16); 5198c2ecf20Sopenharmony_ci else 5208c2ecf20Sopenharmony_ci new_v = vgpu_vreg_t(next, mmio->reg); 5218c2ecf20Sopenharmony_ci } else { 5228c2ecf20Sopenharmony_ci if (mmio->in_context) 5238c2ecf20Sopenharmony_ci continue; 5248c2ecf20Sopenharmony_ci if (mmio->mask) 5258c2ecf20Sopenharmony_ci new_v = mmio->value | (mmio->mask << 16); 5268c2ecf20Sopenharmony_ci else 5278c2ecf20Sopenharmony_ci new_v = mmio->value; 5288c2ecf20Sopenharmony_ci } 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci intel_uncore_write_fw(uncore, mmio->reg, new_v); 5318c2ecf20Sopenharmony_ci 5328c2ecf20Sopenharmony_ci trace_render_mmio(pre ? pre->id : 0, 5338c2ecf20Sopenharmony_ci next ? next->id : 0, 5348c2ecf20Sopenharmony_ci "switch", 5358c2ecf20Sopenharmony_ci i915_mmio_reg_offset(mmio->reg), 5368c2ecf20Sopenharmony_ci old_v, new_v); 5378c2ecf20Sopenharmony_ci } 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci if (next) 5408c2ecf20Sopenharmony_ci handle_tlb_pending_event(next, engine); 5418c2ecf20Sopenharmony_ci} 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci/** 5448c2ecf20Sopenharmony_ci * intel_gvt_switch_render_mmio - switch mmio context of specific engine 5458c2ecf20Sopenharmony_ci * @pre: the last vGPU that own the engine 5468c2ecf20Sopenharmony_ci * @next: the vGPU to switch to 5478c2ecf20Sopenharmony_ci * @engine: the engine 5488c2ecf20Sopenharmony_ci * 5498c2ecf20Sopenharmony_ci * If pre is null indicates that host own the engine. If next is null 5508c2ecf20Sopenharmony_ci * indicates that we are switching to host workload. 5518c2ecf20Sopenharmony_ci */ 5528c2ecf20Sopenharmony_civoid intel_gvt_switch_mmio(struct intel_vgpu *pre, 5538c2ecf20Sopenharmony_ci struct intel_vgpu *next, 5548c2ecf20Sopenharmony_ci const struct intel_engine_cs *engine) 5558c2ecf20Sopenharmony_ci{ 5568c2ecf20Sopenharmony_ci if (WARN(!pre && !next, "switch ring %s from host to HOST\n", 5578c2ecf20Sopenharmony_ci engine->name)) 5588c2ecf20Sopenharmony_ci return; 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci gvt_dbg_render("switch ring %s from %s to %s\n", engine->name, 5618c2ecf20Sopenharmony_ci pre ? "vGPU" : "host", next ? "vGPU" : "HOST"); 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci /** 5648c2ecf20Sopenharmony_ci * We are using raw mmio access wrapper to improve the 5658c2ecf20Sopenharmony_ci * performace for batch mmio read/write, so we need 5668c2ecf20Sopenharmony_ci * handle forcewake mannually. 5678c2ecf20Sopenharmony_ci */ 5688c2ecf20Sopenharmony_ci intel_uncore_forcewake_get(engine->uncore, FORCEWAKE_ALL); 5698c2ecf20Sopenharmony_ci switch_mmio(pre, next, engine); 5708c2ecf20Sopenharmony_ci intel_uncore_forcewake_put(engine->uncore, FORCEWAKE_ALL); 5718c2ecf20Sopenharmony_ci} 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci/** 5748c2ecf20Sopenharmony_ci * intel_gvt_init_engine_mmio_context - Initiate the engine mmio list 5758c2ecf20Sopenharmony_ci * @gvt: GVT device 5768c2ecf20Sopenharmony_ci * 5778c2ecf20Sopenharmony_ci */ 5788c2ecf20Sopenharmony_civoid intel_gvt_init_engine_mmio_context(struct intel_gvt *gvt) 5798c2ecf20Sopenharmony_ci{ 5808c2ecf20Sopenharmony_ci struct engine_mmio *mmio; 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci if (INTEL_GEN(gvt->gt->i915) >= 9) { 5838c2ecf20Sopenharmony_ci gvt->engine_mmio_list.mmio = gen9_engine_mmio_list; 5848c2ecf20Sopenharmony_ci gvt->engine_mmio_list.tlb_mmio_offset_list = gen8_tlb_mmio_offset_list; 5858c2ecf20Sopenharmony_ci gvt->engine_mmio_list.tlb_mmio_offset_list_cnt = ARRAY_SIZE(gen8_tlb_mmio_offset_list); 5868c2ecf20Sopenharmony_ci gvt->engine_mmio_list.mocs_mmio_offset_list = gen9_mocs_mmio_offset_list; 5878c2ecf20Sopenharmony_ci gvt->engine_mmio_list.mocs_mmio_offset_list_cnt = ARRAY_SIZE(gen9_mocs_mmio_offset_list); 5888c2ecf20Sopenharmony_ci } else { 5898c2ecf20Sopenharmony_ci gvt->engine_mmio_list.mmio = gen8_engine_mmio_list; 5908c2ecf20Sopenharmony_ci gvt->engine_mmio_list.tlb_mmio_offset_list = gen8_tlb_mmio_offset_list; 5918c2ecf20Sopenharmony_ci gvt->engine_mmio_list.tlb_mmio_offset_list_cnt = ARRAY_SIZE(gen8_tlb_mmio_offset_list); 5928c2ecf20Sopenharmony_ci } 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci for (mmio = gvt->engine_mmio_list.mmio; 5958c2ecf20Sopenharmony_ci i915_mmio_reg_valid(mmio->reg); mmio++) { 5968c2ecf20Sopenharmony_ci if (mmio->in_context) { 5978c2ecf20Sopenharmony_ci gvt->engine_mmio_list.ctx_mmio_count[mmio->id]++; 5988c2ecf20Sopenharmony_ci intel_gvt_mmio_set_sr_in_ctx(gvt, mmio->reg.reg); 5998c2ecf20Sopenharmony_ci } 6008c2ecf20Sopenharmony_ci } 6018c2ecf20Sopenharmony_ci} 602