mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-17 05:08:30 +07:00
dd18cedfa3
Removing the pin bias from GuC allows us to not check for GuC every time
we pin a context, which fixes the assertion error on unresolved GuC
platform default in mock contexts selftest.
It also seems that we were using uninitialized WOPCM variables when
setting the GuC pin bias. The pin bias has to be set after the WOPCM,
but before the call to i915_gem_contexts_init where the first contexts
are pinned.
v2:
This also makes it so that there's no need to set GuC variables from
within the WOPCM init function or to move the WOPCM init, while keeping
the correct initialization order. Also for mock tests the pin bias is
left at 0 and we make sure that the pin bias with GuC will not be
smaller than without GuC.
v3:
Avoid unused i915 in intel_guc_ggtt_offset if debug is disabled.
v4:
Squash with WOPCM init reordering.
Moved the i915_ggtt_pin_bias helper to this patch, and made some
functions use it instead of directly dereferencing i915->ggtt.
v5:
Since we now don't use wopcm.guc.base for the pin bias there's no need to
validate it. It also has already been verified in WOPCM init.
v6:
Deleted the now unnecessarily introduced includes from previous versions.
Dropped naming changes from dev_priv to i915 for better patch readability.
v7:
Changed some comments to make more sense in the context they're in.
v8:
Moved and renamed the function which now returns the wopcm.guc.size to
intel_guc.c:intel_guc_reserved_gtt_size to avoid any possible confusion
with the pin_bias in ggtt, which should be used for pinning.
Fixed patch not applying or the most recent upstream.
Fixes: f7dc0157e4
("drm/i915/uc: Fetch GuC/HuC firmwares from guc/huc specific init")
Testcase: igt/drv_selftest/mock_contexts #GuC
Signed-off-by: Jakub Bartmiński <jakub.bartminski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@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/20180727141148.30874-3-jakub.bartminski@intel.com
191 lines
6.0 KiB
C
191 lines
6.0 KiB
C
/*
|
|
* 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"
|
|
#include "intel_guc_fw.h"
|
|
#include "intel_guc_fwif.h"
|
|
#include "intel_guc_ct.h"
|
|
#include "intel_guc_log.h"
|
|
#include "intel_guc_reg.h"
|
|
#include "intel_uc_fw.h"
|
|
#include "i915_vma.h"
|
|
|
|
struct guc_preempt_work {
|
|
struct work_struct work;
|
|
struct intel_engine_cs *engine;
|
|
};
|
|
|
|
/*
|
|
* Top level structure of GuC. It handles firmware loading and manages client
|
|
* pool and doorbells. intel_guc owns a intel_guc_client to replace the legacy
|
|
* ExecList submission.
|
|
*/
|
|
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 */
|
|
spinlock_t irq_lock;
|
|
bool interrupts_enabled;
|
|
unsigned int msg_enabled_mask;
|
|
|
|
struct i915_vma *ads_vma;
|
|
struct i915_vma *stage_desc_pool;
|
|
void *stage_desc_pool_vaddr;
|
|
struct ida stage_ids;
|
|
struct i915_vma *shared_data;
|
|
void *shared_data_vaddr;
|
|
|
|
struct intel_guc_client *execbuf_client;
|
|
struct intel_guc_client *preempt_client;
|
|
|
|
struct guc_preempt_work preempt_work[I915_NUM_ENGINES];
|
|
struct workqueue_struct *preempt_wq;
|
|
|
|
DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
|
|
/* Cyclic counter mod pagesize */
|
|
u32 db_cacheline;
|
|
|
|
/* 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,
|
|
u32 *response_buf, u32 response_buf_size);
|
|
|
|
/* GuC's FW specific event handler function */
|
|
void (*handler)(struct intel_guc *guc);
|
|
|
|
/* 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, 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);
|
|
}
|
|
|
|
static inline void intel_guc_notify(struct intel_guc *guc)
|
|
{
|
|
guc->notify(guc);
|
|
}
|
|
|
|
static inline void intel_guc_to_host_event_handler(struct intel_guc *guc)
|
|
{
|
|
guc->handler(guc);
|
|
}
|
|
|
|
/* 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.
|
|
*
|
|
* GuC does not allow any gfx GGTT address that falls into range
|
|
* [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
|
|
* 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 ggtt.pin_bias.
|
|
*
|
|
* Return: GGTT offset of the @vma.
|
|
*/
|
|
static inline u32 intel_guc_ggtt_offset(struct intel_guc *guc,
|
|
struct i915_vma *vma)
|
|
{
|
|
u32 offset = i915_ggtt_offset(vma);
|
|
|
|
GEM_BUG_ON(offset < i915_ggtt_pin_bias(vma));
|
|
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);
|
|
void intel_guc_init_params(struct intel_guc *guc);
|
|
int intel_guc_init_misc(struct intel_guc *guc);
|
|
int intel_guc_init(struct intel_guc *guc);
|
|
void intel_guc_fini(struct intel_guc *guc);
|
|
void intel_guc_fini_misc(struct intel_guc *guc);
|
|
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);
|
|
void intel_guc_to_host_event_handler(struct intel_guc *guc);
|
|
void intel_guc_to_host_event_handler_nop(struct intel_guc *guc);
|
|
void intel_guc_to_host_event_handler_mmio(struct intel_guc *guc);
|
|
void intel_guc_to_host_process_recv_msg(struct intel_guc *guc, u32 msg);
|
|
int intel_guc_sample_forcewake(struct intel_guc *guc);
|
|
int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
|
|
int intel_guc_suspend(struct intel_guc *guc);
|
|
int intel_guc_resume(struct intel_guc *guc);
|
|
struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
|
|
u32 intel_guc_reserved_gtt_size(struct intel_guc *guc);
|
|
|
|
static inline int intel_guc_sanitize(struct intel_guc *guc)
|
|
{
|
|
intel_uc_fw_sanitize(&guc->fw);
|
|
return 0;
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
#endif
|