Add a PAS context-aware qcom_mdt_pas_load() function for remote
processor drivers, which can use the context pointer returned from
qcom_scm_pas_ctx_init() to perform metadata verification and memory
setup via SMC calls.

The qcom_mdt_pas_load() and qcom_mdt_load() functions are almost
similar. Clients using the PAS context-based data structure can adopt
qcom_mdt_pas_load(), and in the future, all users of qcom_mdt_load()
could be migrated to use qcom_mdt_pas_load() instead.

Signed-off-by: Mukesh Ojha <[email protected]>
---
 drivers/soc/qcom/mdt_loader.c       | 29 +++++++++++++++++++++++++++++
 include/linux/soc/qcom/mdt_loader.h | 11 +++++++++++
 2 files changed, 40 insertions(+)

diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
index a5c80d4fcc36..31855836b251 100644
--- a/drivers/soc/qcom/mdt_loader.c
+++ b/drivers/soc/qcom/mdt_loader.c
@@ -486,5 +486,34 @@ int qcom_mdt_load_no_init(struct device *dev, const struct 
firmware *fw,
 }
 EXPORT_SYMBOL_GPL(qcom_mdt_load_no_init);
 
+/**
+ * qcom_mdt_pas_load() - load the firmware which header is loaded as fw
+ *
+ * Client should initialize the PAS context with qcom_scm_pas_context_init()
+ * before calling this function.
+ *
+ * @ctx:       PAS context pointer
+ * @fw:                firmware object for the mdt file
+ * @firmware:  name of the firmware, for construction of segment file names
+ * @mem_region:        allocated memory region to load firmware into
+ * @reloc_base:        adjusted physical address after relocation
+ *
+ * Returns 0 on success, negative errno otherwise.
+ */
+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->metadata);
+       if (ret)
+               return ret;
+
+       return __qcom_mdt_load(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");
diff --git a/include/linux/soc/qcom/mdt_loader.h 
b/include/linux/soc/qcom/mdt_loader.h
index 8ea8230579a2..2832e0717729 100644
--- a/include/linux/soc/qcom/mdt_loader.h
+++ b/include/linux/soc/qcom/mdt_loader.h
@@ -11,6 +11,7 @@
 struct device;
 struct firmware;
 struct qcom_scm_pas_metadata;
+struct qcom_scm_pas_context;
 
 #if IS_ENABLED(CONFIG_QCOM_MDT_LOADER)
 
@@ -23,6 +24,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 +56,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,

-- 
2.50.1


Reply via email to