venus_load_fw() calls qcom_mdt_load(), which bundles metadata initialization, memory setup, and segment loading into a single API that does not expose a PAS context. venus_boot() calls qcom_pas_auth_and_reset() for TrustZone authentication, which is the intended behaviour. However, a new qcom_mdt_pas_load() has recently been introduced that works with a PAS context and can handle everything qcom_mdt_load() provides, along with additional functionality such as shmbridge creation and retrieving memory from the shmbridge buffer when the same remote processor needs to run while Linux runs at EL2. Embed a struct qcom_pas_context in struct video_firmware and initialize it with qcom_pas_context_init() inside venus_load_fw() on each call. Replace qcom_mdt_load() with qcom_mdt_pas_load() for the TZ path and replace qcom_pas_auth_and_reset() with qcom_pas_prepare_and_auth_reset(). The non-TZ path retains its memremap()/qcom_mdt_load_no_init()/memunmap() sequence since qcom_mdt_load_no_init() requires a caller-supplied mapping. Signed-off-by: Mukesh Ojha --- drivers/media/platform/qcom/venus/core.h | 2 ++ drivers/media/platform/qcom/venus/firmware.c | 29 ++++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 93fa77f05834..84a0d4a8426c 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -228,6 +229,7 @@ struct venus_core { size_t mapped_mem_size; phys_addr_t mem_phys; size_t mem_size; + struct qcom_pas_context pas_ctx; } fw; struct mutex lock; struct list_head instances; diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 3a38ff985822..704343e241dc 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -117,21 +117,22 @@ static int venus_load_fw(struct venus_core *core, const char *fwname, goto err_release_fw; } - mem_va = memremap(*mem_phys, *mem_size, MEMREMAP_WC); - if (!mem_va) { - dev_err(dev, "unable to map memory region %pa size %#zx\n", mem_phys, *mem_size); - ret = -ENOMEM; - goto err_release_fw; - } - - if (core->use_tz) - ret = qcom_mdt_load(dev, mdt, fwname, VENUS_PAS_ID, - mem_va, *mem_phys, *mem_size, NULL); - else + if (core->use_tz) { + qcom_pas_context_init(&core->fw.pas_ctx, dev, VENUS_PAS_ID, + *mem_phys, *mem_size); + ret = qcom_mdt_pas_load(&core->fw.pas_ctx, mdt, fwname, NULL); + } else { + mem_va = memremap(*mem_phys, *mem_size, MEMREMAP_WC); + if (!mem_va) { + dev_err(dev, "unable to map memory region %pa size %#zx\n", + mem_phys, *mem_size); + ret = -ENOMEM; + goto err_release_fw; + } ret = qcom_mdt_load_no_init(dev, mdt, fwname, mem_va, *mem_phys, *mem_size, NULL); - - memunmap(mem_va); + memunmap(mem_va); + } err_release_fw: release_firmware(mdt); return ret; @@ -237,7 +238,7 @@ int venus_boot(struct venus_core *core) core->fw.mem_phys = mem_phys; if (core->use_tz) - ret = qcom_pas_auth_and_reset(VENUS_PAS_ID); + ret = qcom_pas_prepare_and_auth_reset(&core->fw.pas_ctx); else ret = venus_boot_no_tz(core, mem_phys, mem_size); -- 2.55.0