soc: qcom: mdt-loader: Return relocation base
authorBjorn Andersson <bjorn.andersson@linaro.org>
Sat, 6 Jan 2018 00:04:19 +0000 (16:04 -0800)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Mon, 12 Feb 2018 19:05:38 +0000 (11:05 -0800)
In order to implement support for grabbing core dumps in remoteproc it's
necessary to know the relocated base of the image, as the offsets from
the virtual memory base might not be based on the physical address.

Return the adjusted physical base address to the caller.

Acked-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/gpu/drm/msm/adreno/a5xx_gpu.c
drivers/media/platform/qcom/venus/firmware.c
drivers/remoteproc/qcom_adsp_pil.c
drivers/remoteproc/qcom_wcnss.c
drivers/soc/qcom/mdt_loader.c
include/linux/soc/qcom/mdt_loader.h

index 7e09d44e4a153b65e557aeb23fc1dadec7eb7296..8676fa9a9f49d3d1932e340ffb911cbcde777f65 100644 (file)
@@ -89,14 +89,14 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname)
         */
        if (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY) {
                ret = qcom_mdt_load(dev, fw, fwname, GPU_PAS_ID,
-                               mem_region, mem_phys, mem_size);
+                               mem_region, mem_phys, mem_size, NULL);
        } else {
                char newname[strlen("qcom/") + strlen(fwname) + 1];
 
                sprintf(newname, "qcom/%s", fwname);
 
                ret = qcom_mdt_load(dev, fw, newname, GPU_PAS_ID,
-                               mem_region, mem_phys, mem_size);
+                               mem_region, mem_phys, mem_size, NULL);
        }
        if (ret)
                goto out;
index 521d4b36c0904d1e6f25e8db688216108ad61c40..c4a577848dd7a889ae474840721e5d557f5c5026 100644 (file)
@@ -76,7 +76,7 @@ int venus_boot(struct device *dev, const char *fwname)
        }
 
        ret = qcom_mdt_load(dev, mdt, fwname, VENUS_PAS_ID, mem_va, mem_phys,
-                           mem_size);
+                           mem_size, NULL);
 
        release_firmware(mdt);
 
index 4a2ee6c5816cd4469e228dfd1022a5ff94ebbcc4..ca2bda9bc71d6c9e2ace83f1a1438da2a37b3f1f 100644 (file)
@@ -82,7 +82,9 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw)
        struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
 
        return qcom_mdt_load(adsp->dev, fw, rproc->firmware, adsp->pas_id,
-                            adsp->mem_region, adsp->mem_phys, adsp->mem_size);
+                            adsp->mem_region, adsp->mem_phys, adsp->mem_size,
+                            &adsp->mem_reloc);
+
 }
 
 static int adsp_start(struct rproc *rproc)
index 043f3d3dea7d321fc831d323aec4e3c9ae270480..f1ae5ecbc392dce66b184d7a4c09b0ab18b10a84 100644 (file)
@@ -153,7 +153,8 @@ static int wcnss_load(struct rproc *rproc, const struct firmware *fw)
        struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv;
 
        return qcom_mdt_load(wcnss->dev, fw, rproc->firmware, WCNSS_PAS_ID,
-                            wcnss->mem_region, wcnss->mem_phys, wcnss->mem_size);
+                            wcnss->mem_region, wcnss->mem_phys,
+                            wcnss->mem_size, &wcnss->mem_reloc);
 }
 
 static void wcnss_indicate_nv_download(struct qcom_wcnss *wcnss)
index 08bd8549242a9d2445ac7aca845f716a97b54ac8..17b314d9a148cb24bf252be3d76ee835c53c4dda 100644 (file)
@@ -83,12 +83,14 @@ EXPORT_SYMBOL_GPL(qcom_mdt_get_size);
  * @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 mem_phys, size_t mem_size,
+                 phys_addr_t *reloc_base)
 {
        const struct elf32_phdr *phdrs;
        const struct elf32_phdr *phdr;
@@ -192,6 +194,9 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
                        memset(ptr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz);
        }
 
+       if (reloc_base)
+               *reloc_base = mem_reloc;
+
 out:
        kfree(fw_name);
 
index bd8e0864b05923a8b4232ca82ffe62b9a9ba4208..5b98bbdabc258f067078b6387847f83a396fcb17 100644 (file)
@@ -14,6 +14,7 @@ struct firmware;
 ssize_t qcom_mdt_get_size(const struct firmware *fw);
 int qcom_mdt_load(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 mem_phys, size_t mem_size,
+                 phys_addr_t *reloc_base);
 
 #endif