ipq807x: rename target to qualcommax
[openwrt/staging/hauke.git] / target / linux / qualcommax / patches-6.1 / 0022-v6.5-soc-qcom-mdt_loader-Fix-unconditional-call-to-scm_pa.patch
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
5 scm_pas_mem_setup
6
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
12 done.
13
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
18 working.
19
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.
23
24 To fix the regression, reintroduce the relocate check in
25 qcom_mdt_pas_init() and correctly skip PAS mem_setup where relocate is
26 not enabled.
27
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
35 ---
36 drivers/soc/qcom/mdt_loader.c | 16 +++++++++++-----
37 1 file changed, 11 insertions(+), 5 deletions(-)
38
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;
46 size_t metadata_len;
47 void *metadata;
48 int ret;
49 @@ -224,6 +225,9 @@ int qcom_mdt_pas_init(struct device *dev
50 if (!mdt_phdr_valid(phdr))
51 continue;
52
53 + if (phdr->p_flags & QCOM_MDT_RELOCATABLE)
54 + relocate = true;
55 +
56 if (phdr->p_paddr < min_addr)
57 min_addr = phdr->p_paddr;
58
59 @@ -246,11 +250,13 @@ int qcom_mdt_pas_init(struct device *dev
60 goto out;
61 }
62
63 - ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
64 - if (ret) {
65 - /* Unable to set up relocation */
66 - dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name);
67 - goto out;
68 + if (relocate) {
69 + ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
70 + if (ret) {
71 + /* Unable to set up relocation */
72 + dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name);
73 + goto out;
74 + }
75 }
76
77 out: