firmware: qcom: scm: Add function to set the maximum IOMMU pool size
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
Wed, 8 Dec 2021 08:34:22 +0000 (09:34 +0100)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Mon, 31 Jan 2022 21:00:46 +0000 (15:00 -0600)
This is not necessary for basic functionality of the IOMMU, but
it's an optimization that tells to the TZ what's the maximum
mappable size for the secure IOMMUs, so that it can optimize
the data structures in the TZ itself.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
[Marijn: ported from 5.3 to the unified architecture in 5.11]
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20211208083423.22037-3-marijn.suijten@somainline.org
drivers/firmware/qcom_scm.c
drivers/firmware/qcom_scm.h
include/linux/qcom_scm.h

index 3f67bf774821d0d689f8e5944dae4225c0ed4cb1..d5a9ba15e2ba3ae7db00c89f5e96adb2ff2c3b29 100644 (file)
@@ -759,6 +759,21 @@ int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare)
 }
 EXPORT_SYMBOL(qcom_scm_iommu_secure_ptbl_init);
 
+int qcom_scm_iommu_set_cp_pool_size(u32 spare, u32 size)
+{
+       struct qcom_scm_desc desc = {
+               .svc = QCOM_SCM_SVC_MP,
+               .cmd = QCOM_SCM_MP_IOMMU_SET_CP_POOL_SIZE,
+               .arginfo = QCOM_SCM_ARGS(2),
+               .args[0] = size,
+               .args[1] = spare,
+               .owner = ARM_SMCCC_OWNER_SIP,
+       };
+
+       return qcom_scm_call(__scm->dev, &desc, NULL);
+}
+EXPORT_SYMBOL(qcom_scm_iommu_set_cp_pool_size);
+
 int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,
                                   u32 cp_nonpixel_start,
                                   u32 cp_nonpixel_size)
index d92156ceb3ac57283c1d20f3c7a5934cca74b064..bb627941702bf550d78962e50f3e16324fa5fa98 100644 (file)
@@ -100,6 +100,7 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc,
 #define QCOM_SCM_MP_RESTORE_SEC_CFG            0x02
 #define QCOM_SCM_MP_IOMMU_SECURE_PTBL_SIZE     0x03
 #define QCOM_SCM_MP_IOMMU_SECURE_PTBL_INIT     0x04
+#define QCOM_SCM_MP_IOMMU_SET_CP_POOL_SIZE     0x05
 #define QCOM_SCM_MP_VIDEO_VAR                  0x08
 #define QCOM_SCM_MP_ASSIGN                     0x16
 
index 81cad9e1e4120f5db1146cb65f4e6e7a25ceea84..8a065f8660c103bd7f357d653b78b38df05ccba9 100644 (file)
@@ -83,6 +83,7 @@ extern bool qcom_scm_restore_sec_cfg_available(void);
 extern int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare);
 extern int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size);
 extern int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare);
+extern int qcom_scm_iommu_set_cp_pool_size(u32 spare, u32 size);
 extern int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,
                                          u32 cp_nonpixel_start,
                                          u32 cp_nonpixel_size);