2017-10-05 01:13:41 +07:00
|
|
|
/*
|
|
|
|
* Copyright © 2014-2017 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_GUC_H_
|
|
|
|
#define _INTEL_GUC_H_
|
|
|
|
|
|
|
|
#include "intel_uncore.h"
|
2017-10-16 21:47:14 +07:00
|
|
|
#include "intel_guc_fw.h"
|
2017-10-05 01:13:41 +07:00
|
|
|
#include "intel_guc_fwif.h"
|
|
|
|
#include "intel_guc_ct.h"
|
|
|
|
#include "intel_guc_log.h"
|
2017-11-24 16:53:40 +07:00
|
|
|
#include "intel_guc_reg.h"
|
2017-10-05 01:13:41 +07:00
|
|
|
#include "intel_uc_fw.h"
|
2019-03-08 20:25:17 +07:00
|
|
|
#include "i915_utils.h"
|
2017-10-05 01:13:41 +07:00
|
|
|
#include "i915_vma.h"
|
|
|
|
|
drm/i915/guc: Preemption! With GuC
Pretty similar to what we have on execlists.
We're reusing most of the GEM code, however, due to GuC quirks we need a
couple of extra bits.
Preemption is implemented as GuC action, and actions can be pretty slow.
Because of that, we're using a mutex to serialize them. Since we're
requesting preemption from the tasklet, the task of creating a workitem
and wrapping it in GuC action is delegated to a worker.
To distinguish that preemption has finished, we're using additional
piece of HWSP, and since we're not getting context switch interrupts,
we're also adding a user interrupt.
The fact that our special preempt context has completed unfortunately
doesn't mean that we're ready to submit new work. We also need to wait
for GuC to finish its own processing.
v2: Don't compile out the wait for GuC, handle workqueue flush on reset,
no need for ordered workqueue, put on a reviewer hat when looking at my own
patches (Chris)
Move struct work around in intel_guc, move user interruput outside of
conditional (Michał)
Keep ring around rather than chase though intel_context
v3: Extract WA for flushing ggtt writes to a helper (Chris)
Keep work_struct in intel_guc rather than engine (Michał)
Use ordered workqueue for inject_preempt worker to avoid GuC quirks.
v4: Drop now unused INTEL_GUC_PREEMPT_OPTION_IMMEDIATE (Daniele)
Drop stray newlines, use container_of for intel_guc in worker,
check for presence of workqueue when flushing it, rather than
enable_guc_submission modparam, reorder preempt postprocessing (Chris)
v5: Make wq NULL after destroying it
v6: Swap struct guc_preempt_work members (Michał)
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jeff McGee <jeff.mcgee@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Oscar Mateo <oscar.mateo@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20171026133558.19580-1-michal.winiarski@intel.com
2017-10-26 20:35:58 +07:00
|
|
|
struct guc_preempt_work {
|
|
|
|
struct work_struct work;
|
|
|
|
struct intel_engine_cs *engine;
|
|
|
|
};
|
|
|
|
|
2017-10-16 21:47:13 +07:00
|
|
|
/*
|
|
|
|
* Top level structure of GuC. It handles firmware loading and manages client
|
2017-11-16 20:32:40 +07:00
|
|
|
* pool and doorbells. intel_guc owns a intel_guc_client to replace the legacy
|
2017-10-16 21:47:13 +07:00
|
|
|
* ExecList submission.
|
|
|
|
*/
|
2017-10-05 01:13:41 +07:00
|
|
|
struct intel_guc {
|
|
|
|
struct intel_uc_fw fw;
|
|
|
|
struct intel_guc_log log;
|
|
|
|
struct intel_guc_ct ct;
|
|
|
|
|
|
|
|
/* Log snapshot if GuC errors during load */
|
|
|
|
struct drm_i915_gem_object *load_err_log;
|
|
|
|
|
|
|
|
/* intel_guc_recv interrupt related state */
|
2018-03-19 16:53:36 +07:00
|
|
|
spinlock_t irq_lock;
|
2017-10-05 01:13:41 +07:00
|
|
|
bool interrupts_enabled;
|
2018-03-19 16:53:36 +07:00
|
|
|
unsigned int msg_enabled_mask;
|
2017-10-05 01:13:41 +07:00
|
|
|
|
|
|
|
struct i915_vma *ads_vma;
|
|
|
|
struct i915_vma *stage_desc_pool;
|
|
|
|
void *stage_desc_pool_vaddr;
|
|
|
|
struct ida stage_ids;
|
2017-10-26 03:00:11 +07:00
|
|
|
struct i915_vma *shared_data;
|
|
|
|
void *shared_data_vaddr;
|
2017-10-05 01:13:41 +07:00
|
|
|
|
2017-11-16 20:32:40 +07:00
|
|
|
struct intel_guc_client *execbuf_client;
|
|
|
|
struct intel_guc_client *preempt_client;
|
2017-10-05 01:13:41 +07:00
|
|
|
|
drm/i915/guc: Preemption! With GuC
Pretty similar to what we have on execlists.
We're reusing most of the GEM code, however, due to GuC quirks we need a
couple of extra bits.
Preemption is implemented as GuC action, and actions can be pretty slow.
Because of that, we're using a mutex to serialize them. Since we're
requesting preemption from the tasklet, the task of creating a workitem
and wrapping it in GuC action is delegated to a worker.
To distinguish that preemption has finished, we're using additional
piece of HWSP, and since we're not getting context switch interrupts,
we're also adding a user interrupt.
The fact that our special preempt context has completed unfortunately
doesn't mean that we're ready to submit new work. We also need to wait
for GuC to finish its own processing.
v2: Don't compile out the wait for GuC, handle workqueue flush on reset,
no need for ordered workqueue, put on a reviewer hat when looking at my own
patches (Chris)
Move struct work around in intel_guc, move user interruput outside of
conditional (Michał)
Keep ring around rather than chase though intel_context
v3: Extract WA for flushing ggtt writes to a helper (Chris)
Keep work_struct in intel_guc rather than engine (Michał)
Use ordered workqueue for inject_preempt worker to avoid GuC quirks.
v4: Drop now unused INTEL_GUC_PREEMPT_OPTION_IMMEDIATE (Daniele)
Drop stray newlines, use container_of for intel_guc in worker,
check for presence of workqueue when flushing it, rather than
enable_guc_submission modparam, reorder preempt postprocessing (Chris)
v5: Make wq NULL after destroying it
v6: Swap struct guc_preempt_work members (Michał)
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jeff McGee <jeff.mcgee@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Oscar Mateo <oscar.mateo@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20171026133558.19580-1-michal.winiarski@intel.com
2017-10-26 20:35:58 +07:00
|
|
|
struct guc_preempt_work preempt_work[I915_NUM_ENGINES];
|
|
|
|
struct workqueue_struct *preempt_wq;
|
|
|
|
|
2017-10-05 01:13:41 +07:00
|
|
|
DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
|
2017-10-06 15:49:40 +07:00
|
|
|
/* Cyclic counter mod pagesize */
|
|
|
|
u32 db_cacheline;
|
2017-10-05 01:13:41 +07:00
|
|
|
|
|
|
|
/* GuC's FW specific registers used in MMIO send */
|
|
|
|
struct {
|
|
|
|
u32 base;
|
|
|
|
unsigned int count;
|
|
|
|
enum forcewake_domains fw_domains;
|
|
|
|
} send_regs;
|
|
|
|
|
|
|
|
/* To serialize the intel_guc_send actions */
|
|
|
|
struct mutex send_mutex;
|
|
|
|
|
|
|
|
/* GuC's FW specific send function */
|
2018-03-27 02:48:20 +07:00
|
|
|
int (*send)(struct intel_guc *guc, const u32 *data, u32 len,
|
|
|
|
u32 *response_buf, u32 response_buf_size);
|
2017-10-05 01:13:41 +07:00
|
|
|
|
2018-03-27 02:48:22 +07:00
|
|
|
/* GuC's FW specific event handler function */
|
|
|
|
void (*handler)(struct intel_guc *guc);
|
|
|
|
|
2017-10-05 01:13:41 +07:00
|
|
|
/* GuC's FW specific notify function */
|
|
|
|
void (*notify)(struct intel_guc *guc);
|
|
|
|
};
|
|
|
|
|
2018-10-03 04:54:28 +07:00
|
|
|
static inline bool intel_guc_is_alive(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
return intel_uc_fw_is_loaded(&guc->fw);
|
|
|
|
}
|
|
|
|
|
2017-10-05 01:13:41 +07:00
|
|
|
static
|
|
|
|
inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
|
|
|
|
{
|
2018-03-27 02:48:20 +07:00
|
|
|
return guc->send(guc, action, len, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
intel_guc_send_and_receive(struct intel_guc *guc, const u32 *action, u32 len,
|
|
|
|
u32 *response_buf, u32 response_buf_size)
|
|
|
|
{
|
|
|
|
return guc->send(guc, action, len, response_buf, response_buf_size);
|
2017-10-05 01:13:41 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void intel_guc_notify(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->notify(guc);
|
|
|
|
}
|
|
|
|
|
2018-03-27 02:48:22 +07:00
|
|
|
static inline void intel_guc_to_host_event_handler(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->handler(guc);
|
|
|
|
}
|
|
|
|
|
2018-03-14 07:32:49 +07:00
|
|
|
/* GuC addresses above GUC_GGTT_TOP also don't map through the GTT */
|
|
|
|
#define GUC_GGTT_TOP 0xFEE00000
|
|
|
|
|
|
|
|
/**
|
|
|
|
* intel_guc_ggtt_offset() - Get and validate the GGTT offset of @vma
|
|
|
|
* @guc: intel_guc structure.
|
|
|
|
* @vma: i915 graphics virtual memory area.
|
|
|
|
*
|
2018-03-14 07:32:50 +07:00
|
|
|
* GuC does not allow any gfx GGTT address that falls into range
|
2018-07-27 21:11:45 +07:00
|
|
|
* [0, ggtt.pin_bias), which is reserved for Boot ROM, SRAM and WOPCM.
|
|
|
|
* Currently, in order to exclude [0, ggtt.pin_bias) address space from
|
2018-03-14 07:32:50 +07:00
|
|
|
* GGTT, all gfx objects used by GuC are allocated with intel_guc_allocate_vma()
|
2018-07-27 21:11:45 +07:00
|
|
|
* and pinned with PIN_OFFSET_BIAS along with the value of ggtt.pin_bias.
|
2018-03-14 07:32:49 +07:00
|
|
|
*
|
2018-03-14 07:32:50 +07:00
|
|
|
* Return: GGTT offset of the @vma.
|
2017-10-16 21:47:13 +07:00
|
|
|
*/
|
2018-03-14 07:32:49 +07:00
|
|
|
static inline u32 intel_guc_ggtt_offset(struct intel_guc *guc,
|
|
|
|
struct i915_vma *vma)
|
2017-10-05 01:13:41 +07:00
|
|
|
{
|
|
|
|
u32 offset = i915_ggtt_offset(vma);
|
|
|
|
|
2018-07-27 21:11:45 +07:00
|
|
|
GEM_BUG_ON(offset < i915_ggtt_pin_bias(vma));
|
2017-10-05 01:13:41 +07:00
|
|
|
GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void intel_guc_init_early(struct intel_guc *guc);
|
|
|
|
void intel_guc_init_send_regs(struct intel_guc *guc);
|
2017-10-16 21:47:11 +07:00
|
|
|
void intel_guc_init_params(struct intel_guc *guc);
|
2018-06-28 21:15:20 +07:00
|
|
|
int intel_guc_init_misc(struct intel_guc *guc);
|
2017-12-14 05:13:46 +07:00
|
|
|
int intel_guc_init(struct intel_guc *guc);
|
|
|
|
void intel_guc_fini(struct intel_guc *guc);
|
2018-06-28 21:15:20 +07:00
|
|
|
void intel_guc_fini_misc(struct intel_guc *guc);
|
2018-03-27 02:48:20 +07:00
|
|
|
int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len,
|
|
|
|
u32 *response_buf, u32 response_buf_size);
|
|
|
|
int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len,
|
|
|
|
u32 *response_buf, u32 response_buf_size);
|
2018-03-08 22:46:55 +07:00
|
|
|
void intel_guc_to_host_event_handler(struct intel_guc *guc);
|
2018-03-27 02:48:22 +07:00
|
|
|
void intel_guc_to_host_event_handler_nop(struct intel_guc *guc);
|
|
|
|
void intel_guc_to_host_event_handler_mmio(struct intel_guc *guc);
|
2019-03-21 19:00:04 +07:00
|
|
|
int intel_guc_to_host_process_recv_msg(struct intel_guc *guc,
|
|
|
|
const u32 *payload, u32 len);
|
2017-10-05 01:13:41 +07:00
|
|
|
int intel_guc_sample_forcewake(struct intel_guc *guc);
|
|
|
|
int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
|
2018-03-02 18:15:49 +07:00
|
|
|
int intel_guc_suspend(struct intel_guc *guc);
|
|
|
|
int intel_guc_resume(struct intel_guc *guc);
|
2017-10-05 01:13:41 +07:00
|
|
|
struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
|
2018-07-27 21:11:45 +07:00
|
|
|
u32 intel_guc_reserved_gtt_size(struct intel_guc *guc);
|
2019-04-20 06:00:12 +07:00
|
|
|
int intel_guc_reserve_ggtt_top(struct intel_guc *guc);
|
|
|
|
void intel_guc_release_ggtt_top(struct intel_guc *guc);
|
2017-10-05 01:13:41 +07:00
|
|
|
|
2018-03-12 20:03:07 +07:00
|
|
|
static inline int intel_guc_sanitize(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
intel_uc_fw_sanitize(&guc->fw);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-21 01:14:19 +07:00
|
|
|
static inline void intel_guc_enable_msg(struct intel_guc *guc, u32 mask)
|
|
|
|
{
|
|
|
|
spin_lock_irq(&guc->irq_lock);
|
|
|
|
guc->msg_enabled_mask |= mask;
|
|
|
|
spin_unlock_irq(&guc->irq_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void intel_guc_disable_msg(struct intel_guc *guc, u32 mask)
|
|
|
|
{
|
|
|
|
spin_lock_irq(&guc->irq_lock);
|
|
|
|
guc->msg_enabled_mask &= ~mask;
|
|
|
|
spin_unlock_irq(&guc->irq_lock);
|
|
|
|
}
|
|
|
|
|
2019-01-16 22:33:04 +07:00
|
|
|
int intel_guc_reset_engine(struct intel_guc *guc,
|
|
|
|
struct intel_engine_cs *engine);
|
|
|
|
|
2017-10-05 01:13:41 +07:00
|
|
|
#endif
|