2019-08-12 09:29:35 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2016-11-25 17:59:35 +00:00
|
|
|
/*
|
2019-08-12 09:29:35 +00:00
|
|
|
* Copyright © 2016-2019 Intel Corporation
|
2016-11-25 17:59:35 +00:00
|
|
|
*/
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
#include "gt/intel_gt.h"
|
2019-04-24 17:48:39 +00:00
|
|
|
#include "gt/intel_reset.h"
|
2017-12-13 22:13:46 +00:00
|
|
|
#include "intel_guc.h"
|
2019-05-27 18:36:00 +00:00
|
|
|
#include "intel_guc_ads.h"
|
|
|
|
#include "intel_guc_submission.h"
|
2019-07-13 10:00:13 +00:00
|
|
|
#include "intel_uc.h"
|
|
|
|
|
2017-10-04 18:13:42 +00:00
|
|
|
#include "i915_drv.h"
|
2016-11-25 17:59:35 +00:00
|
|
|
|
2017-03-14 14:28:11 +00:00
|
|
|
/* Reset GuC providing us with fresh state for both GuC and HuC.
|
|
|
|
*/
|
2019-07-13 10:00:13 +00:00
|
|
|
static int __intel_uc_reset_hw(struct intel_uc *uc)
|
2017-03-14 14:28:11 +00:00
|
|
|
{
|
2019-07-23 09:14:03 +00:00
|
|
|
struct intel_gt *gt = uc_to_gt(uc);
|
2017-03-14 14:28:11 +00:00
|
|
|
int ret;
|
|
|
|
u32 guc_status;
|
|
|
|
|
2019-08-02 18:40:54 +00:00
|
|
|
ret = i915_inject_load_error(gt->i915, -ENXIO);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-07-23 09:14:03 +00:00
|
|
|
ret = intel_reset_guc(gt);
|
2017-03-14 14:28:11 +00:00
|
|
|
if (ret) {
|
2017-10-30 18:56:14 +00:00
|
|
|
DRM_ERROR("Failed to reset GuC, ret = %d\n", ret);
|
2017-03-14 14:28:11 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-07-23 09:14:03 +00:00
|
|
|
guc_status = intel_uncore_read(gt->uncore, GUC_STATUS);
|
2017-03-14 14:28:11 +00:00
|
|
|
WARN(!(guc_status & GS_MIA_IN_RESET),
|
|
|
|
"GuC status: 0x%x, MIA core expected to be in reset\n",
|
|
|
|
guc_status);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-08-01 13:28:40 +00:00
|
|
|
static void __confirm_options(struct intel_uc *uc)
|
2017-03-14 14:28:10 +00:00
|
|
|
{
|
2019-08-07 17:00:28 +00:00
|
|
|
struct drm_i915_private *i915 = uc_to_gt(uc)->i915;
|
|
|
|
|
|
|
|
DRM_DEV_DEBUG_DRIVER(i915->drm.dev,
|
|
|
|
"enable_guc=%d (guc:%s submission:%s huc:%s)\n",
|
|
|
|
i915_modparams.enable_guc,
|
2019-08-16 20:56:58 +00:00
|
|
|
yesno(intel_uc_uses_guc(uc)),
|
|
|
|
yesno(intel_uc_uses_guc_submission(uc)),
|
|
|
|
yesno(intel_uc_uses_huc(uc)));
|
2017-12-06 13:53:15 +00:00
|
|
|
|
2019-08-01 13:28:40 +00:00
|
|
|
if (i915_modparams.enable_guc == -1)
|
|
|
|
return;
|
2017-12-06 13:53:15 +00:00
|
|
|
|
2019-08-01 13:28:40 +00:00
|
|
|
if (i915_modparams.enable_guc == 0) {
|
2019-08-16 20:56:58 +00:00
|
|
|
GEM_BUG_ON(intel_uc_uses_guc(uc));
|
|
|
|
GEM_BUG_ON(intel_uc_uses_guc_submission(uc));
|
|
|
|
GEM_BUG_ON(intel_uc_uses_huc(uc));
|
2019-08-01 13:28:40 +00:00
|
|
|
return;
|
2017-12-06 13:53:15 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 13:28:40 +00:00
|
|
|
if (!intel_uc_supports_guc(uc))
|
2019-08-07 17:00:28 +00:00
|
|
|
dev_info(i915->drm.dev,
|
|
|
|
"Incompatible option enable_guc=%d - %s\n",
|
2019-08-01 13:28:40 +00:00
|
|
|
i915_modparams.enable_guc, "GuC is not supported!");
|
|
|
|
|
|
|
|
if (i915_modparams.enable_guc & ENABLE_GUC_LOAD_HUC &&
|
|
|
|
!intel_uc_supports_huc(uc))
|
2019-08-07 17:00:28 +00:00
|
|
|
dev_info(i915->drm.dev,
|
|
|
|
"Incompatible option enable_guc=%d - %s\n",
|
2019-08-01 13:28:40 +00:00
|
|
|
i915_modparams.enable_guc, "HuC is not supported!");
|
|
|
|
|
|
|
|
if (i915_modparams.enable_guc & ENABLE_GUC_SUBMISSION &&
|
|
|
|
!intel_uc_supports_guc_submission(uc))
|
2019-08-07 17:00:28 +00:00
|
|
|
dev_info(i915->drm.dev,
|
|
|
|
"Incompatible option enable_guc=%d - %s\n",
|
2019-08-01 13:28:40 +00:00
|
|
|
i915_modparams.enable_guc, "GuC submission is N/A");
|
2019-05-27 18:35:58 +00:00
|
|
|
|
2019-08-01 13:28:40 +00:00
|
|
|
if (i915_modparams.enable_guc & ~(ENABLE_GUC_SUBMISSION |
|
|
|
|
ENABLE_GUC_LOAD_HUC))
|
2019-08-07 17:00:28 +00:00
|
|
|
dev_info(i915->drm.dev,
|
|
|
|
"Incompatible option enable_guc=%d - %s\n",
|
2019-08-01 13:28:40 +00:00
|
|
|
i915_modparams.enable_guc, "undocumented flag");
|
2017-03-14 14:28:10 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_init_early(struct intel_uc *uc)
|
2017-10-04 15:33:27 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
intel_guc_init_early(&uc->guc);
|
|
|
|
intel_huc_init_early(&uc->huc);
|
2018-03-12 13:03:06 +00:00
|
|
|
|
2019-08-01 13:28:40 +00:00
|
|
|
__confirm_options(uc);
|
2017-03-14 14:28:09 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 00:57:08 +00:00
|
|
|
void intel_uc_driver_late_release(struct intel_uc *uc)
|
2017-03-22 17:39:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-04 15:33:24 +00:00
|
|
|
/**
|
|
|
|
* intel_uc_init_mmio - setup uC MMIO access
|
2019-07-13 10:00:13 +00:00
|
|
|
* @uc: the intel_uc structure
|
2017-10-04 15:33:24 +00:00
|
|
|
*
|
|
|
|
* Setup minimal state necessary for MMIO accesses later in the
|
|
|
|
* initialization sequence.
|
|
|
|
*/
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_init_mmio(struct intel_uc *uc)
|
2017-10-04 15:33:24 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
intel_guc_init_send_regs(&uc->guc);
|
2017-10-04 15:33:24 +00:00
|
|
|
}
|
|
|
|
|
2019-08-02 18:40:53 +00:00
|
|
|
static void __uc_capture_load_err_log(struct intel_uc *uc)
|
2017-05-22 17:50:28 +00:00
|
|
|
{
|
2019-08-02 18:40:53 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
2017-05-22 17:50:28 +00:00
|
|
|
|
2019-08-02 18:40:53 +00:00
|
|
|
if (guc->log.vma && !uc->load_err_log)
|
|
|
|
uc->load_err_log = i915_gem_object_get(guc->log.vma->obj);
|
2017-05-22 17:50:28 +00:00
|
|
|
}
|
|
|
|
|
2019-08-02 18:40:53 +00:00
|
|
|
static void __uc_free_load_err_log(struct intel_uc *uc)
|
2017-05-22 17:50:28 +00:00
|
|
|
{
|
2019-08-02 18:40:53 +00:00
|
|
|
struct drm_i915_gem_object *log = fetch_and_zero(&uc->load_err_log);
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
i915_gem_object_put(log);
|
2017-05-22 17:50:28 +00:00
|
|
|
}
|
|
|
|
|
2019-06-21 18:21:23 +00:00
|
|
|
/*
|
|
|
|
* Events triggered while CT buffers are disabled are logged in the SCRATCH_15
|
|
|
|
* register using the same bits used in the CT message payload. Since our
|
|
|
|
* communication channel with guc is turned off at this point, we can save the
|
|
|
|
* message and handle it after we turn it back on.
|
|
|
|
*/
|
|
|
|
static void guc_clear_mmio_msg(struct intel_guc *guc)
|
|
|
|
{
|
2019-07-13 10:00:14 +00:00
|
|
|
intel_uncore_write(guc_to_gt(guc)->uncore, SOFT_SCRATCH(15), 0);
|
2019-06-21 18:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_get_mmio_msg(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
spin_lock_irq(&guc->irq_lock);
|
|
|
|
|
2019-07-13 10:00:14 +00:00
|
|
|
val = intel_uncore_read(guc_to_gt(guc)->uncore, SOFT_SCRATCH(15));
|
2019-06-21 18:21:23 +00:00
|
|
|
guc->mmio_msg |= val & guc->msg_enabled_mask;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clear all events, including the ones we're not currently servicing,
|
|
|
|
* to make sure we don't try to process a stale message if we enable
|
|
|
|
* handling of more events later.
|
|
|
|
*/
|
|
|
|
guc_clear_mmio_msg(guc);
|
|
|
|
|
|
|
|
spin_unlock_irq(&guc->irq_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_handle_mmio_msg(struct intel_guc *guc)
|
|
|
|
{
|
2019-07-13 10:00:16 +00:00
|
|
|
struct drm_i915_private *i915 = guc_to_gt(guc)->i915;
|
2019-06-21 18:21:23 +00:00
|
|
|
|
|
|
|
/* we need communication to be enabled to reply to GuC */
|
|
|
|
GEM_BUG_ON(guc->handler == intel_guc_to_host_event_handler_nop);
|
|
|
|
|
|
|
|
if (!guc->mmio_msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
spin_lock_irq(&i915->irq_lock);
|
|
|
|
intel_guc_to_host_process_recv_msg(guc, &guc->mmio_msg, 1);
|
|
|
|
spin_unlock_irq(&i915->irq_lock);
|
|
|
|
|
|
|
|
guc->mmio_msg = 0;
|
|
|
|
}
|
|
|
|
|
2019-05-27 18:36:07 +00:00
|
|
|
static void guc_reset_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
2019-07-13 10:00:09 +00:00
|
|
|
guc->interrupts.reset(guc);
|
2019-05-27 18:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_enable_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
2019-07-13 10:00:09 +00:00
|
|
|
guc->interrupts.enable(guc);
|
2019-05-27 18:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_disable_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
2019-07-13 10:00:09 +00:00
|
|
|
guc->interrupts.disable(guc);
|
2019-05-27 18:36:07 +00:00
|
|
|
}
|
|
|
|
|
2019-07-30 23:07:39 +00:00
|
|
|
static inline bool guc_communication_enabled(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
return guc->send != intel_guc_send_nop;
|
|
|
|
}
|
|
|
|
|
2017-05-02 10:32:42 +00:00
|
|
|
static int guc_enable_communication(struct intel_guc *guc)
|
|
|
|
{
|
2019-07-13 10:00:16 +00:00
|
|
|
struct drm_i915_private *i915 = guc_to_gt(guc)->i915;
|
2019-06-21 18:21:22 +00:00
|
|
|
int ret;
|
|
|
|
|
2019-07-30 23:07:39 +00:00
|
|
|
GEM_BUG_ON(guc_communication_enabled(guc));
|
|
|
|
|
2019-08-02 18:40:54 +00:00
|
|
|
ret = i915_inject_load_error(i915, -ENXIO);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-06-21 18:21:22 +00:00
|
|
|
ret = intel_guc_ct_enable(&guc->ct);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
guc->send = intel_guc_send_ct;
|
|
|
|
guc->handler = intel_guc_to_host_event_handler_ct;
|
|
|
|
|
2019-06-21 18:21:23 +00:00
|
|
|
/* check for mmio messages received before/during the CT enable */
|
|
|
|
guc_get_mmio_msg(guc);
|
|
|
|
guc_handle_mmio_msg(guc);
|
|
|
|
|
2019-05-27 18:36:07 +00:00
|
|
|
guc_enable_interrupts(guc);
|
2018-03-19 09:53:36 +00:00
|
|
|
|
2019-06-21 18:21:23 +00:00
|
|
|
/* check for CT messages received before we enabled interrupts */
|
|
|
|
spin_lock_irq(&i915->irq_lock);
|
|
|
|
intel_guc_to_host_event_handler_ct(guc);
|
|
|
|
spin_unlock_irq(&i915->irq_lock);
|
|
|
|
|
2019-06-21 18:21:22 +00:00
|
|
|
DRM_INFO("GuC communication enabled\n");
|
|
|
|
|
|
|
|
return 0;
|
2017-05-02 10:32:42 +00:00
|
|
|
}
|
|
|
|
|
2019-08-29 17:41:53 +00:00
|
|
|
static void __guc_stop_communication(struct intel_guc *guc)
|
2017-05-02 10:32:42 +00:00
|
|
|
{
|
2019-06-21 18:21:23 +00:00
|
|
|
/*
|
|
|
|
* Events generated during or after CT disable are logged by guc in
|
|
|
|
* via mmio. Make sure the register is clear before disabling CT since
|
|
|
|
* all events we cared about have already been processed via CT.
|
|
|
|
*/
|
|
|
|
guc_clear_mmio_msg(guc);
|
|
|
|
|
2019-05-27 18:36:07 +00:00
|
|
|
guc_disable_interrupts(guc);
|
2018-03-19 09:53:36 +00:00
|
|
|
|
2017-05-02 10:32:42 +00:00
|
|
|
guc->send = intel_guc_send_nop;
|
2018-03-26 19:48:22 +00:00
|
|
|
guc->handler = intel_guc_to_host_event_handler_nop;
|
2019-08-29 17:41:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_stop_communication(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
intel_guc_ct_stop(&guc->ct);
|
|
|
|
|
|
|
|
__guc_stop_communication(guc);
|
|
|
|
|
|
|
|
DRM_INFO("GuC communication stopped\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_disable_communication(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
__guc_stop_communication(guc);
|
2019-06-21 18:21:22 +00:00
|
|
|
|
|
|
|
intel_guc_ct_disable(&guc->ct);
|
|
|
|
|
2019-06-21 18:21:23 +00:00
|
|
|
/*
|
|
|
|
* Check for messages received during/after the CT disable. We do not
|
|
|
|
* expect any messages to have arrived via CT between the interrupt
|
|
|
|
* disable and the CT disable because GuC should've been idle until we
|
|
|
|
* triggered the CT disable protocol.
|
|
|
|
*/
|
|
|
|
guc_get_mmio_msg(guc);
|
|
|
|
|
2019-06-21 18:21:22 +00:00
|
|
|
DRM_INFO("GuC communication disabled\n");
|
2017-05-02 10:32:42 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_fetch_firmwares(struct intel_uc *uc)
|
2017-12-13 22:13:47 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct drm_i915_private *i915 = uc_to_gt(uc)->i915;
|
2019-08-07 17:00:30 +00:00
|
|
|
int err;
|
2019-07-13 10:00:13 +00:00
|
|
|
|
2019-08-16 20:56:58 +00:00
|
|
|
if (!intel_uc_uses_guc(uc))
|
2019-07-13 10:00:07 +00:00
|
|
|
return;
|
2018-06-28 14:15:21 +00:00
|
|
|
|
2019-08-07 17:00:30 +00:00
|
|
|
err = intel_uc_fw_fetch(&uc->guc.fw, i915);
|
|
|
|
if (err)
|
|
|
|
return;
|
2018-06-28 14:15:21 +00:00
|
|
|
|
2019-08-16 20:56:58 +00:00
|
|
|
if (intel_uc_uses_huc(uc))
|
2019-07-25 21:03:14 +00:00
|
|
|
intel_uc_fw_fetch(&uc->huc.fw, i915);
|
2017-12-13 22:13:47 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_cleanup_firmwares(struct intel_uc *uc)
|
2017-12-13 22:13:47 +00:00
|
|
|
{
|
2019-08-16 20:56:58 +00:00
|
|
|
if (!intel_uc_uses_guc(uc))
|
2017-12-13 22:13:47 +00:00
|
|
|
return;
|
|
|
|
|
2019-08-16 20:56:58 +00:00
|
|
|
if (intel_uc_uses_huc(uc))
|
2019-07-13 10:00:13 +00:00
|
|
|
intel_uc_fw_cleanup_fetch(&uc->huc.fw);
|
2018-06-28 14:15:21 +00:00
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
intel_uc_fw_cleanup_fetch(&uc->guc.fw);
|
2017-12-13 22:13:47 +00:00
|
|
|
}
|
|
|
|
|
2019-08-17 13:11:44 +00:00
|
|
|
void intel_uc_init(struct intel_uc *uc)
|
2017-03-14 14:28:11 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
|
|
|
struct intel_huc *huc = &uc->huc;
|
2017-12-13 22:13:48 +00:00
|
|
|
int ret;
|
2017-03-14 14:28:11 +00:00
|
|
|
|
2019-08-16 20:56:58 +00:00
|
|
|
if (!intel_uc_uses_guc(uc))
|
2019-08-17 13:11:44 +00:00
|
|
|
return;
|
2017-03-28 16:53:47 +00:00
|
|
|
|
2019-05-27 18:35:58 +00:00
|
|
|
/* XXX: GuC submission is unavailable for now */
|
2019-07-31 22:33:18 +00:00
|
|
|
GEM_BUG_ON(intel_uc_supports_guc_submission(uc));
|
2019-05-27 18:35:58 +00:00
|
|
|
|
2017-12-13 22:13:46 +00:00
|
|
|
ret = intel_guc_init(guc);
|
2019-08-17 13:11:44 +00:00
|
|
|
if (ret) {
|
|
|
|
intel_uc_fw_cleanup_fetch(&huc->fw);
|
|
|
|
return;
|
2019-04-19 23:00:13 +00:00
|
|
|
}
|
|
|
|
|
2019-08-17 13:11:44 +00:00
|
|
|
if (intel_uc_uses_huc(uc))
|
|
|
|
intel_huc_init(huc);
|
2017-12-13 22:13:48 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_fini(struct intel_uc *uc)
|
2017-12-13 22:13:48 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
2017-12-13 22:13:48 +00:00
|
|
|
|
2019-08-16 20:56:58 +00:00
|
|
|
if (!intel_uc_uses_guc(uc))
|
2017-12-13 22:13:48 +00:00
|
|
|
return;
|
|
|
|
|
2019-08-16 20:56:58 +00:00
|
|
|
if (intel_uc_uses_huc(uc))
|
2019-07-13 10:00:13 +00:00
|
|
|
intel_huc_fini(&uc->huc);
|
2019-04-19 23:00:13 +00:00
|
|
|
|
2017-12-13 22:13:48 +00:00
|
|
|
intel_guc_fini(guc);
|
2019-08-02 18:40:53 +00:00
|
|
|
|
|
|
|
__uc_free_load_err_log(uc);
|
2017-12-13 22:13:48 +00:00
|
|
|
}
|
|
|
|
|
2019-08-02 18:40:51 +00:00
|
|
|
static int __uc_sanitize(struct intel_uc *uc)
|
2018-03-12 13:03:07 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
|
|
|
struct intel_huc *huc = &uc->huc;
|
2018-03-12 13:03:07 +00:00
|
|
|
|
2019-08-04 19:50:51 +00:00
|
|
|
GEM_BUG_ON(!intel_uc_supports_guc(uc));
|
2018-03-12 13:03:07 +00:00
|
|
|
|
|
|
|
intel_huc_sanitize(huc);
|
|
|
|
intel_guc_sanitize(guc);
|
|
|
|
|
2019-08-02 18:40:51 +00:00
|
|
|
return __intel_uc_reset_hw(uc);
|
2018-03-12 13:03:07 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_sanitize(struct intel_uc *uc)
|
2019-05-22 19:31:59 +00:00
|
|
|
{
|
2019-07-31 22:33:18 +00:00
|
|
|
if (!intel_uc_supports_guc(uc))
|
2019-05-22 19:31:59 +00:00
|
|
|
return;
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
__uc_sanitize(uc);
|
2019-05-22 19:31:59 +00:00
|
|
|
}
|
|
|
|
|
2019-07-30 23:07:40 +00:00
|
|
|
/* Initialize and verify the uC regs related to uC positioning in WOPCM */
|
|
|
|
static int uc_init_wopcm(struct intel_uc *uc)
|
|
|
|
{
|
|
|
|
struct intel_gt *gt = uc_to_gt(uc);
|
|
|
|
struct intel_uncore *uncore = gt->uncore;
|
|
|
|
u32 base = intel_wopcm_guc_base(>->i915->wopcm);
|
|
|
|
u32 size = intel_wopcm_guc_size(>->i915->wopcm);
|
2019-08-16 20:56:58 +00:00
|
|
|
u32 huc_agent = intel_uc_uses_huc(uc) ? HUC_LOADING_AGENT_GUC : 0;
|
2019-07-30 23:07:40 +00:00
|
|
|
u32 mask;
|
|
|
|
int err;
|
|
|
|
|
2019-08-02 18:40:55 +00:00
|
|
|
if (unlikely(!base || !size)) {
|
|
|
|
i915_probe_error(gt->i915, "Unsuccessful WOPCM partitioning\n");
|
|
|
|
return -E2BIG;
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:33:18 +00:00
|
|
|
GEM_BUG_ON(!intel_uc_supports_guc(uc));
|
2019-07-30 23:07:40 +00:00
|
|
|
GEM_BUG_ON(!(base & GUC_WOPCM_OFFSET_MASK));
|
|
|
|
GEM_BUG_ON(base & ~GUC_WOPCM_OFFSET_MASK);
|
|
|
|
GEM_BUG_ON(!(size & GUC_WOPCM_SIZE_MASK));
|
|
|
|
GEM_BUG_ON(size & ~GUC_WOPCM_SIZE_MASK);
|
|
|
|
|
2019-08-02 18:40:54 +00:00
|
|
|
err = i915_inject_load_error(gt->i915, -ENXIO);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2019-07-30 23:07:40 +00:00
|
|
|
mask = GUC_WOPCM_SIZE_MASK | GUC_WOPCM_SIZE_LOCKED;
|
|
|
|
err = intel_uncore_write_and_verify(uncore, GUC_WOPCM_SIZE, size, mask,
|
|
|
|
size | GUC_WOPCM_SIZE_LOCKED);
|
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
mask = GUC_WOPCM_OFFSET_MASK | GUC_WOPCM_OFFSET_VALID | huc_agent;
|
|
|
|
err = intel_uncore_write_and_verify(uncore, DMA_GUC_WOPCM_OFFSET,
|
|
|
|
base | huc_agent, mask,
|
|
|
|
base | huc_agent |
|
|
|
|
GUC_WOPCM_OFFSET_VALID);
|
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_out:
|
2019-08-07 17:00:33 +00:00
|
|
|
i915_probe_error(gt->i915, "Failed to init uC WOPCM registers!\n");
|
|
|
|
i915_probe_error(gt->i915, "%s(%#x)=%#x\n", "DMA_GUC_WOPCM_OFFSET",
|
|
|
|
i915_mmio_reg_offset(DMA_GUC_WOPCM_OFFSET),
|
|
|
|
intel_uncore_read(uncore, DMA_GUC_WOPCM_OFFSET));
|
|
|
|
i915_probe_error(gt->i915, "%s(%#x)=%#x\n", "GUC_WOPCM_SIZE",
|
|
|
|
i915_mmio_reg_offset(GUC_WOPCM_SIZE),
|
|
|
|
intel_uncore_read(uncore, GUC_WOPCM_SIZE));
|
2019-07-30 23:07:40 +00:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2019-08-18 09:52:03 +00:00
|
|
|
static bool uc_is_wopcm_locked(struct intel_uc *uc)
|
|
|
|
{
|
|
|
|
struct intel_gt *gt = uc_to_gt(uc);
|
|
|
|
struct intel_uncore *uncore = gt->uncore;
|
|
|
|
|
|
|
|
return (intel_uncore_read(uncore, GUC_WOPCM_SIZE) & GUC_WOPCM_SIZE_LOCKED) ||
|
|
|
|
(intel_uncore_read(uncore, DMA_GUC_WOPCM_OFFSET) & GUC_WOPCM_OFFSET_VALID);
|
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
int intel_uc_init_hw(struct intel_uc *uc)
|
2017-12-13 22:13:48 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct drm_i915_private *i915 = uc_to_gt(uc)->i915;
|
|
|
|
struct intel_guc *guc = &uc->guc;
|
|
|
|
struct intel_huc *huc = &uc->huc;
|
2017-12-13 22:13:48 +00:00
|
|
|
int ret, attempts;
|
|
|
|
|
2019-07-31 22:33:18 +00:00
|
|
|
if (!intel_uc_supports_guc(uc))
|
2017-12-13 22:13:48 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-08-18 09:52:03 +00:00
|
|
|
/*
|
|
|
|
* We can silently continue without GuC only if it was never enabled
|
|
|
|
* before on this system after reboot, otherwise we risk GPU hangs.
|
|
|
|
* To check if GuC was loaded before we look at WOPCM registers.
|
|
|
|
*/
|
|
|
|
if (!intel_uc_uses_guc(uc) && !uc_is_wopcm_locked(uc))
|
2019-08-16 20:56:58 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-08-11 19:51:29 +00:00
|
|
|
if (!intel_uc_fw_is_available(&guc->fw)) {
|
2019-08-18 09:52:03 +00:00
|
|
|
ret = uc_is_wopcm_locked(uc) ||
|
|
|
|
intel_uc_fw_is_overridden(&guc->fw) ||
|
|
|
|
intel_uc_supports_guc_submission(uc) ?
|
|
|
|
intel_uc_fw_status_to_error(guc->fw.status) : 0;
|
2019-08-11 19:51:29 +00:00
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
2019-07-30 23:07:40 +00:00
|
|
|
ret = uc_init_wopcm(uc);
|
|
|
|
if (ret)
|
|
|
|
goto err_out;
|
|
|
|
|
2019-05-27 18:36:07 +00:00
|
|
|
guc_reset_interrupts(guc);
|
2017-12-13 22:13:48 +00:00
|
|
|
|
2017-03-14 14:28:11 +00:00
|
|
|
/* WaEnableuKernelHeaderValidFix:skl */
|
|
|
|
/* WaEnableGuCBootHashCheckNotSet:skl,bxt,kbl */
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 18:10:43 +00:00
|
|
|
if (IS_GEN(i915, 9))
|
2017-03-14 14:28:11 +00:00
|
|
|
attempts = 3;
|
|
|
|
else
|
|
|
|
attempts = 1;
|
|
|
|
|
|
|
|
while (attempts--) {
|
|
|
|
/*
|
|
|
|
* Always reset the GuC just before (re)loading, so
|
|
|
|
* that the state and timing are fairly predictable
|
|
|
|
*/
|
2019-08-02 18:40:51 +00:00
|
|
|
ret = __uc_sanitize(uc);
|
2017-03-14 14:28:11 +00:00
|
|
|
if (ret)
|
2017-12-13 22:13:48 +00:00
|
|
|
goto err_out;
|
2017-03-14 14:28:11 +00:00
|
|
|
|
2019-08-18 09:52:04 +00:00
|
|
|
intel_huc_fw_upload(huc);
|
2019-05-27 18:36:00 +00:00
|
|
|
intel_guc_ads_reset(guc);
|
2019-07-24 08:58:49 +00:00
|
|
|
intel_guc_write_params(guc);
|
2017-10-16 14:47:14 +00:00
|
|
|
ret = intel_guc_fw_upload(guc);
|
2019-03-29 23:17:46 +00:00
|
|
|
if (ret == 0)
|
2017-03-14 14:28:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
DRM_DEBUG_DRIVER("GuC fw load failed: %d; will reset and "
|
|
|
|
"retry %d more time(s)\n", ret, attempts);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Did we succeded or run out of retries? */
|
|
|
|
if (ret)
|
2017-05-22 17:50:28 +00:00
|
|
|
goto err_log_capture;
|
2017-03-14 14:28:11 +00:00
|
|
|
|
2017-05-02 10:32:42 +00:00
|
|
|
ret = guc_enable_communication(guc);
|
|
|
|
if (ret)
|
2017-05-22 17:50:28 +00:00
|
|
|
goto err_log_capture;
|
2017-05-02 10:32:42 +00:00
|
|
|
|
2019-08-18 09:52:04 +00:00
|
|
|
intel_huc_auth(huc);
|
2017-12-06 13:53:16 +00:00
|
|
|
|
2019-05-27 18:36:01 +00:00
|
|
|
ret = intel_guc_sample_forcewake(guc);
|
|
|
|
if (ret)
|
|
|
|
goto err_communication;
|
|
|
|
|
2019-07-31 22:33:18 +00:00
|
|
|
if (intel_uc_supports_guc_submission(uc)) {
|
2017-11-16 13:32:39 +00:00
|
|
|
ret = intel_guc_submission_enable(guc);
|
2017-03-14 14:28:11 +00:00
|
|
|
if (ret)
|
2018-03-19 09:53:36 +00:00
|
|
|
goto err_communication;
|
2017-03-14 14:28:11 +00:00
|
|
|
}
|
|
|
|
|
2019-08-12 07:39:49 +00:00
|
|
|
dev_info(i915->drm.dev, "%s firmware %s version %u.%u %s:%s\n",
|
|
|
|
intel_uc_fw_type_repr(INTEL_UC_FW_TYPE_GUC), guc->fw.path,
|
|
|
|
guc->fw.major_ver_found, guc->fw.minor_ver_found,
|
|
|
|
"submission",
|
2019-07-31 22:33:18 +00:00
|
|
|
enableddisabled(intel_uc_supports_guc_submission(uc)));
|
2019-08-12 07:39:49 +00:00
|
|
|
|
2019-08-16 20:56:58 +00:00
|
|
|
if (intel_uc_uses_huc(uc)) {
|
2019-08-12 07:39:49 +00:00
|
|
|
dev_info(i915->drm.dev, "%s firmware %s version %u.%u %s:%s\n",
|
|
|
|
intel_uc_fw_type_repr(INTEL_UC_FW_TYPE_HUC),
|
|
|
|
huc->fw.path,
|
|
|
|
huc->fw.major_ver_found, huc->fw.minor_ver_found,
|
|
|
|
"authenticated",
|
|
|
|
yesno(intel_huc_is_authenticated(huc)));
|
|
|
|
}
|
2017-10-16 14:47:17 +00:00
|
|
|
|
2017-03-14 14:28:11 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We've failed to load the firmware :(
|
|
|
|
*/
|
2017-12-06 13:53:16 +00:00
|
|
|
err_communication:
|
|
|
|
guc_disable_communication(guc);
|
2017-05-22 17:50:28 +00:00
|
|
|
err_log_capture:
|
2019-08-02 18:40:53 +00:00
|
|
|
__uc_capture_load_err_log(uc);
|
2017-12-06 13:53:15 +00:00
|
|
|
err_out:
|
2019-07-13 10:00:13 +00:00
|
|
|
__uc_sanitize(uc);
|
2019-05-22 19:31:59 +00:00
|
|
|
|
2019-08-18 09:52:03 +00:00
|
|
|
if (!ret) {
|
|
|
|
dev_notice(i915->drm.dev, "GuC is uninitialized\n");
|
|
|
|
/* We want to run without GuC submission */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-08-02 18:40:54 +00:00
|
|
|
i915_probe_error(i915, "GuC initialization failed %d\n", ret);
|
2019-08-11 19:51:32 +00:00
|
|
|
|
|
|
|
/* We want to keep KMS alive */
|
|
|
|
return -EIO;
|
2017-03-14 14:28:11 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_fini_hw(struct intel_uc *uc)
|
2017-03-22 17:39:46 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
2017-11-16 13:32:39 +00:00
|
|
|
|
2019-07-25 00:18:09 +00:00
|
|
|
if (!intel_guc_is_running(guc))
|
2017-03-28 16:53:47 +00:00
|
|
|
return;
|
|
|
|
|
2019-07-31 22:33:18 +00:00
|
|
|
if (intel_uc_supports_guc_submission(uc))
|
2017-11-16 13:32:39 +00:00
|
|
|
intel_guc_submission_disable(guc);
|
2017-05-26 11:13:24 +00:00
|
|
|
|
2019-08-29 17:41:53 +00:00
|
|
|
if (guc_communication_enabled(guc))
|
|
|
|
guc_disable_communication(guc);
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
__uc_sanitize(uc);
|
2017-03-22 17:39:46 +00:00
|
|
|
}
|
2018-03-02 11:15:49 +00:00
|
|
|
|
2019-02-20 01:39:27 +00:00
|
|
|
/**
|
|
|
|
* intel_uc_reset_prepare - Prepare for reset
|
2019-07-13 10:00:13 +00:00
|
|
|
* @uc: the intel_uc structure
|
2019-02-20 01:39:27 +00:00
|
|
|
*
|
|
|
|
* Preparing for full gpu reset.
|
|
|
|
*/
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_reset_prepare(struct intel_uc *uc)
|
2019-02-20 01:39:27 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
2019-02-20 01:39:27 +00:00
|
|
|
|
2019-07-25 00:18:09 +00:00
|
|
|
if (!intel_guc_is_running(guc))
|
2019-02-20 01:39:27 +00:00
|
|
|
return;
|
|
|
|
|
2019-05-23 17:25:55 +00:00
|
|
|
guc_stop_communication(guc);
|
2019-07-13 10:00:13 +00:00
|
|
|
__uc_sanitize(uc);
|
2019-02-20 01:39:27 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_runtime_suspend(struct intel_uc *uc)
|
2018-03-02 11:15:49 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
2018-03-02 11:15:49 +00:00
|
|
|
int err;
|
|
|
|
|
2019-07-25 00:18:09 +00:00
|
|
|
if (!intel_guc_is_running(guc))
|
drm/i915: Invert the GEM wakeref hierarchy
In the current scheme, on submitting a request we take a single global
GEM wakeref, which trickles down to wake up all GT power domains. This
is undesirable as we would like to be able to localise our power
management to the available power domains and to remove the global GEM
operations from the heart of the driver. (The intent there is to push
global GEM decisions to the boundary as used by the GEM user interface.)
Now during request construction, each request is responsible via its
logical context to acquire a wakeref on each power domain it intends to
utilize. Currently, each request takes a wakeref on the engine(s) and
the engines themselves take a chipset wakeref. This gives us a
transition on each engine which we can extend if we want to insert more
powermangement control (such as soft rc6). The global GEM operations
that currently require a struct_mutex are reduced to listening to pm
events from the chipset GT wakeref. As we reduce the struct_mutex
requirement, these listeners should evaporate.
Perhaps the biggest immediate change is that this removes the
struct_mutex requirement around GT power management, allowing us greater
flexibility in request construction. Another important knock-on effect,
is that by tracking engine usage, we can insert a switch back to the
kernel context on that engine immediately, avoiding any extra delay or
inserting global synchronisation barriers. This makes tracking when an
engine and its associated contexts are idle much easier -- important for
when we forgo our assumed execution ordering and need idle barriers to
unpin used contexts. In the process, it means we remove a large chunk of
code whose only purpose was to switch back to the kernel context.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190424200717.1686-5-chris@chris-wilson.co.uk
2019-04-24 20:07:17 +00:00
|
|
|
return;
|
2018-03-02 11:15:49 +00:00
|
|
|
|
2019-05-02 20:30:09 +00:00
|
|
|
err = intel_guc_suspend(guc);
|
|
|
|
if (err)
|
|
|
|
DRM_DEBUG_DRIVER("Failed to suspend GuC, err=%d", err);
|
2018-03-02 11:15:49 +00:00
|
|
|
|
2019-05-02 20:30:09 +00:00
|
|
|
guc_disable_communication(guc);
|
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
void intel_uc_suspend(struct intel_uc *uc)
|
2019-05-02 20:30:09 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
2019-05-02 20:30:09 +00:00
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
2019-07-25 00:18:09 +00:00
|
|
|
if (!intel_guc_is_running(guc))
|
2019-05-02 20:30:09 +00:00
|
|
|
return;
|
|
|
|
|
2019-07-13 10:00:13 +00:00
|
|
|
with_intel_runtime_pm(&uc_to_gt(uc)->i915->runtime_pm, wakeref)
|
|
|
|
intel_uc_runtime_suspend(uc);
|
2018-03-02 11:15:49 +00:00
|
|
|
}
|
|
|
|
|
2019-07-30 23:07:39 +00:00
|
|
|
static int __uc_resume(struct intel_uc *uc, bool enable_communication)
|
2018-03-02 11:15:49 +00:00
|
|
|
{
|
2019-07-13 10:00:13 +00:00
|
|
|
struct intel_guc *guc = &uc->guc;
|
2018-03-02 11:15:49 +00:00
|
|
|
int err;
|
|
|
|
|
2019-07-25 00:18:09 +00:00
|
|
|
if (!intel_guc_is_running(guc))
|
2018-03-02 11:15:49 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-07-30 23:07:39 +00:00
|
|
|
/* Make sure we enable communication if and only if it's disabled */
|
|
|
|
GEM_BUG_ON(enable_communication == guc_communication_enabled(guc));
|
|
|
|
|
|
|
|
if (enable_communication)
|
|
|
|
guc_enable_communication(guc);
|
2018-03-02 11:15:49 +00:00
|
|
|
|
|
|
|
err = intel_guc_resume(guc);
|
|
|
|
if (err) {
|
|
|
|
DRM_DEBUG_DRIVER("Failed to resume GuC, err=%d", err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-07-30 23:07:39 +00:00
|
|
|
|
|
|
|
int intel_uc_resume(struct intel_uc *uc)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* When coming out of S3/S4 we sanitize and re-init the HW, so
|
|
|
|
* communication is already re-enabled at this point.
|
|
|
|
*/
|
|
|
|
return __uc_resume(uc, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
int intel_uc_runtime_resume(struct intel_uc *uc)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* During runtime resume we don't sanitize, so we need to re-init
|
|
|
|
* communication as well.
|
|
|
|
*/
|
|
|
|
return __uc_resume(uc, true);
|
|
|
|
}
|