Skip to contentSkip to conversation

wifi: rtw89: allocate rfe_data with kvzalloc

PATCH In review rcfa 2 participants 2 messages Dec 2 Realtek wireless driver (rtw89)

lore
Share & tools
lore

rcfa

author
#0 lore raw

PATCH v2 1/1 wifi: rtw89: allocate rfe_data with kvzalloc

struct rtw89_rfe_data holds the TX power tables from the firmware file's elements and is 1190784 bytes, so kzalloc() asks for an order-9 (2 MiB) contiguous block. On a host that has been up for a while there may be none, and probing a USB adapter that is plugged in then fails:

kworker/12:1: page allocation failure: order:9, mode:0x40dc0(GFP_KERNEL|__GFP_ZERO|__GFP_COMP)
...
failed to recognize firmware elements
failed to setup chip information
probe with driver rtw89_8922au_git failed with error -12

Tested on an RTL8922AU (a USB 2 adapter).

Fixes 5ee7b2ea07cc ("wifi: rtw89: load TX power related tables from FW elements")

---

Notes:
v2:
- Commit message reduced to the problem and the test line, as asked; the rest of v1's message follows here.
- Rebased on rtw-next ae6b9e98b904; the code is unchanged.

On the name: rcfa is the name I sign with everywhere, and it is my GitHub identity (https://github.com/rcfa), where the out-of-tree side of this rtw89 work is public, e.g. morrownr/rtw89 pull requests #139 and #141. submitting-patches.rst asks for "a known identity" (since d4563201f33a, 2023), not a legal name. I hope that is acceptable.

v1: https://lore.kernel.org/linux-wireless/[email protected]/

Only the CPU reads the tables, so vmalloc memory is fine for them.

Test details: the out-of-tree copy of this driver (morrownr/rtw89, which carries rtw-next as of 2026-11-05; hence the module name in the log), kernel 7.2.15. The failure came from replugging the adapter after 16 hours of uptime, when the Normal zone had no free block of order 8 or above. With this change the driver probes, connects and unloads cleanly, and it has run on that host since 2026-11-07. A test build that always used vzalloc() for rfe_data, to exercise the fallback path, put the tables in vmalloc space (1196032 bytes in /proc/vmallocinfo), showed the same debugfs txpwr_table as the unchanged driver on the same association, passed traffic and unloaded without warnings.

The problem was found with Claude Code (Claude Opus 5.5) while testing the driver; this change and its changelog were written in the same session.

 drivers/net/wireless/realtek/rtw89/core.c | 2 +-
 drivers/net/wireless/realtek/rtw89/fw.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +1 -1
index 3a80ac8dbbd9..273546964f45 100644
@@ -7839,7 +7839,7 @@ EXPORT_SYMBOL(rtw89_alloc_ieee80211_hw);
 void rtw89_free_ieee80211_hw(struct rtw89_dev *rtwdev)
 {
 	kfree(rtwdev->ops);
-	kfree(rtwdev->rfe_data);
+	kvfree(rtwdev->rfe_data);
 	release_firmware(rtwdev->fw.req.firmware);
 	ieee80211_free_hw(rtwdev->hw);
 }
drivers/net/wireless/realtek/rtw89/fw.c +1 -1
index 89559454ebe2..654bc2ce7428 100644
@@ -1285,7 +1285,7 @@ int rtw89_fw_recognize_txpwr_from_elm(struct rtw89_dev *rtwdev,
 		return 1;
 
 	if (!rtwdev->rfe_data) {
-		rtwdev->rfe_data = kzalloc_obj(*rtwdev->rfe_data);
+		rtwdev->rfe_data = kvzalloc_obj(*rtwdev->rfe_data);
 		if (!rtwdev->rfe_data)
 			return -ENOMEM;
 	}

base-commit: ae6b9e98b9045e47f609ec2a8197a3f3109627cb

Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 11 lines · rcfa

struct rtw89_rfe_data holds the TX power tables from the firmware file's elements and is 1190784 bytes, so kzalloc() asks for an order-9 (2 MiB) contiguous block. On a host that has been up for a while there may be none, and probing a USB adapter that is plugged in then fails:

kworker/12:1: page allocation failure: order:9, mode:0x40dc0(GFP_KERNEL|__GFP_ZERO|__GFP_COMP)
...
failed to recognize firmware elements
failed to setup chip information
probe with driver rtw89_8922au_git failed with error -12

Quoted 4 lines

Tested on an RTL8922AU (a USB 2 adapter).

Fixes 5ee7b2ea07cc ("wifi: rtw89: load TX power related tables from FW elements")

Use your real name.