0010-wifi-ath11k-Fix-firmware-crash-on-vdev-delete-race-c.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From 3811fa1f231f1a3e29759efef4992116604aab8b Mon Sep 17 00:00:00 2001
  2. From: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
  3. Date: Tue, 11 Oct 2022 15:23:46 +0530
  4. Subject: [PATCH] wifi: ath11k: Fix firmware crash on vdev delete race
  5. condition
  6. Current code does not wait for vdev delete completion on vdev create
  7. failures and tries to send another vdev create followed by vdev set
  8. param to firmware with same vdev id. This causes firmware crash.
  9. Fix this crash by waiting for vdev delete completion on vdev
  10. create failures.
  11. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.6.0.1-00905-QCAHKSWPL_SILICONZ-1
  12. Signed-off-by: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
  13. Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  14. Link: https://lore.kernel.org/r/20221011095346.3901-1-quic_ssreeela@quicinc.com
  15. ---
  16. drivers/net/wireless/ath/ath11k/mac.c | 60 +++++++++++++++++----------
  17. 1 file changed, 37 insertions(+), 23 deletions(-)
  18. --- a/drivers/net/wireless/ath/ath11k/mac.c
  19. +++ b/drivers/net/wireless/ath/ath11k/mac.c
  20. @@ -6233,6 +6233,40 @@ void ath11k_mac_11d_scan_stop_all(struct
  21. }
  22. }
  23. +static int ath11k_mac_vdev_delete(struct ath11k *ar, struct ath11k_vif *arvif)
  24. +{
  25. + unsigned long time_left;
  26. + struct ieee80211_vif *vif = arvif->vif;
  27. + int ret = 0;
  28. +
  29. + lockdep_assert_held(&ar->conf_mutex);
  30. +
  31. + reinit_completion(&ar->vdev_delete_done);
  32. +
  33. + ret = ath11k_wmi_vdev_delete(ar, arvif->vdev_id);
  34. + if (ret) {
  35. + ath11k_warn(ar->ab, "failed to delete WMI vdev %d: %d\n",
  36. + arvif->vdev_id, ret);
  37. + return ret;
  38. + }
  39. +
  40. + time_left = wait_for_completion_timeout(&ar->vdev_delete_done,
  41. + ATH11K_VDEV_DELETE_TIMEOUT_HZ);
  42. + if (time_left == 0) {
  43. + ath11k_warn(ar->ab, "Timeout in receiving vdev delete response\n");
  44. + return -ETIMEDOUT;
  45. + }
  46. +
  47. + ar->ab->free_vdev_map |= 1LL << (arvif->vdev_id);
  48. + ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
  49. + ar->num_created_vdevs--;
  50. +
  51. + ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "vdev %pM deleted, vdev_id %d\n",
  52. + vif->addr, arvif->vdev_id);
  53. +
  54. + return ret;
  55. +}
  56. +
  57. static int ath11k_mac_op_add_interface(struct ieee80211_hw *hw,
  58. struct ieee80211_vif *vif)
  59. {
  60. @@ -6468,10 +6502,7 @@ err_peer_del:
  61. }
  62. err_vdev_del:
  63. - ath11k_wmi_vdev_delete(ar, arvif->vdev_id);
  64. - ar->num_created_vdevs--;
  65. - ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
  66. - ab->free_vdev_map |= 1LL << arvif->vdev_id;
  67. + ath11k_mac_vdev_delete(ar, arvif);
  68. spin_lock_bh(&ar->data_lock);
  69. list_del(&arvif->list);
  70. spin_unlock_bh(&ar->data_lock);
  71. @@ -6499,7 +6530,6 @@ static void ath11k_mac_op_remove_interfa
  72. struct ath11k *ar = hw->priv;
  73. struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
  74. struct ath11k_base *ab = ar->ab;
  75. - unsigned long time_left;
  76. int ret;
  77. int i;
  78. @@ -6520,29 +6550,13 @@ static void ath11k_mac_op_remove_interfa
  79. arvif->vdev_id, ret);
  80. }
  81. - reinit_completion(&ar->vdev_delete_done);
  82. -
  83. - ret = ath11k_wmi_vdev_delete(ar, arvif->vdev_id);
  84. + ret = ath11k_mac_vdev_delete(ar, arvif);
  85. if (ret) {
  86. - ath11k_warn(ab, "failed to delete WMI vdev %d: %d\n",
  87. + ath11k_warn(ab, "failed to delete vdev %d: %d\n",
  88. arvif->vdev_id, ret);
  89. goto err_vdev_del;
  90. }
  91. - time_left = wait_for_completion_timeout(&ar->vdev_delete_done,
  92. - ATH11K_VDEV_DELETE_TIMEOUT_HZ);
  93. - if (time_left == 0) {
  94. - ath11k_warn(ab, "Timeout in receiving vdev delete response\n");
  95. - goto err_vdev_del;
  96. - }
  97. -
  98. - ab->free_vdev_map |= 1LL << (arvif->vdev_id);
  99. - ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
  100. - ar->num_created_vdevs--;
  101. -
  102. - ath11k_dbg(ab, ATH11K_DBG_MAC, "vdev %pM deleted, vdev_id %d\n",
  103. - vif->addr, arvif->vdev_id);
  104. -
  105. if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) {
  106. clear_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags);
  107. ar->monitor_vdev_id = -1;