Commit Graph

1461834 Commits

Author SHA1 Message Date
Abdun Nihaal
6496ce9084 wifi: rtlwifi: rtl8192du: Fix possible memory leak in rtl92du_init_sw_vars()
The memory allocated inside rtl92du_init_shared_data() is not freed in
any of the subsequent error paths in rtl92du_init_sw_vars().
Fix that by adding a call to rtl92du_deinit_shared_data() in the error
path.

Fixes: b5dc8873b6 ("wifi: rtlwifi: Add rtl8192du/sw.c")
Cc: stable@vger.kernel.org
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260723114539.136986-1-nihaal@cse.iitm.ac.in
2026-07-30 10:26:12 +08:00
Stanislaw Gruszka
799b5f45cb wifi: rtl818x: initialize eeprom_93cx6 struct to zero
Commit 7738a7ab9d ("misc: eeprom: eeprom_93cx6: Add quirk for extra
read clock cycle") added extra 'quirk' field to struct eeprom_93cx6.

Many existing users of eeprom_93cx6, including rtl818x drivers, allocate
the structure on the stack without initializing all fields. As a result,
the added quirk field has an undefined value and can randomly cause
reading wrong data from the EEPROM.

Fix by initializing the structures with {}.

Fixes: 7738a7ab9d ("misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle")
Cc: stable@kernel.org # v6.13+
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260723110640.8588-1-stf_xl@wp.pl
2026-07-30 10:19:06 +08:00
Mihail Dimoski
b0034a2e41 wifi: rtw88: disable ASPM and deep PS on ASUS TUF Gaming A15 FA506II
The RTL8822CE on the ASUS TUF Gaming A15 FA506II wedges during normal
use. The driver watchdog toggles PCIe ASPM while leaving power save;
the DBI read of the ASPM link-config register fails with -EIO, the PCIe
link becomes unstable, and the device drops off the bus, taking Wi-Fi
down until a cold power cycle:

  rtw88_8822ce 0000:03:00.0: failed to read ASPM, ret=-5
  rtw88_8822ce 0000:03:00.0: firmware failed to leave lps state
  rtw88_8822ce 0000:03:00.0: mac power on failed

This is the same platform ASPM inter-operability problem already
handled for other machines through rtw_pci_quirks[]. Disabling PCI
ASPM and deep power save on this model stops the failure. Add a DMI
quirk so the workaround is applied automatically.

Signed-off-by: Mihail Dimoski <mihaildimoski@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260718124045.23493-1-mihaildimoski@gmail.com
2026-07-24 11:38:52 +08:00
Ching-Te Ku
38c58d541c wifi: rtw89: coex: Add firmware 0.27.97.X support for RTL8852C
Newer firmware is using the new TLV-Header format, without this patch
it will lead driver run into length mismatch state.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-14-pkshih@realtek.com
2026-07-24 11:20:30 +08:00
Ching-Te Ku
236badaa50 wifi: rtw89: coex: Add wifi role info version 101
The structure active_role which describes the using Wi-Fi role format is
different with the exist v1. Add branch to cover the difference.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-13-pkshih@realtek.com
2026-07-24 11:19:04 +08:00
Ching-Te Ku
b8892add7e wifi: rtw89: coex: Add cycle status report version 105
The exists version 5 format has FDDT(frequency divided training) related
information. But the feature wasn't support for RTL8852C now, so firmware
will not send the related reference value.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-12-pkshih@realtek.com
2026-07-24 11:17:16 +08:00
Ching-Te Ku
b87da03ee7 wifi: rtw89: coex: Add slots version 2
Slots structure version 2 uses new TLV-Header to package slots information,
patch related entry for version 2.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-11-pkshih@realtek.com
2026-07-24 11:15:31 +08:00
Ching-Te Ku
42a83b5f13 wifi: rtw89: coex: Add TDMA version 4
TDMA version 4 uses new TLV-Header to package TDMA information,
patch related entry for version 4.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-10-pkshih@realtek.com
2026-07-24 11:15:16 +08:00
Ching-Te Ku
58b1bde371 wifi: rtw89: coex: Add firmware 0.29.133.X support for RTL8852B family
The new firmware modified GPIO setup structure format for third party
chip set I/O control & offloaded Wi-Fi TRX status to firmware for training
traffic RF-Parameters & TDMA mechanism.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-9-pkshih@realtek.com
2026-07-24 11:15:01 +08:00
Ching-Te Ku
35b569b60a wifi: rtw89: coex: Fix Wi-Fi role info H2C command header issue
The function to filled up H2C command data is the last step in the driver,
the next step is going to firmware. So the structure version number should
not included driver local branch number (like firmware is v5, but driver
branch to v105), it should be assigned as a explicit version number which
paired with firmware.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-8-pkshih@realtek.com
2026-07-24 11:14:44 +08:00
Ching-Te Ku
81d30a7be8 wifi: rtw89: coex: Add driver info H2C command index version 103
The 0.29.133.X firmware driver info H2C index maximum is 5, to prevent
switch case fall through and send unexpected H2C commands, add version
code 103 as judgment.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-7-pkshih@realtek.com
2026-07-24 11:14:29 +08:00
Ching-Te Ku
49989a3fef wifi: rtw89: coex: Refine chip initial related structure
Due to the firmware version become more and more, the version divided
branch coding method make the related code scattered everywhere, and
too much version macro, rearrange the code, assign the value to version
format only when H2C commands.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-6-pkshih@realtek.com
2026-07-24 11:12:38 +08:00
Ching-Te Ku
00961e2705 wifi: rtw89: coex: Branch out version 105 firmware report map index
RTL8852B in firmware 0.29.133.X do not support BT-TX-PWR report, re-index
and branch out to version 105.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-5-pkshih@realtek.com
2026-07-24 11:12:20 +08:00
Ching-Te Ku
b5bfb43844 wifi: rtw89: coex: Fix unexpected grant-signal assignee
The C2H report is for knowing what the grant-signal setting is now,
not for applying new grant-signal setting.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-4-pkshih@realtek.com
2026-07-24 11:11:55 +08:00
Ching-Te Ku
4bedf26e13 wifi: rtw89: coex: Add version 9 report control info
WiFi firmware will save its build date/time and package into C2H event then
send to driver. It helps to analyze what kind of firmware was loaded now.
Remove unnecessary memory set.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-3-pkshih@realtek.com
2026-07-24 11:10:12 +08:00
Ching-Te Ku
0427315a6e wifi: rtw89: coex: Add version 107 TX/RX info for firmware feature
The previous version 7 format is for Dual-Bluetooth using. This patch
is for single Bluetooth solution using. Driver will summary Wi-Fi now
status for firmware to train RF parameters & TDMA mechanism.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717065739.64124-2-pkshih@realtek.com
2026-07-24 11:08:32 +08:00
Ping-Ke Shih
b3dc0a37fd wifi: rtw89: phy: set CFR to manual mode for some 2GHz channels
The CFR (Channel Frequency Response) manual mode condition for 2GHz is
missing to limit on bandwidth for specific channels, which are channel
13 with 20MHz bandwidth and channel 11 with 40MHz bandwidth. Also add
a band check to avoid affecting 5GHz/6GHz bands.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-10-pkshih@realtek.com
2026-07-24 10:41:04 +08:00
Ping-Ke Shih
e738d2ac80 wifi: rtw89: 8922d: reduce IO in power-on function
To improve initial time, merge some IO to reduce IO times. Two registers
are:
 1. R_BE_SYS_PW_CTRL: 0x4[12:11]=0, 0x4[18]=1, 0x4[15]=0, and 0x4[10]=0
 2. R_BE_SYS_ADIE_PAD_PWR_CTRL: Merge 0x18[6] and 0x18[5]

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-9-pkshih@realtek.com
2026-07-24 10:40:58 +08:00
Ping-Ke Shih
238bc3141c wifi: rtw89: pci: set PCIe maximum TS1 for RTL8922DE
Set TS1 (training sequence 1) to 1024 when PCIe enters recovery state to
improve RF interference while entering and leaving L1ss.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-8-pkshih@realtek.com
2026-07-24 10:40:34 +08:00
Ping-Ke Shih
ce18a0cbc3 wifi: rtw89: wow: extend timeout unit to avoid SER false alarm
With original timeout unit, it might trigger SER false alarm causing
WiFi card lost. Extend timeout unit to avoid wrong SER.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-7-pkshih@realtek.com
2026-07-24 10:40:09 +08:00
Chih-Kang Chang
8983357077 wifi: rtw89: 8922d: bypass TXIQK when scan
When connected to an AP and a scan is triggered, the FW may fail to
transmit probe request because switching channels may load an
uninitialized TXIQK table. Therefore, bypass TXIQK during scanning
to avoid using invalid calibration values.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-6-pkshih@realtek.com
2026-07-24 10:38:23 +08:00
Chih-Kang Chang
e92d5b02b4 wifi: rtw89: rfk: update TXIQK H2C command format to v1
TX IQK is a RF calibration, the v1 format adds a field for the thermal
re-calibration parameter for RTL8922D after FW 0.35.113.0. Update the
format accordingly.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-5-pkshih@realtek.com
2026-07-24 10:36:39 +08:00
David Lee
355626a2c2 wifi: rtw89: 8852cu: add quirk to disable 2.4 GHz band
Add RTW89_QUIRK_DISABLE_2GHZ to the rtw89_quirks enum to allow
per-device suppression of the 2.4 GHz band.

Apply the quirk only for the 0x28de:0x2432 (VID:PID) USB device,
which operates only in 5/6 GHz bands.

Signed-off-by: David Lee <sc.lee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-4-pkshih@realtek.com
2026-07-24 10:34:51 +08:00
Johnson Tsai
721d90c850 wifi: rtw89: add multicolor LED support for RTL8852CU valve board
Add multicolor LED support for the RTL8852CU valve board to reflect
wireless connection status (by default, green LED is ON when associated
and OFF when disconnected).

Extend the rtw89 LED subsystem with a multicolor path via led_classdev_mc,
for board-level variants with more than one LED GPIO channel.

Add a new RTW89_LEDS_MC Kconfig option and support multicolor LEDs
through led_classdev_mc, with per-channel caching to minimize
redundant register writes. The RTL8852CU valve board is wired up as
the first user, driving a multicolor WRGB LED over four GPIO channels
(8, 18, 16, and 17) that map to LED_COLOR_ID_WHITE/RED/GREEN/BLUE.

Usage:
- Auto-triggered (default):
  Green LED ON when connected, OFF when disconnected

- Manual override (e.g., set red; channel order: WHITE RED GREEN BLUE):
    echo "0 1 0 0" > /sys/class/leds/rtw89-phyX-multicolor/multi_intensity
    echo 1         > /sys/class/leds/rtw89-phyX-multicolor/brightness

Signed-off-by: Johnson Tsai <wenjie.tsai@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-3-pkshih@realtek.com
2026-07-24 10:31:35 +08:00
Johnson Tsai
d910631ff3 wifi: rtw89: add LED support to reflect the wireless association status
Add a new RTW89_LEDS Kconfig option, along with LED structures to describe
flexible GPIO mappings for chip common LED definition. Core LED lifecycle
and registration logic default to the mac80211 association trigger, and
chips are wired up as the first user with a single-GPIO monochrome LED.

Usage:
- Auto-triggered (default):
  ON when connected, OFF when disconnected
- Manual override:
    echo <1|0> > /sys/class/leds/rtw89-phyX/brightness

Signed-off-by: Johnson Tsai <wenjie.tsai@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260717061910.54466-2-pkshih@realtek.com
2026-07-24 10:25:48 +08:00
Anirudh Srinivasan
27a5046cc5 wifi: rtw89: pci: enable 36-bit DMA on spacemit K3
The Spacemit K3 Pico ITX Board has a RTL8852BE pcie card behind a PCIe
root port, but the SoC doesn't have any 32 bit DMA addreseses which the
rtw89 seems to use by default. Enable 36 bit DMA ability that the driver
has when this particular root port is detected so that the driver can
probe on this SoC.

Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260716-rtw89-spacemit-k3-v2-2-392b577ebf75@oss.tenstorrent.com
2026-07-24 10:08:47 +08:00
Anirudh Srinivasan
888b193464 PCI: Move Spacemit vendor and device IDs to linux/pci_ids.h
Move the vendor and device ID for the existing Spacemit K1 PCIe Root
Complex to include/linux/pci_ids.h. Also add K3's Root Complex device ID
to this header. This is done so that these values can be referenced in
the rtw89 driver to enable 36-bit DMA ability in it for WiFi to function
on the K3 Pico ITX board.

Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260716-rtw89-spacemit-k3-v2-1-392b577ebf75@oss.tenstorrent.com
2026-07-24 10:02:44 +08:00
Chia-Yuan Li
730dbda6dc wifi: rtw89: fw: use MAC source for IO offload delay command
The udelay/mdelay helpers set the command source to
RTW89_FW_CMD_OFLD_SRC_OTHER (4), which does not fit the two-bit field
RTW89_H2C_CMD_OFLD_W0_SRC (GENMASK(1, 0)). The le32_encode_bits() masks
it down to 0 (RTW89_FW_CMD_OFLD_SRC_BB), and compiler throws
__field_overflow() error. Fortunately it still works because firmware
ignores the source field for a delay command.

Use RTW89_FW_CMD_OFLD_SRC_MAC as the vendor driver does, and drop the
unused RTW89_FW_CMD_OFLD_SRC_OTHER enumerator.

Reported-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Closes: https://github.com/morrownr/rtw89/issues/111
Fixes: ae3d327515 ("wifi: rtw89: add IO offload support via firmware")
Signed-off-by: Chia-Yuan Li <leo.li@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260714074811.30124-1-pkshih@realtek.com
2026-07-17 11:44:37 +08:00
GuoHan Zhao
73aecc221e wifi: rtw89: wow: fix unsupported cipher debug messages
Correct two WoWLAN debug messages to say "unsupported cipher".

Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260715060813.476245-1-zhaoguohan@kylinos.cn
2026-07-17 11:41:21 +08:00
Zong-Zhe Yang
3c15399ef6 wifi: rtw89: debug: add diagnosis for RF
Add debugfs diag_rf and show RFK (RF calibration) diagnosis things for
now. Record channel related info before triggering RFK, and then record
state of each kind of RFK from C2H event report. Besides, in track work,
monitor TSSI status too. Both support history up to 10, and show records
via debugfs.

The following is an example of output.

RFK (next index: 2)
  PHY-X    =    0     0     0     0     0     0     0     0     0     0
  S0-CH    = 0012a 0012a 00000 00000 00000 00000 00000 00000 00000 00000
  S0-CV    = 0032c 0032c 00000 00000 00000 00000 00000 00000 00000 00000
  S0-C5    = 10000 10000 00000 00000 00000 00000 00000 00000 00000 00000
  S1-CH    = 0012a 0012a 00000 00000 00000 00000 00000 00000 00000 00000
  S1-CV    = 0032d 0032d 00000 00000 00000 00000 00000 00000 00000 00000
  S1-C5    = 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000
  PRE_NTFY =    0     0     0     0     0     0     0     0     0     0
  TSSI     =    1     1     0     0     0     0     0     0     0     0
  IQK      =    1     1     0     0     0     0     0     0     0     0
  DPK      =    1     1     0     0     0     0     0     0     0     0
  TXGAPK   =    1     1     0     0     0     0     0     0     0     0
  DACK     =    0     0     0     0     0     0     0     0     0     0
  RX_DCK   =    1     1     0     0     0     0     0     0     0     0
  TX_IQK   =    1     1     0     0     0     0     0     0     0     0
  CIM3k    =    1     1     0     0     0     0     0     0     0     0
TSSI-track (next index: 6)
  S0       =   00e   00e   00c   00d   00d   00e   00d   00d   00d   00e
  S1       =   00a   00b   009   00a   00a   00a   009   009   009   00a

Debugfs diag_rf can also be used to manually trigger RFK when written by 1.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712034506.53209-9-pkshih@realtek.com
2026-07-17 11:28:25 +08:00
Ping-Ke Shih
b5bf2dc96f wifi: rtw89: fw: do bb_preinit before downloading firmware
The firmware access BB registers while initialization, so driver should
do bb_preinit before downloading firmware. Otherwise, it might get BB IO
stuck and throw error.

  rtw89_8922de 0000:04:00.0: loaded firmware rtw89/rtw8922d_fw.bin
  rtw89_8922de 0000:04:00.0: Firmware version 0.35.111.7 (51c56e7b), cmd version 1, type 14
  rtw89_8922de 0000:04:00.0: Firmware version 0.35.111.7 (51c56e7b), cmd version 1, type 15
  rtw89_8922de 0000:04:00.0: fw unexpected status 6
  rtw89_8922de 0000:04:00.0: download firmware fail
  rtw89_8922de 0000:04:00.0: [ERR]fwdl 0x1E0 = 0x8000012
  rtw89_8922de 0000:04:00.0: [ERR]fwdl 0x78F0 = 0x290900
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]fw PC = 0x201445f2
  rtw89_8922de 0000:04:00.0: [ERR]H2C path ready

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712034506.53209-8-pkshih@realtek.com
2026-07-17 11:18:31 +08:00
Zong-Zhe Yang
b4eaac15cb wifi: rtw89: extend tx shape format for regulatory 6 GHz power type
Even under the same regulation, TX shape may need different settings for
different 6 GHz power types. So, add one more dimension for that. Because
TX shape parameters are not quite large, the 2/5/6 GHz sections are not
divided into different structures. So, the 2/5 GHz sections will also get
the new dimension. To 2/5 GHz sections, fill the TX shape settings with
RTW89_REG_6GHZ_POWER_DFLT (0) field.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712034506.53209-7-pkshih@realtek.com
2026-07-17 11:16:44 +08:00
Zong-Zhe Yang
7054b03136 wifi: rtw89: add tx shape v0 to keep built-in arrays compatible during transitions
TX shape parameters can come from (old way) built-in arrays or (new way)
FW elements. The built-in arrays will no longer be updated, but will be
retained during a certain transition period. However, the format of newer
TX shape parameters are going to be expanded. It will only be applied to
FW elements. To keep built-in arrays compatible during transition period,
add tx shape v0 for old format.

The v0 fields can be removed along with built-in arrays once transition
period ends.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712034506.53209-6-pkshih@realtek.com
2026-07-17 11:14:56 +08:00
Zong-Zhe Yang
ed74acea83 wifi: rtw89: introduce helper to get tx shape index
TX shape has a set of parameters inside RFE (RF Front End) parameters.
It also depends on regulation and even will depend on regulatory 6 GHz
power type afterwards. Introduce a helper to encapsulate the access to
TX shape index.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712034506.53209-5-pkshih@realtek.com
2026-07-17 11:13:07 +08:00
Ping-Ke Shih
b9f582e939 wifi: rtw89: 8922d: add TX time limit for 2GHz band
Fix 2.4GHz specific L-SIG length TX issue, causing interoperability problem
with certain APs. Limit the A-MPDU duration to be workaround.

For 8922DE, the MAC limit is 164 ticks, and BB limit is 4608 us. The
conversion is 32.768us / tick. Since smaller limit should be adopted,
BB limit is filled into newly added field.

The units of register and CCTL table are tick and us/512 respectively.
Convert to target unit when filling values.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712034506.53209-4-pkshih@realtek.com
2026-07-17 11:11:20 +08:00
Ping-Ke Shih
07c26ead36 wifi: rtw89: mac: abstract register definition of firmware boot debug
The registers of firmware boot debug are different between WiFi 6 and 7
chips. Add field to abstract it accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712034506.53209-3-pkshih@realtek.com
2026-07-17 11:10:08 +08:00
Eric Huang
b45b22bbe9 wifi: rtw89: pack I/O during bb_sethw to reduce API execution time
Wrap rtw89_chip_bb_sethw() with rtw89_io_pack/unpack so all register
writes during baseband hardware initialization are batched into a single
bus transaction. This reduces API execution time from ~11000 us to
~4000 us on affected platforms.

Signed-off-by: Eric Huang <echuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712034506.53209-2-pkshih@realtek.com
2026-07-17 11:08:23 +08:00
Ching-Te Ku
c2d96cd05c wifi: rtw89: coex: Update coexistence version to 9.24.0
RTL8922D first release, add related feature support.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-12-pkshih@realtek.com
2026-07-17 10:58:12 +08:00
Ching-Te Ku
aed0d7771d wifi: rtw89: coex: update external control length by case
Update recommend external control slot length to driver. Some of the
Wi-Fi feature has its time slot requirement can not be simply controlled
by coexistence firmware TDMA timer. For example: Wi-Fi scan/MCC etc.
In the same time, coexistence need to tell driver the recommend Bluetooth
slot length to make sure Bluetooth can still has enough time slot to
traffic.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-11-pkshih@realtek.com
2026-07-17 10:56:28 +08:00
Ching-Te Ku
578f9b4827 wifi: rtw89: coex: Add firmware report control report v11
In the version 11 report control report, firmware will report firmware
build date, version. And Bluetooth to Wi-Fi scoreboard value will be
read at Wi-Fi firmware and update to Wi-Fi driver.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-10-pkshih@realtek.com
2026-07-17 10:54:44 +08:00
Ching-Te Ku
f59f076734 wifi: rtw89: coex: Correct SET_RFE settings
Because of dual-BT & dual-MAC, RTL8922D has more complex antenna settings.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-9-pkshih@realtek.com
2026-07-17 10:52:52 +08:00
Ching-Te Ku
aaba33e780 wifi: rtw89: coex: Refine _reset_btc_var()
To avoid the default value not match the real using scenario, it should
after assign desired default value after variable reset.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-8-pkshih@realtek.com
2026-07-17 10:50:57 +08:00
Ching-Te Ku
a67bb858ba wifi: rtw89: coex: Refine send firmware command function
Because the coexistence offload more register/ hardware setting I/O to
firmware by coexistence itself, and it goes with the same entry with other
control action, so the firmware command entry need to add different
condition to judge should it followed coexistence TLV format or not.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-7-pkshih@realtek.com
2026-07-17 10:49:05 +08:00
Ching-Te Ku
5d5a5eb7ae wifi: rtw89: coex: Rearrange Bluetooth firmware report entry
To enable/disable firmware report once at the end of mechanism round.
This can make the logic more clearly, and make sure every round the
mechanism running can refresh the settings. It can avoid some report
missing after driver status change.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-6-pkshih@realtek.com
2026-07-17 10:48:50 +08:00
Ching-Te Ku
a20edfbc15 wifi: rtw89: ceox: Update antenna & grant signal setting
Merge set antenna & grant signal logic. Combine all information to big
structure for runtime logic using, only separate to version format while
it is going to assign value to register or offload to firmware. Add new
format for dual-BT & external BT for RTL8922D.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-5-pkshih@realtek.com
2026-07-17 10:47:03 +08:00
Ching-Te Ku
404edeea3b wifi: rtw89: coex: Update driver outsource info to firmware version 6
In order to make dual MAC Wi-Fi performance more stable, and take effect
in time, offload more register/ hardware control to firmware.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-4-pkshih@realtek.com
2026-07-17 10:45:16 +08:00
Ching-Te Ku
3b6dd05aee wifi: rtw89: coex: Rearrange coexistence control structure
The control structure will record some Wi-Fi/Bluetooth status, and
packed send to firmware. The new generation chip had offloaded many
mechanism control to firmware, firmware may need update these very
often to make sure run in correct mechanism.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-3-pkshih@realtek.com
2026-07-17 10:43:32 +08:00
Ching-Te Ku
af7f59e8e8 wifi: rtw89: coex: Add Wi-Fi role info version 10
Because the new generation Bluetooth will able to work on 5/6GHz band,
it will suffer 5/6GHz Wi-Fi, the mechanism need to cover more scenario
with different Wi-Fi/Bluetooth combination.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260712030506.43438-2-pkshih@realtek.com
2026-07-17 10:41:41 +08:00
Chelsy Ratnawat
d4157cd3ae wifi: rtlwifi: rtl8192d: remove dead SMPS rate mask code
mimo_ps is initialized to IEEE80211_SMPS_OFF and never modified in
rtl92d_update_hal_rate_table(). Therefore, the IEEE80211_SMPS_STATIC
case is unreachable.
Remove the unused mimo_ps variable and the dead branch.

Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260709194315.157030-1-chelsyratnawat2001@gmail.com
2026-07-17 10:37:10 +08:00
Fan Wu
6c080026ec wifi: rtl8xxxu: fix use-after-free from rx_urb_wq on stop
rtl8xxxu arms rx_urb_wq from the RX completion path:
rtl8xxxu_rx_complete() hands the URB to rtl8xxxu_queue_rx_urb(), which
queues it on rx_urb_pending_list and, once the list grows past
RTL8XXXU_RX_URB_PENDING_WATER, schedules rx_urb_wq.  The worker
rtl8xxxu_rx_urb_work() drains rx_urb_pending_list, recovers priv through
container_of, and resubmits each URB through rtl8xxxu_submit_rx_urb(),
which anchors it on rx_anchor and dereferences priv->udev.

rtl8xxxu_stop() cancels the sibling work items (c2hcmd_work, ra_watchdog,
update_beacon_work) but never cancels rx_urb_wq, so a worker armed during
the last burst of RX traffic can run rtl8xxxu_rx_urb_work() after
rtl8xxxu_disconnect() has called ieee80211_free_hw(), which frees priv,
producing a use-after-free.  The window opens under active RX traffic
(pending count above the watermark) followed by a disconnect.

There are two teardown races to close:

  * rtl8xxxu_queue_rx_urb() decided whether to enqueue under rx_urb_lock
    but called schedule_work() after dropping the lock.  A completion
    that observed shutdown == false and released the lock could then call
    schedule_work() after rtl8xxxu_stop() had set shutdown and
    cancel_work_sync() had already returned, arming the worker to run
    after the teardown.  Move schedule_work() under the same !shutdown
    branch so the arming decision is atomic with the shutdown check.

  * rtl8xxxu_rx_urb_work() anchors every URB it drained back onto
    rx_anchor through rtl8xxxu_submit_rx_urb().  A worker still running
    when usb_kill_anchored_urbs(&priv->rx_anchor) returned would submit a
    URB that escaped the kill.  In rtl8xxxu_stop(), call
    cancel_work_sync(&priv->rx_urb_wq) before the kill so the worker is
    drained first.

After priv->shutdown is set under rx_urb_lock, completions can no longer
queue rx_urb_wq. cancel_work_sync() then drains the last queued or running
worker, and the following usb_kill_anchored_urbs() kills the URBs it may
have submitted.

rtl8xxxu_disconnect() is covered because ieee80211_unregister_hw()
guarantees .stop() runs for a live interface before ieee80211_free_hw()
frees priv.  The probe error path needs no cancel: rx_urb_wq is
INIT_WORK()'d there but cannot have been scheduled, since no URB is
submitted before ieee80211_register_hw() succeeds.

This bug was found by static analysis.

Fixes: 26f1fad29a ("New driver: rtl8xxxu (mac80211)")
Cc: stable@vger.kernel.org
Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260630033117.3377-1-fanwu01@zju.edu.cn
2026-07-12 12:18:26 +08:00