2014-07-24 23:04:10 +07: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 23:35:01 +07:00
|
|
|
#include "intel_ringbuffer.h"
|
2017-09-13 04:49:05 +07:00
|
|
|
#include "i915_gem_context.h"
|
2016-04-13 23:35:01 +07:00
|
|
|
|
2014-08-07 19:23:20 +07:00
|
|
|
/* Execlists regs */
|
2016-07-21 00:16:05 +07: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 16:11:36 +07:00
|
|
|
#define CTX_CTRL_INHIBIT_SYN_CTX_SWITCH (1 << 3)
|
|
|
|
#define CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT (1 << 0)
|
2015-06-16 17:39:42 +07:00
|
|
|
#define CTX_CTRL_RS_CTX_ENABLE (1 << 1)
|
2018-01-24 04:04:12 +07:00
|
|
|
#define CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT (1 << 2)
|
2016-07-21 00:16:05 +07: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)
|
2018-03-02 23:14:59 +07:00
|
|
|
#define RING_EXECLIST_SQ_CONTENTS(engine) _MMIO((engine)->mmio_base + 0x510)
|
|
|
|
#define RING_EXECLIST_CONTROL(engine) _MMIO((engine)->mmio_base + 0x550)
|
|
|
|
#define EL_CTRL_LOAD (1 << 0)
|
2014-08-07 19:23:20 +07:00
|
|
|
|
2016-01-06 01:30:05 +07: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 19:07:03 +07:00
|
|
|
enum {
|
|
|
|
INTEL_CONTEXT_SCHEDULE_IN = 0,
|
|
|
|
INTEL_CONTEXT_SCHEDULE_OUT,
|
2017-10-04 03:34:47 +07:00
|
|
|
INTEL_CONTEXT_SCHEDULE_PREEMPTED,
|
2016-06-16 19:07:03 +07:00
|
|
|
};
|
|
|
|
|
2014-07-24 23:04:22 +07:00
|
|
|
/* Logical Rings */
|
2016-03-16 18:00:37 +07:00
|
|
|
void intel_logical_ring_cleanup(struct intel_engine_cs *engine);
|
2016-07-13 22:03:40 +07:00
|
|
|
int logical_render_ring_init(struct intel_engine_cs *engine);
|
|
|
|
int logical_xcs_ring_init(struct intel_engine_cs *engine);
|
|
|
|
|
2014-07-24 23:04:12 +07: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 21:43:43 +07:00
|
|
|
|
2017-09-13 15:56:00 +07:00
|
|
|
/*
|
|
|
|
* We allocate a header at the start of the context image for our own
|
|
|
|
* use, therefore the actual location of the logical state is offset
|
|
|
|
* from the start of the VMA. The layout is
|
|
|
|
*
|
|
|
|
* | [guc] | [hwsp] [logical state] |
|
|
|
|
* |<- our header ->|<- context image ->|
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/* The first page is used for sharing data with the GuC */
|
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 21:43:43 +07:00
|
|
|
#define LRC_GUCSHR_PN (0)
|
2017-09-13 15:56:00 +07:00
|
|
|
#define LRC_GUCSHR_SZ (1)
|
|
|
|
/* At the start of the context image is its per-process HWS page */
|
|
|
|
#define LRC_PPHWSP_PN (LRC_GUCSHR_PN + LRC_GUCSHR_SZ)
|
|
|
|
#define LRC_PPHWSP_SZ (1)
|
|
|
|
/* Finally we have the logical state for the context */
|
|
|
|
#define LRC_STATE_PN (LRC_PPHWSP_PN + LRC_PPHWSP_SZ)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Currently we include the PPHWSP in __intel_engine_context_size() so
|
|
|
|
* the size of the header is synonymous with the start of the PPHWSP.
|
|
|
|
*/
|
|
|
|
#define LRC_HEADER_PAGES LRC_PPHWSP_PN
|
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 21:43:43 +07:00
|
|
|
|
2019-01-16 04:29:48 +07:00
|
|
|
struct drm_printer;
|
|
|
|
|
drm/i915: Unify active context tracking between legacy/execlists/guc
The requests conversion introduced a nasty bug where we could generate a
new request in the middle of constructing a request if we needed to idle
the system in order to evict space for a context. The request to idle
would be executed (and waited upon) before the current one, creating a
minor havoc in the seqno accounting, as we will consider the current
request to already be completed (prior to deferred seqno assignment) but
ring->last_retired_head would have been updated and still could allow
us to overwrite the current request before execution.
We also employed two different mechanisms to track the active context
until it was switched out. The legacy method allowed for waiting upon an
active context (it could forcibly evict any vma, including context's),
but the execlists method took a step backwards by pinning the vma for
the entire active lifespan of the context (the only way to evict was to
idle the entire GPU, not individual contexts). However, to circumvent
the tricky issue of locking (i.e. we cannot take struct_mutex at the
time of i915_gem_request_submit(), where we would want to move the
previous context onto the active tracker and unpin it), we take the
execlists approach and keep the contexts pinned until retirement.
The benefit of the execlists approach, more important for execlists than
legacy, was the reduction in work in pinning the context for each
request - as the context was kept pinned until idle, it could short
circuit the pinning for all active contexts.
We introduce new engine vfuncs to pin and unpin the context
respectively. The context is pinned at the start of the request, and
only unpinned when the following request is retired (this ensures that
the context is idle and coherent in main memory before we unpin it). We
move the engine->last_context tracking into the retirement itself
(rather than during request submission) in order to allow the submission
to be reordered or unwound without undue difficultly.
And finally an ulterior motive for unifying context handling was to
prepare for mock requests.
v2: Rename to last_retired_context, split out legacy_context tracking
for MI_SET_CONTEXT.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161218153724.8439-3-chris@chris-wilson.co.uk
2016-12-18 22:37:20 +07:00
|
|
|
struct drm_i915_private;
|
2016-05-24 20:53:34 +07:00
|
|
|
struct i915_gem_context;
|
|
|
|
|
2016-09-09 20:11:53 +07:00
|
|
|
void intel_lr_context_resume(struct drm_i915_private *dev_priv);
|
2018-07-18 03:29:32 +07:00
|
|
|
void intel_execlists_set_default_submission(struct intel_engine_cs *engine);
|
|
|
|
|
2019-01-16 04:29:48 +07:00
|
|
|
void intel_execlists_show_requests(struct intel_engine_cs *engine,
|
|
|
|
struct drm_printer *m,
|
|
|
|
void (*show_request)(struct drm_printer *m,
|
|
|
|
struct i915_request *rq,
|
|
|
|
const char *prefix),
|
|
|
|
unsigned int max);
|
|
|
|
|
2019-02-05 16:50:29 +07:00
|
|
|
u32 gen8_make_rpcs(struct drm_i915_private *i915, struct intel_sseu *ctx_sseu);
|
|
|
|
|
2014-07-24 23:04:10 +07:00
|
|
|
#endif /* _INTEL_LRC_H_ */
|