Commit 22916bad authored by Matthew Brost's avatar Matthew Brost Committed by Matt Roper

drm/i915: Move submission tasklet to i915_sched_engine

The submission tasklet operates on i915_sched_engine, thus it is the
correct place for it.

v3:
 (Jason Ekstrand)
  Change sched_engine->engine to a void* private data pointer
  Add kernel doc
v4:
 (Daniele)
  Update private_data comment
  Set queue_priority_hint in kick_execlists
v5:
 (CI)
  Rebase and fix build error
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210618010638.98941-9-matthew.brost@intel.com
parent d2a31d02
...@@ -125,20 +125,6 @@ execlists_active(const struct intel_engine_execlists *execlists) ...@@ -125,20 +125,6 @@ execlists_active(const struct intel_engine_execlists *execlists)
return active; return active;
} }
static inline void
execlists_active_lock_bh(struct intel_engine_execlists *execlists)
{
local_bh_disable(); /* prevent local softirq and lock recursion */
tasklet_lock(&execlists->tasklet);
}
static inline void
execlists_active_unlock_bh(struct intel_engine_execlists *execlists)
{
tasklet_unlock(&execlists->tasklet);
local_bh_enable(); /* restore softirq, and kick ksoftirqd! */
}
struct i915_request * struct i915_request *
execlists_unwind_incomplete_requests(struct intel_engine_execlists *execlists); execlists_unwind_incomplete_requests(struct intel_engine_execlists *execlists);
......
...@@ -713,6 +713,7 @@ static int engine_setup_common(struct intel_engine_cs *engine) ...@@ -713,6 +713,7 @@ static int engine_setup_common(struct intel_engine_cs *engine)
err = -ENOMEM; err = -ENOMEM;
goto err_sched_engine; goto err_sched_engine;
} }
engine->sched_engine->private_data = engine;
err = intel_engine_init_cmd_parser(engine); err = intel_engine_init_cmd_parser(engine);
if (err) if (err)
...@@ -944,7 +945,6 @@ int intel_engines_init(struct intel_gt *gt) ...@@ -944,7 +945,6 @@ int intel_engines_init(struct intel_gt *gt)
void intel_engine_cleanup_common(struct intel_engine_cs *engine) void intel_engine_cleanup_common(struct intel_engine_cs *engine)
{ {
GEM_BUG_ON(!list_empty(&engine->sched_engine->requests)); GEM_BUG_ON(!list_empty(&engine->sched_engine->requests));
tasklet_kill(&engine->execlists.tasklet); /* flush the callback */
i915_sched_engine_put(engine->sched_engine); i915_sched_engine_put(engine->sched_engine);
intel_breadcrumbs_free(engine->breadcrumbs); intel_breadcrumbs_free(engine->breadcrumbs);
...@@ -1193,7 +1193,7 @@ static bool ring_is_idle(struct intel_engine_cs *engine) ...@@ -1193,7 +1193,7 @@ static bool ring_is_idle(struct intel_engine_cs *engine)
void __intel_engine_flush_submission(struct intel_engine_cs *engine, bool sync) void __intel_engine_flush_submission(struct intel_engine_cs *engine, bool sync)
{ {
struct tasklet_struct *t = &engine->execlists.tasklet; struct tasklet_struct *t = &engine->sched_engine->tasklet;
if (!t->callback) if (!t->callback)
return; return;
...@@ -1454,8 +1454,8 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine, ...@@ -1454,8 +1454,8 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine,
drm_printf(m, "\tExeclist tasklet queued? %s (%s), preempt? %s, timeslice? %s\n", drm_printf(m, "\tExeclist tasklet queued? %s (%s), preempt? %s, timeslice? %s\n",
yesno(test_bit(TASKLET_STATE_SCHED, yesno(test_bit(TASKLET_STATE_SCHED,
&engine->execlists.tasklet.state)), &engine->sched_engine->tasklet.state)),
enableddisabled(!atomic_read(&engine->execlists.tasklet.count)), enableddisabled(!atomic_read(&engine->sched_engine->tasklet.count)),
repr_timer(&engine->execlists.preempt), repr_timer(&engine->execlists.preempt),
repr_timer(&engine->execlists.timer)); repr_timer(&engine->execlists.timer));
...@@ -1479,7 +1479,7 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine, ...@@ -1479,7 +1479,7 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine,
idx, hws[idx * 2], hws[idx * 2 + 1]); idx, hws[idx * 2], hws[idx * 2 + 1]);
} }
execlists_active_lock_bh(execlists); i915_sched_engine_active_lock_bh(engine->sched_engine);
rcu_read_lock(); rcu_read_lock();
for (port = execlists->active; (rq = *port); port++) { for (port = execlists->active; (rq = *port); port++) {
char hdr[160]; char hdr[160];
...@@ -1510,7 +1510,7 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine, ...@@ -1510,7 +1510,7 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine,
i915_request_show(m, rq, hdr, 0); i915_request_show(m, rq, hdr, 0);
} }
rcu_read_unlock(); rcu_read_unlock();
execlists_active_unlock_bh(execlists); i915_sched_engine_active_unlock_bh(engine->sched_engine);
} else if (GRAPHICS_VER(dev_priv) > 6) { } else if (GRAPHICS_VER(dev_priv) > 6) {
drm_printf(m, "\tPP_DIR_BASE: 0x%08x\n", drm_printf(m, "\tPP_DIR_BASE: 0x%08x\n",
ENGINE_READ(engine, RING_PP_DIR_BASE)); ENGINE_READ(engine, RING_PP_DIR_BASE));
......
...@@ -138,11 +138,6 @@ struct st_preempt_hang { ...@@ -138,11 +138,6 @@ struct st_preempt_hang {
* driver and the hardware state for execlist mode of submission. * driver and the hardware state for execlist mode of submission.
*/ */
struct intel_engine_execlists { struct intel_engine_execlists {
/**
* @tasklet: softirq tasklet for bottom handler
*/
struct tasklet_struct tasklet;
/** /**
* @timer: kick the current context if its timeslice expires * @timer: kick the current context if its timeslice expires
*/ */
......
...@@ -349,6 +349,7 @@ int mock_engine_init(struct intel_engine_cs *engine) ...@@ -349,6 +349,7 @@ int mock_engine_init(struct intel_engine_cs *engine)
engine->sched_engine = i915_sched_engine_create(ENGINE_MOCK); engine->sched_engine = i915_sched_engine_create(ENGINE_MOCK);
if (!engine->sched_engine) if (!engine->sched_engine)
return -ENOMEM; return -ENOMEM;
engine->sched_engine->private_data = engine;
intel_engine_init_execlists(engine); intel_engine_init_execlists(engine);
intel_engine_init__pm(engine); intel_engine_init__pm(engine);
......
...@@ -43,7 +43,7 @@ static int wait_for_submit(struct intel_engine_cs *engine, ...@@ -43,7 +43,7 @@ static int wait_for_submit(struct intel_engine_cs *engine,
unsigned long timeout) unsigned long timeout)
{ {
/* Ignore our own attempts to suppress excess tasklets */ /* Ignore our own attempts to suppress excess tasklets */
tasklet_hi_schedule(&engine->execlists.tasklet); tasklet_hi_schedule(&engine->sched_engine->tasklet);
timeout += jiffies; timeout += jiffies;
do { do {
...@@ -553,13 +553,13 @@ static int live_pin_rewind(void *arg) ...@@ -553,13 +553,13 @@ static int live_pin_rewind(void *arg)
static int engine_lock_reset_tasklet(struct intel_engine_cs *engine) static int engine_lock_reset_tasklet(struct intel_engine_cs *engine)
{ {
tasklet_disable(&engine->execlists.tasklet); tasklet_disable(&engine->sched_engine->tasklet);
local_bh_disable(); local_bh_disable();
if (test_and_set_bit(I915_RESET_ENGINE + engine->id, if (test_and_set_bit(I915_RESET_ENGINE + engine->id,
&engine->gt->reset.flags)) { &engine->gt->reset.flags)) {
local_bh_enable(); local_bh_enable();
tasklet_enable(&engine->execlists.tasklet); tasklet_enable(&engine->sched_engine->tasklet);
intel_gt_set_wedged(engine->gt); intel_gt_set_wedged(engine->gt);
return -EBUSY; return -EBUSY;
...@@ -574,7 +574,7 @@ static void engine_unlock_reset_tasklet(struct intel_engine_cs *engine) ...@@ -574,7 +574,7 @@ static void engine_unlock_reset_tasklet(struct intel_engine_cs *engine)
&engine->gt->reset.flags); &engine->gt->reset.flags);
local_bh_enable(); local_bh_enable();
tasklet_enable(&engine->execlists.tasklet); tasklet_enable(&engine->sched_engine->tasklet);
} }
static int live_hold_reset(void *arg) static int live_hold_reset(void *arg)
...@@ -628,7 +628,7 @@ static int live_hold_reset(void *arg) ...@@ -628,7 +628,7 @@ static int live_hold_reset(void *arg)
if (err) if (err)
goto out; goto out;
engine->execlists.tasklet.callback(&engine->execlists.tasklet); engine->sched_engine->tasklet.callback(&engine->sched_engine->tasklet);
GEM_BUG_ON(execlists_active(&engine->execlists) != rq); GEM_BUG_ON(execlists_active(&engine->execlists) != rq);
i915_request_get(rq); i915_request_get(rq);
...@@ -1200,7 +1200,7 @@ static int live_timeslice_rewind(void *arg) ...@@ -1200,7 +1200,7 @@ static int live_timeslice_rewind(void *arg)
while (i915_request_is_active(rq[A2])) { /* semaphore yield! */ while (i915_request_is_active(rq[A2])) { /* semaphore yield! */
/* Wait for the timeslice to kick in */ /* Wait for the timeslice to kick in */
del_timer(&engine->execlists.timer); del_timer(&engine->execlists.timer);
tasklet_hi_schedule(&engine->execlists.tasklet); tasklet_hi_schedule(&engine->sched_engine->tasklet);
intel_engine_flush_submission(engine); intel_engine_flush_submission(engine);
} }
/* -> ELSP[] = { { A:rq1 }, { B:rq1 } } */ /* -> ELSP[] = { { A:rq1 }, { B:rq1 } } */
...@@ -4606,7 +4606,7 @@ static int reset_virtual_engine(struct intel_gt *gt, ...@@ -4606,7 +4606,7 @@ static int reset_virtual_engine(struct intel_gt *gt,
if (err) if (err)
goto out_heartbeat; goto out_heartbeat;
engine->execlists.tasklet.callback(&engine->execlists.tasklet); engine->sched_engine->tasklet.callback(&engine->sched_engine->tasklet);
GEM_BUG_ON(execlists_active(&engine->execlists) != rq); GEM_BUG_ON(execlists_active(&engine->execlists) != rq);
/* Fake a preemption event; failed of course */ /* Fake a preemption event; failed of course */
......
...@@ -1702,7 +1702,7 @@ static int __igt_atomic_reset_engine(struct intel_engine_cs *engine, ...@@ -1702,7 +1702,7 @@ static int __igt_atomic_reset_engine(struct intel_engine_cs *engine,
const struct igt_atomic_section *p, const struct igt_atomic_section *p,
const char *mode) const char *mode)
{ {
struct tasklet_struct * const t = &engine->execlists.tasklet; struct tasklet_struct * const t = &engine->sched_engine->tasklet;
int err; int err;
GEM_TRACE("i915_reset_engine(%s:%s) under %s\n", GEM_TRACE("i915_reset_engine(%s:%s) under %s\n",
......
...@@ -49,7 +49,7 @@ static int wait_for_submit(struct intel_engine_cs *engine, ...@@ -49,7 +49,7 @@ static int wait_for_submit(struct intel_engine_cs *engine,
unsigned long timeout) unsigned long timeout)
{ {
/* Ignore our own attempts to suppress excess tasklets */ /* Ignore our own attempts to suppress excess tasklets */
tasklet_hi_schedule(&engine->execlists.tasklet); tasklet_hi_schedule(&engine->sched_engine->tasklet);
timeout += jiffies; timeout += jiffies;
do { do {
...@@ -1613,12 +1613,12 @@ static void garbage_reset(struct intel_engine_cs *engine, ...@@ -1613,12 +1613,12 @@ static void garbage_reset(struct intel_engine_cs *engine,
local_bh_disable(); local_bh_disable();
if (!test_and_set_bit(bit, lock)) { if (!test_and_set_bit(bit, lock)) {
tasklet_disable(&engine->execlists.tasklet); tasklet_disable(&engine->sched_engine->tasklet);
if (!rq->fence.error) if (!rq->fence.error)
__intel_engine_reset_bh(engine, NULL); __intel_engine_reset_bh(engine, NULL);
tasklet_enable(&engine->execlists.tasklet); tasklet_enable(&engine->sched_engine->tasklet);
clear_and_wake_up_bit(bit, lock); clear_and_wake_up_bit(bit, lock);
} }
local_bh_enable(); local_bh_enable();
......
...@@ -321,7 +321,7 @@ static int igt_atomic_engine_reset(void *arg) ...@@ -321,7 +321,7 @@ static int igt_atomic_engine_reset(void *arg)
goto out_unlock; goto out_unlock;
for_each_engine(engine, gt, id) { for_each_engine(engine, gt, id) {
struct tasklet_struct *t = &engine->execlists.tasklet; struct tasklet_struct *t = &engine->sched_engine->tasklet;
if (t->func) if (t->func)
tasklet_disable(t); tasklet_disable(t);
......
...@@ -241,8 +241,9 @@ static void __guc_dequeue(struct intel_engine_cs *engine) ...@@ -241,8 +241,9 @@ static void __guc_dequeue(struct intel_engine_cs *engine)
static void guc_submission_tasklet(struct tasklet_struct *t) static void guc_submission_tasklet(struct tasklet_struct *t)
{ {
struct intel_engine_cs * const engine = struct i915_sched_engine *sched_engine =
from_tasklet(engine, t, execlists.tasklet); from_tasklet(sched_engine, t, tasklet);
struct intel_engine_cs * const engine = sched_engine->private_data;
struct intel_engine_execlists * const execlists = &engine->execlists; struct intel_engine_execlists * const execlists = &engine->execlists;
struct i915_request **port, *rq; struct i915_request **port, *rq;
unsigned long flags; unsigned long flags;
...@@ -272,14 +273,12 @@ static void cs_irq_handler(struct intel_engine_cs *engine, u16 iir) ...@@ -272,14 +273,12 @@ static void cs_irq_handler(struct intel_engine_cs *engine, u16 iir)
{ {
if (iir & GT_RENDER_USER_INTERRUPT) { if (iir & GT_RENDER_USER_INTERRUPT) {
intel_engine_signal_breadcrumbs(engine); intel_engine_signal_breadcrumbs(engine);
tasklet_hi_schedule(&engine->execlists.tasklet); tasklet_hi_schedule(&engine->sched_engine->tasklet);
} }
} }
static void guc_reset_prepare(struct intel_engine_cs *engine) static void guc_reset_prepare(struct intel_engine_cs *engine)
{ {
struct intel_engine_execlists * const execlists = &engine->execlists;
ENGINE_TRACE(engine, "\n"); ENGINE_TRACE(engine, "\n");
/* /*
...@@ -291,7 +290,7 @@ static void guc_reset_prepare(struct intel_engine_cs *engine) ...@@ -291,7 +290,7 @@ static void guc_reset_prepare(struct intel_engine_cs *engine)
* Turning off the execlists->tasklet until the reset is over * Turning off the execlists->tasklet until the reset is over
* prevents the race. * prevents the race.
*/ */
__tasklet_disable_sync_once(&execlists->tasklet); __tasklet_disable_sync_once(&engine->sched_engine->tasklet);
} }
static void guc_reset_state(struct intel_context *ce, static void guc_reset_state(struct intel_context *ce,
...@@ -395,14 +394,12 @@ static void guc_reset_cancel(struct intel_engine_cs *engine) ...@@ -395,14 +394,12 @@ static void guc_reset_cancel(struct intel_engine_cs *engine)
static void guc_reset_finish(struct intel_engine_cs *engine) static void guc_reset_finish(struct intel_engine_cs *engine)
{ {
struct intel_engine_execlists * const execlists = &engine->execlists; if (__tasklet_enable(&engine->sched_engine->tasklet))
if (__tasklet_enable(&execlists->tasklet))
/* And kick in case we missed a new request submission. */ /* And kick in case we missed a new request submission. */
tasklet_hi_schedule(&execlists->tasklet); tasklet_hi_schedule(&engine->sched_engine->tasklet);
ENGINE_TRACE(engine, "depth->%d\n", ENGINE_TRACE(engine, "depth->%d\n",
atomic_read(&execlists->tasklet.count)); atomic_read(&engine->sched_engine->tasklet.count));
} }
/* /*
...@@ -520,7 +517,7 @@ static void guc_submit_request(struct i915_request *rq) ...@@ -520,7 +517,7 @@ static void guc_submit_request(struct i915_request *rq)
GEM_BUG_ON(i915_sched_engine_is_empty(engine->sched_engine)); GEM_BUG_ON(i915_sched_engine_is_empty(engine->sched_engine));
GEM_BUG_ON(list_empty(&rq->sched.link)); GEM_BUG_ON(list_empty(&rq->sched.link));
tasklet_hi_schedule(&engine->execlists.tasklet); tasklet_hi_schedule(&engine->sched_engine->tasklet);
spin_unlock_irqrestore(&engine->sched_engine->lock, flags); spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
} }
...@@ -600,7 +597,7 @@ static void guc_release(struct intel_engine_cs *engine) ...@@ -600,7 +597,7 @@ static void guc_release(struct intel_engine_cs *engine)
{ {
engine->sanitize = NULL; /* no longer in control, nothing to sanitize */ engine->sanitize = NULL; /* no longer in control, nothing to sanitize */
tasklet_kill(&engine->execlists.tasklet); tasklet_kill(&engine->sched_engine->tasklet);
intel_engine_cleanup_common(engine); intel_engine_cleanup_common(engine);
lrc_fini_wa_ctx(engine); lrc_fini_wa_ctx(engine);
...@@ -679,7 +676,7 @@ int intel_guc_submission_setup(struct intel_engine_cs *engine) ...@@ -679,7 +676,7 @@ int intel_guc_submission_setup(struct intel_engine_cs *engine)
*/ */
GEM_BUG_ON(GRAPHICS_VER(i915) < 11); GEM_BUG_ON(GRAPHICS_VER(i915) < 11);
tasklet_setup(&engine->execlists.tasklet, guc_submission_tasklet); tasklet_setup(&engine->sched_engine->tasklet, guc_submission_tasklet);
guc_default_vfuncs(engine); guc_default_vfuncs(engine);
guc_default_irqs(engine); guc_default_irqs(engine);
......
...@@ -436,6 +436,7 @@ void i915_sched_engine_free(struct kref *kref) ...@@ -436,6 +436,7 @@ void i915_sched_engine_free(struct kref *kref)
struct i915_sched_engine *sched_engine = struct i915_sched_engine *sched_engine =
container_of(kref, typeof(*sched_engine), ref); container_of(kref, typeof(*sched_engine), ref);
tasklet_kill(&sched_engine->tasklet); /* flush the callback */
kfree(sched_engine); kfree(sched_engine);
} }
......
...@@ -79,6 +79,20 @@ i915_sched_engine_reset_on_empty(struct i915_sched_engine *sched_engine) ...@@ -79,6 +79,20 @@ i915_sched_engine_reset_on_empty(struct i915_sched_engine *sched_engine)
sched_engine->no_priolist = false; sched_engine->no_priolist = false;
} }
static inline void
i915_sched_engine_active_lock_bh(struct i915_sched_engine *sched_engine)
{
local_bh_disable(); /* prevent local softirq and lock recursion */
tasklet_lock(&sched_engine->tasklet);
}
static inline void
i915_sched_engine_active_unlock_bh(struct i915_sched_engine *sched_engine)
{
tasklet_unlock(&sched_engine->tasklet);
local_bh_enable(); /* restore softirq, and kick ksoftirqd! */
}
void i915_request_show_with_schedule(struct drm_printer *m, void i915_request_show_with_schedule(struct drm_printer *m,
const struct i915_request *rq, const struct i915_request *rq,
const char *prefix, const char *prefix,
......
...@@ -124,6 +124,11 @@ struct i915_sched_engine { ...@@ -124,6 +124,11 @@ struct i915_sched_engine {
*/ */
struct list_head hold; struct list_head hold;
/**
* @tasklet: softirq tasklet for submission
*/
struct tasklet_struct tasklet;
/** /**
* @default_priolist: priority list for I915_PRIORITY_NORMAL * @default_priolist: priority list for I915_PRIORITY_NORMAL
*/ */
...@@ -153,6 +158,11 @@ struct i915_sched_engine { ...@@ -153,6 +158,11 @@ struct i915_sched_engine {
*/ */
bool no_priolist; bool no_priolist;
/**
* @private_data: private data of the submission backend
*/
void *private_data;
/** /**
* @kick_backend: kick backend after a request's priority has changed * @kick_backend: kick backend after a request's priority has changed
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment