2024年12月

ath9K驱动使用客户端模式连接热点,出现ctrl-event-beacon-loss异常,导致无线断流。
经搜索,发现此patch补丁可以修复此问题:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bddac7c1e02ba47f0570e494c9289acea3062cc1
但不适用于openwrt 19.06(kernel 4.14) ,经参照修改,在MT7621A架构下运行良好。将补丁文件保存到./target/linux/ramips/patches-4.14目录下,重新编译,即可生成打过补丁的固件。

--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -601,7 +601,7 @@
     for (i = 0; i < nslots; i++)
         io_tlb_orig_addr[index+i] = orig_addr + (i << IO_TLB_SHIFT);
     if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
-        (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
+        (!(attrs & DMA_ATTR_OVERWRITE) || dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
         swiotlb_bounce(orig_addr, tlb_addr, size, DMA_TO_DEVICE);
 
     return tlb_addr;

 
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -70,6 +70,14 @@
  */
 #define DMA_ATTR_PRIVILEGED        (1UL << 9)
 
+ /*
+ * This is a hint to the DMA-mapping subsystem that the device is expected
+ * to overwrite the entire mapped size, thus the caller does not require any
+ * of the previous buffer contents to be preserved. This allows
+ * bounce-buffering implementations to optimise DMA_FROM_DEVICE transfers.
+ */
+#define DMA_ATTR_OVERWRITE        (1UL << 10)
+
 /*
  * A dma_addr_t can hold any valid DMA or bus address for the platform.
  * It can be given to a device to use as a DMA source or target.  A CPU cannot

下载地址:999-Revert-swiotlb-rework-DMA_FROM_DEVICE.zip

修复backports-4.19驱动bug,运行中随机出现“SWBA overrun on vdev 0, skipped old beacon”异常,导致无线断流。
backports新版本已经修复此问题:
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers.git/commit/?id=d79749f7716d9dc32fa2d5075f6ec29aac63c76d
但新驱动不适用于4.14的内核,参照这个commit修改4.19版本。
以下是 patch补丁内容:

--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1869,8 +1869,19 @@
         return ret;
     }
 
-    if (!uart_print)
+    if (!uart_print) {
+        if (true) {
+            ret = ath10k_bmi_write32(ar, hi_dbg_uart_txpin,
+                         ar->hw_params.uart_pin);
+            if (ret) {
+                ath10k_warn(ar, "failed to set UART TX pin: %d",
+                        ret);
+                return ret;
+            }
+        }
+
         return 0;
+    }
 
     ret = ath10k_bmi_write32(ar, hi_dbg_uart_txpin, ar->hw_params.uart_pin);
     if (ret) {

将内容保存为999-ath10k-skipped-old-beacon.patch保存到package/kernel/mac80211/patches/ath/目录下,再编译,完成bug修补。
补丁下载:999-ath10k-skipped-old-beacon.zip