mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-24 23:34:40 +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
128 lines
3.5 KiB
C
128 lines
3.5 KiB
C
/*
|
|
* Copyright © 2016-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.
|
|
*
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include "intel_huc.h"
|
|
#include "i915_drv.h"
|
|
|
|
void intel_huc_init_early(struct intel_huc *huc)
|
|
{
|
|
intel_huc_fw_init_early(huc);
|
|
}
|
|
|
|
int intel_huc_init_misc(struct intel_huc *huc)
|
|
{
|
|
struct drm_i915_private *i915 = huc_to_i915(huc);
|
|
|
|
intel_uc_fw_fetch(i915, &huc->fw);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* intel_huc_auth() - Authenticate HuC uCode
|
|
* @huc: intel_huc structure
|
|
*
|
|
* Called after HuC and GuC firmware loading during intel_uc_init_hw().
|
|
*
|
|
* This function pins HuC firmware image object into GGTT.
|
|
* Then it invokes GuC action to authenticate passing the offset to RSA
|
|
* signature through intel_guc_auth_huc(). It then waits for 50ms for
|
|
* firmware verification ACK and unpins the object.
|
|
*/
|
|
int intel_huc_auth(struct intel_huc *huc)
|
|
{
|
|
struct drm_i915_private *i915 = huc_to_i915(huc);
|
|
struct intel_guc *guc = &i915->guc;
|
|
struct i915_vma *vma;
|
|
u32 status;
|
|
int ret;
|
|
|
|
if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
|
|
return -ENOEXEC;
|
|
|
|
vma = i915_gem_object_ggtt_pin(huc->fw.obj, NULL, 0, 0,
|
|
PIN_OFFSET_BIAS | i915->ggtt.pin_bias);
|
|
if (IS_ERR(vma)) {
|
|
ret = PTR_ERR(vma);
|
|
DRM_ERROR("HuC: Failed to pin huc fw object %d\n", ret);
|
|
goto fail;
|
|
}
|
|
|
|
ret = intel_guc_auth_huc(guc,
|
|
intel_guc_ggtt_offset(guc, vma) +
|
|
huc->fw.rsa_offset);
|
|
if (ret) {
|
|
DRM_ERROR("HuC: GuC did not ack Auth request %d\n", ret);
|
|
goto fail_unpin;
|
|
}
|
|
|
|
/* Check authentication status, it should be done by now */
|
|
ret = __intel_wait_for_register(i915,
|
|
HUC_STATUS2,
|
|
HUC_FW_VERIFIED,
|
|
HUC_FW_VERIFIED,
|
|
2, 50, &status);
|
|
if (ret) {
|
|
DRM_ERROR("HuC: Firmware not verified %#x\n", status);
|
|
goto fail_unpin;
|
|
}
|
|
|
|
i915_vma_unpin(vma);
|
|
return 0;
|
|
|
|
fail_unpin:
|
|
i915_vma_unpin(vma);
|
|
fail:
|
|
huc->fw.load_status = INTEL_UC_FIRMWARE_FAIL;
|
|
|
|
DRM_ERROR("HuC: Authentication failed %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* intel_huc_check_status() - check HuC status
|
|
* @huc: intel_huc structure
|
|
*
|
|
* This function reads status register to verify if HuC
|
|
* firmware was successfully loaded.
|
|
*
|
|
* Returns positive value if HuC firmware is loaded and verified
|
|
* and -ENODEV if HuC is not present.
|
|
*/
|
|
int intel_huc_check_status(struct intel_huc *huc)
|
|
{
|
|
struct drm_i915_private *dev_priv = huc_to_i915(huc);
|
|
u32 status;
|
|
|
|
if (!HAS_HUC(dev_priv))
|
|
return -ENODEV;
|
|
|
|
intel_runtime_pm_get(dev_priv);
|
|
status = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED;
|
|
intel_runtime_pm_put(dev_priv);
|
|
|
|
return status;
|
|
}
|