From: Ping-Ke Shih pkshih@realtek.com
[ Upstream commit 7e1c44fe4c2e1e01fa47d9490893d95309a99687 ]
When driver receives new or unknown C2H events, it print out messages repeatedly once events are received, like
rtw89_8922ae 0000:81:00.0: PHY c2h class 2 not support
To avoid the thousands of messages, use rtw89_info_once() instead. Also, print out class/func for unknown (undefined) class.
Reported-by: Sean Anderson sean.anderson@linux.dev Closes: https://lore.kernel.org/linux-wireless/20250729204437.164320-1-sean.anderson... Reviewed-by: Sean Anderson sean.anderson@linux.dev Signed-off-by: Ping-Ke Shih pkshih@realtek.com Link: https://patch.msgid.link/20250804012234.8913-2-pkshih@realtek.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
Why this is a good stable backport - Fixes real user pain (log flooding): The current rtw89 driver logs an info message for every unknown/unhandled C2H event, leading to “thousands of messages” per the commit message. In-tree code shows exactly this behavior: - `drivers/net/wireless/realtek/rtw89/mac.c:5535` prints “MAC c2h class %d not support” and returns for every unknown class; `drivers/net/wireless/realtek/rtw89/mac.c:5539` prints “MAC c2h class %d func %d not support”. - `drivers/net/wireless/realtek/rtw89/phy.c:3128` prints “PHY c2h class %d not support”; `drivers/net/wireless/realtek/rtw89/phy.c:3132` prints “PHY c2h class %d func %d not support”. This can flood dmesg/syslog when firmware repeatedly sends such events, crowding out important logs and consuming resources. Reducing this to a single print per callsite is a tangible bugfix for system reliability and observability. - Minimal and contained change: - Adds a single helper macro mapping to a long‑standing kernel facility: `rtw89_info_once` → `dev_info_once` in `drivers/net/wireless/realtek/rtw89/debug.h` near `rtw89_info` (see `drivers/net/wireless/realtek/rtw89/debug.h:58`). `dev_info_once` is widely available (see `include/linux/dev_printk.h:204`), so no portability concerns across stable series. - In both handlers, shifts unknown/unsupported printing into the common “no handler” path and uses `rtw89_info_once`: - For MAC: stops logging in the switch `default:` and instead logs once when `handler == NULL` with class/func, then returns. Behavior remains identical (unknowns are dropped), but message prints once instead of per-event. - For PHY: same pattern—remove per-event `default:` logging and replace the final “no handler” print with `rtw89_info_once` showing class/func. - No data path, timing, locking, or ABI changes; only logging behavior is touched. - Low regression risk: - Control flow remains the same for unknown events: they are ignored after a single informational notice. Previously an unknown class returned early after printing; now it falls through and returns at the `!handler` check. Since `handler` is `NULL` for unknowns, the net effect is the same. - `dev_info_once` is per callsite, preventing floods while still signaling the condition once. - Aligns with stable policy: This is a focused, risk‑free improvement that prevents severe kernel log spam, a class of fixes commonly accepted into stable when the noise can degrade system usability or mask other issues. It is confined to the rtw89 driver and does not introduce features or architectural changes. - Reported and reviewed: The patch addresses a real report (Closes/Reported-by in the message), with a clear rationale and review, indicating practical relevance.
Notes for backporting - Context differences: Some older branches (e.g., `drivers/net/wireless/realtek/rtw89/phy.c:3123-3126`) have a special- case return for `RTW89_PHY_C2H_CLASS_DM` with `RTW89_PHY_C2H_DM_FUNC_LOWRT_RTY`. The logging adjustment is still trivial: remove per-event prints in the switch `default:` and convert the final `!handler` print to `rtw89_info_once` with class/func. No functional behavior needs to change. - No external dependencies: `dev_info_once` is present in the tree (`include/linux/dev_printk.h:204`), so introducing `rtw89_info_once` in `debug.h` is safe across stable series.
Summary of changes that matter - Add `#define rtw89_info_once(rtwdev, a...) dev_info_once((rtwdev)->dev, ##a)` next to `rtw89_info` (drivers/net/wireless/realtek/rtw89/debug.h:58). - In `rtw89_mac_c2h_handle`, stop printing in the `default:` and instead log once in the `if (!handler)` block with class/func and return (drivers/net/wireless/realtek/rtw89/mac.c:5535, 5539). - In `rtw89_phy_c2h_handle`, same pattern: remove per-event `default:` log and use `rtw89_info_once` with class/func in the `!handler` block (drivers/net/wireless/realtek/rtw89/phy.c:3128, 3132).
Given the concrete reduction of harmful log spam, tiny and contained code deltas, and zero behavioral risk, this is a solid candidate for stable backport.
drivers/net/wireless/realtek/rtw89/debug.h | 1 + drivers/net/wireless/realtek/rtw89/mac.c | 7 +++---- drivers/net/wireless/realtek/rtw89/phy.c | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/debug.h b/drivers/net/wireless/realtek/rtw89/debug.h index fc690f7c55dc7..a364e7adb0798 100644 --- a/drivers/net/wireless/realtek/rtw89/debug.h +++ b/drivers/net/wireless/realtek/rtw89/debug.h @@ -56,6 +56,7 @@ static inline void rtw89_debugfs_deinit(struct rtw89_dev *rtwdev) {} #endif
#define rtw89_info(rtwdev, a...) dev_info((rtwdev)->dev, ##a) +#define rtw89_info_once(rtwdev, a...) dev_info_once((rtwdev)->dev, ##a) #define rtw89_warn(rtwdev, a...) dev_warn((rtwdev)->dev, ##a) #define rtw89_err(rtwdev, a...) dev_err((rtwdev)->dev, ##a)
diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c index 5a5da9d9c0c5b..ef17a307b7702 100644 --- a/drivers/net/wireless/realtek/rtw89/mac.c +++ b/drivers/net/wireless/realtek/rtw89/mac.c @@ -5813,12 +5813,11 @@ void rtw89_mac_c2h_handle(struct rtw89_dev *rtwdev, struct sk_buff *skb, case RTW89_MAC_C2H_CLASS_ROLE: return; default: - rtw89_info(rtwdev, "MAC c2h class %d not support\n", class); - return; + break; } if (!handler) { - rtw89_info(rtwdev, "MAC c2h class %d func %d not support\n", class, - func); + rtw89_info_once(rtwdev, "MAC c2h class %d func %d not support\n", + class, func); return; } handler(rtwdev, skb, len); diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c index d607577b353c6..01a03d2de3ffb 100644 --- a/drivers/net/wireless/realtek/rtw89/phy.c +++ b/drivers/net/wireless/realtek/rtw89/phy.c @@ -3626,12 +3626,11 @@ void rtw89_phy_c2h_handle(struct rtw89_dev *rtwdev, struct sk_buff *skb, handler = rtw89_phy_c2h_dm_handler[func]; break; default: - rtw89_info(rtwdev, "PHY c2h class %d not support\n", class); - return; + break; } if (!handler) { - rtw89_info(rtwdev, "PHY c2h class %d func %d not support\n", class, - func); + rtw89_info_once(rtwdev, "PHY c2h class %d func %d not support\n", + class, func); return; } handler(rtwdev, skb, len);