1 From b8295c6eb276b60f7b75c53a9703ca8fee01eba2 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 26 May 2023 13:09:17 +0200
4 Subject: [PATCH] soc: qcom: mdt_loader: Fix unconditional call to
7 Commit ebeb20a9cd3f ("soc: qcom: mdt_loader: Always invoke PAS
8 mem_setup") dropped the relocate check and made pas_mem_setup run
9 unconditionally. The code was later moved with commit f4e526ff7e38
10 ("soc: qcom: mdt_loader: Extract PAS operations") to
11 qcom_mdt_pas_init() effectively losing track of what was actually
14 The assumption that PAS mem_setup can be done anytime was effectively
15 wrong, with no good reason and this caused regression on some SoC
16 that use remoteproc to bringup ath11k. One example is IPQ8074 SoC that
17 effectively broke resulting in remoteproc silently die and ath11k not
20 On this SoC FW relocate is not enabled and PAS mem_setup was correctly
21 skipped in previous kernel version resulting in correct bringup and
22 function of remoteproc and ath11k.
24 To fix the regression, reintroduce the relocate check in
25 qcom_mdt_pas_init() and correctly skip PAS mem_setup where relocate is
28 Fixes: ebeb20a9cd3f ("soc: qcom: mdt_loader: Always invoke PAS mem_setup")
29 Reported-by: Robert Marko <robimarko@gmail.com>
30 Tested-by: Robert Marko <robimarko@gmail.com>
31 Co-developed-by: Robert Marko <robimarko@gmail.com>
32 Signed-off-by: Robert Marko <robimarko@gmail.com>
33 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
34 Cc: stable@vger.kernel.org
36 drivers/soc/qcom/mdt_loader.c | 16 +++++++++++-----
37 1 file changed, 11 insertions(+), 5 deletions(-)
39 --- a/drivers/soc/qcom/mdt_loader.c
40 +++ b/drivers/soc/qcom/mdt_loader.c
41 @@ -210,6 +210,7 @@ int qcom_mdt_pas_init(struct device *dev
42 const struct elf32_hdr *ehdr;
43 phys_addr_t min_addr = PHYS_ADDR_MAX;
44 phys_addr_t max_addr = 0;
45 + bool relocate = false;
49 @@ -224,6 +225,9 @@ int qcom_mdt_pas_init(struct device *dev
50 if (!mdt_phdr_valid(phdr))
53 + if (phdr->p_flags & QCOM_MDT_RELOCATABLE)
56 if (phdr->p_paddr < min_addr)
57 min_addr = phdr->p_paddr;
59 @@ -246,11 +250,13 @@ int qcom_mdt_pas_init(struct device *dev
63 - ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
65 - /* Unable to set up relocation */
66 - dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name);
69 + ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
71 + /* Unable to set up relocation */
72 + dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name);