]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soc: qcom: mdtloader: Add PAS context aware qcom_mdt_pas_load() function
authorMukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Mon, 5 Jan 2026 13:22:54 +0000 (18:52 +0530)
committerBjorn Andersson <andersson@kernel.org>
Tue, 13 Jan 2026 18:14:34 +0000 (12:14 -0600)
Introduce a new PAS context-aware function, qcom_mdt_pas_load(), for
remote processor drivers. This function utilizes the PAS context
pointer returned from qcom_scm_pas_ctx_init() to perform firmware
metadata verification and memory setup via SMC calls.

The qcom_mdt_pas_load() and qcom_mdt_load() functions are largely
similar, but the former is designed for clients using the PAS
context-based data structure. Over time, all users of qcom_mdt_load()
can be migrated to use qcom_mdt_pas_load() for consistency and
improved abstraction.

As the remoteproc PAS driver (qcom_q6v5_pas) has already adopted the
PAS context-based approach, update it to use qcom_mdt_pas_load().

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260105-kvmrprocv10-v10-6-022e96815380@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/remoteproc/qcom_q6v5_pas.c
drivers/soc/qcom/mdt_loader.c
include/linux/soc/qcom/mdt_loader.h

index bfcb65aed00862868bd0c6b2c8655bb42dab2c86..f746d2f39a1d89cef2f1470eb548c9903cf3d66a 100644 (file)
@@ -239,15 +239,9 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)
                        return ret;
                }
 
-               ret = qcom_mdt_pas_init(pas->dev, pas->dtb_firmware, pas->dtb_firmware_name,
-                                       pas->dtb_pas_id, pas->dtb_mem_phys,
-                                       pas->dtb_pas_ctx);
-               if (ret)
-                       goto release_dtb_firmware;
-
-               ret = qcom_mdt_load_no_init(pas->dev, pas->dtb_firmware, pas->dtb_firmware_name,
-                                           pas->dtb_mem_region, pas->dtb_mem_phys,
-                                           pas->dtb_mem_size, &pas->dtb_mem_reloc);
+               ret = qcom_mdt_pas_load(pas->dtb_pas_ctx, pas->dtb_firmware,
+                                       pas->dtb_firmware_name, pas->dtb_mem_region,
+                                       &pas->dtb_mem_reloc);
                if (ret)
                        goto release_dtb_metadata;
        }
@@ -256,8 +250,6 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)
 
 release_dtb_metadata:
        qcom_scm_pas_metadata_release(pas->dtb_pas_ctx);
-
-release_dtb_firmware:
        release_firmware(pas->dtb_firmware);
 
        return ret;
@@ -305,14 +297,8 @@ static int qcom_pas_start(struct rproc *rproc)
                }
        }
 
-       ret = qcom_mdt_pas_init(pas->dev, pas->firmware, rproc->firmware, pas->pas_id,
-                               pas->mem_phys, pas->pas_ctx);
-       if (ret)
-               goto disable_px_supply;
-
-       ret = qcom_mdt_load_no_init(pas->dev, pas->firmware, rproc->firmware,
-                                   pas->mem_region, pas->mem_phys, pas->mem_size,
-                                   &pas->mem_reloc);
+       ret = qcom_mdt_pas_load(pas->pas_ctx, pas->firmware, rproc->firmware,
+                               pas->mem_region, &pas->mem_reloc);
        if (ret)
                goto release_pas_metadata;
 
index b125140100db770e00b0605c0bb4a47ba0103b7d..50c6a3c6b2a3e9900a8197a5bdb83336b17e7cea 100644 (file)
@@ -478,5 +478,36 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
 }
 EXPORT_SYMBOL_GPL(qcom_mdt_load);
 
+/**
+ * qcom_mdt_pas_load - Loads and authenticates the metadata of the firmware
+ * (typically contained in the .mdt file), followed by loading the actual
+ * firmware segments (e.g., .bXX files). Authentication of the segments done
+ * by a separate call.
+ *
+ * The PAS context must be initialized using qcom_scm_pas_context_init()
+ * prior to invoking this function.
+ *
+ * @ctx:        Pointer to the PAS (Peripheral Authentication Service) context
+ * @fw:         Firmware object representing the .mdt file
+ * @firmware:   Name of the firmware used to construct segment file names
+ * @mem_region: Memory region allocated for loading the firmware
+ * @reloc_base: Physical address adjusted after relocation
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx, const struct firmware *fw,
+                     const char *firmware, void *mem_region, phys_addr_t *reloc_base)
+{
+       int ret;
+
+       ret = qcom_mdt_pas_init(ctx->dev, fw, firmware, ctx->pas_id, ctx->mem_phys, ctx);
+       if (ret)
+               return ret;
+
+       return qcom_mdt_load_no_init(ctx->dev, fw, firmware, mem_region, ctx->mem_phys,
+                                    ctx->mem_size, reloc_base);
+}
+EXPORT_SYMBOL_GPL(qcom_mdt_pas_load);
+
 MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format");
 MODULE_LICENSE("GPL v2");
index 07c27884181669b7a9c4522c70c537b81ea5bdff..7d57746fbbfa50ad8d59af337fc1ea71d5b340d1 100644 (file)
@@ -23,6 +23,9 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
                  phys_addr_t mem_phys, size_t mem_size,
                  phys_addr_t *reloc_base);
 
+int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx, const struct firmware *fw,
+                     const char *firmware, void *mem_region, phys_addr_t *reloc_base);
+
 int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
                          const char *fw_name, void *mem_region,
                          phys_addr_t mem_phys, size_t mem_size,
@@ -52,6 +55,13 @@ static inline int qcom_mdt_load(struct device *dev, const struct firmware *fw,
        return -ENODEV;
 }
 
+static inline int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx,
+                                   const struct firmware *fw, const char *firmware,
+                                   void *mem_region, phys_addr_t *reloc_base)
+{
+       return -ENODEV;
+}
+
 static inline int qcom_mdt_load_no_init(struct device *dev,
                                        const struct firmware *fw,
                                        const char *fw_name, void *mem_region,