2016-11-26 00:59:35 +07:00
|
|
|
/*
|
|
|
|
* Copyright © 2016 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-04-25 00:48:39 +07:00
|
|
|
#include "gt/intel_reset.h"
|
2016-11-26 00:59:35 +07:00
|
|
|
#include "intel_uc.h"
|
2017-12-14 05:13:46 +07:00
|
|
|
#include "intel_guc.h"
|
2019-05-28 01:36:00 +07:00
|
|
|
#include "intel_guc_ads.h"
|
|
|
|
#include "intel_guc_submission.h"
|
2017-10-05 01:13:42 +07:00
|
|
|
#include "i915_drv.h"
|
2016-11-26 00:59:35 +07:00
|
|
|
|
2018-02-01 00:32:37 +07:00
|
|
|
static void guc_free_load_err_log(struct intel_guc *guc);
|
|
|
|
|
2017-03-14 21:28:11 +07:00
|
|
|
/* Reset GuC providing us with fresh state for both GuC and HuC.
|
|
|
|
*/
|
|
|
|
static int __intel_uc_reset_hw(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
u32 guc_status;
|
|
|
|
|
2017-10-31 01:56:14 +07:00
|
|
|
ret = intel_reset_guc(dev_priv);
|
2017-03-14 21:28:11 +07:00
|
|
|
if (ret) {
|
2017-10-31 01:56:14 +07:00
|
|
|
DRM_ERROR("Failed to reset GuC, ret = %d\n", ret);
|
2017-03-14 21:28:11 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
guc_status = I915_READ(GUC_STATUS);
|
|
|
|
WARN(!(guc_status & GS_MIA_IN_RESET),
|
|
|
|
"GuC status: 0x%x, MIA core expected to be in reset\n",
|
|
|
|
guc_status);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
static int __get_platform_enable_guc(struct drm_i915_private *i915)
|
2017-03-14 21:28:10 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
struct intel_uc_fw *guc_fw = &i915->guc.fw;
|
|
|
|
struct intel_uc_fw *huc_fw = &i915->huc.fw;
|
2017-12-06 20:53:15 +07:00
|
|
|
int enable_guc = 0;
|
2017-03-14 21:28:10 +07:00
|
|
|
|
2019-05-28 01:35:57 +07:00
|
|
|
/* Default is to use HuC if we know GuC and HuC firmwares */
|
|
|
|
if (intel_uc_fw_is_selected(guc_fw) && intel_uc_fw_is_selected(huc_fw))
|
2017-12-06 20:53:15 +07:00
|
|
|
enable_guc |= ENABLE_GUC_LOAD_HUC;
|
2017-03-14 21:28:13 +07:00
|
|
|
|
2017-12-06 20:53:15 +07:00
|
|
|
/* Any platform specific fine-tuning can be done here */
|
2017-03-15 20:37:41 +07:00
|
|
|
|
2017-12-06 20:53:15 +07:00
|
|
|
return enable_guc;
|
|
|
|
}
|
2017-03-15 20:37:41 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
static int __get_default_guc_log_level(struct drm_i915_private *i915)
|
2018-01-11 22:24:40 +07:00
|
|
|
{
|
2018-03-20 18:55:17 +07:00
|
|
|
int guc_log_level;
|
2018-01-11 22:24:40 +07:00
|
|
|
|
2018-12-27 21:33:39 +07:00
|
|
|
if (!HAS_GUC(i915) || !intel_uc_is_using_guc(i915))
|
2018-03-20 18:55:17 +07:00
|
|
|
guc_log_level = GUC_LOG_LEVEL_DISABLED;
|
|
|
|
else if (IS_ENABLED(CONFIG_DRM_I915_DEBUG) ||
|
|
|
|
IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
|
|
|
|
guc_log_level = GUC_LOG_LEVEL_MAX;
|
|
|
|
else
|
|
|
|
guc_log_level = GUC_LOG_LEVEL_NON_VERBOSE;
|
2018-01-11 22:24:40 +07:00
|
|
|
|
|
|
|
/* Any platform specific fine-tuning can be done here */
|
|
|
|
|
|
|
|
return guc_log_level;
|
|
|
|
}
|
|
|
|
|
2017-12-06 20:53:15 +07:00
|
|
|
/**
|
2018-03-12 20:03:06 +07:00
|
|
|
* sanitize_options_early - sanitize uC related modparam options
|
2018-05-25 19:18:58 +07:00
|
|
|
* @i915: device private
|
2017-12-06 20:53:15 +07:00
|
|
|
*
|
|
|
|
* In case of "enable_guc" option this function will attempt to modify
|
|
|
|
* it only if it was initially set to "auto(-1)". Default value for this
|
|
|
|
* modparam varies between platforms and it is hardcoded in driver code.
|
|
|
|
* Any other modparam value is only monitored against availability of the
|
|
|
|
* related hardware or firmware definitions.
|
2018-01-11 22:24:40 +07:00
|
|
|
*
|
|
|
|
* In case of "guc_log_level" option this function will attempt to modify
|
|
|
|
* it only if it was initially set to "auto(-1)" or if initial value was
|
|
|
|
* "enable(1..4)" on platforms without the GuC. Default value for this
|
|
|
|
* modparam varies between platforms and is usually set to "disable(0)"
|
|
|
|
* unless GuC is enabled on given platform and the driver is compiled with
|
|
|
|
* debug config when this modparam will default to "enable(1..4)".
|
2017-12-06 20:53:15 +07:00
|
|
|
*/
|
2018-05-25 19:18:58 +07:00
|
|
|
static void sanitize_options_early(struct drm_i915_private *i915)
|
2017-12-06 20:53:15 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
struct intel_uc_fw *guc_fw = &i915->guc.fw;
|
|
|
|
struct intel_uc_fw *huc_fw = &i915->huc.fw;
|
2017-03-15 20:37:41 +07:00
|
|
|
|
|
|
|
/* A negative value means "use platform default" */
|
2017-12-06 20:53:15 +07:00
|
|
|
if (i915_modparams.enable_guc < 0)
|
2018-05-25 19:18:58 +07:00
|
|
|
i915_modparams.enable_guc = __get_platform_enable_guc(i915);
|
2017-12-06 20:53:15 +07:00
|
|
|
|
|
|
|
DRM_DEBUG_DRIVER("enable_guc=%d (submission:%s huc:%s)\n",
|
|
|
|
i915_modparams.enable_guc,
|
2018-12-27 21:33:39 +07:00
|
|
|
yesno(intel_uc_is_using_guc_submission(i915)),
|
|
|
|
yesno(intel_uc_is_using_huc(i915)));
|
2017-12-06 20:53:15 +07:00
|
|
|
|
|
|
|
/* Verify GuC firmware availability */
|
2018-12-27 21:33:39 +07:00
|
|
|
if (intel_uc_is_using_guc(i915) && !intel_uc_fw_is_selected(guc_fw)) {
|
2018-01-11 22:24:40 +07:00
|
|
|
DRM_WARN("Incompatible option detected: %s=%d, %s!\n",
|
|
|
|
"enable_guc", i915_modparams.enable_guc,
|
2018-05-25 19:18:58 +07:00
|
|
|
!HAS_GUC(i915) ? "no GuC hardware" :
|
|
|
|
"no GuC firmware");
|
2017-12-06 20:53:15 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify HuC firmware availability */
|
2018-12-27 21:33:39 +07:00
|
|
|
if (intel_uc_is_using_huc(i915) && !intel_uc_fw_is_selected(huc_fw)) {
|
2018-01-11 22:24:40 +07:00
|
|
|
DRM_WARN("Incompatible option detected: %s=%d, %s!\n",
|
|
|
|
"enable_guc", i915_modparams.enable_guc,
|
2018-05-25 19:18:58 +07:00
|
|
|
!HAS_HUC(i915) ? "no HuC hardware" :
|
|
|
|
"no HuC firmware");
|
2017-12-06 20:53:15 +07:00
|
|
|
}
|
|
|
|
|
2019-05-28 01:35:58 +07:00
|
|
|
/* XXX: GuC submission is unavailable for now */
|
|
|
|
if (intel_uc_is_using_guc_submission(i915)) {
|
|
|
|
DRM_INFO("Incompatible option detected: %s=%d, %s!\n",
|
|
|
|
"enable_guc", i915_modparams.enable_guc,
|
|
|
|
"GuC submission not supported");
|
|
|
|
DRM_INFO("Switching to non-GuC submission mode!\n");
|
|
|
|
i915_modparams.enable_guc &= ~ENABLE_GUC_SUBMISSION;
|
|
|
|
}
|
|
|
|
|
2018-01-11 22:24:40 +07:00
|
|
|
/* A negative value means "use platform/config default" */
|
|
|
|
if (i915_modparams.guc_log_level < 0)
|
|
|
|
i915_modparams.guc_log_level =
|
2018-05-25 19:18:58 +07:00
|
|
|
__get_default_guc_log_level(i915);
|
2018-01-11 22:24:40 +07:00
|
|
|
|
2018-12-27 21:33:39 +07:00
|
|
|
if (i915_modparams.guc_log_level > 0 && !intel_uc_is_using_guc(i915)) {
|
2018-01-11 22:24:40 +07:00
|
|
|
DRM_WARN("Incompatible option detected: %s=%d, %s!\n",
|
|
|
|
"guc_log_level", i915_modparams.guc_log_level,
|
2018-05-25 19:18:58 +07:00
|
|
|
!HAS_GUC(i915) ? "no GuC hardware" :
|
|
|
|
"GuC not enabled");
|
2018-01-11 22:24:40 +07:00
|
|
|
i915_modparams.guc_log_level = 0;
|
|
|
|
}
|
|
|
|
|
2018-03-20 18:55:17 +07:00
|
|
|
if (i915_modparams.guc_log_level > GUC_LOG_LEVEL_MAX) {
|
2018-01-11 22:24:40 +07:00
|
|
|
DRM_WARN("Incompatible option detected: %s=%d, %s!\n",
|
|
|
|
"guc_log_level", i915_modparams.guc_log_level,
|
|
|
|
"verbosity too high");
|
2018-03-20 18:55:17 +07:00
|
|
|
i915_modparams.guc_log_level = GUC_LOG_LEVEL_MAX;
|
2018-01-11 22:24:40 +07:00
|
|
|
}
|
|
|
|
|
2018-03-19 16:53:45 +07:00
|
|
|
DRM_DEBUG_DRIVER("guc_log_level=%d (enabled:%s, verbose:%s, verbosity:%d)\n",
|
2018-01-11 22:24:40 +07:00
|
|
|
i915_modparams.guc_log_level,
|
|
|
|
yesno(i915_modparams.guc_log_level),
|
2018-03-20 18:55:17 +07:00
|
|
|
yesno(GUC_LOG_LEVEL_IS_VERBOSE(i915_modparams.guc_log_level)),
|
2018-03-19 16:53:45 +07:00
|
|
|
GUC_LOG_LEVEL_TO_VERBOSITY(i915_modparams.guc_log_level));
|
2018-01-11 22:24:40 +07:00
|
|
|
|
2017-12-06 20:53:15 +07:00
|
|
|
/* Make sure that sanitization was done */
|
|
|
|
GEM_BUG_ON(i915_modparams.enable_guc < 0);
|
2018-01-11 22:24:40 +07:00
|
|
|
GEM_BUG_ON(i915_modparams.guc_log_level < 0);
|
2017-03-14 21:28:10 +07:00
|
|
|
}
|
|
|
|
|
2018-03-23 19:34:50 +07:00
|
|
|
void intel_uc_init_early(struct drm_i915_private *i915)
|
2017-10-04 22:33:27 +07:00
|
|
|
{
|
2018-03-23 19:34:50 +07:00
|
|
|
struct intel_guc *guc = &i915->guc;
|
|
|
|
struct intel_huc *huc = &i915->huc;
|
2018-03-12 20:03:06 +07:00
|
|
|
|
2018-03-23 19:34:50 +07:00
|
|
|
intel_guc_init_early(guc);
|
|
|
|
intel_huc_init_early(huc);
|
2017-10-04 22:33:27 +07:00
|
|
|
|
2018-03-23 19:34:50 +07:00
|
|
|
sanitize_options_early(i915);
|
2017-03-14 21:28:09 +07:00
|
|
|
}
|
|
|
|
|
2018-03-23 19:34:50 +07:00
|
|
|
void intel_uc_cleanup_early(struct drm_i915_private *i915)
|
2017-03-23 00:39:46 +07:00
|
|
|
{
|
2018-03-23 19:34:50 +07:00
|
|
|
struct intel_guc *guc = &i915->guc;
|
2018-02-01 00:32:37 +07:00
|
|
|
|
2018-03-23 19:34:50 +07:00
|
|
|
guc_free_load_err_log(guc);
|
2017-03-23 00:39:46 +07:00
|
|
|
}
|
|
|
|
|
2017-10-04 22:33:24 +07:00
|
|
|
/**
|
|
|
|
* intel_uc_init_mmio - setup uC MMIO access
|
2018-05-25 19:18:58 +07:00
|
|
|
* @i915: device private
|
2017-10-04 22:33:24 +07:00
|
|
|
*
|
|
|
|
* Setup minimal state necessary for MMIO accesses later in the
|
|
|
|
* initialization sequence.
|
|
|
|
*/
|
2018-05-25 19:18:58 +07:00
|
|
|
void intel_uc_init_mmio(struct drm_i915_private *i915)
|
2017-10-04 22:33:24 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
intel_guc_init_send_regs(&i915->guc);
|
2017-10-04 22:33:24 +07:00
|
|
|
}
|
|
|
|
|
2017-05-23 00:50:28 +07:00
|
|
|
static void guc_capture_load_err_log(struct intel_guc *guc)
|
|
|
|
{
|
2018-06-04 21:19:41 +07:00
|
|
|
if (!guc->log.vma || !intel_guc_log_get_level(&guc->log))
|
2017-05-23 00:50:28 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!guc->load_err_log)
|
|
|
|
guc->load_err_log = i915_gem_object_get(guc->log.vma->obj);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_free_load_err_log(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
if (guc->load_err_log)
|
|
|
|
i915_gem_object_put(guc->load_err_log);
|
|
|
|
}
|
|
|
|
|
2019-05-28 01:36:07 +07:00
|
|
|
static void guc_reset_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->interrupts.reset(guc_to_i915(guc));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_enable_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->interrupts.enable(guc_to_i915(guc));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void guc_disable_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->interrupts.disable(guc_to_i915(guc));
|
|
|
|
}
|
|
|
|
|
2017-05-02 17:32:42 +07:00
|
|
|
static int guc_enable_communication(struct intel_guc *guc)
|
|
|
|
{
|
2019-05-28 01:36:07 +07:00
|
|
|
guc_enable_interrupts(guc);
|
2018-03-19 16:53:36 +07:00
|
|
|
|
2019-06-07 05:42:24 +07:00
|
|
|
return intel_guc_ct_enable(&guc->ct);
|
2017-05-02 17:32:42 +07:00
|
|
|
}
|
|
|
|
|
2019-05-24 00:25:55 +07:00
|
|
|
static void guc_stop_communication(struct intel_guc *guc)
|
|
|
|
{
|
2019-06-07 05:42:24 +07:00
|
|
|
intel_guc_ct_stop(&guc->ct);
|
2019-05-24 00:25:55 +07:00
|
|
|
|
|
|
|
guc->send = intel_guc_send_nop;
|
|
|
|
guc->handler = intel_guc_to_host_event_handler_nop;
|
|
|
|
}
|
|
|
|
|
2017-05-02 17:32:42 +07:00
|
|
|
static void guc_disable_communication(struct intel_guc *guc)
|
|
|
|
{
|
2019-06-07 05:42:24 +07:00
|
|
|
intel_guc_ct_disable(&guc->ct);
|
2017-05-26 18:13:25 +07:00
|
|
|
|
2019-05-28 01:36:07 +07:00
|
|
|
guc_disable_interrupts(guc);
|
2018-03-19 16:53:36 +07:00
|
|
|
|
2017-05-02 17:32:42 +07:00
|
|
|
guc->send = intel_guc_send_nop;
|
2018-03-27 02:48:22 +07:00
|
|
|
guc->handler = intel_guc_to_host_event_handler_nop;
|
2017-05-02 17:32:42 +07:00
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
int intel_uc_init_misc(struct drm_i915_private *i915)
|
2017-12-14 05:13:47 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
struct intel_guc *guc = &i915->guc;
|
2018-06-28 21:15:21 +07:00
|
|
|
struct intel_huc *huc = &i915->huc;
|
2017-12-14 05:13:47 +07:00
|
|
|
int ret;
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (!USES_GUC(i915))
|
2017-12-14 05:13:47 +07:00
|
|
|
return 0;
|
|
|
|
|
2018-06-28 21:15:20 +07:00
|
|
|
ret = intel_guc_init_misc(guc);
|
2018-03-08 22:46:54 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2017-12-14 05:13:47 +07:00
|
|
|
|
2018-06-28 21:15:21 +07:00
|
|
|
if (USES_HUC(i915)) {
|
|
|
|
ret = intel_huc_init_misc(huc);
|
|
|
|
if (ret)
|
|
|
|
goto err_guc;
|
|
|
|
}
|
|
|
|
|
2017-12-14 05:13:47 +07:00
|
|
|
return 0;
|
2018-06-28 21:15:21 +07:00
|
|
|
|
|
|
|
err_guc:
|
|
|
|
intel_guc_fini_misc(guc);
|
|
|
|
return ret;
|
2017-12-14 05:13:47 +07:00
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
void intel_uc_fini_misc(struct drm_i915_private *i915)
|
2017-12-14 05:13:47 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
struct intel_guc *guc = &i915->guc;
|
2018-06-28 21:15:21 +07:00
|
|
|
struct intel_huc *huc = &i915->huc;
|
drm/i915/guc: Fix lockdep due to log relay channel handling under struct_mutex
This patch fixes lockdep issue due to circular locking dependency of
struct_mutex, i_mutex_key, mmap_sem, relay_channels_mutex.
For GuC log relay channel we create debugfs file that requires i_mutex_key
lock and we are doing that under struct_mutex. So we introduced newer
dependency as:
&dev->struct_mutex --> &sb->s_type->i_mutex_key#3 --> &mm->mmap_sem
However, there is dependency from mmap_sem to struct_mutex. Hence we
separate the relay create/destroy operation from under struct_mutex.
Also added runtime check of relay buffer status.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
======================================================
WARNING: possible circular locking dependency detected
4.15.0-rc6-CI-Patchwork_7614+ #1 Not tainted
------------------------------------------------------
debugfs_test/1388 is trying to acquire lock:
(&dev->struct_mutex){+.+.}, at: [<00000000d5e1d915>] i915_mutex_lock_interruptible+0x47/0x130 [i915]
but task is already holding lock:
(&mm->mmap_sem){++++}, at: [<0000000029a9c131>] __do_page_fault+0x106/0x560
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #3 (&mm->mmap_sem){++++}:
_copy_to_user+0x1e/0x70
filldir+0x8c/0xf0
dcache_readdir+0xeb/0x160
iterate_dir+0xdc/0x140
SyS_getdents+0xa0/0x130
entry_SYSCALL_64_fastpath+0x1c/0x89
-> #2 (&sb->s_type->i_mutex_key#3){++++}:
start_creating+0x59/0x110
__debugfs_create_file+0x2e/0xe0
relay_create_buf_file+0x62/0x80
relay_late_setup_files+0x84/0x250
guc_log_late_setup+0x4f/0x110 [i915]
i915_guc_log_register+0x32/0x40 [i915]
i915_driver_load+0x7b6/0x1720 [i915]
i915_pci_probe+0x2e/0x90 [i915]
pci_device_probe+0x9c/0x120
driver_probe_device+0x2a3/0x480
__driver_attach+0xd9/0xe0
bus_for_each_dev+0x57/0x90
bus_add_driver+0x168/0x260
driver_register+0x52/0xc0
do_one_initcall+0x39/0x150
do_init_module+0x56/0x1ef
load_module+0x231c/0x2d70
SyS_finit_module+0xa5/0xe0
entry_SYSCALL_64_fastpath+0x1c/0x89
-> #1 (relay_channels_mutex){+.+.}:
relay_open+0x12c/0x2b0
intel_guc_log_runtime_create+0xab/0x230 [i915]
intel_guc_init+0x81/0x120 [i915]
intel_uc_init+0x29/0xa0 [i915]
i915_gem_init+0x182/0x530 [i915]
i915_driver_load+0xaa9/0x1720 [i915]
i915_pci_probe+0x2e/0x90 [i915]
pci_device_probe+0x9c/0x120
driver_probe_device+0x2a3/0x480
__driver_attach+0xd9/0xe0
bus_for_each_dev+0x57/0x90
bus_add_driver+0x168/0x260
driver_register+0x52/0xc0
do_one_initcall+0x39/0x150
do_init_module+0x56/0x1ef
load_module+0x231c/0x2d70
SyS_finit_module+0xa5/0xe0
entry_SYSCALL_64_fastpath+0x1c/0x89
-> #0 (&dev->struct_mutex){+.+.}:
__mutex_lock+0x81/0x9b0
i915_mutex_lock_interruptible+0x47/0x130 [i915]
i915_gem_fault+0x201/0x790 [i915]
__do_fault+0x15/0x70
__handle_mm_fault+0x677/0xdc0
handle_mm_fault+0x14f/0x2f0
__do_page_fault+0x2d1/0x560
page_fault+0x4c/0x60
other info that might help us debug this:
Chain exists of:
&dev->struct_mutex --> &sb->s_type->i_mutex_key#3 --> &mm->mmap_sem
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&mm->mmap_sem);
lock(&sb->s_type->i_mutex_key#3);
lock(&mm->mmap_sem);
lock(&dev->struct_mutex);
*** DEADLOCK ***
1 lock held by debugfs_test/1388:
#0: (&mm->mmap_sem){++++}, at: [<0000000029a9c131>] __do_page_fault+0x106/0x560
stack backtrace:
CPU: 2 PID: 1388 Comm: debugfs_test Not tainted 4.15.0-rc6-CI-Patchwork_7614+ #1
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./J4205-ITX, BIOS P1.10 09/29/2016
Call Trace:
dump_stack+0x5f/0x86
print_circular_bug.isra.18+0x1d0/0x2c0
__lock_acquire+0x14ae/0x1b60
? lock_acquire+0xaf/0x200
lock_acquire+0xaf/0x200
? i915_mutex_lock_interruptible+0x47/0x130 [i915]
__mutex_lock+0x81/0x9b0
? i915_mutex_lock_interruptible+0x47/0x130 [i915]
? i915_mutex_lock_interruptible+0x47/0x130 [i915]
? i915_mutex_lock_interruptible+0x47/0x130 [i915]
i915_mutex_lock_interruptible+0x47/0x130 [i915]
? __pm_runtime_resume+0x4f/0x80
i915_gem_fault+0x201/0x790 [i915]
__do_fault+0x15/0x70
? _raw_spin_unlock+0x29/0x40
__handle_mm_fault+0x677/0xdc0
handle_mm_fault+0x14f/0x2f0
__do_page_fault+0x2d1/0x560
? page_fault+0x36/0x60
page_fault+0x4c/0x60
v2: Added lock protection to guc->log.runtime.relay_chan (Chris)
Fixed locking inside guc_flush_logs uncovered by new lockdep.
v3: Locking guc_read_update_log_buffer entirely with relay_lock. (Chris)
Prepared intel_guc_init_early. Moved relay_lock inside relay_create
relay_destroy, relay_file_create, guc_read_update_log_buffer. (Michal)
Removed struct_mutex lock around guc_log_flush and removed usage
of guc_log_has_relay() from runtime_create path as it needs
struct_mutex lock.
v4: Handle NULL relay sub buffer pointer earlier in read_update_log_buffer
(Chris). Fixed comment suffix **/. (Michal)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104693
Testcase: igt/debugfs_test/read_all_entries # with enable_guc=1 and guc_log_level=1
Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Marta Lofstedt <marta.lofstedt@intel.com>
Cc: Michal Winiarski <michal.winiarski@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/1516808821-3638-3-git-send-email-sagar.a.kamble@intel.com
2018-01-24 22:46:58 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (!USES_GUC(i915))
|
2017-12-14 05:13:47 +07:00
|
|
|
return;
|
|
|
|
|
2018-06-28 21:15:21 +07:00
|
|
|
if (USES_HUC(i915))
|
|
|
|
intel_huc_fini_misc(huc);
|
|
|
|
|
2018-06-28 21:15:20 +07:00
|
|
|
intel_guc_fini_misc(guc);
|
2017-12-14 05:13:47 +07:00
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
int intel_uc_init(struct drm_i915_private *i915)
|
2017-03-14 21:28:11 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
struct intel_guc *guc = &i915->guc;
|
2019-04-20 06:00:13 +07:00
|
|
|
struct intel_huc *huc = &i915->huc;
|
2017-12-14 05:13:48 +07:00
|
|
|
int ret;
|
2017-03-14 21:28:11 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (!USES_GUC(i915))
|
2017-03-28 23:53:47 +07:00
|
|
|
return 0;
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (!HAS_GUC(i915))
|
2017-12-14 05:13:48 +07:00
|
|
|
return -ENODEV;
|
2017-03-14 21:28:11 +07:00
|
|
|
|
2019-05-28 01:35:58 +07:00
|
|
|
/* XXX: GuC submission is unavailable for now */
|
|
|
|
GEM_BUG_ON(USES_GUC_SUBMISSION(i915));
|
|
|
|
|
2017-12-14 05:13:46 +07:00
|
|
|
ret = intel_guc_init(guc);
|
|
|
|
if (ret)
|
2017-12-14 05:13:48 +07:00
|
|
|
return ret;
|
2017-03-14 21:28:11 +07:00
|
|
|
|
2019-04-20 06:00:13 +07:00
|
|
|
if (USES_HUC(i915)) {
|
|
|
|
ret = intel_huc_init(huc);
|
|
|
|
if (ret)
|
|
|
|
goto err_guc;
|
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (USES_GUC_SUBMISSION(i915)) {
|
2017-03-23 00:39:52 +07:00
|
|
|
/*
|
|
|
|
* This is stuff we need to have available at fw load time
|
|
|
|
* if we are planning to enable submission later
|
|
|
|
*/
|
2017-11-16 20:32:39 +07:00
|
|
|
ret = intel_guc_submission_init(guc);
|
2019-04-20 06:00:13 +07:00
|
|
|
if (ret)
|
|
|
|
goto err_huc;
|
2017-03-23 00:39:52 +07:00
|
|
|
}
|
2017-03-14 21:28:11 +07:00
|
|
|
|
2017-12-14 05:13:48 +07:00
|
|
|
return 0;
|
2019-04-20 06:00:13 +07:00
|
|
|
|
|
|
|
err_huc:
|
|
|
|
if (USES_HUC(i915))
|
|
|
|
intel_huc_fini(huc);
|
|
|
|
err_guc:
|
|
|
|
intel_guc_fini(guc);
|
|
|
|
return ret;
|
2017-12-14 05:13:48 +07:00
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
void intel_uc_fini(struct drm_i915_private *i915)
|
2017-12-14 05:13:48 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
struct intel_guc *guc = &i915->guc;
|
2017-12-14 05:13:48 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (!USES_GUC(i915))
|
2017-12-14 05:13:48 +07:00
|
|
|
return;
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
GEM_BUG_ON(!HAS_GUC(i915));
|
2017-12-14 05:13:48 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (USES_GUC_SUBMISSION(i915))
|
2017-12-14 05:13:48 +07:00
|
|
|
intel_guc_submission_fini(guc);
|
|
|
|
|
2019-04-20 06:00:13 +07:00
|
|
|
if (USES_HUC(i915))
|
|
|
|
intel_huc_fini(&i915->huc);
|
|
|
|
|
2017-12-14 05:13:48 +07:00
|
|
|
intel_guc_fini(guc);
|
|
|
|
}
|
|
|
|
|
2019-05-23 02:31:59 +07:00
|
|
|
static void __uc_sanitize(struct drm_i915_private *i915)
|
2018-03-12 20:03:07 +07:00
|
|
|
{
|
|
|
|
struct intel_guc *guc = &i915->guc;
|
|
|
|
struct intel_huc *huc = &i915->huc;
|
|
|
|
|
|
|
|
GEM_BUG_ON(!HAS_GUC(i915));
|
|
|
|
|
|
|
|
intel_huc_sanitize(huc);
|
|
|
|
intel_guc_sanitize(guc);
|
|
|
|
|
|
|
|
__intel_uc_reset_hw(i915);
|
|
|
|
}
|
|
|
|
|
2019-05-23 02:31:59 +07:00
|
|
|
void intel_uc_sanitize(struct drm_i915_private *i915)
|
|
|
|
{
|
|
|
|
if (!USES_GUC(i915))
|
|
|
|
return;
|
|
|
|
|
|
|
|
__uc_sanitize(i915);
|
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
int intel_uc_init_hw(struct drm_i915_private *i915)
|
2017-12-14 05:13:48 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
struct intel_guc *guc = &i915->guc;
|
|
|
|
struct intel_huc *huc = &i915->huc;
|
2017-12-14 05:13:48 +07:00
|
|
|
int ret, attempts;
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (!USES_GUC(i915))
|
2017-12-14 05:13:48 +07:00
|
|
|
return 0;
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
GEM_BUG_ON(!HAS_GUC(i915));
|
2017-12-14 05:13:48 +07:00
|
|
|
|
2019-05-28 01:36:07 +07:00
|
|
|
guc_reset_interrupts(guc);
|
2017-12-14 05:13:48 +07:00
|
|
|
|
2017-03-14 21:28:11 +07: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-13 01:10:43 +07:00
|
|
|
if (IS_GEN(i915, 9))
|
2017-03-14 21:28:11 +07: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
|
|
|
|
*/
|
2018-05-25 19:18:58 +07:00
|
|
|
ret = __intel_uc_reset_hw(i915);
|
2017-03-14 21:28:11 +07:00
|
|
|
if (ret)
|
2017-12-14 05:13:48 +07:00
|
|
|
goto err_out;
|
2017-03-14 21:28:11 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (USES_HUC(i915)) {
|
2018-03-01 23:45:45 +07:00
|
|
|
ret = intel_huc_fw_upload(huc);
|
2017-12-06 20:53:16 +07:00
|
|
|
if (ret)
|
2017-12-14 05:13:48 +07:00
|
|
|
goto err_out;
|
2017-12-06 20:53:16 +07:00
|
|
|
}
|
|
|
|
|
2019-05-28 01:36:00 +07:00
|
|
|
intel_guc_ads_reset(guc);
|
2017-10-16 21:47:11 +07:00
|
|
|
intel_guc_init_params(guc);
|
2017-10-16 21:47:14 +07:00
|
|
|
ret = intel_guc_fw_upload(guc);
|
2019-03-30 06:17:46 +07:00
|
|
|
if (ret == 0)
|
2017-03-14 21:28:11 +07: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-23 00:50:28 +07:00
|
|
|
goto err_log_capture;
|
2017-03-14 21:28:11 +07:00
|
|
|
|
2017-05-02 17:32:42 +07:00
|
|
|
ret = guc_enable_communication(guc);
|
|
|
|
if (ret)
|
2017-05-23 00:50:28 +07:00
|
|
|
goto err_log_capture;
|
2017-05-02 17:32:42 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (USES_HUC(i915)) {
|
2017-12-06 20:53:16 +07:00
|
|
|
ret = intel_huc_auth(huc);
|
|
|
|
if (ret)
|
|
|
|
goto err_communication;
|
|
|
|
}
|
|
|
|
|
2019-05-28 01:36:01 +07:00
|
|
|
ret = intel_guc_sample_forcewake(guc);
|
|
|
|
if (ret)
|
|
|
|
goto err_communication;
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (USES_GUC_SUBMISSION(i915)) {
|
2017-11-16 20:32:39 +07:00
|
|
|
ret = intel_guc_submission_enable(guc);
|
2017-03-14 21:28:11 +07:00
|
|
|
if (ret)
|
2018-03-19 16:53:36 +07:00
|
|
|
goto err_communication;
|
2017-03-14 21:28:11 +07:00
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
dev_info(i915->drm.dev, "GuC firmware version %u.%u\n",
|
2017-10-16 21:47:17 +07:00
|
|
|
guc->fw.major_ver_found, guc->fw.minor_ver_found);
|
2018-05-25 19:18:58 +07:00
|
|
|
dev_info(i915->drm.dev, "GuC submission %s\n",
|
|
|
|
enableddisabled(USES_GUC_SUBMISSION(i915)));
|
|
|
|
dev_info(i915->drm.dev, "HuC %s\n",
|
|
|
|
enableddisabled(USES_HUC(i915)));
|
2017-10-16 21:47:17 +07:00
|
|
|
|
2017-03-14 21:28:11 +07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We've failed to load the firmware :(
|
|
|
|
*/
|
2017-12-06 20:53:16 +07:00
|
|
|
err_communication:
|
|
|
|
guc_disable_communication(guc);
|
2017-05-23 00:50:28 +07:00
|
|
|
err_log_capture:
|
|
|
|
guc_capture_load_err_log(guc);
|
2017-12-06 20:53:15 +07:00
|
|
|
err_out:
|
2019-05-23 02:31:59 +07:00
|
|
|
__uc_sanitize(i915);
|
|
|
|
|
2017-12-06 20:53:15 +07:00
|
|
|
/*
|
|
|
|
* Note that there is no fallback as either user explicitly asked for
|
|
|
|
* the GuC or driver default option was to run with the GuC enabled.
|
|
|
|
*/
|
|
|
|
if (GEM_WARN_ON(ret == -EIO))
|
|
|
|
ret = -EINVAL;
|
2017-03-14 21:28:11 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
dev_err(i915->drm.dev, "GuC initialization failed %d\n", ret);
|
2017-03-14 21:28:11 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
void intel_uc_fini_hw(struct drm_i915_private *i915)
|
2017-03-23 00:39:46 +07:00
|
|
|
{
|
2018-05-25 19:18:58 +07:00
|
|
|
struct intel_guc *guc = &i915->guc;
|
2017-11-16 20:32:39 +07:00
|
|
|
|
2019-05-23 02:32:01 +07:00
|
|
|
if (!intel_guc_is_loaded(guc))
|
2017-03-28 23:53:47 +07:00
|
|
|
return;
|
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
GEM_BUG_ON(!HAS_GUC(i915));
|
2017-12-14 05:13:48 +07:00
|
|
|
|
2018-05-25 19:18:58 +07:00
|
|
|
if (USES_GUC_SUBMISSION(i915))
|
2017-11-16 20:32:39 +07:00
|
|
|
intel_guc_submission_disable(guc);
|
2017-05-26 18:13:24 +07:00
|
|
|
|
2017-11-16 20:32:39 +07:00
|
|
|
guc_disable_communication(guc);
|
2019-05-23 02:31:59 +07:00
|
|
|
__uc_sanitize(i915);
|
2017-03-23 00:39:46 +07:00
|
|
|
}
|
2018-03-02 18:15:49 +07:00
|
|
|
|
2019-02-20 08:39:27 +07:00
|
|
|
/**
|
|
|
|
* intel_uc_reset_prepare - Prepare for reset
|
|
|
|
* @i915: device private
|
|
|
|
*
|
|
|
|
* Preparing for full gpu reset.
|
|
|
|
*/
|
|
|
|
void intel_uc_reset_prepare(struct drm_i915_private *i915)
|
|
|
|
{
|
|
|
|
struct intel_guc *guc = &i915->guc;
|
|
|
|
|
2019-05-23 02:32:03 +07:00
|
|
|
if (!intel_guc_is_loaded(guc))
|
2019-02-20 08:39:27 +07:00
|
|
|
return;
|
|
|
|
|
2019-05-24 00:25:55 +07:00
|
|
|
guc_stop_communication(guc);
|
2019-05-23 02:31:59 +07:00
|
|
|
__uc_sanitize(i915);
|
2019-02-20 08:39:27 +07:00
|
|
|
}
|
|
|
|
|
2019-05-03 03:30:09 +07:00
|
|
|
void intel_uc_runtime_suspend(struct drm_i915_private *i915)
|
2018-03-02 18:15:49 +07:00
|
|
|
{
|
|
|
|
struct intel_guc *guc = &i915->guc;
|
|
|
|
int err;
|
|
|
|
|
2019-05-23 02:32:00 +07:00
|
|
|
if (!intel_guc_is_loaded(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-25 03:07:17 +07:00
|
|
|
return;
|
2018-03-02 18:15:49 +07:00
|
|
|
|
2019-05-03 03:30:09 +07:00
|
|
|
err = intel_guc_suspend(guc);
|
|
|
|
if (err)
|
|
|
|
DRM_DEBUG_DRIVER("Failed to suspend GuC, err=%d", err);
|
2018-03-02 18:15:49 +07:00
|
|
|
|
2019-05-03 03:30:09 +07:00
|
|
|
guc_disable_communication(guc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void intel_uc_suspend(struct drm_i915_private *i915)
|
|
|
|
{
|
|
|
|
struct intel_guc *guc = &i915->guc;
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
2019-05-23 02:32:00 +07:00
|
|
|
if (!intel_guc_is_loaded(guc))
|
2019-05-03 03:30:09 +07:00
|
|
|
return;
|
|
|
|
|
2019-06-14 06:21:55 +07:00
|
|
|
with_intel_runtime_pm(&i915->runtime_pm, wakeref)
|
2019-05-03 03:30:09 +07:00
|
|
|
intel_uc_runtime_suspend(i915);
|
2018-03-02 18:15:49 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int intel_uc_resume(struct drm_i915_private *i915)
|
|
|
|
{
|
|
|
|
struct intel_guc *guc = &i915->guc;
|
|
|
|
int err;
|
|
|
|
|
2019-05-23 02:32:00 +07:00
|
|
|
if (!intel_guc_is_loaded(guc))
|
2018-03-02 18:15:49 +07:00
|
|
|
return 0;
|
|
|
|
|
2019-02-20 08:39:27 +07:00
|
|
|
guc_enable_communication(guc);
|
2018-03-02 18:15:49 +07:00
|
|
|
|
|
|
|
err = intel_guc_resume(guc);
|
|
|
|
if (err) {
|
|
|
|
DRM_DEBUG_DRIVER("Failed to resume GuC, err=%d", err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|