081-ath10k-fix-module-load-regression-with-iram-recovery-feature.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. From 6f8c8bf4c7c9be1c42088689fd4370e06b46608a Mon Sep 17 00:00:00 2001
  2. From: Abinaya Kalaiselvan <[email protected]>
  3. Date: Wed, 20 Oct 2021 11:59:07 +0300
  4. Subject: ath10k: fix module load regression with iram-recovery feature
  5. Commit 9af7c32ceca8 ("ath10k: add target IRAM recovery feature support")
  6. introduced a new firmware feature flag ATH10K_FW_FEATURE_IRAM_RECOVERY. But
  7. this caused ath10k_pci module load to fail if ATH10K_FW_CRASH_DUMP_RAM_DATA bit
  8. was not enabled in the ath10k coredump_mask module parameter:
  9. [ 2209.328190] ath10k_pci 0000:02:00.0: qca9984/qca9994 hw1.0 target 0x01000000 chip_id 0x00000000 sub 168c:cafe
  10. [ 2209.434414] ath10k_pci 0000:02:00.0: kconfig debug 1 debugfs 1 tracing 1 dfs 1 testmode 1
  11. [ 2209.547191] ath10k_pci 0000:02:00.0: firmware ver 10.4-3.9.0.2-00099 api 5 features no-p2p,mfp,peer-flow-ctrl,btcoex-param,allows-mesh-bcast,no-ps,peer-fixed-rate,iram-recovery crc32 cbade90a
  12. [ 2210.896485] ath10k_pci 0000:02:00.0: board_file api 1 bmi_id 0:1 crc32 a040efc2
  13. [ 2213.603339] ath10k_pci 0000:02:00.0: failed to copy target iram contents: -12
  14. [ 2213.839027] ath10k_pci 0000:02:00.0: could not init core (-12)
  15. [ 2213.933910] ath10k_pci 0000:02:00.0: could not probe fw (-12)
  16. And by default coredump_mask does not have ATH10K_FW_CRASH_DUMP_RAM_DATA
  17. enabled so anyone using a firmware with iram-recovery feature would fail. To my
  18. knowledge only QCA9984 firmwares starting from release 10.4-3.9.0.2-00099
  19. enabled the feature.
  20. The reason for regression was that ath10k_core_copy_target_iram() used
  21. ath10k_coredump_get_mem_layout() to get the memory layout, but when
  22. ATH10K_FW_CRASH_DUMP_RAM_DATA was disabled it would get just NULL and bail out
  23. with an error.
  24. While looking at all this I noticed another bug: if CONFIG_DEV_COREDUMP is
  25. disabled but the firmware has iram-recovery enabled the module load fails with
  26. similar error messages. I fixed that by returning 0 from
  27. ath10k_core_copy_target_iram() when _ath10k_coredump_get_mem_layout() returns
  28. NULL.
  29. Tested-on: QCA9984 hw2.0 PCI 10.4-3.9.0.2-00139
  30. Fixes: 9af7c32ceca8 ("ath10k: add target IRAM recovery feature support")
  31. Signed-off-by: Abinaya Kalaiselvan <[email protected]>
  32. Signed-off-by: Jouni Malinen <[email protected]>
  33. Signed-off-by: Kalle Valo <[email protected]>
  34. Link: https://lore.kernel.org/r/[email protected]
  35. ---
  36. drivers/net/wireless/ath/ath10k/core.c | 11 +++++++++--
  37. drivers/net/wireless/ath/ath10k/coredump.c | 11 ++++++++---
  38. drivers/net/wireless/ath/ath10k/coredump.h | 7 +++++++
  39. 3 files changed, 24 insertions(+), 5 deletions(-)
  40. --- a/drivers/net/wireless/ath/ath10k/core.c
  41. +++ b/drivers/net/wireless/ath/ath10k/core.c
  42. @@ -2690,9 +2690,16 @@ static int ath10k_core_copy_target_iram(
  43. int i, ret;
  44. u32 len, remaining_len;
  45. - hw_mem = ath10k_coredump_get_mem_layout(ar);
  46. + /* copy target iram feature must work also when
  47. + * ATH10K_FW_CRASH_DUMP_RAM_DATA is disabled, so
  48. + * _ath10k_coredump_get_mem_layout() to accomplist that
  49. + */
  50. + hw_mem = _ath10k_coredump_get_mem_layout(ar);
  51. if (!hw_mem)
  52. - return -ENOMEM;
  53. + /* if CONFIG_DEV_COREDUMP is disabled we get NULL, then
  54. + * just silently disable the feature by doing nothing
  55. + */
  56. + return 0;
  57. for (i = 0; i < hw_mem->region_table.size; i++) {
  58. tmp = &hw_mem->region_table.regions[i];
  59. --- a/drivers/net/wireless/ath/ath10k/coredump.c
  60. +++ b/drivers/net/wireless/ath/ath10k/coredump.c
  61. @@ -1447,11 +1447,17 @@ static u32 ath10k_coredump_get_ramdump_s
  62. const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10k *ar)
  63. {
  64. - int i;
  65. -
  66. if (!test_bit(ATH10K_FW_CRASH_DUMP_RAM_DATA, &ath10k_coredump_mask))
  67. return NULL;
  68. + return _ath10k_coredump_get_mem_layout(ar);
  69. +}
  70. +EXPORT_SYMBOL(ath10k_coredump_get_mem_layout);
  71. +
  72. +const struct ath10k_hw_mem_layout *_ath10k_coredump_get_mem_layout(struct ath10k *ar)
  73. +{
  74. + int i;
  75. +
  76. if (WARN_ON(ar->target_version == 0))
  77. return NULL;
  78. @@ -1464,7 +1470,6 @@ const struct ath10k_hw_mem_layout *ath10
  79. return NULL;
  80. }
  81. -EXPORT_SYMBOL(ath10k_coredump_get_mem_layout);
  82. struct ath10k_fw_crash_data *ath10k_coredump_new(struct ath10k *ar)
  83. {
  84. --- a/drivers/net/wireless/ath/ath10k/coredump.h
  85. +++ b/drivers/net/wireless/ath/ath10k/coredump.h
  86. @@ -176,6 +176,7 @@ int ath10k_coredump_register(struct ath1
  87. void ath10k_coredump_unregister(struct ath10k *ar);
  88. void ath10k_coredump_destroy(struct ath10k *ar);
  89. +const struct ath10k_hw_mem_layout *_ath10k_coredump_get_mem_layout(struct ath10k *ar);
  90. const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10k *ar);
  91. #else /* CONFIG_DEV_COREDUMP */
  92. @@ -213,6 +214,12 @@ ath10k_coredump_get_mem_layout(struct at
  93. {
  94. return NULL;
  95. }
  96. +
  97. +static inline const struct ath10k_hw_mem_layout *
  98. +_ath10k_coredump_get_mem_layout(struct ath10k *ar)
  99. +{
  100. + return NULL;
  101. +}
  102. #endif /* CONFIG_DEV_COREDUMP */