1: 98f18afe4e7f ! 1: 7815997896d7 wifi: rtw88: 8822c: filter hardware-handled control frames on SDIO @@ Commit message PS-Poll and the remaining subtypes, and store the default in rxfltmap1 so FIF_CONTROL can still request all control frames.  - Limit the new default to SDIO, where profiling identified the overhead - and throughput tests measured a benefit. PCIe and USB use different - receive paths and have not been validated with this filter setting. + Limit the new default to SDIO, where profiling identified this overhead. + PCIe and USB receive paths have not been tested with this filter setting.  FriendlyElec's RTL8822CS driver also filters control frames at startup; this change retains additional subtypes for mac80211.  - On RTL8822CS/NanoPi M5 at 198 MHz SDR104, this patch alone increased - median TCP upload from 170 to 258 Mbit/s (+52%). - - A separate download test (four 30-second samples per configuration) - measured 241 to 263 Mbit/s (+9%). - Link: https://github.com/friendlyarm/rtl8822cs/blob/c8b944a34bba2116fcdb060362bde40242bb87e5/hal/rtl8822c/rtl8822c_halinit.c + Signed-off-by: Leonard Lausen   ## drivers/net/wireless/realtek/rtw88/reg.h ##  @@ @@ drivers/net/wireless/realtek/rtw88/rtw8822c.c: static int rtw8822c_mac_init(stru rtw_write16(rtwdev, REG_RXFLTMAP0, WLAN_RX_FILTER0); rtwdev->hal.rxfltmap1 = WLAN_RX_FILTER1;  + if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_SDIO) { -+ /* Hardware handles these frames; retain BAR and PS-Poll for ++ /* ++ * Hardware handles these frames; retain BAR and PS-Poll for  + * mac80211. FIF_CONTROL restores all subtypes for monitors.  + */  + rtwdev->hal.rxfltmap1 &= ~(BIT_RXFLTMAP1_BACK | -+ BIT_RXFLTMAP1_RTS | -+ BIT_RXFLTMAP1_CTS | -+ BIT_RXFLTMAP1_ACK); ++ BIT_RXFLTMAP1_RTS | ++ BIT_RXFLTMAP1_CTS | ++ BIT_RXFLTMAP1_ACK);  + } rtw_write16(rtwdev, REG_RXFLTMAP1, rtwdev->hal.rxfltmap1); rtw_write16(rtwdev, REG_RXFLTMAP2, WLAN_RX_FILTER2); 2: 0639e4e27315 ! 2: 0e236c780923 wifi: rtw88: sdio: combine free TX page register reads @@ Commit message into the caller's array before releasing the host. Holding the host through the read and copy serializes access to the shared buffer.  - On RTL8822CS/NanoPi M5 at 198 MHz SDR104, median TCP upload increased - from 170 to 186 Mbit/s (+9%) with this patch alone, and from 258 to - 287 Mbit/s (+11%) when added after control-frame filtering. - - A separate download test measured 241 to 262 Mbit/s (+8%) with this - patch alone, and 263 to 274 Mbit/s (+4%) when added after filtering. - - Assisted-by: LLM Signed-off-by: Leonard Lausen   ## drivers/net/wireless/realtek/rtw88/sdio.c ## @@ drivers/net/wireless/realtek/rtw88/sdio.c: static atomic_t *rtw_sdio_8723bs_free   +static int rtw_sdio_read_free_txpg(struct rtw_dev *rtwdev, u32 *free_txpg)  +{ ++ u32 addr = rtw_sdio_to_bus_offset(rtwdev, REG_SDIO_FREE_TXPG);  + struct rtw_sdio *rtwsdio = (struct rtw_sdio *)rtwdev->priv;  + bool bus_claim = rtw_sdio_bus_claim_needed(rtwsdio); -+ u32 addr = rtw_sdio_to_bus_offset(rtwdev, REG_SDIO_FREE_TXPG);  + int i, ret;  +  + if (bus_claim) @@ drivers/net/wireless/realtek/rtw88/sdio.c: static atomic_t *rtw_sdio_8723bs_free  +  + if (!rtw_sdio_use_memcpy_io(rtwdev, addr, sizeof(u32))) {  + for (i = 0; i < RTW_SDIO_FREE_TXPG_COUNT; i++) { -+ free_txpg[i] = rtw_sdio_readl(rtwdev, addr + i * sizeof(u32), &ret); ++ free_txpg[i] = rtw_sdio_readl(rtwdev, ++ addr + i * sizeof(u32), ++ &ret);  + if (ret)  + break;  + }  + goto out;  + }  + -+ ret = sdio_memcpy_fromio(rtwsdio->sdio_func, rtwsdio->free_txpg, addr, ++ ret = sdio_memcpy_fromio(rtwsdio->sdio_func, ++ rtwsdio->free_txpg_buf, addr,  + RTW_SDIO_FREE_TXPG_COUNT * sizeof(__le32));  + if (!ret) {  + /* Copy the shared DMA buffer before releasing the host. */  + for (i = 0; i < RTW_SDIO_FREE_TXPG_COUNT; i++) -+ free_txpg[i] = le32_to_cpu(rtwsdio->free_txpg[i]); ++ free_txpg[i] = le32_to_cpu(rtwsdio->free_txpg_buf[i]);  + }  +  +out: @@ drivers/net/wireless/realtek/rtw88/sdio.c: static int rtw_sdio_check_free_txpg(s  - free_txpg[2] = rtw_sdio_read32(rtwdev, REG_SDIO_FREE_TXPG + 8);  + ret = rtw_sdio_read_free_txpg(rtwdev, free_txpg);  + if (ret) { -+ rtw_warn(rtwdev, "Failed to read free TX pages: %d\n", ret); ++ rtw_warn(rtwdev, "Failed to read free TX pages: %d\n", ++ ret);  + return ret;  + }  switch (queue) { case RTW_TX_QUEUE_BCN: -@@ drivers/net/wireless/realtek/rtw88/sdio.c: int rtw_sdio_probe(struct sdio_func *sdio_func, +@@ drivers/net/wireless/realtek/rtw88/sdio.c: static void rtw_sdio_deinit_tx(struct rtw_dev *rtwdev) + int rtw_sdio_probe(struct sdio_func *sdio_func, + const struct sdio_device_id *id) { ++ struct rtw_sdio *rtwsdio; struct ieee80211_hw *hw; struct rtw_dev *rtwdev; -+ struct rtw_sdio *rtwsdio; int drv_data_size; - int ret; -   @@ drivers/net/wireless/realtek/rtw88/sdio.c: int rtw_sdio_probe(struct sdio_func *sdio_func, if (ret) goto err_release_hw;   + rtwsdio = (struct rtw_sdio *)rtwdev->priv;  + if (!rtw_chip_wcpu_8051(rtwdev)) { -+ rtwsdio->free_txpg = devm_kmalloc_array(rtwdev->dev, -+ RTW_SDIO_FREE_TXPG_COUNT, -+ sizeof(*rtwsdio->free_txpg), GFP_KERNEL); -+ if (!rtwsdio->free_txpg) { ++ rtwsdio->free_txpg_buf = ++ devm_kmalloc_array(rtwdev->dev, ++ RTW_SDIO_FREE_TXPG_COUNT, ++ sizeof(*rtwsdio->free_txpg_buf), ++ GFP_KERNEL); ++ if (!rtwsdio->free_txpg_buf) {  + ret = -ENOMEM;  + goto err_deinit_core;  + } @@ drivers/net/wireless/realtek/rtw88/sdio.h: struct rtw_sdio { atomic_t tx_oqt_free; /* one writer at a time between the credit check and the accounting */ struct mutex tx_credit_lock; -+ __le32 *free_txpg; ++ __le32 *free_txpg_buf; };  extern const struct dev_pm_ops rtw_sdio_pm_ops;