1. 19 Oct, 2022 1 commit
    • Youghandhar Chintala's avatar
      wifi: ath10k: Delay the unmapping of the buffer · acd4324e
      Youghandhar Chintala authored
      On WCN3990, we are seeing a rare scenario where copy engine hardware is
      sending a copy complete interrupt to the host driver while still
      processing the buffer that the driver has sent, this is leading into an
      SMMU fault triggering kernel panic. This is happening on copy engine
      channel 3 (CE3) where the driver normally enqueues WMI commands to the
      firmware. Upon receiving a copy complete interrupt, host driver will
      immediately unmap and frees the buffer presuming that hardware has
      processed the buffer. In the issue case, upon receiving copy complete
      interrupt, host driver will unmap and free the buffer but since hardware
      is still accessing the buffer (which in this case got unmapped in
      parallel), SMMU hardware will trigger an SMMU fault resulting in a
      kernel panic.
      
      In order to avoid this, as a work around, add a delay before unmapping
      the copy engine source DMA buffer. This is conditionally done for
      WCN3990 and only for the CE3 channel where issue is seen.
      
      Below is the crash signature:
      
      wifi smmu error: kernel: [ 10.120965] arm-smmu 15000000.iommu: Unhandled
      context fault: fsr=0x402, iova=0x7fdfd8ac0,
      fsynr=0x500003,cbfrsynra=0xc1, cb=6 arm-smmu 15000000.iommu: Unhandled
      context fault:fsr=0x402, iova=0x7fe06fdc0, fsynr=0x710003,
      cbfrsynra=0xc1, cb=6 qcom-q6v5-mss 4080000.remoteproc: fatal error
      received: err_qdi.c:1040:EF:wlan_process:0x1:WLAN RT:0x2091:
      cmnos_thread.c:3998:Asserted in copy_engine.c:AXI_ERROR_DETECTED:2149
      remoteproc remoteproc0: crash detected in
      4080000.remoteproc: type fatal error <3> remoteproc remoteproc0:
      handling crash #1 in 4080000.remoteproc
      
      pc : __arm_lpae_unmap+0x500/0x514
      lr : __arm_lpae_unmap+0x4bc/0x514
      sp : ffffffc011ffb530
      x29: ffffffc011ffb590 x28: 0000000000000000
      x27: 0000000000000000 x26: 0000000000000004
      x25: 0000000000000003 x24: ffffffc011ffb890
      x23: ffffffa762ef9be0 x22: ffffffa77244ef00
      x21: 0000000000000009 x20: 00000007fff7c000
      x19: 0000000000000003 x18: 0000000000000000
      x17: 0000000000000004 x16: ffffffd7a357d9f0
      x15: 0000000000000000 x14: 00fd5d4fa7ffffff
      x13: 000000000000000e x12: 0000000000000000
      x11: 00000000ffffffff x10: 00000000fffffe00
      x9 : 000000000000017c x8 : 000000000000000c
      x7 : 0000000000000000 x6 : ffffffa762ef9000
      x5 : 0000000000000003 x4 : 0000000000000004
      x3 : 0000000000001000 x2 : 00000007fff7c000
      x1 : ffffffc011ffb890 x0 : 0000000000000000 Call trace:
      __arm_lpae_unmap+0x500/0x514
      __arm_lpae_unmap+0x4bc/0x514
      __arm_lpae_unmap+0x4bc/0x514
      arm_lpae_unmap_pages+0x78/0xa4
      arm_smmu_unmap_pages+0x78/0x104
      __iommu_unmap+0xc8/0x1e4
      iommu_unmap_fast+0x38/0x48
      __iommu_dma_unmap+0x84/0x104
      iommu_dma_free+0x34/0x50
      dma_free_attrs+0xa4/0xd0
      ath10k_htt_rx_free+0xc4/0xf4 [ath10k_core] ath10k_core_stop+0x64/0x7c
      [ath10k_core]
      ath10k_halt+0x11c/0x180 [ath10k_core]
      ath10k_stop+0x54/0x94 [ath10k_core]
      drv_stop+0x48/0x1c8 [mac80211]
      ieee80211_do_open+0x638/0x77c [mac80211] ieee80211_open+0x48/0x5c
      [mac80211]
      __dev_open+0xb4/0x174
      __dev_change_flags+0xc4/0x1dc
      dev_change_flags+0x3c/0x7c
      devinet_ioctl+0x2b4/0x580
      inet_ioctl+0xb0/0x1b4
      sock_do_ioctl+0x4c/0x16c
      compat_ifreq_ioctl+0x1cc/0x35c
      compat_sock_ioctl+0x110/0x2ac
      __arm64_compat_sys_ioctl+0xf4/0x3e0
      el0_svc_common+0xb4/0x17c
      el0_svc_compat_handler+0x2c/0x58
      el0_svc_compat+0x8/0x2c
      
      Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0-01387-QCAHLSWMTPLZ-1
      Tested-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarYoughandhar Chintala <quic_youghand@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20221012142733.32420-1-quic_youghand@quicinc.com
      acd4324e
  2. 13 Oct, 2022 2 commits
  3. 12 Oct, 2022 6 commits
  4. 11 Oct, 2022 4 commits
  5. 10 Oct, 2022 3 commits
  6. 30 Sep, 2022 3 commits
    • Wen Gong's avatar
      wifi: ath11k: fix warning in dma_free_coherent() of memory chunks while recovery · f7487843
      Wen Gong authored
      Commit 26f3a021 ("ath11k: allocate smaller chunks of memory for
      firmware") and commit f6f92968 ("ath11k: qmi: try to allocate a
      big block of DMA memory first") change ath11k to allocate the memory
      chunks for target twice while wlan load. It fails for the 1st time
      because of large memory and then changed to allocate many small chunks
      for the 2nd time sometimes as below log.
      
      1st time failed:
      [10411.640620] ath11k_pci 0000:05:00.0: qmi firmware request memory request
      [10411.640625] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 6881280
      [10411.640630] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 3784704
      [10411.640658] ath11k_pci 0000:05:00.0: qmi dma allocation failed (6881280 B type 1), will try later with small size
      [10411.640671] ath11k_pci 0000:05:00.0: qmi delays mem_request 2
      [10411.640677] ath11k_pci 0000:05:00.0: qmi respond memory request delayed 1
      2nd time success:
      [10411.642004] ath11k_pci 0000:05:00.0: qmi firmware request memory request
      [10411.642008] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642012] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642014] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642016] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642018] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642020] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642022] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642024] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642027] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642029] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      [10411.642031] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 458752
      [10411.642033] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 131072
      [10411.642035] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
      [10411.642037] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
      [10411.642039] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
      [10411.642041] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
      [10411.642043] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
      [10411.642045] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
      [10411.642047] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 491520
      [10411.642049] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
      
      And then commit 5962f370 ("ath11k: Reuse the available memory after
      firmware reload") skip the ath11k_qmi_free_resource() which frees the
      memory chunks while recovery, after that, when run recovery test on
      WCN6855, a warning happened every time as below and finally leads fail
      for recovery.
      
      [  159.570318] BUG: Bad page state in process kworker/u16:5  pfn:33300
      [  159.570320] page:0000000096ffdbb9 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x33300
      [  159.570324] flags: 0xfffffc0000000(node=0|zone=1|lastcpupid=0x1fffff)
      [  159.570329] raw: 000fffffc0000000 0000000000000000 dead000000000122 0000000000000000
      [  159.570332] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
      [  159.570334] page dumped because: nonzero _refcount
      [  159.570440]  firewire_ohci syscopyarea sysfillrect psmouse sdhci_pci ahci sysimgblt firewire_core fb_sys_fops libahci crc_itu_t cqhci drm sdhci e1000e wmi video
      [  159.570460] CPU: 2 PID: 217 Comm: kworker/u16:5 Kdump: loaded Tainted: G    B             5.19.0-rc1-wt-ath+ #3
      [  159.570465] Hardware name: LENOVO 418065C/418065C, BIOS 83ET63WW (1.33 ) 07/29/2011
      [  159.570467] Workqueue: qmi_msg_handler qmi_data_ready_work [qmi_helpers]
      [  159.570475] Call Trace:
      [  159.570476]  <TASK>
      [  159.570478]  dump_stack_lvl+0x49/0x5f
      [  159.570486]  dump_stack+0x10/0x12
      [  159.570493]  bad_page+0xab/0xf0
      [  159.570502]  check_free_page_bad+0x66/0x70
      [  159.570511]  __free_pages_ok+0x530/0x9a0
      [  159.570517]  ? __dev_printk+0x58/0x6b
      [  159.570525]  ? _dev_printk+0x56/0x72
      [  159.570534]  ? qmi_decode+0x119/0x470 [qmi_helpers]
      [  159.570543]  __free_pages+0x91/0xd0
      [  159.570548]  dma_free_contiguous+0x50/0x60
      [  159.570556]  dma_direct_free+0xe5/0x140
      [  159.570564]  dma_free_attrs+0x35/0x50
      [  159.570570]  ath11k_qmi_msg_mem_request_cb+0x2ae/0x3c0 [ath11k]
      [  159.570620]  qmi_invoke_handler+0xac/0xe0 [qmi_helpers]
      [  159.570630]  qmi_handle_message+0x6d/0x180 [qmi_helpers]
      [  159.570643]  qmi_data_ready_work+0x2ca/0x440 [qmi_helpers]
      [  159.570656]  process_one_work+0x227/0x440
      [  159.570667]  worker_thread+0x31/0x3d0
      [  159.570676]  ? process_one_work+0x440/0x440
      [  159.570685]  kthread+0xfe/0x130
      [  159.570692]  ? kthread_complete_and_exit+0x20/0x20
      [  159.570701]  ret_from_fork+0x22/0x30
      [  159.570712]  </TASK>
      
      The reason is because when wlan start to recovery, the type, size and
      count is not same for the 1st and 2nd QMI_WLFW_REQUEST_MEM_IND message,
      Then it leads the parameter size is not correct for the dma_free_coherent().
      For the chunk[1], the actual dma size is 524288 which allocate in the
      2nd time of the initial wlan load phase, and the size which pass to
      dma_free_coherent() is 3784704 which is got in the 1st time of recovery
      phase, then warning above happened.
      
      Change to use prev_size of struct target_mem_chunk for the paramter of
      dma_free_coherent() since prev_size is the real size of last load/recovery.
      Also change to check both type and size of struct target_mem_chunk to
      reuse the memory to avoid mismatch buffer size for target. Then the
      warning disappear and recovery success. When the 1st QMI_WLFW_REQUEST_MEM_IND
      for recovery arrived, the trunk[0] is freed in ath11k_qmi_alloc_target_mem_chunk()
      and then dma_alloc_coherent() failed caused by large size, and then
      trunk[1] is freed in ath11k_qmi_free_target_mem_chunk(), the left 18
      trunks will be reuse for the 2nd QMI_WLFW_REQUEST_MEM_IND message.
      
      Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
      
      Fixes: 5962f370 ("ath11k: Reuse the available memory after firmware reload")
      Signed-off-by: default avatarWen Gong <quic_wgong@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20220928073832.16251-1-quic_wgong@quicinc.com
      f7487843
    • Baochen Qiang's avatar
      wifi: ath11k: Don't exit on wakeup failure · 45d2e268
      Baochen Qiang authored
      Currently, ath11k_pcic_read() returns an error if wakeup()
      fails, this makes firmware crash debug quite hard because we can
      get nothing.
      
      Change to go ahead on wakeup failure, in that case we still may
      get something valid to check. There should be no mislead due
      to incorrect content because we are aware of the failure with the
      log printed.
      
      Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
      Signed-off-by: default avatarBaochen Qiang <quic_bqiang@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20220928015140.5431-1-quic_bqiang@quicinc.com
      45d2e268
    • Gustavo A. R. Silva's avatar
      carl9170: Replace zero-length array with DECLARE_FLEX_ARRAY() helper · 9ec6e207
      Gustavo A. R. Silva authored
      Zero-length arrays are deprecated and we are moving towards adopting
      C99 flexible-array members, instead. So, replace zero-length arrays
      declarations in anonymous union with the new DECLARE_FLEX_ARRAY()
      helper macro.
      
      This helper allows for flexible-array members in unions.
      
      Link: https://github.com/KSPP/linux/issues/193
      Link: https://github.com/KSPP/linux/issues/215
      Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.htmlSigned-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/YzIdWc8QSdZFHBYg@work
      9ec6e207
  7. 28 Sep, 2022 3 commits
  8. 27 Sep, 2022 6 commits
  9. 26 Sep, 2022 4 commits
    • Baochen Qiang's avatar
      wifi: ath11k: Fix deadlock during WoWLAN suspend · d78c8b71
      Baochen Qiang authored
      We are seeing system hangs during WoWLAN suspend, and get below
      two stacks:
      
      Stack1:
      [ffffb02cc1557b20] __schedule at ffffffff8bb10860
      [ffffb02cc1557ba8] schedule at ffffffff8bb10f24
      [ffffb02cc1557bb8] schedule_timeout at ffffffff8bb16d88
      [ffffb02cc1557c30] wait_for_completion at ffffffff8bb11778
      [ffffb02cc1557c78] __flush_work at ffffffff8b0b30cd
      [ffffb02cc1557cf0] __cancel_work_timer at ffffffff8b0b33ad
      [ffffb02cc1557d60] ath11k_mac_drain_tx at ffffffffc0c1f0ca [ath11k]
      [ffffb02cc1557d70] ath11k_wow_op_suspend at ffffffffc0c5201e [ath11k]
      [ffffb02cc1557da8] __ieee80211_suspend at ffffffffc11e2bd3 [mac80211]
      [ffffb02cc1557dd8] wiphy_suspend at ffffffffc0f901ac [cfg80211]
      [ffffb02cc1557e08] dpm_run_callback at ffffffff8b75118a
      [ffffb02cc1557e38] __device_suspend at ffffffff8b751630
      [ffffb02cc1557e70] async_suspend at ffffffff8b7519ea
      [ffffb02cc1557e88] async_run_entry_fn at ffffffff8b0bf4ce
      [ffffb02cc1557ea8] process_one_work at ffffffff8b0b1a24
      [ffffb02cc1557ee0] worker_thread at ffffffff8b0b1c4a
      [ffffb02cc1557f18] kthread at ffffffff8b0b9cb8
      [ffffb02cc1557f50] ret_from_fork at ffffffff8b001d32
      
      Stack2:
      [ffffb02cc00b7d18] __schedule at ffffffff8bb10860
      [ffffb02cc00b7da0] schedule at ffffffff8bb10f24
      [ffffb02cc00b7db0] schedule_preempt_disabled at ffffffff8bb112b4
      [ffffb02cc00b7db8] __mutex_lock at ffffffff8bb127ea
      [ffffb02cc00b7e38] ath11k_mgmt_over_wmi_tx_work at ffffffffc0c1aa44 [ath11k]
      [ffffb02cc00b7ea8] process_one_work at ffffffff8b0b1a24
      [ffffb02cc00b7ee0] worker_thread at ffffffff8b0b1c4a
      [ffffb02cc00b7f18] kthread at ffffffff8b0b9cb8
      [ffffb02cc00b7f50] ret_from_fork at ffffffff8b001d32
      
      From the first stack, ath11k_mac_drain_tx calls
      cancel_work_sync(&ar->wmi_mgmt_tx_work) and waits all packets to be sent
      out or dropped. However, we find from Stack2 that this work item is blocked
      because ar->conf_mutex is already held by ath11k_wow_op_suspend.
      
      Fix this issue by moving ath11k_mac_wait_tx_complete to the start of
      ath11k_wow_op_suspend where ar->conf_mutex has not been acquired. And
      this change also makes the logic in ath11k_wow_op_suspend match the
      logic in ath11k_mac_op_start and ath11k_mac_op_stop.
      
      Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
      Signed-off-by: default avatarBaochen Qiang <quic_bqiang@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20220919021435.2459-1-quic_bqiang@quicinc.com
      d78c8b71
    • Baochen Qiang's avatar
      wifi: ath11k: Remove redundant ath11k_mac_drain_tx · d50ebec1
      Baochen Qiang authored
      ath11k_mac_drain_tx is already called in ath11k_mac_wait_tx_complete, no need to call it again. So remove it.
      
      This is found in code review.
      
      Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
      Signed-off-by: default avatarBaochen Qiang <quic_bqiang@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20220919020259.1746-1-quic_bqiang@quicinc.com
      d50ebec1
    • Tamizh Chelvam Raja's avatar
      wifi: ath11k: Add spectral scan support for 160 MHz · c92f774a
      Tamizh Chelvam Raja authored
      There are two types of 160 MHz spectral scan support mentioned below
      
      1. Fragmented approach
      2. Single event approach
      
      In this fragmented approach, single 160 MHz will be split as two
      80 MHz buffer. First fft sample buffer will contain spectral scan
      result of primary 80 MHz and the second fft sample buffer will contain
      secondary 80 MHz and here cfreq1 and cfreq2 will be mentioned.
      In case of 160 MHz on 36th channel will contain cfreq1 as 5210 and
      cfreq2 as 5290. Chipsets which support this approach are IPQ8074/IPQ6018.
      
      Replacing freq1 with freq2 in every secondary sepctral scan event to
      distinguish between two different 80 MHz spectral event data.
      
      In the 2nd approach each fft sample buffer will contain spectral scan
      result for whole 160 MHz by mentioning cfreq1 as 5250 which is center
      frequency of whole 160 MHz. Chipset which support this approach is QCN9074.
      
      Host will receive spectral event from target for every 5 fft samples.
      
      Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01120-QCAHKSWPL-1
      Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01120-QCAHKSWP
      Signed-off-by: default avatarTamizh Chelvam Raja <quic_tamizhr@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20220725055001.15194-1-quic_tamizhr@quicinc.com
      c92f774a
    • Venkateswara Naralasetty's avatar
      wifi: ath11k: Add support to get power save duration for each client · 710a95f9
      Venkateswara Naralasetty authored
      Add support to get the following power save information through debugfs interface,
      
       * Current ps state of the peer
       * Time duration since the peer is in power save
       * Total duration of the peer spent in power save
      
      Above information is helpful in debugging the issues with power save clients.
      
      This patch also add trace log support for PS timekeeper to track the PS state
      change of the peers alongs with the peer MAC address and timestamp.
      
      Use the below commands to get the above power save information,
      
      To know the time_since_station_in_power_save:
      cat /sys/kernel/debug/ieee80211/phyX/netdev:wlanX/stations/
      XX:XX:XX:XX:XX:XX/current_ps_duration
      
      To know power_save_duration:
      cat /sys/kernel/debug/ieee80211/phyX/netdev:wlanX/stations/
      XX:XX:XX:XX:XX:XX/total_ps_duration
      
      To reset the power_save_duration of all stations connected to AP:
      echo 1 > /sys/kernel/debug/ieee80211/phyX/ath11k/reset_ps_duration
      
      To enable/disable the ps_timekeeper:
      echo Y > /sys/kernel/debug/ieee80211/phyX/ath11k/ps_timekeeper_enable
      Y = 1 to enable and Y = 0 to disable.
      
      To record PS timekeeer logs after enabling ps_timekeeper:
      trace-cmd record -e ath11k_ps_timekeeper
      
      Tested-on: Tested-on: IPQ8074 WLAN.HK.2.5.0.1-00991-QCAHKSWPL_SILICONZ-1
      Signed-off-by: default avatarVenkateswara Naralasetty <quic_vnaralas@quicinc.com>
      Signed-off-by: default avatarTamizh Chelvam Raja <quic_tamizhr@quicinc.com>
      Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
      Link: https://lore.kernel.org/r/20220725054601.14719-1-quic_tamizhr@quicinc.com
      710a95f9
  10. 24 Sep, 2022 8 commits