From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00A8D278768; Wed, 4 Jun 2025 01:06:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748999204; cv=none; b=LpMSPmRacN4t+EtAjdL3UhII5RhmY2GL3LcwzZXdOYa+QV0I+rE2uanMzwf5yo/YbGInLCthZjvlUNuM59vbeeTd2GwIN0q8tMNojTCBAizPgdoF1z1DWDPG6Pri9F/Ocukae3LKLNsJnjAHGxq7G9H/+veZ7vjenMy3yMKHHHo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748999204; c=relaxed/simple; bh=7la9tkxVWChGcACeRi/wCBQUcgZX5m1UrEUx/l3PrLs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=MfdAcxhRLdbcqfcTzoIFqRIpDXEQgUqi3XvY5QlDQG5z6DBeVLxiaAy3awNKUnmS71xHqCeoCpH7uBxzqACiyoPPWFHrB7IHWuQb+4mB+Dnw1COblgWyymnTUiRkhpx2Z9aAcDq/GbmyO/8YCFN/EQZ3GOsvxLDQWgbTK1+rk1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pgJ7n00x; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pgJ7n00x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08437C4CEED; Wed, 4 Jun 2025 01:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748999203; bh=7la9tkxVWChGcACeRi/wCBQUcgZX5m1UrEUx/l3PrLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pgJ7n00xgTDVuiJeLvIZMzQhI/kHVjk6Ew3HoHIKeYDNdUQTAnsn0dZpBLI2I+9kf Zu5RTyz3VLO/B5zkzdTbsa2zYXPlTwYXnMNTT9aTF0l/IKjpfw//CxAXD5cEmq7qMM qYf4Hnivmxzf3kmEacx6JnxwjosNYzrHmCScWg1BtVvI0jUFqH7rG5d/gW+VXCk7YW J5atkQKpLnZLH3nlBn9iDWmdkJfEZ8lQlBKwwvVIdMIOwQejS/6UZUpNreHH0d4+BT TH9xDvvOAupzeJtqi6O/+uhHIyjbeHiIpPslfxRxCXF77NZ+GjvTEifZMcYZIZf1ea 5rXzndUuRxdlQ== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Jason Xing , Jakub Kicinski , Sasha Levin , irusskikh@marvell.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 13/27] net: atlantic: generate software timestamp just before the doorbell Date: Tue, 3 Jun 2025 21:06:06 -0400 Message-Id: <20250604010620.6819-13-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250604010620.6819-1-sashal@kernel.org> References: <20250604010620.6819-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.237 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jason Xing [ Upstream commit 285ad7477559b6b5ceed10ba7ecfed9d17c0e7c6 ] Make sure the call of skb_tx_timestamp is as close as possible to the doorbell. Signed-off-by: Jason Xing Link: https://patch.msgid.link/20250510134812.48199-2-kerneljasonxing@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- **YES** This commit should be backported to stable kernel trees. Here's my comprehensive analysis: ## Primary Analysis **This is a timestamp accuracy fix that addresses when software timestamps are recorded relative to hardware transmission**. The commit moves `skb_tx_timestamp(skb)` from before the hardware doorbell to immediately after it, ensuring timestamps are recorded as close as possible to actual packet transmission. ## Code Change Analysis ### What Changed 1. **In `aq_main.c`**: Removed `skb_tx_timestamp(skb)` from the main transmission path 2. **In `aq_nic.c`**: Added `skb_tx_timestamp(skb)` in `aq_nic_xmit()` right after `aq_nic_map_skb()` but before the hardware doorbell via `hw_ring_tx_xmit()` ### Critical Timing Issue Fixed The original sequence was: ```c // BEFORE (problematic): skb_tx_timestamp(skb); // Timestamp recorded before hardware notification return aq_nic_xmit(aq_nic, skb); └─ frags = aq_nic_map_skb(self, skb, ring); └─ hw_ring_tx_xmit() // Hardware doorbell rung HERE ``` The fixed sequence is: ```c // AFTER (correct): return aq_nic_xmit(aq_nic, skb); └─ frags = aq_nic_map_skb(self, skb, ring); └─ skb_tx_timestamp(skb); // Timestamp recorded right before hardware doorbell └─ hw_ring_tx_xmit() // Hardware doorbell rung immediately after ``` ## Backporting Assessment ### 1. **Fixes Important Timing Bug** ✅ - **Software timestamp accuracy** is critical for network applications, especially PTP (Precision Time Protocol) - **Wrong timestamp ordering** can cause timing skew and affect time-sensitive applications - **Low-latency networking** applications depend on accurate TX timestamps ### 2. **Minimal Risk** ✅ - **Small, contained change**: Only moves one function call - **No behavioral changes**: Same timestamp function, just better timing - **No architectural modifications**: Same code path, different ordering - **No new dependencies**: Uses existing functionality ### 3. **Clear Bug Fix** ✅ - **Specific problem**: Timestamps recorded too early in TX pipeline - **Well-defined solution**: Move timestamp closer to hardware transmission - **Matches stable criteria**: Important bugfix with minimal regression risk ### 4. **Comparison with Similar Commits** This commit is **nearly identical** to Similar Commit #1 (marked YES for backporting): - **Subject: "nfp: TX time stamp packets before HW doorbell is rung"** - **Same exact issue**: Moving timestamp call to be closer to hardware doorbell - **Same pattern**: `skb_tx_timestamp(skb)` moved from after to before hardware notification - **Same stable tree acceptance**: The NFP driver fix was accepted The only differences are: - Different driver (atlantic vs nfp) - Same underlying network timing issue - Same solution approach ### 5. **User Impact** ✅ - **Affects all atlantic driver users** who rely on software timestamps - **Time- sensitive applications** like PTP, trading systems, and real-time monitoring - **Improves timestamp precision** without breaking existing functionality ### 6. **Stable Tree Compatibility** ✅ - **No API changes**: Uses standard `skb_tx_timestamp()` function - **No kernel version dependencies**: Should work across stable versions - **Self- contained**: Limited to atlantic driver code ## Conclusion This commit meets all stable backporting criteria: - **Fixes important timestamp accuracy bug** - **Minimal regression risk** - **Clear, contained solution** - **Matches proven pattern** from Similar Commit #1 (NFP driver fix) - **Benefits time-sensitive network applications** The fix ensures software timestamps are recorded as close as possible to when hardware actually starts transmitting packets, which is crucial for applications requiring precise timing information. drivers/net/ethernet/aquantia/atlantic/aq_main.c | 1 - drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c index 1401fc4632b51..d9d3bf9b9277b 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c @@ -117,7 +117,6 @@ static netdev_tx_t aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *nd } #endif - skb_tx_timestamp(skb); return aq_nic_xmit(aq_nic, skb); } diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c index 54aa84f06e403..8b0531c085be2 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c @@ -751,6 +751,8 @@ int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb) frags = aq_nic_map_skb(self, skb, ring); + skb_tx_timestamp(skb); + if (likely(frags)) { err = self->aq_hw_ops->hw_ring_tx_xmit(self->aq_hw, ring, frags); -- 2.39.5