From patchwork Fri Jun 16 10:04:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1225212vqr; Fri, 16 Jun 2023 03:18:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MeBfBIi1pFIJvYAJWYXPJIH8j56wrMpbe99LuEwQCLzgqqDB+xX4ej9bZ0Hyho0iGHltC X-Received: by 2002:a05:6359:2e90:b0:12f:1792:6bfc with SMTP id rp16-20020a0563592e9000b0012f17926bfcmr1108958rwb.17.1686910688135; Fri, 16 Jun 2023 03:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910688; cv=none; d=google.com; s=arc-20160816; b=ZfY+izgre0ZjsPjpfEkdaZ+77L7xc7pIqCLQFf49tafAmhpWsYqO1lFB1sjomFHfbd nCNdHBWkz557/+axjoRWv0wv4KvShlXVNlXkihTPlAqiit4ElvAvQ1mueZxtzmwstghf zthrme1e+gGS2YPiLmOfWdZK9dXAkpo+u/BEJCpaJ9LPbdJ19FIeA50azNX48QAKYcUA tIVRekZIHC22ImWfXnByUR2qlf53PoaG90/vJYv0ppWxbppmpCoDvB6KDG2kGLWH1NcB cN22q8xYih3J/FQrGQeWEAQSeqtisGMxnHyPCM017s4LDzTde+G++VlbxaFxU1Zz5Chx wKKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NYtleP6ALm9DjFnX75BkWEiXccu4UQqKWZMcyeQcTVc=; b=hARfftsODYJH44m9MLHbT4JJwklJjNn1Bg7i8KboW88t/H719Uei/Px6/OY6O7wp+Z PlopqYKqrFaS12Xb/npOsCfYkwKn7YmJ35IrOWhLbb+j2sMtlAbVVje4JskwqdWU6I5j BfypcMzCmdaw75mm6sro02VlVgbqkKGxxO53RTg45ZiG1lKf9Xd/7/h5a2v4ABANcadE 7o5NSKlZzL/9F3CgR16Mf3boEiY3o0Q/SStmX5XwOZrkau9WeFoBGGqd3MyCElYZ2A14 9coo/jdvr0vhV9siJ4qIOMpPJghKy3oMwfTXtsUvN7oSHYGIFCOCpXRJiuUHQ6Lr4qNm kR6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bVuD32OC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a63934f000000b005533db5fbb0si1523294pgm.379.2023.06.16.03.17.53; Fri, 16 Jun 2023 03:18:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bVuD32OC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbjFPKGH (ORCPT + 99 others); Fri, 16 Jun 2023 06:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232355AbjFPKFk (ORCPT ); Fri, 16 Jun 2023 06:05:40 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5570B194; Fri, 16 Jun 2023 03:05:39 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NYtleP6ALm9DjFnX75BkWEiXccu4UQqKWZMcyeQcTVc=; b=bVuD32OCRkfoKqqd+GjpOZlYBL3/cZ0Gs1SZIDvFe+/r51UUGDB5Cx5AYiAKtYihhicTB9 QPA8ezsc4lv0pVDzIXZ/E4xMMXQ2cVJPko+EmH4Qer8NH3fl7CN07G4C1ufbp0DO3OZdA8 R5SO/tk4qD/V6AIFTnmJWYx6hHYkLiT1lEEBlfXgZJSx2giXMIEbIIHy5FIKi4DTWzbqhp BBZ+OAPvRSYaki/0kKFa8d5l6n0JpTLOZPKiX/TCp20ieG/9r8tiIUn8Mwn+Rg9341eCIJ UQcYf+abSmCGMKr5WDElVT3bSdYWIr9FrcHr77Xp6qe2awhZVUVwvtHIBZp1fw== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id EB87C20013; Fri, 16 Jun 2023 10:05:36 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 6/8] net: stmmac: introduce setter/getter for timestamp configuration Date: Fri, 16 Jun 2023 12:04:07 +0200 Message-ID: <20230616100409.164583-7-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768854061495154175?= X-GMAIL-MSGID: =?utf-8?q?1768854061495154175?= From: Alexis Lothoré stmmac_hwtstamp_set currently writes the whole Timestamp Control register when configuring hardware timestamping. It is done for all GMAC variants, and leads to issues with DWMAC1000: this version also bears the Auxiliary Snapshot Trigger bit in the same register. This field, which is set independently with during PTP_CLK_REQ_EXTTS ioctl, is then overwritten when stmmac_hwtstamp_set is called. Introduce setter and getter to allow modifying only relevant parts of the timestamp control register instead of overwriting it all. Signed-off-by: Alexis Lothoré --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 9 ++++++--- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 10 ++++++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index d0b2f13510aa..927324e3d748 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -534,7 +534,8 @@ struct stmmac_ops { /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { - void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); + void (*config_hw_tstamping_set)(void __iomem *ioaddr, u32 data); + u32 (*config_hw_tstamping_get)(void __iomem *ioaddr); void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock, int gmac4, u32 *ssinc); int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec); @@ -546,8 +547,10 @@ struct stmmac_hwtimestamp { void (*timestamp_interrupt)(struct stmmac_priv *priv); }; -#define stmmac_config_hw_tstamping(__priv, __args...) \ - stmmac_do_void_callback(__priv, ptp, config_hw_tstamping, __args) +#define stmmac_config_hw_tstamping_set(__priv, __args...) \ + stmmac_do_void_callback(__priv, ptp, config_hw_tstamping_set, __args) +#define stmmac_config_hw_tstamping_get(__priv, __args...) \ + stmmac_do_callback(__priv, ptp, config_hw_tstamping_get, __args) #define stmmac_config_sub_second_increment(__priv, __args...) \ stmmac_do_void_callback(__priv, ptp, config_sub_second_increment, __args) #define stmmac_init_systime(__priv, __args...) \ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 2cd0ec17f4c6..cbb94d3e0fa1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -18,11 +18,16 @@ #include "dwmac4.h" #include "stmmac.h" -static void config_hw_tstamping(void __iomem *ioaddr, u32 data) +static void config_hw_tstamping_set(void __iomem *ioaddr, u32 data) { writel(data, ioaddr + PTP_TCR); } +static u32 config_hw_tstamping_get(void __iomem *ioaddr) +{ + return readl(ioaddr + PTP_TCR); +} + static void config_sub_second_increment(void __iomem *ioaddr, u32 ptp_clock, int gmac4, u32 *ssinc) { @@ -163,7 +168,8 @@ static void get_systime(void __iomem *ioaddr, u64 *systime) } const struct stmmac_hwtimestamp stmmac_ptp = { - .config_hw_tstamping = config_hw_tstamping, + .config_hw_tstamping_set = config_hw_tstamping_set, + .config_hw_tstamping_get = config_hw_tstamping_get, .init_systime = init_systime, .config_sub_second_increment = config_sub_second_increment, .config_addend = config_addend, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4f0ef73d5121..528d2e010926 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -792,7 +792,7 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) ts_master_en | snap_type_sel; } - stmmac_config_hw_tstamping(priv, priv->ptpaddr, priv->systime_flags); + stmmac_config_hw_tstamping_set(priv, priv->ptpaddr, priv->systime_flags); memcpy(&priv->tstamp_config, &config, sizeof(config)); @@ -841,7 +841,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags) if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) return -EOPNOTSUPP; - stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags); + stmmac_config_hw_tstamping_set(priv, priv->ptpaddr, systime_flags); priv->systime_flags = systime_flags; /* program Sub Second Increment reg */