Skip to content
Open
15 changes: 13 additions & 2 deletions drivers/media/platform/qcom/iris/iris_firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/of_address.h>
#include <linux/of_reserved_mem.h>
#include <linux/soc/qcom/mdt_loader.h>
#include <linux/string.h>

#include "iris_core.h"
#include "iris_firmware.h"
Expand Down Expand Up @@ -186,6 +187,7 @@ static void iris_fw_iommu_unmap(struct iris_core *core)
int iris_fw_load(struct iris_core *core)
{
const struct tz_cp_config *cp_config;
const char *pas_backend;
int i, ret;

ret = iris_load_fw_to_memory(core);
Expand All @@ -200,6 +202,15 @@ int iris_fw_load(struct iris_core *core)
goto err_unmap;
}

/*
* qcom_scm_mem_protect_video_var() only applies to the SCM backend;
* other backends (e.g. OP-TEE) own secure memory protection and do
* not service this call.
*/
pas_backend = qcom_pas_get_backend();
if (!pas_backend || strcmp(pas_backend, QCOM_PAS_BACKEND_SCM))
return 0;

for (i = 0; i < core->iris_platform_data->tz_cp_config_data_size; i++) {
cp_config = &core->iris_platform_data->tz_cp_config_data[i];
ret = qcom_scm_mem_protect_video_var(cp_config->cp_start,
Expand All @@ -215,7 +226,7 @@ int iris_fw_load(struct iris_core *core)
return 0;

err_pas_shutdown:
qcom_scm_pas_shutdown(IRIS_PAS_ID);
qcom_pas_shutdown(IRIS_PAS_ID);
err_unmap:
iris_fw_iommu_unmap(core);

Expand All @@ -226,7 +237,7 @@ int iris_fw_unload(struct iris_core *core)
{
int ret;

ret = qcom_scm_pas_shutdown(IRIS_PAS_ID);
ret = qcom_pas_shutdown(IRIS_PAS_ID);
iris_fw_iommu_unmap(core);

return ret;
Expand Down
16 changes: 13 additions & 3 deletions drivers/media/platform/qcom/venus/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/sizes.h>
#include <linux/soc/qcom/mdt_loader.h>
#include <dt-bindings/media/qcom,qcs615-venus.h>
#include <linux/string.h>

#include "core.h"
#include "firmware.h"
Expand Down Expand Up @@ -254,12 +255,13 @@ int venus_boot(struct venus_core *core)
const struct venus_resources *res = core->res;
const struct firmware *mdt;
const char *fwpath = NULL;
const char *pas_backend;
phys_addr_t mem_phys;
size_t res_size;
int ret;

if (!IS_ENABLED(CONFIG_QCOM_MDT_LOADER) ||
(!core->use_tz && !core->fw.dev))
(!core->use_tz && !qcom_pas_is_available()))
return driver_deferred_probe_check_state(core->dev);

ret = of_property_read_string_index(dev->of_node, "firmware-name", 0, &fwpath);
Expand All @@ -283,6 +285,14 @@ int venus_boot(struct venus_core *core)
}

if (core->use_tz && res->cp_size) {
/*
* qcom_scm_mem_protect_video_var() only applies to the SCM
* backend; other backends (e.g. OP-TEE) own secure memory
* protection and do not service this call.
*/
pas_backend = qcom_pas_get_backend();
if (!pas_backend || strcmp(pas_backend, QCOM_PAS_BACKEND_SCM))
return ret;
/*
* Clues for porting using downstream data:
* cp_start = 0
Expand Down Expand Up @@ -411,8 +421,8 @@ static int venus_firmware_init_auto_detect(struct venus_core *core)
int ret;

core->use_tz = false;
if (qcom_scm_is_available()) {
if (qcom_scm_pas_supported(VENUS_PAS_ID))
if (qcom_pas_is_available()) {
if (qcom_pas_supported(VENUS_PAS_ID))
core->use_tz = true;
} else {
ret = driver_deferred_probe_check_state(core->dev);
Expand Down