Home | History | Annotate | Line # | Download | only in gt
      1  1.1  riastrad /*	$NetBSD: intel_lrc.h,v 1.2 2021/12/18 23:45:30 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright  2014 Intel Corporation
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice (including the next
     14  1.1  riastrad  * paragraph) shall be included in all copies or substantial portions of the
     15  1.1  riastrad  * Software.
     16  1.1  riastrad  *
     17  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  1.1  riastrad  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     21  1.1  riastrad  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     22  1.1  riastrad  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     23  1.1  riastrad  * DEALINGS IN THE SOFTWARE.
     24  1.1  riastrad  */
     25  1.1  riastrad 
     26  1.1  riastrad #ifndef _INTEL_LRC_H_
     27  1.1  riastrad #define _INTEL_LRC_H_
     28  1.1  riastrad 
     29  1.1  riastrad #include <linux/types.h>
     30  1.1  riastrad 
     31  1.1  riastrad struct drm_printer;
     32  1.1  riastrad 
     33  1.1  riastrad struct drm_i915_private;
     34  1.1  riastrad struct i915_gem_context;
     35  1.1  riastrad struct i915_request;
     36  1.1  riastrad struct intel_context;
     37  1.1  riastrad struct intel_engine_cs;
     38  1.1  riastrad 
     39  1.1  riastrad /* Execlists regs */
     40  1.1  riastrad #define RING_ELSP(base)				_MMIO((base) + 0x230)
     41  1.1  riastrad #define RING_EXECLIST_STATUS_LO(base)		_MMIO((base) + 0x234)
     42  1.1  riastrad #define RING_EXECLIST_STATUS_HI(base)		_MMIO((base) + 0x234 + 4)
     43  1.1  riastrad #define RING_CONTEXT_CONTROL(base)		_MMIO((base) + 0x244)
     44  1.1  riastrad #define	  CTX_CTRL_INHIBIT_SYN_CTX_SWITCH	(1 << 3)
     45  1.1  riastrad #define	  CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT	(1 << 0)
     46  1.1  riastrad #define   CTX_CTRL_RS_CTX_ENABLE		(1 << 1)
     47  1.1  riastrad #define	  CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT	(1 << 2)
     48  1.1  riastrad #define	  GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE	(1 << 8)
     49  1.1  riastrad #define RING_CONTEXT_STATUS_PTR(base)		_MMIO((base) + 0x3a0)
     50  1.1  riastrad #define RING_EXECLIST_SQ_CONTENTS(base)		_MMIO((base) + 0x510)
     51  1.1  riastrad #define RING_EXECLIST_CONTROL(base)		_MMIO((base) + 0x550)
     52  1.1  riastrad 
     53  1.1  riastrad #define	  EL_CTRL_LOAD				(1 << 0)
     54  1.1  riastrad 
     55  1.1  riastrad /* The docs specify that the write pointer wraps around after 5h, "After status
     56  1.1  riastrad  * is written out to the last available status QW at offset 5h, this pointer
     57  1.1  riastrad  * wraps to 0."
     58  1.1  riastrad  *
     59  1.1  riastrad  * Therefore, one must infer than even though there are 3 bits available, 6 and
     60  1.1  riastrad  * 7 appear to be * reserved.
     61  1.1  riastrad  */
     62  1.1  riastrad #define GEN8_CSB_ENTRIES 6
     63  1.1  riastrad #define GEN8_CSB_PTR_MASK 0x7
     64  1.1  riastrad #define GEN8_CSB_READ_PTR_MASK (GEN8_CSB_PTR_MASK << 8)
     65  1.1  riastrad #define GEN8_CSB_WRITE_PTR_MASK (GEN8_CSB_PTR_MASK << 0)
     66  1.1  riastrad 
     67  1.1  riastrad #define GEN11_CSB_ENTRIES 12
     68  1.1  riastrad #define GEN11_CSB_PTR_MASK 0xf
     69  1.1  riastrad #define GEN11_CSB_READ_PTR_MASK (GEN11_CSB_PTR_MASK << 8)
     70  1.1  riastrad #define GEN11_CSB_WRITE_PTR_MASK (GEN11_CSB_PTR_MASK << 0)
     71  1.1  riastrad 
     72  1.1  riastrad #define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */
     73  1.1  riastrad #define MAX_GUC_CONTEXT_HW_ID (1 << 20) /* exclusive */
     74  1.1  riastrad #define GEN11_MAX_CONTEXT_HW_ID (1<<11) /* exclusive */
     75  1.1  riastrad /* in Gen12 ID 0x7FF is reserved to indicate idle */
     76  1.1  riastrad #define GEN12_MAX_CONTEXT_HW_ID	(GEN11_MAX_CONTEXT_HW_ID - 1)
     77  1.1  riastrad 
     78  1.1  riastrad enum {
     79  1.1  riastrad 	INTEL_CONTEXT_SCHEDULE_IN = 0,
     80  1.1  riastrad 	INTEL_CONTEXT_SCHEDULE_OUT,
     81  1.1  riastrad 	INTEL_CONTEXT_SCHEDULE_PREEMPTED,
     82  1.1  riastrad };
     83  1.1  riastrad 
     84  1.1  riastrad /* Logical Rings */
     85  1.1  riastrad void intel_logical_ring_cleanup(struct intel_engine_cs *engine);
     86  1.1  riastrad 
     87  1.1  riastrad int intel_execlists_submission_setup(struct intel_engine_cs *engine);
     88  1.1  riastrad 
     89  1.1  riastrad /* Logical Ring Contexts */
     90  1.1  riastrad /* At the start of the context image is its per-process HWS page */
     91  1.1  riastrad #define LRC_PPHWSP_PN	(0)
     92  1.1  riastrad #define LRC_PPHWSP_SZ	(1)
     93  1.1  riastrad /* After the PPHWSP we have the logical state for the context */
     94  1.1  riastrad #define LRC_STATE_PN	(LRC_PPHWSP_PN + LRC_PPHWSP_SZ)
     95  1.1  riastrad 
     96  1.1  riastrad /* Space within PPHWSP reserved to be used as scratch */
     97  1.1  riastrad #define LRC_PPHWSP_SCRATCH		0x34
     98  1.1  riastrad #define LRC_PPHWSP_SCRATCH_ADDR		(LRC_PPHWSP_SCRATCH * sizeof(u32))
     99  1.1  riastrad 
    100  1.1  riastrad void intel_execlists_set_default_submission(struct intel_engine_cs *engine);
    101  1.1  riastrad 
    102  1.1  riastrad void intel_lr_context_reset(struct intel_engine_cs *engine,
    103  1.1  riastrad 			    struct intel_context *ce,
    104  1.1  riastrad 			    u32 head,
    105  1.1  riastrad 			    bool scrub);
    106  1.1  riastrad 
    107  1.1  riastrad void intel_execlists_show_requests(struct intel_engine_cs *engine,
    108  1.1  riastrad 				   struct drm_printer *m,
    109  1.1  riastrad 				   void (*show_request)(struct drm_printer *m,
    110  1.1  riastrad 							struct i915_request *rq,
    111  1.1  riastrad 							const char *prefix),
    112  1.1  riastrad 				   unsigned int max);
    113  1.1  riastrad 
    114  1.1  riastrad struct intel_context *
    115  1.1  riastrad intel_execlists_create_virtual(struct intel_engine_cs **siblings,
    116  1.1  riastrad 			       unsigned int count);
    117  1.1  riastrad 
    118  1.1  riastrad struct intel_context *
    119  1.1  riastrad intel_execlists_clone_virtual(struct intel_engine_cs *src);
    120  1.1  riastrad 
    121  1.1  riastrad int intel_virtual_engine_attach_bond(struct intel_engine_cs *engine,
    122  1.1  riastrad 				     const struct intel_engine_cs *master,
    123  1.1  riastrad 				     const struct intel_engine_cs *sibling);
    124  1.1  riastrad 
    125  1.1  riastrad struct intel_engine_cs *
    126  1.1  riastrad intel_virtual_engine_get_sibling(struct intel_engine_cs *engine,
    127  1.1  riastrad 				 unsigned int sibling);
    128  1.1  riastrad 
    129  1.1  riastrad bool
    130  1.1  riastrad intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine);
    131  1.1  riastrad 
    132  1.1  riastrad #endif /* _INTEL_LRC_H_ */
    133