From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 D4FAE1C07DA; Mon, 4 Nov 2024 17:02:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739779; cv=none; b=fflICMnjzEY3o58Tr3aKPWsP/hl1zQUyNafM8jZe1SGZ9HZlGsxs73tvvALAOBrIWzvtS6ZJ3h1nIG0hO1jXrI96InKydKA+ePSn9DSsrxn1fjXORPKTs6VlaHkIodkjzTFHnJJub+SSB1dfIa4Pz70q2zO9Ff6gzYS9CfOnnfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739779; c=relaxed/simple; bh=tljdDapYJFFJEqAElH3D21yZVfqbjf67djvOEfOa3m0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AhDs/p10N8q6XCla7aNYKd7lBsCM0Xo77F8+gw358nDG78ii4cvTee9Ew3fhDRv5aYp6DWAyh80Bgr/pFwJLKsgnnXOaskokdxjhlI7DLBef+uaoCteDq8dR60+vKkPmKgBth6/kHm9lYZSEUS8Nofn05ojLp6OcSMetCaVU5Ec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=iSTN4Tsj; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iSTN4Tsj" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8B47160007; Mon, 4 Nov 2024 17:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739776; 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=AN4fth8gn0V4juHtySJyZLmB6iEU13zuPAy5gH50m6I=; b=iSTN4TsjYi2ZwyM/1BALrfDCQa7BwkpW0Mi1hlHSaHz/psLP+lSVMZ3cz25n/lOCSTo70Q yMh1pFes2GCfL5kmGn1syo1oP5ZcZouB/DL5dklnfHTMq2/UWk3n0SQ/vg3K4B6A0ttn2L wPjk4S+yTLX2d0gHKFjfDkx1y3AL6lb2CXYW/Rfhjro/R32cXOO93Ctx5IhPXMDsGwiOcZ LnvPnb7r6cuvh1i027sQYLRQRo04g0NvggNWgj2ULgOjCDrnYd8MuZdUTwVJWseGvA4aQX eZL0rxvUbyZawKAQY1MM2jyDqd4BMYF/4Mb/81zggDrqa5i0fn0kR95Ey8mCuw== 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=20Lothor=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 1/9] net: stmmac: Don't modify the global ptp ops directly Date: Mon, 4 Nov 2024 18:02:41 +0100 Message-ID: <20241104170251.2202270-2-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The stmmac_ptp_clock_ops are copied into the stmmac_priv structure before being registered to the PTP core. Some adjustments are made prior to that, such as the number of snapshots or max adjustment parameters. Instead of modifying the global definition, then copying into the local private data, let's first copy then modify the local parameters. Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_ptp.c index a6b1de9a251d..11ab1d6b916a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -298,20 +298,21 @@ void stmmac_ptp_register(struct stmmac_priv *priv) priv->pps[i].available =3D true; } =20 - if (priv->plat->ptp_max_adj) - stmmac_ptp_clock_ops.max_adj =3D priv->plat->ptp_max_adj; - /* Calculate the clock domain crossing (CDC) error if necessary */ priv->plat->cdc_error_adj =3D 0; if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate) priv->plat->cdc_error_adj =3D (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_r= ate; =20 - stmmac_ptp_clock_ops.n_per_out =3D priv->dma_cap.pps_out_num; - stmmac_ptp_clock_ops.n_ext_ts =3D priv->dma_cap.aux_snapshot_n; + priv->ptp_clock_ops =3D stmmac_ptp_clock_ops; + + priv->ptp_clock_ops.n_per_out =3D priv->dma_cap.pps_out_num; + priv->ptp_clock_ops.n_ext_ts =3D priv->dma_cap.aux_snapshot_n; + + if (priv->plat->ptp_max_adj) + priv->ptp_clock_ops.max_adj =3D priv->plat->ptp_max_adj; =20 rwlock_init(&priv->ptp_lock); mutex_init(&priv->aux_ts_lock); - priv->ptp_clock_ops =3D stmmac_ptp_clock_ops; =20 priv->ptp_clock =3D ptp_clock_register(&priv->ptp_clock_ops, priv->device); --=20 2.47.0 From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 BF01B1C243C; Mon, 4 Nov 2024 17:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739781; cv=none; b=E7J46a9+lhH9LDQkc3NriEURf1phxAtfYltDGu4TWCBYOTNXyifG7+wF7OelMWujjja184dt42hZRTqOFvMfyVK0Znb2CEEBCvGzaGPff1Hf5zn4lduHRhFuvapu7v8biAubR4euCOdM5d8xNXnMOxyERJ9bS1naT4mszkdbKZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739781; c=relaxed/simple; bh=MMFxpJZFvVilpm803AibMkyMpy76A7o8br/xaTlUSvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BALuTxTJeuxqBNjQm4aAZhvkVyz/vxVpzahDWuzQee37/YGkeN+bVGugD139PghSAf0Bg4Qdl9pF8Q9HbA44rSvIB2UZgEwC7MNpBDz6gVC0ydsLNZlqFoK362Tso9oNYketRW3lo7dI3xmY/hZlegsiKB7cBPujwtkXDWBcyIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=jY2BFzvL; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="jY2BFzvL" Received: by mail.gandi.net (Postfix) with ESMTPSA id 7A18160009; Mon, 4 Nov 2024 17:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739777; 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=/Q0nQf1p3aEQdaIekpf69KA9b+oSlJsiJVdZh+xBY4k=; b=jY2BFzvLc1owNblIdY6rrlkicCZj0lfJRmf0oZZnrjAQuWDhfXHNumDYHtXAZtTxcK3sYH uuko9DYYI03drvyKUAWILR3Z93+fXKYxo6hsEwGFAD0/t5WpUUorPoEZujOrmuEDGhLbRE WCFww3F/ssEgoQUVW2aHHz6Co8Pvi1L0b9J8P+JNAz+DnIeFOWDbd37RL5U4WdjYZzcjZs yE2bpFG5Zy6j3r8sFaqccVjJqoKmtTCdDxhv3dule+U/jeMzWyHFAB5M9VqkL4JYjRMSWU wtv6DI4mdU0yOpPquKw1AHx2JrRee+SNJEWEYcwDhuqUIKoAV14cjb2YDS7fGQ== 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=20Lothor=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 2/9] net: stmmac: Use per-hw ptp clock ops Date: Mon, 4 Nov 2024 18:02:42 +0100 Message-ID: <20241104170251.2202270-3-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The auxiliary snapshot configuration was found to differ depending on the dwmac version. To prepare supporting this, allow specifying the ptp_clock_info ops in the hwif array Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/stmicro/stmmac/common.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/hwif.c | 11 +++++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 4 +--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/eth= ernet/stmicro/stmmac/common.h index 684489156dce..4a0a1708c391 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -551,6 +551,8 @@ struct mac_device_info; extern const struct stmmac_hwtimestamp stmmac_ptp; extern const struct stmmac_mode_ops dwmac4_ring_mode_ops; =20 +extern const struct ptp_clock_info stmmac_ptp_clock_ops; + struct mac_link { u32 caps; u32 speed_mask; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ether= net/stmicro/stmmac/hwif.c index 88cce28b2f98..9b6d817e8f1e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -112,6 +112,7 @@ static const struct stmmac_hwif_entry { const void *dma; const void *mac; const void *hwtimestamp; + const void *ptp; const void *mode; const void *tc; const void *mmc; @@ -133,6 +134,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwmac100_dma_ops, .mac =3D &dwmac100_ops, .hwtimestamp =3D &stmmac_ptp, + .ptp =3D &stmmac_ptp_clock_ops, .mode =3D NULL, .tc =3D NULL, .mmc =3D &dwmac_mmc_ops, @@ -151,6 +153,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwmac1000_dma_ops, .mac =3D &dwmac1000_ops, .hwtimestamp =3D &stmmac_ptp, + .ptp =3D &stmmac_ptp_clock_ops, .mode =3D NULL, .tc =3D NULL, .mmc =3D &dwmac_mmc_ops, @@ -170,6 +173,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwmac4_dma_ops, .mac =3D &dwmac4_ops, .hwtimestamp =3D &stmmac_ptp, + .ptp =3D &stmmac_ptp_clock_ops, .mode =3D NULL, .tc =3D &dwmac4_tc_ops, .mmc =3D &dwmac_mmc_ops, @@ -190,6 +194,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwmac4_dma_ops, .mac =3D &dwmac410_ops, .hwtimestamp =3D &stmmac_ptp, + .ptp =3D &stmmac_ptp_clock_ops, .mode =3D &dwmac4_ring_mode_ops, .tc =3D &dwmac510_tc_ops, .mmc =3D &dwmac_mmc_ops, @@ -210,6 +215,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwmac410_dma_ops, .mac =3D &dwmac410_ops, .hwtimestamp =3D &stmmac_ptp, + .ptp =3D &stmmac_ptp_clock_ops, .mode =3D &dwmac4_ring_mode_ops, .tc =3D &dwmac510_tc_ops, .mmc =3D &dwmac_mmc_ops, @@ -230,6 +236,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwmac410_dma_ops, .mac =3D &dwmac510_ops, .hwtimestamp =3D &stmmac_ptp, + .ptp =3D &stmmac_ptp_clock_ops, .mode =3D &dwmac4_ring_mode_ops, .tc =3D &dwmac510_tc_ops, .mmc =3D &dwmac_mmc_ops, @@ -251,6 +258,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwxgmac210_dma_ops, .mac =3D &dwxgmac210_ops, .hwtimestamp =3D &stmmac_ptp, + .ptp =3D &stmmac_ptp_clock_ops, .mode =3D NULL, .tc =3D &dwxgmac_tc_ops, .mmc =3D &dwxgmac_mmc_ops, @@ -272,6 +280,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwxgmac210_dma_ops, .mac =3D &dwxlgmac2_ops, .hwtimestamp =3D &stmmac_ptp, + .ptp =3D &stmmac_ptp_clock_ops, .mode =3D NULL, .tc =3D &dwxgmac_tc_ops, .mmc =3D &dwxgmac_mmc_ops, @@ -355,6 +364,8 @@ int stmmac_hwif_init(struct stmmac_priv *priv) priv->hw =3D mac; priv->ptpaddr =3D priv->ioaddr + entry->regs.ptp_off; priv->mmcaddr =3D priv->ioaddr + entry->regs.mmc_off; + memcpy(&priv->ptp_clock_ops, entry->ptp, + sizeof(struct ptp_clock_info)); if (entry->est) priv->estaddr =3D priv->ioaddr + entry->regs.est_off; =20 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_ptp.c index 11ab1d6b916a..41581f516ea9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -265,7 +265,7 @@ static int stmmac_getcrosststamp(struct ptp_clock_info = *ptp, } =20 /* structure describing a PTP hardware clock */ -static struct ptp_clock_info stmmac_ptp_clock_ops =3D { +const struct ptp_clock_info stmmac_ptp_clock_ops =3D { .owner =3D THIS_MODULE, .name =3D "stmmac ptp", .max_adj =3D 62500000, @@ -303,8 +303,6 @@ void stmmac_ptp_register(struct stmmac_priv *priv) if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate) priv->plat->cdc_error_adj =3D (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_r= ate; =20 - priv->ptp_clock_ops =3D stmmac_ptp_clock_ops; - priv->ptp_clock_ops.n_per_out =3D priv->dma_cap.pps_out_num; priv->ptp_clock_ops.n_ext_ts =3D priv->dma_cap.aux_snapshot_n; =20 --=20 2.47.0 From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 BEFC11CD15; Mon, 4 Nov 2024 17:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739781; cv=none; b=bFIONHQQmLOu9knSC5UgFlq6OpbNPjUWI2tn+WpsLt/dY/i7OwIBjcScnZdSe5WqPfQ13RyDD4IpJ3oyP8YNJvy8pwblzqw9drtqUPU7y6dHXAkEn3BKJKjMDE+qeYBQn3ZCUikBUWk0ybE+H5IppzuBgoBmfHMxFr8UnBXCPHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739781; c=relaxed/simple; bh=h0ET1UOrL/Rv2bl967sK/TaJGPwryi3uBWVbrLf1dGo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nswOHJyDO2S3ek4/YTOVqUIbVARUzugsEjmwJ6ztBilr5uh6wvTZoEHquFGRGYcjCrM8yvLYu+2FR6OVY6Oha6hNqhHF5piz+8mlqvOuohobWGbps//kQJSvQzreCS2w1N9XoPy/DYdC1kgGs3jhl0etqDl7qN5QfWBLAnNJC0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=P/ylVa50; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="P/ylVa50" Received: by mail.gandi.net (Postfix) with ESMTPSA id 67A0260003; Mon, 4 Nov 2024 17:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739778; 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=/SPSBRQipSII7hd35ejo1FRCOBIsfi2Df67vBJxKStA=; b=P/ylVa50a+BLdkHAgE7RjPYnPZ2RVCr9fPAnphAuuCYjYTKraswaYmWf0aDEbPzaYSLzrm XsFpX1Fl0SPyWabDsuWUXldUhR8/MIbP3DTaB9Q1cabYNyxOLeKeOwLUmsbcIGXWH1xCwn ZhK9tofPBP/dFq5TX9mBsdbyYNAdxVBZ6UczkW6HnnlFmRa56RJZeCPmZHH8qtUtt5RMLI 2/8BcVWO0ERuUpFB4OHm6NKrj+xIKToRjV5E1IVg2o4b46eFNHSDj6FzsHRoxBjsMI2EnA SBX2dSDqxbVKNqRgRnDrd1L9+QB3y5PvPqI2tYPADfiNX8B1Qqsr5P8GHvc9+g== 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=20Lothor=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 3/9] net: stmmac: Only update the auto-discovered PTP clock features Date: Mon, 4 Nov 2024 18:02:43 +0100 Message-ID: <20241104170251.2202270-4-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Some DWMAC variants such as dwmac1000 don't support discovering the number of output pps and auxiliary snapshots. Allow these parameters to be defined in default ptp_clock_info, and let them be updated only when the feature discovery yielded a result. Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_ptp.c index 41581f516ea9..8ea2b4226234 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -303,8 +303,14 @@ void stmmac_ptp_register(struct stmmac_priv *priv) if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate) priv->plat->cdc_error_adj =3D (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_r= ate; =20 - priv->ptp_clock_ops.n_per_out =3D priv->dma_cap.pps_out_num; - priv->ptp_clock_ops.n_ext_ts =3D priv->dma_cap.aux_snapshot_n; + /* Update the ptp clock parameters based on feature discovery, when + * available + */ + if (priv->dma_cap.pps_out_num) + priv->ptp_clock_ops.n_per_out =3D priv->dma_cap.pps_out_num; + + if (priv->dma_cap.aux_snapshot_n) + priv->ptp_clock_ops.n_ext_ts =3D priv->dma_cap.aux_snapshot_n; =20 if (priv->plat->ptp_max_adj) priv->ptp_clock_ops.max_adj =3D priv->plat->ptp_max_adj; --=20 2.47.0 From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 C9594762EB; Mon, 4 Nov 2024 17:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739783; cv=none; b=Sf1KlgQyzBePXqRIdgLHJSBCbYxCRrW4RofAJffP469u6a1VZhoJqvHtKs/yuA9im6pGzJF0+NQk++cOemKoQo3hU1vU2nAieEtWQFu0rUmszKj+VdZitgBAF1c371B/U7/U9A6l8/wk+97p0PzpcvKqNSwljxMB2dGHClCMiJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739783; c=relaxed/simple; bh=SwYPaML/m+2xlE7bFiASP090aemPXqfRl2KtqzUESLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gR4OtgmcRlVgkuw2R+H65zsoLIWYb5AMjS93GJPTAaEMX3DlKNU9LdNCvpelZevkA4aBJ3exKM1azvB16TeXggPppDqxPQbhFbKc0fw6gz4LiOnKSfRDllJcCtwaT24yI98tTFbKELQiYJ9GjJvWfpQZijpZ62PFmeC9mmHVinQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=FT419QD0; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="FT419QD0" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5152760008; Mon, 4 Nov 2024 17:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739779; 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=2MZHYosEgWulG/VziP7VK5RTnwW9NHOqqCP8UOYgP1c=; b=FT419QD0SobyzNsNN/cV8FWOV6qZCeMsqlYhb03hVKDaFN6xsHn38Q+cZvp8suifA/PitF OeJHPUN3r49cdozgz2zyxsvRznrhYFewuLem94x1Fc62/fBsgzq3Q/QL3BhZ+jbamyp0P9 wqDPF7tOodPwktCinQy+pDSzyV0xDHaImtowdT4CksRrIjhjbvLyve/TqFHf/ZjmsedATy 6SIh0abVZPFb3MK2eT3H1+QJIFwk83FoVpPQ9fD4Bu+gF2EHBV2tqCBkVAYKJt5bZe7dtp JcdFy3UYTTBdZvH9u0BPvSTdd2wtgqwPzJpHkP3XIUEK/RUW+vMfiBQEUS8oQQ== 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=20Lothor=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 4/9] net: stmmac: Introduce dwmac1000 ptp_clock_info and operations Date: Mon, 4 Nov 2024 18:02:44 +0100 Message-ID: <20241104170251.2202270-5-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The PTP configuration for GMAC3_X differs from the other implementations in several ways : - There's only one external snapshot trigger - The snapshot configuration is done through the PTP_TCR register, whereas the other dwmac variants have a dedicated ACR (auxiliary control reg) for that purpose - The layout for the PTP_TCR register also differs, as bits 24/25 are used for the snapshot configuration. These bits are reserved on other variants. On GMAC3_X, we also can't discover the number of snapshot triggers automatically. The GMAC3_X has one PPS output, however it's configuration isn't supported yet so report 0 n_per_out for now. Introduce a dedicated set of ptp_clock_info ops and configuration parameters to reflect these differences specific to GMAC3_X. This was tested on dwmac_socfpga. Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/stmicro/stmmac/common.h | 1 + .../net/ethernet/stmicro/stmmac/dwmac1000.h | 5 +++ .../ethernet/stmicro/stmmac/dwmac1000_core.c | 45 +++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.c | 4 +- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 18 ++++++++ .../net/ethernet/stmicro/stmmac/stmmac_ptp.h | 6 +++ 6 files changed, 77 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/eth= ernet/stmicro/stmmac/common.h index 4a0a1708c391..6f68a6b298c9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -552,6 +552,7 @@ extern const struct stmmac_hwtimestamp stmmac_ptp; extern const struct stmmac_mode_ops dwmac4_ring_mode_ops; =20 extern const struct ptp_clock_info stmmac_ptp_clock_ops; +extern const struct ptp_clock_info dwmac1000_ptp_clock_ops; =20 struct mac_link { u32 caps; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/= ethernet/stmicro/stmmac/dwmac1000.h index 4296ddda8aaa..01eafeb1272f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h @@ -329,5 +329,10 @@ enum rtc_control { #define GMAC_MMC_RX_CSUM_OFFLOAD 0x208 #define GMAC_EXTHASH_BASE 0x500 =20 +/* PTP and timestamping registers */ + +#define GMAC_PTP_TCR_ATSFC BIT(24) +#define GMAC_PTP_TCR_ATSEN0 BIT(25) + extern const struct stmmac_dma_ops dwmac1000_dma_ops; #endif /* __DWMAC1000_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers= /net/ethernet/stmicro/stmmac/dwmac1000_core.c index d413d76a8936..b6930009ea06 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -18,6 +18,7 @@ #include #include "stmmac.h" #include "stmmac_pcs.h" +#include "stmmac_ptp.h" #include "dwmac1000.h" =20 static void dwmac1000_core_init(struct mac_device_info *hw, @@ -551,3 +552,47 @@ int dwmac1000_setup(struct stmmac_priv *priv) =20 return 0; } + +/* DWMAC 1000 ptp_clock_info ops */ + +int dwmac1000_ptp_enable(struct ptp_clock_info *ptp, + struct ptp_clock_request *rq, int on) +{ + struct stmmac_priv *priv =3D + container_of(ptp, struct stmmac_priv, ptp_clock_ops); + void __iomem *ptpaddr =3D priv->ptpaddr; + int ret =3D -EOPNOTSUPP; + u32 tcr_val; + + switch (rq->type) { + case PTP_CLK_REQ_EXTTS: + mutex_lock(&priv->aux_ts_lock); + tcr_val =3D readl(ptpaddr + PTP_TCR); + + if (on) { + tcr_val |=3D GMAC_PTP_TCR_ATSEN0; + tcr_val |=3D GMAC_PTP_TCR_ATSFC; + priv->plat->flags |=3D STMMAC_FLAG_EXT_SNAPSHOT_EN; + } else { + tcr_val &=3D ~GMAC_PTP_TCR_ATSEN0; + priv->plat->flags &=3D ~STMMAC_FLAG_EXT_SNAPSHOT_EN; + } + + netdev_dbg(priv->dev, "Auxiliary Snapshot %s.\n", + on ? "enabled" : "disabled"); + writel(tcr_val, ptpaddr + PTP_TCR); + + mutex_unlock(&priv->aux_ts_lock); + + /* wait for auxts fifo clear to finish */ + ret =3D readl_poll_timeout(ptpaddr + PTP_TCR, tcr_val, + !(tcr_val & GMAC_PTP_TCR_ATSFC), + 10, 10000); + break; + + default: + break; + } + + return ret; +} diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ether= net/stmicro/stmmac/hwif.c index 9b6d817e8f1e..f425fe3bc22a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -134,7 +134,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwmac100_dma_ops, .mac =3D &dwmac100_ops, .hwtimestamp =3D &stmmac_ptp, - .ptp =3D &stmmac_ptp_clock_ops, + .ptp =3D &dwmac1000_ptp_clock_ops, .mode =3D NULL, .tc =3D NULL, .mmc =3D &dwmac_mmc_ops, @@ -153,7 +153,7 @@ static const struct stmmac_hwif_entry { .dma =3D &dwmac1000_dma_ops, .mac =3D &dwmac1000_ops, .hwtimestamp =3D &stmmac_ptp, - .ptp =3D &stmmac_ptp_clock_ops, + .ptp =3D &dwmac1000_ptp_clock_ops, .mode =3D NULL, .tc =3D NULL, .mmc =3D &dwmac_mmc_ops, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_ptp.c index 8ea2b4226234..430905f591b2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -282,6 +282,24 @@ const struct ptp_clock_info stmmac_ptp_clock_ops =3D { .getcrosststamp =3D stmmac_getcrosststamp, }; =20 +/* structure describing a PTP hardware clock */ +const struct ptp_clock_info dwmac1000_ptp_clock_ops =3D { + .owner =3D THIS_MODULE, + .name =3D "stmmac ptp", + .max_adj =3D 62500000, + .n_alarm =3D 0, + .n_ext_ts =3D 1, + .n_per_out =3D 0, + .n_pins =3D 0, + .pps =3D 0, + .adjfine =3D stmmac_adjust_freq, + .adjtime =3D stmmac_adjust_time, + .gettime64 =3D stmmac_get_time, + .settime64 =3D stmmac_set_time, + .enable =3D dwmac1000_ptp_enable, + .getcrosststamp =3D stmmac_getcrosststamp, +}; + /** * stmmac_ptp_register * @priv: driver private structure diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net= /ethernet/stmicro/stmmac/stmmac_ptp.h index fce3fba2ffd2..fa4611855311 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h @@ -94,4 +94,10 @@ enum aux_snapshot { AUX_SNAPSHOT3 =3D 0x80, }; =20 +struct ptp_clock_info; +struct ptp_clock_request; + +int dwmac1000_ptp_enable(struct ptp_clock_info *ptp, + struct ptp_clock_request *rq, int on); + #endif /* __STMMAC_PTP_H__ */ --=20 2.47.0 From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 855B11C6F66; Mon, 4 Nov 2024 17:03:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739783; cv=none; b=kd0c2a1Yk3Wtwtq1oU1eL8oJMYOooAwfbU/+DomtfVHCp3/GsgelTtZedh0UNmnQheTZsGH3Z295+2aQ+SFKI51NLXLe8xJEVxORu/nJhKxr2xtrUTJWdafbVgi6U5hw/eEV+1IBOzD2ZnocXH2eLw8/Sve2g7RXC7GCEYM7KBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739783; c=relaxed/simple; bh=y7ooFwKM+HxJO0eNvOnu1Kq9KYaF4jfFiCs096MOoKk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SMm19lHtwYwt39E1Xlyv/xzGnq7YL4ooh6fMHZ/Sq0QS8PvuDu5DZ6f4HGDTUtpdIkcuHR8R8hek6ZFW3dGILnD1C0nDZeH2sYELy7a56rBKQk0KYwOo4vy1NM7JFF7mE92ATSqOvMsG7+mFaI37BB4xV8ceQ7ThjQO5Qxn62eQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=eSC1O7hP; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="eSC1O7hP" Received: by mail.gandi.net (Postfix) with ESMTPSA id 40BD46000C; Mon, 4 Nov 2024 17:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739780; 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=S9I/jlRO0WchcgVErrYdjy3RxOS1Ge52ZVB9HE9s8lw=; b=eSC1O7hP+InxX1J3egif3HK7xuxs3tmmsW0iDMUzzh7MxjPUXdQzBhKKGsUKyS1MOy0hHe RmM2gB175SUKXGmuYINgshs5Uf2tl99Nq6Cj0rVz9vpcG201Fp3a+GsjWnsGrtscgAekOV vsvTJedmq7VlluY4XBhcLPfpoWQOFQyTXJA1y02t1n6pyK0nAIpdMkreUYpMUoVhMcwzWu ItJ0jBnNVe2e3RbWkJhX9L9uO7XL97KqLWxhVy7VaGaN1jQhZ+9rC+ddBO2EvXlASBFS8l K4q5hclyNULmelBcrhqPgMd8oTGl7XrcrJDHDmLJc32/nrivISV1MaTIInW5JQ== 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=20Lothor=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 5/9] net: stmmac: Introduce dwmac1000 timestamping operations Date: Mon, 4 Nov 2024 18:02:45 +0100 Message-ID: <20241104170251.2202270-6-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" In GMAC3_X, the timestamping configuration differs from GMAC4 in the layout of the registers accessed to grab the number of snapshots in FIFO as well as the register offset to grab the aux snapshot timestamp. Introduce dedicated ops to configure timestamping on dwmac100 and dwmac1000. The latency correction doesn't seem to exist on GMAC3, so its corresponding operation isn't populated. Signed-off-by: Maxime Chevallier --- V2: Read the timestamping status from ptpaddr instead of ioaddr drivers/net/ethernet/stmicro/stmmac/common.h | 1 + .../net/ethernet/stmicro/stmmac/dwmac1000.h | 7 ++++ .../ethernet/stmicro/stmmac/dwmac1000_core.c | 40 +++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.c | 4 +- .../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 11 +++++ .../net/ethernet/stmicro/stmmac/stmmac_ptp.h | 4 ++ 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/eth= ernet/stmicro/stmmac/common.h index 6f68a6b298c9..1367fa5c9b8e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -549,6 +549,7 @@ extern const struct stmmac_desc_ops ndesc_ops; struct mac_device_info; =20 extern const struct stmmac_hwtimestamp stmmac_ptp; +extern const struct stmmac_hwtimestamp dwmac1000_ptp; extern const struct stmmac_mode_ops dwmac4_ring_mode_ops; =20 extern const struct ptp_clock_info stmmac_ptp_clock_ops; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/= ethernet/stmicro/stmmac/dwmac1000.h index 01eafeb1272f..600fea8f712f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h @@ -331,8 +331,15 @@ enum rtc_control { =20 /* PTP and timestamping registers */ =20 +#define GMAC3_X_ATSNS GENMASK(19, 16) +#define GMAC3_X_ATSNS_SHIFT 16 + #define GMAC_PTP_TCR_ATSFC BIT(24) #define GMAC_PTP_TCR_ATSEN0 BIT(25) =20 +#define GMAC3_X_TIMESTAMP_STATUS 0x28 +#define GMAC_PTP_ATNR 0x30 +#define GMAC_PTP_ATSR 0x34 + extern const struct stmmac_dma_ops dwmac1000_dma_ops; #endif /* __DWMAC1000_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers= /net/ethernet/stmicro/stmmac/dwmac1000_core.c index b6930009ea06..dbbd834f9fc8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -553,6 +553,46 @@ int dwmac1000_setup(struct stmmac_priv *priv) return 0; } =20 +/* DWMAC 1000 HW Timestaming ops */ + +void dwmac1000_get_ptptime(void __iomem *ptpaddr, u64 *ptp_time) +{ + u64 ns; + + ns =3D readl(ptpaddr + GMAC_PTP_ATNR); + ns +=3D readl(ptpaddr + GMAC_PTP_ATSR) * NSEC_PER_SEC; + + *ptp_time =3D ns; +} + +void dwmac1000_timestamp_interrupt(struct stmmac_priv *priv) +{ + struct ptp_clock_event event; + u32 ts_status, num_snapshot; + unsigned long flags; + u64 ptp_time; + int i; + + /* Clears the timestamp interrupt */ + ts_status =3D readl(priv->ptpaddr + GMAC3_X_TIMESTAMP_STATUS); + + if (!(priv->plat->flags & STMMAC_FLAG_EXT_SNAPSHOT_EN)) + return; + + num_snapshot =3D (ts_status & GMAC3_X_ATSNS) >> GMAC3_X_ATSNS_SHIFT; + + for (i =3D 0; i < num_snapshot; i++) { + read_lock_irqsave(&priv->ptp_lock, flags); + stmmac_get_ptptime(priv, priv->ptpaddr, &ptp_time); + read_unlock_irqrestore(&priv->ptp_lock, flags); + + event.type =3D PTP_CLOCK_EXTTS; + event.index =3D 0; + event.timestamp =3D ptp_time; + ptp_clock_event(priv->ptp_clock, &event); + } +} + /* DWMAC 1000 ptp_clock_info ops */ =20 int dwmac1000_ptp_enable(struct ptp_clock_info *ptp, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ether= net/stmicro/stmmac/hwif.c index f425fe3bc22a..13c73df4fbc9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -133,7 +133,7 @@ static const struct stmmac_hwif_entry { .desc =3D NULL, .dma =3D &dwmac100_dma_ops, .mac =3D &dwmac100_ops, - .hwtimestamp =3D &stmmac_ptp, + .hwtimestamp =3D &dwmac1000_ptp, .ptp =3D &dwmac1000_ptp_clock_ops, .mode =3D NULL, .tc =3D NULL, @@ -152,7 +152,7 @@ static const struct stmmac_hwif_entry { .desc =3D NULL, .dma =3D &dwmac1000_dma_ops, .mac =3D &dwmac1000_ops, - .hwtimestamp =3D &stmmac_ptp, + .hwtimestamp =3D &dwmac1000_ptp, .ptp =3D &dwmac1000_ptp_clock_ops, .mode =3D NULL, .tc =3D NULL, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/driver= s/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 5ef52ef2698f..a94829ef8cfb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -269,3 +269,14 @@ const struct stmmac_hwtimestamp stmmac_ptp =3D { .timestamp_interrupt =3D timestamp_interrupt, .hwtstamp_correct_latency =3D hwtstamp_correct_latency, }; + +const struct stmmac_hwtimestamp dwmac1000_ptp =3D { + .config_hw_tstamping =3D config_hw_tstamping, + .init_systime =3D init_systime, + .config_sub_second_increment =3D config_sub_second_increment, + .config_addend =3D config_addend, + .adjust_systime =3D adjust_systime, + .get_systime =3D get_systime, + .get_ptptime =3D dwmac1000_get_ptptime, + .timestamp_interrupt =3D dwmac1000_timestamp_interrupt, +}; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net= /ethernet/stmicro/stmmac/stmmac_ptp.h index fa4611855311..4cc70480ce0f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h @@ -96,8 +96,12 @@ enum aux_snapshot { =20 struct ptp_clock_info; struct ptp_clock_request; +struct stmmac_priv; =20 int dwmac1000_ptp_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *rq, int on); =20 +void dwmac1000_get_ptptime(void __iomem *ptpaddr, u64 *ptp_time); +void dwmac1000_timestamp_interrupt(struct stmmac_priv *priv); + #endif /* __STMMAC_PTP_H__ */ --=20 2.47.0 From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 897331CB9EB; Mon, 4 Nov 2024 17:03:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739784; cv=none; b=FjsijVVE2BxYZ0ejkK3o36fK4fwMeP9lKMtJvlT98I+pr2MPO8bN9arzPYwJ9896jgkNpHPbx3iZf7hwOmrnNZ/FWBPnUu1kn175sxTx3Qkj1AsJsvN4YtUEh39ML+CpeSvAzCbHyOdYT4FVcFxUHHjnRohq/AwO6jeR5J3CW7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739784; c=relaxed/simple; bh=P16V2mkI4qSBlelW6W/sXFScztNs05ZbmwbDljXRKr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mjOvG420E99bzjkpzkSNPLANOW44wVJLco1fQ8lMoEcdNr5EgQ2hcCQ7joj94RjU2c6gP1KVsaI9RUh1Zp0YE1UN7EdgyKyo16qsvOL9+/L07PQ+lkOGLF1CZZN9cU7yzD0Kvg5amdZJE5QMy21Z0UilwQR+EOO0ZwaPbWSuYsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KrYfvu8U; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KrYfvu8U" Received: by mail.gandi.net (Postfix) with ESMTPSA id 273D46000D; Mon, 4 Nov 2024 17:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739780; 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=XDh3EdnrR/PCsOp5ZedOmai1CHRqkh3yfIKuvIijDks=; b=KrYfvu8UGeDJygxO2L11K7UVqHgApKJ6B5G0XrJMQIaknLfvN9O3oLj6VKn4iOwqPDa/uu EhN13ONnoDp3uK44HuLR8PjaIsGDhxayoGp6XlN6xWZ0vKUJlZmpk3Wef12J9DfQF4yL3o qM53QmE/Km5NHFcwl/T2SFrG/xo8XyMinYndAxh03PHlN/fEKtaNeL08f6hiXo0UjiniHJ g4rMCdzmBsX79GI2ttDupJSVo0MnV8gKUqaGKlmviuGke0jDKAJCEeZW2Jr6t66fK1lpPg g5r9NG9D0k7Xl4s93XjRSQ1xCkLM/8oVqsDF0yRDRzpeqQ8TVEheT5eXVlfauA== 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=20Lothor=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 6/9] net: stmmac: Enable timestamping interrupt on dwmac1000 Date: Mon, 4 Nov 2024 18:02:46 +0100 Message-ID: <20241104170251.2202270-7-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The default configuration for the interrupts on dwmac1000 have the timestamping interrupt masked. Now that the timestamping has been adapted to dwmac1000, enable the timestamping interrupt on these platforms. On dwmac1000, the external snapshot interrupt is configured through a dedicated bit, that is set as reserved on other dwmac variants. The timestaming interrupt is acknowledged by reading the GMAC3_X_TIMESTAMP_STATUS register. Make sure that this interrupt is enabled when snapshot is enabled, and masked when disabled. Signed-off-by: Maxime Chevallier --- V2: Make that interrupt unmasked only when necessary .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers= /net/ethernet/stmicro/stmmac/dwmac1000_core.c index dbbd834f9fc8..37374f5a15c4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -595,6 +595,20 @@ void dwmac1000_timestamp_interrupt(struct stmmac_priv = *priv) =20 /* DWMAC 1000 ptp_clock_info ops */ =20 +static void dwmac1000_timestamp_interrupt_cfg(struct stmmac_priv *priv, bo= ol en) +{ + void __iomem *ioaddr =3D priv->ioaddr; + + u32 intr_mask =3D readl(ioaddr + GMAC_INT_MASK); + + if (en) + intr_mask &=3D ~GMAC_INT_DISABLE_TIMESTAMP; + else + intr_mask |=3D GMAC_INT_DISABLE_TIMESTAMP; + + writel(intr_mask, ioaddr + GMAC_INT_MASK); +} + int dwmac1000_ptp_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *rq, int on) { @@ -628,6 +642,8 @@ int dwmac1000_ptp_enable(struct ptp_clock_info *ptp, ret =3D readl_poll_timeout(ptpaddr + PTP_TCR, tcr_val, !(tcr_val & GMAC_PTP_TCR_ATSFC), 10, 10000); + + dwmac1000_timestamp_interrupt_cfg(priv, on); break; =20 default: --=20 2.47.0 From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 5ACDE1CC163; Mon, 4 Nov 2024 17:03:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739785; cv=none; b=ETMab6B2yqucACVuJhRDRIRpJK60o/zsDaMBl/soNbx7MlF4WaCtkYlnsqtpsxtvEYx79lJZCz00fCDMEsYnJDTj+iXY42fUteR5CUYBUyQEGNQaIcZQadP327L9lm6cCZnjcT0RvCyK4oRsYt5ZgodCVlahjKrHvABoh4zn6rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739785; c=relaxed/simple; bh=taCm7jGrsMwVaRpcMPC8pIyj/uNkzIXNqh9XL7lssJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bZeSdfYJzveBXfR55EKlGk5O5nyGc8fYRZ0CqyfvRJR+D0bAC5Nv+mCZG9DySaXkpq5Vfgh0e2drGa7asiOrQP8HtxD84nlaDeUMAAVY4zuKiYoCVEQea2OiHPlKp89lAH7kBIa07MttkM8NAVD5OXVU53OeIP9v7OblUp/desc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dmkVavHt; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dmkVavHt" Received: by mail.gandi.net (Postfix) with ESMTPSA id 07D286000F; Mon, 4 Nov 2024 17:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739781; 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=OkO1POXX6QJMBWryIQ5Nked+++Y4eOh+hwdKXFwqivE=; b=dmkVavHtsJHHquw13b+tInggEp3vFcIPTe/P4Zu28rz+dP5Z6MqAgxx7F9d/N7iqDXUmjT tkGWlU7UUoEiOkPQ2A5VRJrmX4uI7XpZ5XvA4XN4c7nzW2UCSZKZTMiZ8ihFLWhbWAtJm3 4gm6AtGc0QCTspcni2MmBL6JVMRgrxqY9tsbYUIHjsNI+APqD3fP7gP6MqG5o8wgejwS0M wORiWBvpJAjeCBG1z7gY+Wb49CJo0Wy+EX51M/7qRK/Ai9It1eNkqey3YQ89VFUnP0jHJz jCWeS4uoOlIOK/5Oxia0F5J0vre17T8oj9yn3RdkXmxqVPkfO0hWnpBp+h2O5g== 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=20Lothor=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 7/9] net: stmmac: Don't include dwmac4 definitions in stmmac_ptp Date: Mon, 4 Nov 2024 18:02:47 +0100 Message-ID: <20241104170251.2202270-8-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The stmmac_ptp code doesn't need the dwmac4 register definitions, remove the inclusion. Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_ptp.c index 430905f591b2..429b2d357813 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -9,7 +9,6 @@ **************************************************************************= *****/ #include "stmmac.h" #include "stmmac_ptp.h" -#include "dwmac4.h" =20 /** * stmmac_adjust_freq --=20 2.47.0 From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 0CCC61CCB35; Mon, 4 Nov 2024 17:03:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739786; cv=none; b=uRbSDv7Nx2zxrfP+ryVFvEl2fJrWaHRdd0ulfIlmwbPwJnebzsdtOcFQxVqWvjfWyr7mQk4UC0kHdCex9GwtblM83MmrAWVDu6w7A+r+lxzOK5oF+fI81uYmqMWLegBS2dzmzvXtcbyRIN9HHGNV+TKCzK4FLlCPeQXlC8yY3Wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739786; c=relaxed/simple; bh=YjO4EbGR6w7XuGAYzkolUUBk1OmGR67wq0LhFUtFq3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SFnZ+aMR3jaEsNHUU6BpsbK3gb+EE7o+X+2bcxfxC2i9UOAajMDs86StNBSGgCBXH0/cPe0y/G8B87wwN2a+3sUuR+Wq8oK12hqKcc3Lqghwjbz21LcqbgYp7+EkcRZeSBaWdiJ5pu5ZpXFSzohdyzpg3shohHJbdVDoWuN5Hak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Dhjf6682; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Dhjf6682" 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=20Lothor=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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" 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/driver= s/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" =20 +#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 =3D readl(ioaddr + PTP_TCR); + + regval &=3D ~STMMAC_HWTS_CFG_MASK; + regval |=3D data; + + writel(regval, ioaddr + PTP_TCR); } =20 static void config_sub_second_increment(void __iomem *ioaddr, --=20 2.47.0 From nobody Sun Nov 24 14:23:28 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 4AC5C1CD15; Mon, 4 Nov 2024 17:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739787; cv=none; b=O/IDFBqlDeOzkNdxdapgBX0TWbdwaR6v9t/9swMG/8gKhbqB4F/3xJW0dhRCj/I6E/RPTJfUI2BJhfY2ISReLWmuOKFJxi9njq9vI0U+nCOv8aOfyG92zUn1kS3B6EoY5ZneW1aCi1wAKFP5QkWlSCPWWgACbP1G+WYIqlq4vrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730739787; c=relaxed/simple; bh=Qhke3aQ/LKX8NgnOjf25kpHzyWzOYic/Qlwn68EtZMg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dt8neyeklVoOh9szFCc9ljtMoZo17ASOUd10P/ibkSutv4SQLja9CYgf+WQOt9OoOn9TRgcHWrmp42ckalIVOJ+k4oAcGZGrcIlUN6akKMaFzcvn4ggrhL0cKsQrnohLJqHOx6N3UMaqkEEaXE31ctohwpuzj1fsDhJOWsymbJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=LzD3z90R; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="LzD3z90R" Received: by mail.gandi.net (Postfix) with ESMTPSA id CA89B60011; Mon, 4 Nov 2024 17:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730739783; 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=42kxzvTWuXxqunQIkofuM5yI8E9ydjyRl0t7IPFnnsE=; b=LzD3z90R2ZmbkZFhVPMAW0gFfa9+bUK16e+zoEJoUBBvhtWJPhZcznkicbtoAdTxMZrVix xLZJ952dU70MPKkt74w4plYF1NWSGl1mryyakbyJM9kKdBOvJYL3k24voD5zOSexzFIJdd UcWxH3vg5UC/a6yek1Fb2zGqahRyBZcXbctWPyaE7aq4Bm24IpEQzeUun7ep81+Ml1wFHr CuJbpYp6xqa36dUYYxjkkQBNR1Uwx3z9MRLAWkzqgoRt5BcjFnFVFSenBDrvAcMYxiOVIR FmDI5xqlgJZcG69FqRrXkwsDCpyk+yhbyXkUOdLtWptTGkk3Ou2rZONsxtvf4w== 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=20Lothor=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 9/9] net: stmmac: dwmac_socfpga: This platform has GMAC Date: Mon, 4 Nov 2024 18:02:49 +0100 Message-ID: <20241104170251.2202270-10-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Indicate that dwmac_socfpga has a gmac. This will make sure that gmac-specific interrupt processing is done, including timestamp interrupt handling. Without this, the external snapshot interrupt is never ack'd and we have an interrupt storm on external snapshot event. Signed-off-by: Maxime Chevallier --- V2: new patch drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/= net/ethernet/stmicro/stmmac/dwmac-socfpga.c index 0745117d5872..248b30d7b864 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c @@ -485,6 +485,7 @@ static int socfpga_dwmac_probe(struct platform_device *= pdev) plat_dat->pcs_init =3D socfpga_dwmac_pcs_init; plat_dat->pcs_exit =3D socfpga_dwmac_pcs_exit; plat_dat->select_pcs =3D socfpga_dwmac_select_pcs; + plat_dat->has_gmac =3D true; =20 ret =3D stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) --=20 2.47.0