drm/i915/huc: Copy huc rsa only once
The binary is perma-pinned and the rsa is not going to change, so copy it only once and not on every load. v2: onion unwind (Chris) Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: Fernando Pacheco <fernando.pacheco@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> #v1 Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/20190725001813.4740-7-daniele.ceraolospurio@intel.com
This commit is contained in:
parent
90dd992260
commit
9cb2794557
@ -50,6 +50,7 @@ static int intel_huc_rsa_data_create(struct intel_huc *huc)
|
|||||||
struct intel_gt *gt = huc_to_gt(huc);
|
struct intel_gt *gt = huc_to_gt(huc);
|
||||||
struct intel_guc *guc = >->uc.guc;
|
struct intel_guc *guc = >->uc.guc;
|
||||||
struct i915_vma *vma;
|
struct i915_vma *vma;
|
||||||
|
size_t copied;
|
||||||
void *vaddr;
|
void *vaddr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -62,6 +63,7 @@ static int intel_huc_rsa_data_create(struct intel_huc *huc)
|
|||||||
* the authentication since its GGTT offset will be GuC
|
* the authentication since its GGTT offset will be GuC
|
||||||
* accessible.
|
* accessible.
|
||||||
*/
|
*/
|
||||||
|
GEM_BUG_ON(huc->fw.rsa_size > PAGE_SIZE);
|
||||||
vma = intel_guc_allocate_vma(guc, PAGE_SIZE);
|
vma = intel_guc_allocate_vma(guc, PAGE_SIZE);
|
||||||
if (IS_ERR(vma))
|
if (IS_ERR(vma))
|
||||||
return PTR_ERR(vma);
|
return PTR_ERR(vma);
|
||||||
@ -72,26 +74,43 @@ static int intel_huc_rsa_data_create(struct intel_huc *huc)
|
|||||||
return PTR_ERR(vaddr);
|
return PTR_ERR(vaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copied = intel_uc_fw_copy_rsa(&huc->fw, vaddr, vma->size);
|
||||||
|
GEM_BUG_ON(copied < huc->fw.rsa_size);
|
||||||
|
|
||||||
|
i915_gem_object_unpin_map(vma->obj);
|
||||||
|
|
||||||
huc->rsa_data = vma;
|
huc->rsa_data = vma;
|
||||||
huc->rsa_data_vaddr = vaddr;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void intel_huc_rsa_data_destroy(struct intel_huc *huc)
|
static void intel_huc_rsa_data_destroy(struct intel_huc *huc)
|
||||||
{
|
{
|
||||||
i915_vma_unpin_and_release(&huc->rsa_data, I915_VMA_RELEASE_MAP);
|
i915_vma_unpin_and_release(&huc->rsa_data, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int intel_huc_init(struct intel_huc *huc)
|
int intel_huc_init(struct intel_huc *huc)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = intel_huc_rsa_data_create(huc);
|
err = intel_uc_fw_init(&huc->fw);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
return intel_uc_fw_init(&huc->fw);
|
/*
|
||||||
|
* HuC firmware image is outside GuC accessible range.
|
||||||
|
* Copy the RSA signature out of the image into
|
||||||
|
* a perma-pinned region set aside for it
|
||||||
|
*/
|
||||||
|
err = intel_huc_rsa_data_create(huc);
|
||||||
|
if (err)
|
||||||
|
goto out_fini;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
out_fini:
|
||||||
|
intel_uc_fw_fini(&huc->fw);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void intel_huc_fini(struct intel_huc *huc)
|
void intel_huc_fini(struct intel_huc *huc)
|
||||||
|
@ -35,7 +35,6 @@ struct intel_huc {
|
|||||||
|
|
||||||
/* HuC-specific additions */
|
/* HuC-specific additions */
|
||||||
struct i915_vma *rsa_data;
|
struct i915_vma *rsa_data;
|
||||||
void *rsa_data_vaddr;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
i915_reg_t reg;
|
i915_reg_t reg;
|
||||||
|
@ -34,21 +34,6 @@ void intel_huc_fw_init_early(struct intel_huc *huc)
|
|||||||
intel_uc_fw_init_early(&huc->fw, INTEL_UC_FW_TYPE_HUC, huc_to_gt(huc)->i915);
|
intel_uc_fw_init_early(&huc->fw, INTEL_UC_FW_TYPE_HUC, huc_to_gt(huc)->i915);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void huc_xfer_rsa(struct intel_huc *huc)
|
|
||||||
{
|
|
||||||
size_t copied;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* HuC firmware image is outside GuC accessible range.
|
|
||||||
* Copy the RSA signature out of the image into
|
|
||||||
* the perma-pinned region set aside for it
|
|
||||||
*/
|
|
||||||
GEM_BUG_ON(huc->fw.rsa_size > huc->rsa_data->size);
|
|
||||||
copied = intel_uc_fw_copy_rsa(&huc->fw, huc->rsa_data_vaddr,
|
|
||||||
huc->rsa_data->size);
|
|
||||||
GEM_BUG_ON(copied < huc->fw.rsa_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int huc_xfer_ucode(struct intel_huc *huc)
|
static int huc_xfer_ucode(struct intel_huc *huc)
|
||||||
{
|
{
|
||||||
struct intel_uc_fw *huc_fw = &huc->fw;
|
struct intel_uc_fw *huc_fw = &huc->fw;
|
||||||
@ -108,8 +93,6 @@ static int huc_fw_xfer(struct intel_uc_fw *huc_fw)
|
|||||||
{
|
{
|
||||||
struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw);
|
struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw);
|
||||||
|
|
||||||
huc_xfer_rsa(huc);
|
|
||||||
|
|
||||||
return huc_xfer_ucode(huc);
|
return huc_xfer_ucode(huc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user