2014-07-24 16:04:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2014 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INTEL_LRC_H_
|
|
|
|
#define _INTEL_LRC_H_
|
|
|
|
|
2016-04-13 16:35:01 +00:00
|
|
|
#include "intel_ringbuffer.h"
|
|
|
|
|
drm/i915/bdw: Pin the context backing objects to GGTT on-demand
Up until now, we have pinned every logical ring context backing object
during creation, and left it pinned until destruction. This made my life
easier, but it's a harmful thing to do, because we cause fragmentation
of the GGTT (and, eventually, we would run out of space).
This patch makes the pinning on-demand: the backing objects of the two
contexts that are written to the ELSP are pinned right before submission
and unpinned once the hardware is done with them. The only context that
is still pinned regardless is the global default one, so that the HWS can
still be accessed in the same way (ring->status_page).
v2: In the early version of this patch, we were pinning the context as
we put it into the ELSP: on the one hand, this is very efficient because
only a maximum two contexts are pinned at any given time, but on the other
hand, we cannot really pin in interrupt time :(
v3: Use a mutex rather than atomic_t to protect pin count to avoid races.
Do not unpin default context in free_request.
v4: Break out pin and unpin into functions. Fix style problems reported
by checkpatch
v5: Remove unpin_lock as all pinning and unpinning is done with the struct
mutex already locked. Add WARN_ONs to make sure this is the case in future.
Issue: VIZ-4277
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Signed-off-by: Thomas Daniel <thomas.daniel@intel.com>
Reviewed-by: Akash Goel <akash.goels@gmail.com>
Reviewed-by: Deepak S<deepak.s@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-11-13 10:28:10 +00:00
|
|
|
#define GEN8_LR_CONTEXT_ALIGN 4096
|
|
|
|
|
2014-08-07 12:23:20 +00:00
|
|
|
/* Execlists regs */
|
2016-07-20 17:16:05 +00:00
|
|
|
#define RING_ELSP(engine) _MMIO((engine)->mmio_base + 0x230)
|
|
|
|
#define RING_EXECLIST_STATUS_LO(engine) _MMIO((engine)->mmio_base + 0x234)
|
|
|
|
#define RING_EXECLIST_STATUS_HI(engine) _MMIO((engine)->mmio_base + 0x234 + 4)
|
|
|
|
#define RING_CONTEXT_CONTROL(engine) _MMIO((engine)->mmio_base + 0x244)
|
2015-02-10 09:11:36 +00:00
|
|
|
#define CTX_CTRL_INHIBIT_SYN_CTX_SWITCH (1 << 3)
|
|
|
|
#define CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT (1 << 0)
|
2015-06-16 10:39:42 +00:00
|
|
|
#define CTX_CTRL_RS_CTX_ENABLE (1 << 1)
|
2016-07-20 17:16:05 +00:00
|
|
|
#define RING_CONTEXT_STATUS_BUF_BASE(engine) _MMIO((engine)->mmio_base + 0x370)
|
|
|
|
#define RING_CONTEXT_STATUS_BUF_LO(engine, i) _MMIO((engine)->mmio_base + 0x370 + (i) * 8)
|
|
|
|
#define RING_CONTEXT_STATUS_BUF_HI(engine, i) _MMIO((engine)->mmio_base + 0x370 + (i) * 8 + 4)
|
|
|
|
#define RING_CONTEXT_STATUS_PTR(engine) _MMIO((engine)->mmio_base + 0x3a0)
|
2014-08-07 12:23:20 +00:00
|
|
|
|
2016-01-05 18:30:05 +00:00
|
|
|
/* The docs specify that the write pointer wraps around after 5h, "After status
|
|
|
|
* is written out to the last available status QW at offset 5h, this pointer
|
|
|
|
* wraps to 0."
|
|
|
|
*
|
|
|
|
* Therefore, one must infer than even though there are 3 bits available, 6 and
|
|
|
|
* 7 appear to be * reserved.
|
|
|
|
*/
|
|
|
|
#define GEN8_CSB_ENTRIES 6
|
|
|
|
#define GEN8_CSB_PTR_MASK 0x7
|
|
|
|
#define GEN8_CSB_READ_PTR_MASK (GEN8_CSB_PTR_MASK << 8)
|
|
|
|
#define GEN8_CSB_WRITE_PTR_MASK (GEN8_CSB_PTR_MASK << 0)
|
|
|
|
#define GEN8_CSB_WRITE_PTR(csb_status) \
|
|
|
|
(((csb_status) & GEN8_CSB_WRITE_PTR_MASK) >> 0)
|
|
|
|
#define GEN8_CSB_READ_PTR(csb_status) \
|
|
|
|
(((csb_status) & GEN8_CSB_READ_PTR_MASK) >> 8)
|
|
|
|
|
2016-06-16 12:07:03 +00:00
|
|
|
enum {
|
|
|
|
INTEL_CONTEXT_SCHEDULE_IN = 0,
|
|
|
|
INTEL_CONTEXT_SCHEDULE_OUT,
|
|
|
|
};
|
|
|
|
|
2014-07-24 16:04:22 +00:00
|
|
|
/* Logical Rings */
|
2015-05-29 16:43:26 +00:00
|
|
|
int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request);
|
2015-05-29 16:44:09 +00:00
|
|
|
int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request);
|
2016-03-16 11:00:37 +00:00
|
|
|
void intel_logical_ring_stop(struct intel_engine_cs *engine);
|
|
|
|
void intel_logical_ring_cleanup(struct intel_engine_cs *engine);
|
2016-07-13 15:03:40 +00:00
|
|
|
int logical_render_ring_init(struct intel_engine_cs *engine);
|
|
|
|
int logical_xcs_ring_init(struct intel_engine_cs *engine);
|
|
|
|
|
2016-07-13 15:03:37 +00:00
|
|
|
int intel_engines_init(struct drm_device *dev);
|
2014-07-24 16:04:22 +00:00
|
|
|
|
2014-07-24 16:04:12 +00:00
|
|
|
/* Logical Ring Contexts */
|
drm/i915: Integrate GuC-based command submission
GuC-based submission is mostly the same as execlist mode, up to
intel_logical_ring_advance_and_submit(), where the context being
dispatched would be added to the execlist queue; at this point
we submit the context to the GuC backend instead.
There are, however, a few other changes also required, notably:
1. Contexts must be pinned at GGTT addresses accessible by the GuC
i.e. NOT in the range [0..WOPCM_SIZE), so we have to add the
PIN_OFFSET_BIAS flag to the relevant GGTT-pinning calls.
2. The GuC's TLB must be invalidated after a context is pinned at
a new GGTT address.
3. GuC firmware uses the one page before Ring Context as shared data.
Therefore, whenever driver wants to get base address of LRC, we
will offset one page for it. LRC_PPHWSP_PN is defined as the page
number of LRCA.
4. In the work queue used to pass requests to the GuC, the GuC
firmware requires the ring-tail-offset to be represented as an
11-bit value, expressed in QWords. Therefore, the ringbuffer
size must be reduced to the representable range (4 pages).
v2:
Defer adding #defines until needed [Chris Wilson]
Rationalise type declarations [Chris Wilson]
v4:
Squashed kerneldoc patch into here [Daniel Vetter]
v5:
Update request->tail in code common to both GuC and execlist modes.
Add a private version of lr_context_update(), as sharing the
execlist version leads to race conditions when the CPU and
the GuC both update TAIL in the context image.
Conversion of error-captured HWS page to string must account
for offset from start of object to actual HWS (LRC_PPHWSP_PN).
Issue: VIZ-4884
Signed-off-by: Alex Dai <yu.dai@intel.com>
Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Reviewed-by: Tom O'Rourke <Tom.O'Rourke@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-08-12 14:43:43 +00:00
|
|
|
|
|
|
|
/* One extra page is added before LRC for GuC as shared data */
|
|
|
|
#define LRC_GUCSHR_PN (0)
|
|
|
|
#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1)
|
|
|
|
#define LRC_STATE_PN (LRC_PPHWSP_PN + 1)
|
|
|
|
|
2016-05-24 13:53:34 +00:00
|
|
|
struct i915_gem_context;
|
|
|
|
|
2016-03-16 11:00:37 +00:00
|
|
|
uint32_t intel_lr_context_size(struct intel_engine_cs *engine);
|
2016-05-24 13:53:34 +00:00
|
|
|
void intel_lr_context_unpin(struct i915_gem_context *ctx,
|
2016-01-28 10:29:54 +00:00
|
|
|
struct intel_engine_cs *engine);
|
2016-04-12 14:40:42 +00:00
|
|
|
|
|
|
|
struct drm_i915_private;
|
|
|
|
|
2016-09-09 13:11:53 +00:00
|
|
|
void intel_lr_context_resume(struct drm_i915_private *dev_priv);
|
2016-05-24 13:53:34 +00:00
|
|
|
uint64_t intel_lr_context_descriptor(struct i915_gem_context *ctx,
|
2016-03-16 11:00:37 +00:00
|
|
|
struct intel_engine_cs *engine);
|
2014-07-24 16:04:12 +00:00
|
|
|
|
2014-07-24 16:04:11 +00:00
|
|
|
/* Execlists */
|
2016-05-06 14:40:21 +00:00
|
|
|
int intel_sanitize_enable_execlists(struct drm_i915_private *dev_priv,
|
|
|
|
int enable_execlists);
|
2016-08-02 21:50:31 +00:00
|
|
|
void intel_execlists_enable_submission(struct drm_i915_private *dev_priv);
|
2016-11-07 09:20:04 +00:00
|
|
|
bool intel_execlists_idle(struct drm_i915_private *dev_priv);
|
2016-08-02 21:50:31 +00:00
|
|
|
|
2014-07-24 16:04:10 +00:00
|
|
|
#endif /* _INTEL_LRC_H_ */
|