18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright © 2014 Intel Corporation 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 208c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 218c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#ifndef _INTEL_LRC_H_ 258c2ecf20Sopenharmony_ci#define _INTEL_LRC_H_ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#include <linux/types.h> 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistruct drm_printer; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistruct drm_i915_private; 328c2ecf20Sopenharmony_cistruct i915_gem_context; 338c2ecf20Sopenharmony_cistruct i915_request; 348c2ecf20Sopenharmony_cistruct intel_context; 358c2ecf20Sopenharmony_cistruct intel_engine_cs; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* Execlists regs */ 388c2ecf20Sopenharmony_ci#define RING_ELSP(base) _MMIO((base) + 0x230) 398c2ecf20Sopenharmony_ci#define RING_EXECLIST_STATUS_LO(base) _MMIO((base) + 0x234) 408c2ecf20Sopenharmony_ci#define RING_EXECLIST_STATUS_HI(base) _MMIO((base) + 0x234 + 4) 418c2ecf20Sopenharmony_ci#define RING_CONTEXT_CONTROL(base) _MMIO((base) + 0x244) 428c2ecf20Sopenharmony_ci#define CTX_CTRL_INHIBIT_SYN_CTX_SWITCH (1 << 3) 438c2ecf20Sopenharmony_ci#define CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT (1 << 0) 448c2ecf20Sopenharmony_ci#define CTX_CTRL_RS_CTX_ENABLE (1 << 1) 458c2ecf20Sopenharmony_ci#define CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT (1 << 2) 468c2ecf20Sopenharmony_ci#define GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE (1 << 8) 478c2ecf20Sopenharmony_ci#define RING_CONTEXT_STATUS_PTR(base) _MMIO((base) + 0x3a0) 488c2ecf20Sopenharmony_ci#define RING_EXECLIST_SQ_CONTENTS(base) _MMIO((base) + 0x510) 498c2ecf20Sopenharmony_ci#define RING_EXECLIST_CONTROL(base) _MMIO((base) + 0x550) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define EL_CTRL_LOAD (1 << 0) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* The docs specify that the write pointer wraps around after 5h, "After status 548c2ecf20Sopenharmony_ci * is written out to the last available status QW at offset 5h, this pointer 558c2ecf20Sopenharmony_ci * wraps to 0." 568c2ecf20Sopenharmony_ci * 578c2ecf20Sopenharmony_ci * Therefore, one must infer than even though there are 3 bits available, 6 and 588c2ecf20Sopenharmony_ci * 7 appear to be * reserved. 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_ci#define GEN8_CSB_ENTRIES 6 618c2ecf20Sopenharmony_ci#define GEN8_CSB_PTR_MASK 0x7 628c2ecf20Sopenharmony_ci#define GEN8_CSB_READ_PTR_MASK (GEN8_CSB_PTR_MASK << 8) 638c2ecf20Sopenharmony_ci#define GEN8_CSB_WRITE_PTR_MASK (GEN8_CSB_PTR_MASK << 0) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define GEN11_CSB_ENTRIES 12 668c2ecf20Sopenharmony_ci#define GEN11_CSB_PTR_MASK 0xf 678c2ecf20Sopenharmony_ci#define GEN11_CSB_READ_PTR_MASK (GEN11_CSB_PTR_MASK << 8) 688c2ecf20Sopenharmony_ci#define GEN11_CSB_WRITE_PTR_MASK (GEN11_CSB_PTR_MASK << 0) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */ 718c2ecf20Sopenharmony_ci#define MAX_GUC_CONTEXT_HW_ID (1 << 20) /* exclusive */ 728c2ecf20Sopenharmony_ci#define GEN11_MAX_CONTEXT_HW_ID (1<<11) /* exclusive */ 738c2ecf20Sopenharmony_ci/* in Gen12 ID 0x7FF is reserved to indicate idle */ 748c2ecf20Sopenharmony_ci#define GEN12_MAX_CONTEXT_HW_ID (GEN11_MAX_CONTEXT_HW_ID - 1) 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cienum { 778c2ecf20Sopenharmony_ci INTEL_CONTEXT_SCHEDULE_IN = 0, 788c2ecf20Sopenharmony_ci INTEL_CONTEXT_SCHEDULE_OUT, 798c2ecf20Sopenharmony_ci INTEL_CONTEXT_SCHEDULE_PREEMPTED, 808c2ecf20Sopenharmony_ci}; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* Logical Rings */ 838c2ecf20Sopenharmony_civoid intel_logical_ring_cleanup(struct intel_engine_cs *engine); 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciint intel_execlists_submission_setup(struct intel_engine_cs *engine); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* Logical Ring Contexts */ 888c2ecf20Sopenharmony_ci/* At the start of the context image is its per-process HWS page */ 898c2ecf20Sopenharmony_ci#define LRC_PPHWSP_PN (0) 908c2ecf20Sopenharmony_ci#define LRC_PPHWSP_SZ (1) 918c2ecf20Sopenharmony_ci/* After the PPHWSP we have the logical state for the context */ 928c2ecf20Sopenharmony_ci#define LRC_STATE_PN (LRC_PPHWSP_PN + LRC_PPHWSP_SZ) 938c2ecf20Sopenharmony_ci#define LRC_STATE_OFFSET (LRC_STATE_PN * PAGE_SIZE) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* Space within PPHWSP reserved to be used as scratch */ 968c2ecf20Sopenharmony_ci#define LRC_PPHWSP_SCRATCH 0x34 978c2ecf20Sopenharmony_ci#define LRC_PPHWSP_SCRATCH_ADDR (LRC_PPHWSP_SCRATCH * sizeof(u32)) 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_civoid intel_execlists_set_default_submission(struct intel_engine_cs *engine); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_civoid intel_lr_context_reset(struct intel_engine_cs *engine, 1028c2ecf20Sopenharmony_ci struct intel_context *ce, 1038c2ecf20Sopenharmony_ci u32 head, 1048c2ecf20Sopenharmony_ci bool scrub); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_civoid intel_execlists_show_requests(struct intel_engine_cs *engine, 1078c2ecf20Sopenharmony_ci struct drm_printer *m, 1088c2ecf20Sopenharmony_ci void (*show_request)(struct drm_printer *m, 1098c2ecf20Sopenharmony_ci struct i915_request *rq, 1108c2ecf20Sopenharmony_ci const char *prefix), 1118c2ecf20Sopenharmony_ci unsigned int max); 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_cistruct intel_context * 1148c2ecf20Sopenharmony_ciintel_execlists_create_virtual(struct intel_engine_cs **siblings, 1158c2ecf20Sopenharmony_ci unsigned int count); 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cistruct intel_context * 1188c2ecf20Sopenharmony_ciintel_execlists_clone_virtual(struct intel_engine_cs *src); 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ciint intel_virtual_engine_attach_bond(struct intel_engine_cs *engine, 1218c2ecf20Sopenharmony_ci const struct intel_engine_cs *master, 1228c2ecf20Sopenharmony_ci const struct intel_engine_cs *sibling); 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistruct intel_engine_cs * 1258c2ecf20Sopenharmony_ciintel_virtual_engine_get_sibling(struct intel_engine_cs *engine, 1268c2ecf20Sopenharmony_ci unsigned int sibling); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cibool 1298c2ecf20Sopenharmony_ciintel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine); 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#endif /* _INTEL_LRC_H_ */ 132