zap_shader_load_mdt() uses qcom_mdt_load() which bundles metadata init, memory setup, and segment loading but exposes no PAS context, and then calls qcom_pas_auth_and_reset() which skips the shmbridge prepare step required before TrustZone authentication.
Replace the open-coded memremap()/qcom_mdt_load()/memunmap() sequence with devm_qcom_pas_context_alloc() and qcom_mdt_pas_load(), then pass the same context to qcom_pas_prepare_and_auth_reset(). The -EOPNOTSUPP handling for targets without zap shader support is preserved. Signed-off-by: Mukesh Ojha <[email protected]> --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index 5832dc25d6bf..d3e843220b73 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -34,11 +34,11 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, struct device *dev = &gpu->pdev->dev; const struct firmware *fw; const char *signed_fwname = NULL; + struct qcom_pas_context *ctx; struct device_node *np; struct resource r; phys_addr_t mem_phys; ssize_t mem_size; - void *mem_region = NULL; int ret; if (!IS_ENABLED(CONFIG_ARCH_QCOM)) { @@ -122,9 +122,9 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, } /* Allocate memory for the firmware image */ - mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC); - if (!mem_region) { - ret = -ENOMEM; + ctx = devm_qcom_pas_context_alloc(dev, pasid, mem_phys, resource_size(&r)); + if (IS_ERR(ctx)) { + ret = PTR_ERR(ctx); goto out; } @@ -133,27 +133,25 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, * * Note that we could be dealing with two different paths, since * with upstream linux-firmware it would be in a qcom/ subdir.. - * adreno_request_fw() handles this, but qcom_mdt_load() does + * adreno_request_fw() handles this, but qcom_mdt_pas_load() does * not. But since we've already gotten through adreno_request_fw() * we know which of the two cases it is: */ if (signed_fwname || (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY)) { - ret = qcom_mdt_load(dev, fw, fwname, pasid, - mem_region, mem_phys, mem_size, NULL); + ret = qcom_mdt_pas_load(ctx, fw, fwname, NULL); } else { char *newname; newname = kasprintf(GFP_KERNEL, "qcom/%s", fwname); - ret = qcom_mdt_load(dev, fw, newname, pasid, - mem_region, mem_phys, mem_size, NULL); + ret = qcom_mdt_pas_load(ctx, fw, newname, NULL); kfree(newname); } if (ret) goto out; /* Send the image to the secure world */ - ret = qcom_pas_auth_and_reset(pasid); + ret = qcom_pas_prepare_and_auth_reset(ctx); /* * If the pas call returns -EOPNOTSUPP we assume that this target @@ -165,9 +163,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, DRM_DEV_ERROR(dev, "Unable to authorize the image\n"); out: - if (mem_region) - memunmap(mem_region); - release_firmware(fw); return ret; -- 2.55.0

