From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3190634C826 for ; Wed, 15 Apr 2026 11:13:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776251637; cv=none; b=iO4baginlYevxzwUn8x58hNE5XgAhzoAaBAfGI1UqXeSQb3sofg9JSGpwEwPUgOuhpR5Jwsw0E72N3mSSpnpcsbh6UzNw3NjiVdVqAQitAyQOz8GGcpujMVW9GMOakIEyvjbBUnDTx+MFUiOwVli3yjeBxEGGdSlAM9+oj5/q/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776251637; c=relaxed/simple; bh=+WmQBag2xKG2Gx7djYJ7iyEhZicjNmTbO6K5EBS12tQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D0pKwakuHrhIYqqN5QK0erjfc+gGiGAAhHsfX0igzBQM+Eq91Wv+k9AcgBaMtJ7TWdwSmf8yygOD2HI+svwZYoMXiNuZvtbQXzf2i20x/Gj++tOCsAWBZHalUd6HGo2T3otPFo8nu9VBEkdT1HQULtYKeu6DB7apKZ1RqyFCtTU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RIRmn9GP; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RIRmn9GP" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-488b0e1b870so103288995e9.2 for ; Wed, 15 Apr 2026 04:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776251632; x=1776856432; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bpedEU7mGkTRSv5C/AyW29lZoy8mTTrAXlbvsWFWNaY=; b=RIRmn9GP6ZsBXx/co/Ukt+5TAZq2hOCDMGJuiaSF/xBE0POK8l+ifh0gSqB3SCi4RN YBk4Wf0PbZoL7PO6c4Dvwm5lZb0g4zO0SNpY/+2jLgC6Uovt6IbKXNHw6xm9KuH3GVeH WBr0tFDMYz1jT4aNunmLuVHf5X8uKJmwtFz9Z35kXh8rymHDsoEmaHEzvIz/do1imqCd sHplOl7FDzpNlA5iImNkI2JQq9t9yYNrORib4CYHBSYsxwEQU0O/j7WJclOKa0zlAriQ +YNQgUIThJsVmWia+tb00vqDPghcdTc9HYpSWev20wmh/Ol/ExLE4ZrcnFsxjhZd8+bq 0EuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776251632; x=1776856432; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bpedEU7mGkTRSv5C/AyW29lZoy8mTTrAXlbvsWFWNaY=; b=R9rPACNfQT8UqVhhPfjPzFSND3IebNd42GyLHTlgfjf6Vi7lFX/WZ0/Rur0v9gqWMJ Fcy9f6tV4pLwK5us0PDWieTqrYfFFMnJnhUqxH3m+LTly4MvucA/GR9agZTFscfJAK6Q Sxcsl9mUzjyXlRPQg6QA64isrsItkX5oOvkIySdtH0xGSCHlm/l1fVu8HPvhKf2pXvrY ITlLcbKybdOsohixQ1yUUPae8Te355+8dbuJApJxwb+zP+g+gDidNFZrXlxlNSjtXFHu B70C3te6IANrtP0428KOXG/yAqcxSuIv2wi2j7odJtc9IeNp90AFflf21+o24TNi2+ON sB6g== X-Forwarded-Encrypted: i=1; AFNElJ/4js18zGDic1p7rd4hVD+m3YtXXezLWV//8gjQdoQK3ehvJVOty+CcbctNJv400O2CehH8QUujNWtTY/w=@vger.kernel.org X-Gm-Message-State: AOJu0YwHueWgywhQz8h9QQJjFHobDTRZAwYLDCQmh8/sznLXFy/72KMj gMqS4SEZvvU7RWGjoLTnm1ZeiN9AiG/hLqIrhCzLFB5gyLKeeskm5mDs X-Gm-Gg: AeBDieswNl/vYxSp4n3tZLFaHA5JAoJak1DKg+Wh61HaQPOPgVLNHefvhbZnGTYtvCj wCflMGGLjkD+EeL13UYVWnFOuFheqOtBT8LllhsQAYNzXVrajNfdFjZ5v6IPlLL3m+Z/+6PBe6s O7RuCVQcrcxId/ctAw4E8e89fOYeMJHEJXIm1+EWmStz3fCgYv3w8Zx2LpjCtRAZ5CIHY9BP4rB wLp+ZVmXFayMIIc7QA3k4se9FusIUI+7j1ydT3cq3XRZhhAc8ksZ/xzHtBrq0BNUSqBdCk270Ca KuSzClLj7l6EeSqPuo9TRL2LF2saBRUsSceWRmdEdfDMRGsQwITtjh9vPLRATo/YVw70nujMe9z FMs47DBWw5TlrKCfFVKrTxZCLfUzPCeb0V4fxAGE7g28xM03PAAe9tmEvbyX5PY1yEqIf1UWZTw j9wt/vFJSKOh4509U/6xrPvSWQoI0RGoT5R6AHAt8HHPKpn6ZeQ4kSaoMdOg== X-Received: by 2002:a05:600c:8883:b0:488:a82f:bb95 with SMTP id 5b1f17b1804b1-488d689c18fmr221931445e9.29.1776251632200; Wed, 15 Apr 2026 04:13:52 -0700 (PDT) Received: from bazzite ([102.128.175.252]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488f0ebd0e1sm17995625e9.28.2026.04.15.04.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2026 04:13:51 -0700 (PDT) From: Louis Kotze To: Ping-Ke Shih Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, rtl8821cerfe2@gmail.com, Louis Kotze Subject: [PATCH v2] wifi: rtw89: phy: increase RF calibration timeouts for USB transport Date: Wed, 15 Apr 2026 13:13:37 +0200 Message-ID: <20260415111339.453602-1-loukot@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410080017.82946-1-loukot@gmail.com> References: <20260410080017.82946-1-loukot@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit USB transport adds significant latency to H2C/C2H round-trips used by RF calibration. The existing timeout values were designed for PCIe and are too tight for USB, causing "failed to wait RF DACK", "failed to wait RF TSSI" and similar errors on USB adapters. Apply a 4x timeout multiplier when the device uses USB transport. The multiplier is applied in rtw89_phy_rfk_report_wait() so all calibrations benefit without changing any call sites or PCIe timeout values. The 4x multiplier was chosen based on measured data from two independent testers (RTL8922AU, 6GHz MLO and 2.4/5GHz): Calibration PCIe timeout Max measured (USB) 4x timeout PRE_NTFY 5ms 1ms 20ms DACK 58ms 72ms 232ms RX_DCK 128ms 374ms 512ms TSSI normal 20ms 24ms 80ms TSSI scan 6ms 14ms 24ms TXGAPK 54ms 18ms 216ms IQK 84ms 53ms 336ms DPK 34ms 30ms 136ms Tested with RTL8922AU on 6GHz MLO (5GHz + 6GHz simultaneous): 25 connect/disconnect cycles with zero failures. In response to review feedback on v1, the 4x multiplier was also re-verified under adverse host conditions on 5GHz. 5 cycles per scenario, stress-ng as the load generator, max observed time per calibration: Calibration PCIe 4x Baseline CPU stress Mem stress Combined PRE_NTFY 5 20 0 0 0 1 DACK 58 232 71 (!) 71 (!) 71 (!) 71 (!) RX_DCK 128 512 23 22 22 23 IQK 84 336 53 53 53 53 DPK 34 136 23 23 26 23 TSSI 20 80 6 9 14 9 TXGAPK 54 216 16 16 16 16 Legend: (!) = exceeds PCIe budget but within 4x budget. Two observations from that matrix: 1. DACK exceeds the stock PCIe budget (58ms) in baseline on 5GHz on this hardware. Without the 4x multiplier, DACK fails -ETIMEDOUT deterministically on every connect, no stress needed. This is the specific bug the patch fixes. 2. Calibration times are I/O bound (USB H2C/C2H round-trip latency), not CPU or memory bound. DACK stays at 71ms across all four scenarios. Host-side stress has essentially zero effect on observed calibration duration. Bumping the multiplier above 4x would not address a failure mode that this stress matrix produces. Signed-off-by: Louis Kotze --- Changes since v1: - Fix comment style per Ping-Ke Shih review (first line '/*' on its own line, kernel-standard format). - Add stress-test verification table to the commit message. The 4x multiplier was re-measured on 5GHz under CPU stress, memory stress, and combined stress using stress-ng. DACK max is 71ms in all four scenarios, confirming calibration times are I/O bound (USB H2C/C2H round-trip) and not affected by host-side load. - Drop v1 patch 2/2 ("make RF calibration timeouts non-fatal on USB"). As Ping-Ke noted, the return code from rtw89_phy_rfk_*_and_wait() is discarded by all 8922a callers, making the non-fatal change a no-op for 8922a. Worse, the one 8922d caller that does check the return (rtw8922d_rfk_tssi) uses it to fall back to non-TSSI mode on calibration failure — patch 2/2 would have silently broken that fallback. With patch 1/2's multiplier alone, 25 connect/disconnect cycles complete with zero failures, and the new stress matrix above confirms the margin. drivers/net/wireless/realtek/rtw89/phy.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c index e70d0e283..1f249c297 100644 --- a/drivers/net/wireless/realtek/rtw89/phy.c +++ b/drivers/net/wireless/realtek/rtw89/phy.c @@ -3956,6 +3956,14 @@ int rtw89_phy_rfk_report_wait(struct rtw89_dev *rtwdev, const char *rfk_name, struct rtw89_rfk_wait_info *wait = &rtwdev->rfk_wait; unsigned long time_left; + /* + * USB transport adds latency to H2C/C2H round-trips, so RF + * calibrations take longer than on PCIe. Apply a 4x multiplier + * to avoid spurious timeouts. + */ + if (rtwdev->hci.type == RTW89_HCI_TYPE_USB) + ms *= 4; + /* Since we can't receive C2H event during SER, use a fixed delay. */ if (test_bit(RTW89_FLAG_SER_HANDLING, rtwdev->flags)) { fsleep(1000 * ms / 2); -- 2.53.0