2
0

0022-v6.5-soc-qcom-mdt_loader-Fix-unconditional-call-to-scm_pa.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From b8295c6eb276b60f7b75c53a9703ca8fee01eba2 Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  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. Commit ebeb20a9cd3f ("soc: qcom: mdt_loader: Always invoke PAS
  7. mem_setup") dropped the relocate check and made pas_mem_setup run
  8. unconditionally. The code was later moved with commit f4e526ff7e38
  9. ("soc: qcom: mdt_loader: Extract PAS operations") to
  10. qcom_mdt_pas_init() effectively losing track of what was actually
  11. done.
  12. The assumption that PAS mem_setup can be done anytime was effectively
  13. wrong, with no good reason and this caused regression on some SoC
  14. that use remoteproc to bringup ath11k. One example is IPQ8074 SoC that
  15. effectively broke resulting in remoteproc silently die and ath11k not
  16. working.
  17. On this SoC FW relocate is not enabled and PAS mem_setup was correctly
  18. skipped in previous kernel version resulting in correct bringup and
  19. function of remoteproc and ath11k.
  20. To fix the regression, reintroduce the relocate check in
  21. qcom_mdt_pas_init() and correctly skip PAS mem_setup where relocate is
  22. not enabled.
  23. Fixes: ebeb20a9cd3f ("soc: qcom: mdt_loader: Always invoke PAS mem_setup")
  24. Reported-by: Robert Marko <[email protected]>
  25. Tested-by: Robert Marko <[email protected]>
  26. Co-developed-by: Robert Marko <[email protected]>
  27. Signed-off-by: Robert Marko <[email protected]>
  28. Signed-off-by: Christian Marangi <[email protected]>
  29. Cc: [email protected]
  30. ---
  31. drivers/soc/qcom/mdt_loader.c | 16 +++++++++++-----
  32. 1 file changed, 11 insertions(+), 5 deletions(-)
  33. --- a/drivers/soc/qcom/mdt_loader.c
  34. +++ b/drivers/soc/qcom/mdt_loader.c
  35. @@ -210,6 +210,7 @@ int qcom_mdt_pas_init(struct device *dev
  36. const struct elf32_hdr *ehdr;
  37. phys_addr_t min_addr = PHYS_ADDR_MAX;
  38. phys_addr_t max_addr = 0;
  39. + bool relocate = false;
  40. size_t metadata_len;
  41. void *metadata;
  42. int ret;
  43. @@ -224,6 +225,9 @@ int qcom_mdt_pas_init(struct device *dev
  44. if (!mdt_phdr_valid(phdr))
  45. continue;
  46. + if (phdr->p_flags & QCOM_MDT_RELOCATABLE)
  47. + relocate = true;
  48. +
  49. if (phdr->p_paddr < min_addr)
  50. min_addr = phdr->p_paddr;
  51. @@ -246,11 +250,13 @@ int qcom_mdt_pas_init(struct device *dev
  52. goto out;
  53. }
  54. - ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
  55. - if (ret) {
  56. - /* Unable to set up relocation */
  57. - dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name);
  58. - goto out;
  59. + if (relocate) {
  60. + ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
  61. + if (ret) {
  62. + /* Unable to set up relocation */
  63. + dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name);
  64. + goto out;
  65. + }
  66. }
  67. out: