2017-10-05 02:13:41 +08: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 22:47:14 +08:00
|
|
|
#include "intel_guc_fw.h"
|
2017-10-05 02:13:41 +08:00
|
|
|
#include "intel_guc_fwif.h"
|
|
|
|
#include "intel_guc_ct.h"
|
|
|
|
#include "intel_guc_log.h"
|
2017-11-24 17:53:40 +08:00
|
|
|
#include "intel_guc_reg.h"
|
2017-10-05 02:13:41 +08:00
|
|
|
#include "intel_uc_fw.h"
|
|
|
|
#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 21:35:58 +08:00
|
|
|
struct guc_preempt_work {
|
|
|
|
struct work_struct work;
|
|
|
|
struct intel_engine_cs *engine;
|
|
|
|
};
|
|
|
|
|
2017-10-16 22:47:13 +08:00
|
|
|
/*
|
|
|
|
* Top level structure of GuC. It handles firmware loading and manages client
|
2017-11-16 21:32:40 +08:00
|
|
|
* pool and doorbells. intel_guc owns a intel_guc_client to replace the legacy
|
2017-10-16 22:47:13 +08:00
|
|
|
* ExecList submission.
|
|
|
|
*/
|
2017-10-05 02:13:41 +08:00
|
|
|
struct intel_guc {
|
|
|
|
struct intel_uc_fw fw;
|
|
|
|
struct intel_guc_log log;
|
|
|
|
struct intel_guc_ct ct;
|
|
|
|
|
2018-03-14 08:32:50 +08:00
|
|
|
/* Offset where Non-WOPCM memory starts. */
|
|
|
|
u32 ggtt_pin_bias;
|
|
|
|
|
2017-10-05 02:13:41 +08:00
|
|
|
/* Log snapshot if GuC errors during load */
|
|
|
|
struct drm_i915_gem_object *load_err_log;
|
|
|
|
|
|
|
|
/* intel_guc_recv interrupt related state */
|
|
|
|
bool interrupts_enabled;
|
|
|
|
|
|
|
|
struct i915_vma *ads_vma;
|
|
|
|
struct i915_vma *stage_desc_pool;
|
|
|
|
void *stage_desc_pool_vaddr;
|
|
|
|
struct ida stage_ids;
|
2017-10-26 04:00:11 +08:00
|
|
|
struct i915_vma *shared_data;
|
|
|
|
void *shared_data_vaddr;
|
2017-10-05 02:13:41 +08:00
|
|
|
|
2017-11-16 21:32:40 +08:00
|
|
|
struct intel_guc_client *execbuf_client;
|
|
|
|
struct intel_guc_client *preempt_client;
|
2017-10-05 02:13:41 +08: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 21:35:58 +08:00
|
|
|
struct guc_preempt_work preempt_work[I915_NUM_ENGINES];
|
|
|
|
struct workqueue_struct *preempt_wq;
|
|
|
|
|
2017-10-05 02:13:41 +08:00
|
|
|
DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
|
2017-10-06 16:49:40 +08:00
|
|
|
/* Cyclic counter mod pagesize */
|
|
|
|
u32 db_cacheline;
|
2017-10-05 02:13:41 +08: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 */
|
|
|
|
int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
|
|
|
|
|
|
|
|
/* GuC's FW specific notify function */
|
|
|
|
void (*notify)(struct intel_guc *guc);
|
|
|
|
};
|
|
|
|
|
|
|
|
static
|
|
|
|
inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
|
|
|
|
{
|
|
|
|
return guc->send(guc, action, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void intel_guc_notify(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->notify(guc);
|
|
|
|
}
|
|
|
|
|
2018-03-14 08:32:49 +08: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 08:32:50 +08:00
|
|
|
* GuC does not allow any gfx GGTT address that falls into range
|
|
|
|
* [0, GuC ggtt_pin_bias), which is reserved for Boot ROM, SRAM and WOPCM.
|
|
|
|
* Currently, in order to exclude [0, GuC ggtt_pin_bias) address space from
|
|
|
|
* GGTT, all gfx objects used by GuC are allocated with intel_guc_allocate_vma()
|
|
|
|
* and pinned with PIN_OFFSET_BIAS along with the value of GuC ggtt_pin_bias.
|
2018-03-14 08:32:49 +08:00
|
|
|
*
|
2018-03-14 08:32:50 +08:00
|
|
|
* Return: GGTT offset of the @vma.
|
2017-10-16 22:47:13 +08:00
|
|
|
*/
|
2018-03-14 08:32:49 +08:00
|
|
|
static inline u32 intel_guc_ggtt_offset(struct intel_guc *guc,
|
|
|
|
struct i915_vma *vma)
|
2017-10-05 02:13:41 +08:00
|
|
|
{
|
|
|
|
u32 offset = i915_ggtt_offset(vma);
|
|
|
|
|
2018-03-14 08:32:50 +08:00
|
|
|
GEM_BUG_ON(offset < guc->ggtt_pin_bias);
|
2017-10-05 02:13:41 +08: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 22:47:11 +08:00
|
|
|
void intel_guc_init_params(struct intel_guc *guc);
|
2018-03-14 08:32:50 +08:00
|
|
|
void intel_guc_init_ggtt_pin_bias(struct intel_guc *guc);
|
2017-12-14 06:13:47 +08:00
|
|
|
int intel_guc_init_wq(struct intel_guc *guc);
|
|
|
|
void intel_guc_fini_wq(struct intel_guc *guc);
|
2017-12-14 06:13:46 +08:00
|
|
|
int intel_guc_init(struct intel_guc *guc);
|
|
|
|
void intel_guc_fini(struct intel_guc *guc);
|
2017-10-05 02:13:41 +08:00
|
|
|
int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len);
|
|
|
|
int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
|
2018-03-08 23:46:55 +08:00
|
|
|
void intel_guc_to_host_event_handler(struct intel_guc *guc);
|
2017-10-05 02:13:41 +08: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 19:15:49 +08:00
|
|
|
int intel_guc_suspend(struct intel_guc *guc);
|
|
|
|
int intel_guc_resume(struct intel_guc *guc);
|
2017-10-05 02:13:41 +08:00
|
|
|
struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
|
|
|
|
|
2018-03-12 21:03:07 +08:00
|
|
|
static inline int intel_guc_sanitize(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
intel_uc_fw_sanitize(&guc->fw);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-05 02:13:41 +08:00
|
|
|
#endif
|