From patchwork Mon Nov 4 17:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13861738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24F68D1BDD3 for ; Mon, 4 Nov 2024 17:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RP36RjvCwPOylQasEUaQxwrtQMn0Bt0cFylsHQ8bSh4=; b=f9Jb8GmEnCJyy4u6aVNfOeLcm/ lYMO4u/YBKD+8c9HCFGqgH+aIkjC3r15yjbXYP9st00b0iwgQewAwPHiexSVUaJ3V65P/Aae+RKQY xQERIq8OA6o4F6y6RuHkgc/IX8cwkQqkLABgwxqJ73CeNvGVx4Ht3K3+WeeNXIWChfLIJh5IFgFYH wn9OzDTGL9HzGzYwnUdvc/tf5yA22UHOfWQI6kwQfO5aDCGmUPiEsTW1TPDxraQ9Q7UXYwg5gM2n4 Gjkxgn2j8W/q+3MI76HvJJoMCqruXCB3RhSuhP4d9vnvAzzQPpVKddNuYI7OxH6ZjESBhSp5PbES0 xZJojRTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t80zl-0000000EYQO-3uVK; Mon, 04 Nov 2024 17:36:05 +0000 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t80To-0000000ES2a-1yKr for linux-arm-kernel@lists.infradead.org; Mon, 04 Nov 2024 17:03:06 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id DC17B60010; Mon, 4 Nov 2024 17:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RP36RjvCwPOylQasEUaQxwrtQMn0Bt0cFylsHQ8bSh4=; b=Dhjf6682t53u5gsARBQTlLptGcvBkSQ5+OqgLMHCVXrZUZ1cg4tVjQ0gb+WrCjAW5NEw0m 8qpaudhYnLoTTbtDpD3XqSgp3KpUgEkKHIWoZDdRQETpGP7cFw4MC84wme94mbVQKP1tol E3GmhjHyBOWYl0Y0EK/yM8p9H3fVf1Hr6G604IpJ3oP9Ntr7E0fn3yIjc1+K+xd4N9MRQq 1a1JNIMEviGDhr7olP9Bk+6FEcFTCdjEI4OQDt8nttbcujvHEVThcH6LUlkfrutHnGHc0m ZLN2hq+u/+lF2HyucDscxzb7uv1nrcIflCjy+ebCEaKQR7da8Ogp2stYeSp0XQ== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 8/9] net: stmmac: Configure only the relevant bits for timestamping setup Date: Mon, 4 Nov 2024 18:02:48 +0100 Message-ID: <20241104170251.2202270-9-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241104170251.2202270-1-maxime.chevallier@bootlin.com> References: <20241104170251.2202270-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_090304_898033_DBB6B1B7 X-CRM114-Status: GOOD ( 13.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The PTP_TCR (Timestamp Control Register) is used to configure several features related to packet timestamping. On one hand, it configures the 1588 packet processing, to indicate what types of frames should be timestamped (all, only 1588v1 or 1588v2, using L2 or L4 timestamping, on IPv4 or IPv6, etc.). This is congfigured usually through the ioctl / ndo dedicated for such setup. This configuration is done by setting some fields in that register, that seem to behave the same way on all dwmac variants, including DWMAC1000. On the other hand, and only on DWMAC1000 apparently, some fields in that register are used to configure external snapshots (bits 24/25). On DWMAC4 and others, these fields are reserved and external snapshots are configured through a dedicated register that simply doesn't seem to exist on DWMAC1000. This configuration is done in the dwmac1000-specific ptp_clock_info ops (cf dwmac1000_ptp_enable()). So to avoid the timestamping configuration interfering with the external snapshots, this commit makes sure that the config_hw_tstamping only configures the relevant bits in PTP_TCR, so that the DWMAC1000 timestamping can correctly rely on these otherwise reserved fields. Signed-off-by: Maxime Chevallier --- V2: new patch .../net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index a94829ef8cfb..0f59aa982604 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -18,9 +18,22 @@ #include "dwmac4.h" #include "stmmac.h" +#define STMMAC_HWTS_CFG_MASK (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | \ + PTP_TCR_TSINIT | PTP_TCR_TSUPDT | \ + PTP_TCR_TSCTRLSSR | PTP_TCR_SNAPTYPSEL_1 | \ + PTP_TCR_TSIPV4ENA | PTP_TCR_TSIPV6ENA | \ + PTP_TCR_TSEVNTENA | PTP_TCR_TSMSTRENA | \ + PTP_TCR_TSVER2ENA | PTP_TCR_TSIPENA | \ + PTP_TCR_TSTRIG | PTP_TCR_TSENALL) + static void config_hw_tstamping(void __iomem *ioaddr, u32 data) { - writel(data, ioaddr + PTP_TCR); + u32 regval = readl(ioaddr + PTP_TCR); + + regval &= ~STMMAC_HWTS_CFG_MASK; + regval |= data; + + writel(regval, ioaddr + PTP_TCR); } static void config_sub_second_increment(void __iomem *ioaddr,