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_
|
|
|
|
|
2019-04-25 00:48:39 +07:00
|
|
|
#include "intel_engine.h"
|
2016-04-13 23:35:01 +07:00
|
|
|
|
2014-08-07 19:23:20 +07:00
|
|
|
/* Execlists regs */
|
2019-03-26 04:49:40 +07:00
|
|
|
#define RING_ELSP(base) _MMIO((base) + 0x230)
|
|
|
|
#define RING_EXECLIST_STATUS_LO(base) _MMIO((base) + 0x234)
|
|
|
|
#define RING_EXECLIST_STATUS_HI(base) _MMIO((base) + 0x234 + 4)
|
|
|
|
#define RING_CONTEXT_CONTROL(base) _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)
|
2019-03-26 04:49:40 +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)
|
2019-03-26 04:49:40 +07:00
|
|
|
#define RING_CONTEXT_STATUS_PTR(base) _MMIO((base) + 0x3a0)
|
|
|
|
#define RING_EXECLIST_SQ_CONTENTS(base) _MMIO((base) + 0x510)
|
|
|
|
#define RING_EXECLIST_CONTROL(base) _MMIO((base) + 0x550)
|
2019-04-06 03:46:56 +07:00
|
|
|
|
2018-03-02 23:14:59 +07:00
|
|
|
#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)
|
2019-04-06 03:46:56 +07:00
|
|
|
|
|
|
|
#define GEN11_CSB_ENTRIES 12
|
|
|
|
#define GEN11_CSB_PTR_MASK 0xf
|
|
|
|
#define GEN11_CSB_READ_PTR_MASK (GEN11_CSB_PTR_MASK << 8)
|
|
|
|
#define GEN11_CSB_WRITE_PTR_MASK (GEN11_CSB_PTR_MASK << 0)
|
2016-01-06 01:30:05 +07:00
|
|
|
|
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);
|
2019-04-26 23:33:33 +07:00
|
|
|
|
|
|
|
int intel_execlists_submission_setup(struct intel_engine_cs *engine);
|
|
|
|
int intel_execlists_submission_init(struct intel_engine_cs *engine);
|
2016-07-13 22:03:40 +07:00
|
|
|
|
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
|
|
|
|
2018-07-18 03:29:32 +07:00
|
|
|
void intel_execlists_set_default_submission(struct intel_engine_cs *engine);
|
|
|
|
|
2019-04-11 20:05:14 +07:00
|
|
|
void intel_lr_context_reset(struct intel_engine_cs *engine,
|
|
|
|
struct intel_context *ce,
|
|
|
|
u32 head,
|
|
|
|
bool scrub);
|
|
|
|
|
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);
|
|
|
|
|
drm/i915: Load balancing across a virtual engine
Having allowed the user to define a set of engines that they will want
to only use, we go one step further and allow them to bind those engines
into a single virtual instance. Submitting a batch to the virtual engine
will then forward it to any one of the set in a manner as best to
distribute load. The virtual engine has a single timeline across all
engines (it operates as a single queue), so it is not able to concurrently
run batches across multiple engines by itself; that is left up to the user
to submit multiple concurrent batches to multiple queues. Multiple users
will be load balanced across the system.
The mechanism used for load balancing in this patch is a late greedy
balancer. When a request is ready for execution, it is added to each
engine's queue, and when an engine is ready for its next request it
claims it from the virtual engine. The first engine to do so, wins, i.e.
the request is executed at the earliest opportunity (idle moment) in the
system.
As not all HW is created equal, the user is still able to skip the
virtual engine and execute the batch on a specific engine, all within the
same queue. It will then be executed in order on the correct engine,
with execution on other virtual engines being moved away due to the load
detection.
A couple of areas for potential improvement left!
- The virtual engine always take priority over equal-priority tasks.
Mostly broken up by applying FQ_CODEL rules for prioritising new clients,
and hopefully the virtual and real engines are not then congested (i.e.
all work is via virtual engines, or all work is to the real engine).
- We require the breadcrumb irq around every virtual engine request. For
normal engines, we eliminate the need for the slow round trip via
interrupt by using the submit fence and queueing in order. For virtual
engines, we have to allow any job to transfer to a new ring, and cannot
coalesce the submissions, so require the completion fence instead,
forcing the persistent use of interrupts.
- We only drip feed single requests through each virtual engine and onto
the physical engines, even if there was enough work to fill all ELSP,
leaving small stalls with an idle CS event at the end of every request.
Could we be greedy and fill both slots? Being lazy is virtuous for load
distribution on less-than-full workloads though.
Other areas of improvement are more general, such as reducing lock
contention, reducing dispatch overhead, looking at direct submission
rather than bouncing around tasklets etc.
sseu: Lift the restriction to allow sseu to be reconfigured on virtual
engines composed of RENDER_CLASS (rcs).
v2: macroize check_user_mbz()
v3: Cancel virtual engines on wedging
v4: Commence commenting
v5: Replace 64b sibling_mask with a list of class:instance
v6: Drop the one-element array in the uabi
v7: Assert it is an virtual engine in to_virtual_engine()
v8: Skip over holes in [class][inst] so we can selftest with (vcs0, vcs2)
Link: https://github.com/intel/media-driver/pull/283
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190521211134.16117-6-chris@chris-wilson.co.uk
2019-05-22 04:11:30 +07:00
|
|
|
struct intel_context *
|
|
|
|
intel_execlists_create_virtual(struct i915_gem_context *ctx,
|
|
|
|
struct intel_engine_cs **siblings,
|
|
|
|
unsigned int count);
|
|
|
|
|
|
|
|
struct intel_context *
|
|
|
|
intel_execlists_clone_virtual(struct i915_gem_context *ctx,
|
|
|
|
struct intel_engine_cs *src);
|
|
|
|
|
2019-05-22 04:11:33 +07:00
|
|
|
int intel_virtual_engine_attach_bond(struct intel_engine_cs *engine,
|
|
|
|
const struct intel_engine_cs *master,
|
|
|
|
const struct intel_engine_cs *sibling);
|
|
|
|
|
2014-07-24 23:04:10 +07:00
|
|
|
#endif /* _INTEL_LRC_H_ */
|