]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
remoteproc: qcom: mdt_loader: Make the firmware authentication optional
authorSricharan R <sricharan@codeaurora.org>
Mon, 4 Jun 2018 20:30:35 +0000 (13:30 -0700)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Mon, 18 Jun 2018 22:55:31 +0000 (15:55 -0700)
qcom_mdt_load function loads the mdt type firmware and
initialises the secure memory as well. Make the initialisation only
when requested by the caller, so that the function can be used
by self-authenticating remoteproc as well.

Acked-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/soc/qcom/mdt_loader.c
include/linux/soc/qcom/mdt_loader.h

index dc09d7ac905fff805bedb073e2a4e79529f88032..1c488024c69874d1a8b613f96a5f292ff2cef729 100644 (file)
@@ -74,23 +74,10 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)
 }
 EXPORT_SYMBOL_GPL(qcom_mdt_get_size);
 
-/**
- * qcom_mdt_load() - load the firmware which header is loaded as fw
- * @dev:       device handle to associate resources with
- * @fw:                firmware object for the mdt file
- * @firmware:  name of the firmware, for construction of segment file names
- * @pas_id:    PAS identifier
- * @mem_region:        allocated memory region to load firmware into
- * @mem_phys:  physical address of allocated memory region
- * @mem_size:  size of the allocated memory region
- * @reloc_base:        adjusted physical address after relocation
- *
- * Returns 0 on success, negative errno otherwise.
- */
-int qcom_mdt_load(struct device *dev, const struct firmware *fw,
-                 const char *firmware, int pas_id, void *mem_region,
-                 phys_addr_t mem_phys, size_t mem_size,
-                 phys_addr_t *reloc_base)
+static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
+                          const char *firmware, int pas_id, void *mem_region,
+                          phys_addr_t mem_phys, size_t mem_size,
+                          phys_addr_t *reloc_base, bool pas_init)
 {
        const struct elf32_phdr *phdrs;
        const struct elf32_phdr *phdr;
@@ -121,10 +108,12 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
        if (!fw_name)
                return -ENOMEM;
 
-       ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size);
-       if (ret) {
-               dev_err(dev, "invalid firmware metadata\n");
-               goto out;
+       if (pas_init) {
+               ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size);
+               if (ret) {
+                       dev_err(dev, "invalid firmware metadata\n");
+                       goto out;
+               }
        }
 
        for (i = 0; i < ehdr->e_phnum; i++) {
@@ -144,10 +133,13 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
        }
 
        if (relocate) {
-               ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
-               if (ret) {
-                       dev_err(dev, "unable to setup relocation\n");
-                       goto out;
+               if (pas_init) {
+                       ret = qcom_scm_pas_mem_setup(pas_id, mem_phys,
+                                                    max_addr - min_addr);
+                       if (ret) {
+                               dev_err(dev, "unable to setup relocation\n");
+                               goto out;
+                       }
                }
 
                /*
@@ -202,7 +194,52 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
 
        return ret;
 }
+
+/**
+ * qcom_mdt_load() - load the firmware which header is loaded as fw
+ * @dev:       device handle to associate resources with
+ * @fw:                firmware object for the mdt file
+ * @firmware:  name of the firmware, for construction of segment file names
+ * @pas_id:    PAS identifier
+ * @mem_region:        allocated memory region to load firmware into
+ * @mem_phys:  physical address of allocated memory region
+ * @mem_size:  size of the allocated memory region
+ * @reloc_base:        adjusted physical address after relocation
+ *
+ * Returns 0 on success, negative errno otherwise.
+ */
+int qcom_mdt_load(struct device *dev, const struct firmware *fw,
+                 const char *firmware, int pas_id, void *mem_region,
+                 phys_addr_t mem_phys, size_t mem_size,
+                 phys_addr_t *reloc_base)
+{
+       return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys,
+                              mem_size, reloc_base, true);
+}
 EXPORT_SYMBOL_GPL(qcom_mdt_load);
 
+/**
+ * qcom_mdt_load_no_init() - load the firmware which header is loaded as fw
+ * @dev:       device handle to associate resources with
+ * @fw:                firmware object for the mdt file
+ * @firmware:  name of the firmware, for construction of segment file names
+ * @pas_id:    PAS identifier
+ * @mem_region:        allocated memory region to load firmware into
+ * @mem_phys:  physical address of allocated memory region
+ * @mem_size:  size of the allocated memory region
+ * @reloc_base:        adjusted physical address after relocation
+ *
+ * Returns 0 on success, negative errno otherwise.
+ */
+int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
+                         const char *firmware, int pas_id,
+                         void *mem_region, phys_addr_t mem_phys,
+                         size_t mem_size, phys_addr_t *reloc_base)
+{
+       return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys,
+                              mem_size, reloc_base, false);
+}
+EXPORT_SYMBOL_GPL(qcom_mdt_load_no_init);
+
 MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format");
 MODULE_LICENSE("GPL v2");
index 5b98bbdabc258f067078b6387847f83a396fcb17..944b06aefb0f3f712af63fd7b1331ac8ee094ed1 100644 (file)
@@ -17,4 +17,8 @@ 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_load_no_init(struct device *dev, const struct firmware *fw,
+                         const char *fw_name, int pas_id, void *mem_region,
+                         phys_addr_t mem_phys, size_t mem_size,
+                         phys_addr_t *reloc_base);
 #endif