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: 13282535 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 7FBE0EB64DC for ; Fri, 16 Jun 2023 10:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qKbnFkROIJ5J2ZxYJBUwr34TWSKzo/pgsxwr1sfuuws=; b=MwrPtjoXI8HuJ9 JeobxBfHtTiMxRpNwMuGJm8kUcVHsF6KsrzcO09+K05WC8xuVKij5dTOF+HA2CrAwAuivtotCmaTo rDkFbqzRUXtU4IetFmgkbhTBnRXKW7poeSJo8Yp7O4JY4JvA2ZUJWiBgWgSCaBymZtinGgg5Mbf2S f7pm1BK/2loqzMrgseSqjwSvIHcWGiNMUSnxei3QYUIQUGcwIEJRe1X2fHk7ymEDdb9tlmBgqcqUa fSRmbFBDptDLfsfYP0HQVA8TVxYuy1oR58Y5+CADodoHiNVOOvQqui10XzE/n9fRY7M0RMeVcVsdD bL/+1bD6GERep5jJxVlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qA6L4-00HXya-0a; Fri, 16 Jun 2023 10:05:54 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qA6Kp-00HXqt-1B for linux-arm-kernel@lists.infradead.org; Fri, 16 Jun 2023 10:05:41 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230616_030539_674347_34992CE6 X-CRM114-Status: GOOD ( 14.89 ) 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 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 */