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-05-28 16:29:49 +07:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
struct drm_printer;
|
|
|
|
|
|
|
|
struct drm_i915_private;
|
|
|
|
struct i915_gem_context;
|
|
|
|
struct i915_request;
|
|
|
|
struct intel_context;
|
|
|
|
struct intel_engine_cs;
|
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-10-26 02:37:46 +07:00
|
|
|
#define GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE (1 << 8)
|
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
|
|
|
|
2019-10-04 20:40:08 +07:00
|
|
|
#define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */
|
|
|
|
#define MAX_GUC_CONTEXT_HW_ID (1 << 20) /* exclusive */
|
|
|
|
#define GEN11_MAX_CONTEXT_HW_ID (1<<11) /* exclusive */
|
|
|
|
/* in Gen12 ID 0x7FF is reserved to indicate idle */
|
|
|
|
#define GEN12_MAX_CONTEXT_HW_ID (GEN11_MAX_CONTEXT_HW_ID - 1)
|
|
|
|
|
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 */
|
2017-09-13 15:56:00 +07:00
|
|
|
/* At the start of the context image is its per-process HWS page */
|
2019-10-31 08:30:39 +07:00
|
|
|
#define LRC_PPHWSP_PN (0)
|
2017-09-13 15:56:00 +07:00
|
|
|
#define LRC_PPHWSP_SZ (1)
|
2019-10-31 08:30:39 +07:00
|
|
|
/* After the PPHWSP we have the logical state for the context */
|
2017-09-13 15:56:00 +07:00
|
|
|
#define LRC_STATE_PN (LRC_PPHWSP_PN + LRC_PPHWSP_SZ)
|
|
|
|
|
2019-09-26 20:31:41 +07:00
|
|
|
/* Space within PPHWSP reserved to be used as scratch */
|
|
|
|
#define LRC_PPHWSP_SCRATCH 0x34
|
|
|
|
#define LRC_PPHWSP_SCRATCH_ADDR (LRC_PPHWSP_SCRATCH * sizeof(u32))
|
|
|
|
|
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);
|
|
|
|
|
2019-08-27 20:59:35 +07:00
|
|
|
struct intel_engine_cs *
|
|
|
|
intel_virtual_engine_get_sibling(struct intel_engine_cs *engine,
|
|
|
|
unsigned int sibling);
|
|
|
|
|
2019-10-28 23:45:20 +07:00
|
|
|
bool
|
|
|
|
intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine);
|
|
|
|
|
2014-07-24 23:04:10 +07:00
|
|
|
#endif /* _INTEL_LRC_H_ */
|