0047-wifi-ath11k-fix-deinitialization-of-firmware-resourc.patch 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 5a78ac33e3cb8822da64dd1af196e83664b332b0 Mon Sep 17 00:00:00 2001
  2. From: Aditya Kumar Singh <quic_adisi@quicinc.com>
  3. Date: Thu, 9 Mar 2023 15:23:08 +0530
  4. Subject: [PATCH] wifi: ath11k: fix deinitialization of firmware resources
  5. Currently, in ath11k_ahb_fw_resources_init(), iommu domain
  6. mapping is done only for the chipsets having fixed firmware
  7. memory. Also, for such chipsets, mapping is done only if it
  8. does not have TrustZone support.
  9. During deinitialization, only if TrustZone support is not there,
  10. iommu is unmapped back. However, for non fixed firmware memory
  11. chipsets, TrustZone support is not there and this makes the
  12. condition check to true and it tries to unmap the memory which
  13. was not mapped during initialization.
  14. This leads to the following trace -
  15. [ 83.198790] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
  16. [ 83.259537] Modules linked in: ath11k_ahb ath11k qmi_helpers
  17. .. snip ..
  18. [ 83.280286] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  19. [ 83.287228] pc : __iommu_unmap+0x30/0x140
  20. [ 83.293907] lr : iommu_unmap+0x5c/0xa4
  21. [ 83.298072] sp : ffff80000b3abad0
  22. .. snip ..
  23. [ 83.369175] Call trace:
  24. [ 83.376282] __iommu_unmap+0x30/0x140
  25. [ 83.378541] iommu_unmap+0x5c/0xa4
  26. [ 83.382360] ath11k_ahb_fw_resource_deinit.part.12+0x2c/0xac [ath11k_ahb]
  27. [ 83.385666] ath11k_ahb_free_resources+0x140/0x17c [ath11k_ahb]
  28. [ 83.392521] ath11k_ahb_shutdown+0x34/0x40 [ath11k_ahb]
  29. [ 83.398248] platform_shutdown+0x20/0x2c
  30. [ 83.403455] device_shutdown+0x16c/0x1c4
  31. [ 83.407621] kernel_restart_prepare+0x34/0x3c
  32. [ 83.411529] kernel_restart+0x14/0x74
  33. [ 83.415781] __do_sys_reboot+0x1c4/0x22c
  34. [ 83.419427] __arm64_sys_reboot+0x1c/0x24
  35. [ 83.423420] invoke_syscall+0x44/0xfc
  36. [ 83.427326] el0_svc_common.constprop.3+0xac/0xe8
  37. [ 83.430974] do_el0_svc+0xa0/0xa8
  38. [ 83.435659] el0_svc+0x1c/0x44
  39. [ 83.438957] el0t_64_sync_handler+0x60/0x144
  40. [ 83.441910] el0t_64_sync+0x15c/0x160
  41. [ 83.446343] Code: aa0103f4 f9400001 f90027a1 d2800001 (f94006a0)
  42. [ 83.449903] ---[ end trace 0000000000000000 ]---
  43. This can be reproduced by probing an AHB chipset which is not
  44. having a fixed memory region. During reboot (or rmmod) trace
  45. can be seen.
  46. Fix this issue by adding a condition check on firmware fixed memory
  47. hw_param as done in the counter initialization function.
  48. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
  49. Fixes: f9eec4947add ("ath11k: Add support for targets without trustzone")
  50. Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
  51. Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  52. Link: https://lore.kernel.org/r/20230309095308.24937-1-quic_adisi@quicinc.com
  53. ---
  54. drivers/net/wireless/ath/ath11k/ahb.c | 6 ++++++
  55. 1 file changed, 6 insertions(+)
  56. --- a/drivers/net/wireless/ath/ath11k/ahb.c
  57. +++ b/drivers/net/wireless/ath/ath11k/ahb.c
  58. @@ -1078,6 +1078,12 @@ static int ath11k_ahb_fw_resource_deinit
  59. struct iommu_domain *iommu;
  60. size_t unmapped_size;
  61. + /* Chipsets not requiring MSA would have not initialized
  62. + * MSA resources, return success in such cases.
  63. + */
  64. + if (!ab->hw_params.fixed_fw_mem)
  65. + return 0;
  66. +
  67. if (ab_ahb->fw.use_tz)
  68. return 0;