From nobody Sun Nov 24 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 2B7941D5AA8; Wed, 6 Nov 2024 09:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883820; cv=none; b=ZshjBMXMiblXvTeqgptrNArQpQlj75VUjVirnTRa90izOQEk1H0ozgCua/3gELi2bqvL+Aa2DQi2CC8EafUm4NPdeK3S0gHZeYbBwC9SMFo8230CghJvepz9nLCAnkhtSuXJGMoTqjuM4s3BLADHep8Z/BW7pjnHJMkz882WXTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883820; c=relaxed/simple; bh=RFedb7d1yVzyHiGwdyMHJM8bG3GO/6BXjfejl8KlpAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N9qx6S+BjUSPcnt3ahrzHzPbOz0QNIsuw+bZoX/8ZTJIyDKVqM3DXxc6o1DHVOcJhuSWi6bb5BplSenZI0JarUG89n0FURf9taDnkNxTlnyE5ZkRnSKhKNai7OZnU5gUAvomAy1EueRhwsSq2SLoka/Dop4pOAfHa12wMcrHe5I= 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=RWY7lVUm; arc=none smtp.client-ip=217.70.183.198 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="RWY7lVUm" Received: by mail.gandi.net (Postfix) with ESMTPSA id 698B3C0005; Wed, 6 Nov 2024 09:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883816; 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=eGCWRSOQMmjS9ZFY7AhKJ0VNqkvKkp9FxTzYgROnlPc=; b=RWY7lVUmIWk6KHbkfB3AD3i1Nsocxd1OToyqCa4TOg0PWNoLZnYz9Kh0RdaSyEL98S14/6 4psxyailckfwsb755RTMsLqUPDmIdrq7P870xV0a7K732bmBuTXJj5F4Qh2SvpKV+FfimN dS5ik7uDNPrpLtko8KETD5IiJc6fzTQIN2JP4GRAg+PA/duk9rLuLFw2aETgFZ0ZBQyyn8 hVb11yog8HElELmoJ+JcKuw5n0Oyf0SIE9GrKgIb+ngGaM359+87+3e93Gq1W9eojkNbH5 ugevFWL81vyY0HTtJ/OmfnXE3E8u/jDcJmMO2bFaXAakU7lzgVnWIHMPe3djVg== 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 v3 1/9] net: stmmac: Don't modify the global ptp ops directly Date: Wed, 6 Nov 2024 10:03:22 +0100 Message-ID: <20241106090331.56519-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- 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 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 F12DC1D61A1; Wed, 6 Nov 2024 09:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883821; cv=none; b=c1HO5AmdvDahkiBYVt1mIxy8brN+VfRTbjQuzhaT5vmEJcuXfZ1pAjpQO/Ngt3p72U/N+HpEBNEbCdiWZpNpW+OS8rFZ1TfDgxDD+1ptYc86HS+Jx8EI8B0ae6AVCDdw7wYiHhFJhiR5vC99ZOFyHIV46buqkBtI4wl0yTs1Fng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883821; c=relaxed/simple; bh=GtHcLeBsn3O23uFyOkN7l0rYCQD8LcKmQjIeNqm63oI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=inxYNO+KheymtVVmiDpPgJcZqybfhh/bisSORwDx0vrwSOOyzbNpd9klFuYuCiRhMlTGDQG7kPRmhJWDJFZXGksFeoPA5feWFzSIzgPBj38POmCY6aCtbeiClp5JAGI/AHEW00aRHf4f7IC6JcNmCPZqm8R6BjwXAU4IO3e8Wnw= 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=TrIjxgdf; arc=none smtp.client-ip=217.70.183.198 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="TrIjxgdf" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5B52EC000B; Wed, 6 Nov 2024 09:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883817; 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=6X8ox1zyxVxHxIdKjT3dUrrJCv68QyJRIj6PRTEmhEM=; b=TrIjxgdflkgz3StI3vrBOiff2vsFdviG4J11hSA1syO5cxtBBdPsPnbEYfd5fhmx6vEe76 ua27GaR13dBTfbZVknjlja1+LkexHmytS9EoCZQfQtU58gqBVOuDWeF3UszHBfh2Z34iuR YRKKXyx/1UP8Hyxep3RIvBcDmjMsIKkkCYVWSbW8HtVjHOGya/3c5KCeaA8p0yoPOa69K7 WP3bQz/t7GTI5VmNf6WURiKVCgkWm4t2ECVtf/1rG4skCzsEmIonpbaT5HAzQprttQQnTl ilWJ4tPIuRkWP45VdMxWIJVEPZ43qh7BC4JQisbSpyUCXPCSMpAkqXG4hFJZZg== 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 v3 2/9] net: stmmac: Use per-hw ptp clock ops Date: Wed, 6 Nov 2024 10:03:23 +0100 Message-ID: <20241106090331.56519-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- 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 cfc50289aed6..47458cbcbc94 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -113,6 +113,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; @@ -134,6 +135,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, @@ -152,6 +154,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, @@ -171,6 +174,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, @@ -192,6 +196,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, @@ -213,6 +218,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, @@ -234,6 +240,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, @@ -256,6 +263,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, @@ -278,6 +286,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, @@ -362,6 +371,8 @@ int stmmac_hwif_init(struct stmmac_priv *priv) priv->fpe_cfg.reg =3D entry->regs.fpe_reg; 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 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 A92541D6DB4; Wed, 6 Nov 2024 09:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883821; cv=none; b=YUyVlHqNLi8UDikYu6rUTa7JHXr/9gtx8wNpIVAtgnx2+KA6Ikw0xtr+XGviqXP3Z90ThZKKFiMgRV3M6eDFhzP6vh5rm/m0mLTMGs3j73WreQn1vn2R8RHf8heBNacxL3rlm5d/OiQElmRyrpqNNWKUv+QWOH4jAx/a3Yfknlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883821; c=relaxed/simple; bh=Rb/YdaGhYsLS2sFxamiAfxpvrN+cLnkLpEBed7xX1ac=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fpSV8PzYOzD2RMxlczgCZiCPCHZC+Q53/R5ufEjHCZJpy4hUBSrIrrgrfmlc3xAS26OAehVX0ItPaAU0iEqpz/kIEcooHfhGpUh/HoHmw5D9CyBrge0/PGEaT5R6GguiNnHVDnHdmAnXxKvqiLyL0coRKwwYrci0vJchg0KeiQs= 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=CD8znPWu; arc=none smtp.client-ip=217.70.183.198 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="CD8znPWu" Received: by mail.gandi.net (Postfix) with ESMTPSA id 3F107C000F; Wed, 6 Nov 2024 09:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883818; 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=NkGxMlPDNP8jSIw5T0tZvfBvg6tLoLPlBAwO+v2kSjk=; b=CD8znPWuyklEx5hX2MW1sCNG4NJxsDPL3l3qOm2dfkRMd2qpyAKOZncIzrCt/sIcl1kwNf vQXtWNilwUZkDeO20MqK1dGat5MCvm83zpOeKUGP/vDVZ8PyydviSjZBix3WxcMhQQ1bW3 v6ua8iNs5TH+vIoUEFJvUAzJRkRR2OY/NtoZ/hP7e22Xv5rm6pdwXJVSEAoXHOV9C+Rrl8 FVC4Eo4WRs92PK6bf9M668BcCa91mpQeHnxpiQiKbrQnL3OYNQLvUF9SV9vXOy4zkDsUXg v0DP9L5GtWOPYYyXNmwe1HiXnijcM4oiXmRUG3bXV1uFiACkoByiS3pP6yvPEA== 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 v3 3/9] net: stmmac: Only update the auto-discovered PTP clock features Date: Wed, 6 Nov 2024 10:03:24 +0100 Message-ID: <20241106090331.56519-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- 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 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 B22EA1D90AC; Wed, 6 Nov 2024 09:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883822; cv=none; b=h7qiwDFRyBB2gsluwYlGUQ9suj7zciwjPCB0Q3ClZD7PtNlcvbGMQWwKDcsC/wzG4IxareJaq1ctr3Vz2isl1+wV8na4Rfaf3UDH30JIQ/DGRdjKgUOCsTFstNbQsn40jPNnTfaSoISe3wfB/jc0hYrPLZl0jsh6ZMIlUTng+mA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883822; c=relaxed/simple; bh=pErn1GECl4fXNG5riQTFxiOaQcp/7Xhg8Q2yRcay4Eg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NbQi+xw6ErSJxqkVfZJOsgR6OD5lWyBB2+f4wTR69+YYj84qKtfDfYfBjOgLV9so5jXhDwi8CFqu6VSvUQlO3l/Ydh96NhGdmF177pMWS4sBY/udO+5a4yKsJwZAGfdDSijJ8AO3LR+yxURoWwo833ze8zAuxWvNRKHaHks1Ivg= 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=pleMMZ0z; arc=none smtp.client-ip=217.70.183.198 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="pleMMZ0z" Received: by mail.gandi.net (Postfix) with ESMTPSA id 2B289C0010; Wed, 6 Nov 2024 09:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883819; 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=rmARGAYQkgRNBm0EE79julCV0sizLn05+nPxjeLziJg=; b=pleMMZ0zXoraZmfOOxeaYClc5Gb4r8o6yakoXM9rOr7EnNFntvnoaR9di0God/YVUzPziY pVH4AYMyGkz5+Sb9+EshwMSDXbtxvPj0X/P39iRy1zNxH5pqlBaaOfc7+WP6x0QPw5PgZJ 8LBKEWClrd/E4WwWc4nj8ozJYuj1DWkaz0FYdMF9gzS63QTWs8KREyRzmhq8p8N5jlBzmU 58JwA5mi0Hgl85nTs96FS+hubQZ94HnybLB7w2GXD6UmG/mY7RydqIROPurbXBTw1Qi3Bf 6fdcDFfMF5aAZsaIWyQLcU6i8tSP7C7lVtJPbPOLqmCXz+vV7hwkyKKzY458hg== 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 v3 4/9] net: stmmac: Introduce dwmac1000 ptp_clock_info and operations Date: Wed, 6 Nov 2024 10:03:25 +0100 Message-ID: <20241106090331.56519-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- 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 47458cbcbc94..1f508843fb5a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -135,7 +135,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, @@ -154,7 +154,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 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 7B6BF1D95B5; Wed, 6 Nov 2024 09:03:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883823; cv=none; b=UsJCU2OkuIYiykKwsyUxbR/aQacE2jsCDQMgvO7BDQMWtS4Sl17qm7tywOzUS0R0E70e1SrgEmEw0Qtx/PMc5R3HMFOhvmhN753qD+4z3+Mbf+ZFshWdkGO6YY2JE1ZuKEHSSeZmEnryA42dRecAZrUifu3nmg4VbBQqmaPB/4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883823; c=relaxed/simple; bh=W0imOmICHdaLi6ccNReO7BUC8/qCsZKJTKIGp7c+i+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qGLEEEZMB69yFzWv0XFAvNgQRiMFa4fPR1Q0MNtJcUyIL6SY3v97Dzb6xFhOS4ECcSAZW+YtTphlgwFdnvFyjU1iT4rtbvrx/NK+2qaHtQT8m9HCMsCR0HTuIluwBKZgrJMct+ONahIMVGJ7uNV9SqdSZbEwV2jTlKoh5A8RvEM= 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=iZ81FDdD; arc=none smtp.client-ip=217.70.183.198 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="iZ81FDdD" Received: by mail.gandi.net (Postfix) with ESMTPSA id 295AEC0008; Wed, 6 Nov 2024 09:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883820; 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=4yOD67QmwjZdiHTTDroIrCKnheoQt6SF0kW3Ac+U+wM=; b=iZ81FDdDo2xrqAH5pXI0Kj8agNSI06Li7NNfIrbvMXeP9fbuOYVE4csnnQqs9jXfYwG9YG 2QPo/yzXDdNq4Hn+q1meQUFVFVU+TaH8BiL+kMjFAge5k7laxUwog+ue00dGV8vyuw/fbI ioDROv2nzeFHH8oHKw4gX62shpeiB3D+BN/t4fDB46UYXgwtBiPh1PxNXEtthNwWRqHMv7 SkXt+4XI7o4nZ1LCeoc9CgzGd+uSXUrAg1oAqWvAOI7DVoPLLq2AFooVykM3KdVB5pw+OG M53VzEIg3u5U/I+HoeZOfKHp8j4EGpc22gSJNwB6VkovMYXmmzjDbxwxmyC2Sg== 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 v3 5/9] net: stmmac: Introduce dwmac1000 timestamping operations Date: Wed, 6 Nov 2024 10:03:26 +0100 Message-ID: <20241106090331.56519-6-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- 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 1f508843fb5a..a72d336a8350 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 { .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, @@ -153,7 +153,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 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 7150F1DA631; Wed, 6 Nov 2024 09:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883824; cv=none; b=uW74mUwOM+YT2L/8qipH0aiKj06yi6Sip5/vmWbL19oARsiSda3IYHlwJ4k1VfPdDY6A6bT65E7LffbK7Txj1tJ0BOv2iZg/KghtpV5OrgM1Fqx1M32vu2oOQo9rGXn0WpuonlQ9mTJNp2hZCY3P6UVFejW16igQ/0LLXgwp7ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883824; c=relaxed/simple; bh=wHSkO3i4E3QVVJuUzsudtVocN6toZEOaX0qWO3m4zzI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E2VIFCWc2RkAffDtfKf4Bg7Yw92LBVJA24erxpCYJT5zKYagkN2JKZuLC2VSfUll0NWc49xywIxP0NYxBlGgSJH1oVq8oZIoVGMeBl4WldmVSUK7oPN1qLb66YqhL/1ugc/Cdk4w42au+wrjJX+ZVAVklLeEMq4ZIhoaYYIr20M= 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=XUpUb+JT; arc=none smtp.client-ip=217.70.183.198 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="XUpUb+JT" Received: by mail.gandi.net (Postfix) with ESMTPSA id 1AC37C000E; Wed, 6 Nov 2024 09:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883820; 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=bsLQRHH9qcfVm0KFq9nbu7CAMOKMnDfpEsC1vjJ0/qg=; b=XUpUb+JT6rjH1kpItlNyHplkrG9yd0WFPn/4A272FO38lRygb+7vRZeZF87FVMA1+KVHuP 9d7x0xGXW4XOMxQBvhpZEoYOLcUYrK8V3DXejJil2BlVTG3Z5VU5gMGmFbRv66lyBTWUW4 RjN7z5G02uX7prPHiOjVQNrTw98Se6eDYNCjBOzxQi93xpFREQaJyzXNqm7F1bfjZCdW5X nUx2gaw4YiQXqwJBPJprBfY4wr1XaR68ftcIqs+IREamQgBcviKsDuGYcihuvzxYt8jSLq oH/tr8EnhdN0x00dELjl7FqKL8TYKw7CY5CVs5FNtHRDbkV6S0ewPEE2jM+iGg== 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 v3 6/9] net: stmmac: Enable timestamping interrupt on dwmac1000 Date: Wed, 6 Nov 2024 10:03:27 +0100 Message-ID: <20241106090331.56519-7-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- .../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 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 415A81DB522; Wed, 6 Nov 2024 09:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883825; cv=none; b=duix6AHawu2Z1ettOFdyHOEp3M59reXgPwf4memt0NH+x1mkhxc08qBY+Sa9hubI7a3i64eGpci6arK7gA8n5xDF0xrQeNPnfFkWuoumO4QMkSoqcwi1Xg9ZecRJc7JvjbQp6PuSpbf2N0fXyqeapBKEovCy+IyGxKexp9l3YlQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883825; c=relaxed/simple; bh=1gVOx7nJBT2hbmD/H6fKlrhljqTLUC8tKX9QCyRhVqc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cQ74G7qt+6C6Fc0fI6ngCatcqhP984rwbe4rAGpSqF0JzEX/DRqyIV/GAu/RrGOY7vD86QNf+43N+BlFHzZTwfgXDYkloqJ2q8240chfZBxuq1JGdeBk8wxfb1dk7lcZ2gWKIzwbREx9eTImuHv+9/VHVRbup76EFSMH8JXObQs= 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=QSZdGVv3; arc=none smtp.client-ip=217.70.183.198 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="QSZdGVv3" Received: by mail.gandi.net (Postfix) with ESMTPSA id 06823C0011; Wed, 6 Nov 2024 09:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883821; 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=+tS5coFjCL1GpMVLn+Jt4VDJfqi7WRWtEsSocGUBw08=; b=QSZdGVv3ycCS5kk4vrRroi+FE3i7NJdyKHC9j0KU6LTlVP+FToYYrp6RlSu4WylUgNfVqN sNwVLKIPIZ2E6wIFjZUKv/zKjRY3MdR4SYvFlK1MB4pwPWcnkgg2q5NvxRuj/Ih6tRpvnV JSyQFFjdckBWVY1F496Gh278MnqbIhxweZ+m48A4W/yvvzhwyQ/gN5+9L+FxWZroWSsrpL vIL+28Ve0Amya4LMns9oMXdq4oBO04NDVit+lqtjbXJKTxU9LMOH6rkPTG7c6upxBHl2FP ResMKZzz1cL4lAmvXPeIQFMON2mopaJjqA2irerfsB0mgnx5QspMgrdMbzil1w== 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 v3 7/9] net: stmmac: Don't include dwmac4 definitions in stmmac_ptp Date: Wed, 6 Nov 2024 10:03:28 +0100 Message-ID: <20241106090331.56519-8-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- 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 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 469C31DC1A7; Wed, 6 Nov 2024 09:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883826; cv=none; b=NTDrUx0s4Qlb+vW6S236CXTxQFG99ypf0jD2PzFUigKpCSIuBuZpSQow0eDuWAfItXRvnG5GlvhwTKcplpUhXt+Y6E2tEeOr3hnWSizcQHyrkWJ1B6O2PmkSRnnQPiVzcY0gXxmyA/InOuMT/tMJyIrGryfV3bJYs66XdWtPjuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883826; c=relaxed/simple; bh=L7+YOJA9BbsV2tyTIEWCcTOVQjJKDvOb9EFArgvsLrc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RwpM87xb4USbkJVMUeZrvhx0TO1yArjV5xX65sWBPA5pJXDb92Nwg7wZRU4gybVd20EkFcweV+SNB7eAN85rIwcUaSWbh6V5V8YE2flXhZYLta4oeGdAkBs58m+93LLoF6hr8sBtiyWrR9Sou8kFPKzRiqEd8qMwDGMB9+QrTnA= 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=dMiJmSrz; arc=none smtp.client-ip=217.70.183.198 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="dMiJmSrz" Received: by mail.gandi.net (Postfix) with ESMTPSA id 09AC8C0005; Wed, 6 Nov 2024 09:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883822; 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=YY/BFgC6bGU8aHXsQwu5u3ZdGvQcTEQGF6Gva3LQNL4=; b=dMiJmSrzFewBNUuaWceqSLWR6fRO6pEH+oboc1R+HHxvzd0ut92rEWa4JprfE9CroX+2bp AsZpRjTE8mfc7mLFseC2uRnFeOcy/qsomBMgUmkICslYODjuq2OAxHR9dg15ulRAbVviV2 yNaNBv6hX0o3IWdwqcmh9mM6RrZ94kvBWjAbirbiB3e1axiqrC4aIWjlLKtI+1G+GsMWSI 0DlQ2v3IAjdilxUK69KzKqY4f2T5KCjpUS11BKogwZcwLHom+X0C+7CCQNvB+k1gYWw529 irEZkMTrx9geAsaQgb9eFCaVG1py5MtwJp+QbA93GEr8DJprbcTB1IuJOCRcKA== 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 v3 8/9] net: stmmac: Configure only the relevant bits for timestamping setup Date: Wed, 6 Nov 2024 10:03:29 +0100 Message-ID: <20241106090331.56519-9-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- .../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 09:36:33 2024 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 141C91DD0E1; Wed, 6 Nov 2024 09:03:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883826; cv=none; b=K8FcrO2c55LyHatyw9TuBUXXvWqH5XE4kZ5p0gd/XlW3qtiysBd+S6RYpA6GPKYd9zb50/F7zQvLTHJvkX4wrobFI+1wVoU83L8hzKqAknXnLOBI24lxRbLojrLVktdwcfWrKvg7sSmkAMfIgSvo8PZxFN5MxNNpvUqcs8iOYOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730883826; c=relaxed/simple; bh=HgpNPhPmBRsJWksj0+A8DbSRT3GIfHWeaZBQkwOcymk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cKu3EnAJdLlLgmzlTgrfIByOpqby2GST+OoGmVP0faxIXMY7Wglk1WZN5pmgl5FOlFtyoKQ5JnxW5eIbcRglnO0UAF1YAEWpWD9GAYB3EQ7I3P1W+21sCcAxrwqnpZf8eZGQ4RUTxdv1wL6S7tKPckTNsvUL3eNnRCqhlwV/GNc= 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=GzRhmvhD; arc=none smtp.client-ip=217.70.183.198 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="GzRhmvhD" Received: by mail.gandi.net (Postfix) with ESMTPSA id E4815C000C; Wed, 6 Nov 2024 09:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730883823; 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=E93S7Q8y++FOL3m/D0GbV+rHXdW8GgCuYU8lejTM1Gw=; b=GzRhmvhDYab6e+aCvOAiscJ14yt1FYl8jh7MKLtr4A4vMqEZOHzd0P8TdQn6hOnAyQuYbf hQnynd8cO05pDbs8uNL+GptssVm1mvRJbKcXtGWAEe7qmBqnymwkcCTPqNM2PDIa99+ZWO uMs6xRvQnebX+7JxKrDlm6SHHRIECJJtO5Q9ePjtPjsaCA7d48br78MNm4j9w9cPKkTLzu taNlpdcAE5Rxfs79B6Fae5yrpit0C7nurQMyDs2yPYhuTOswLbwzo3h2MZH5XAZXyFqXBk wiSdvDBZp0SioSFlTzsKTCqGtkoiFXGIYLT1wGOzxi5D5yrh9mWqg5/h+LRy8Q== 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 v3 9/9] net: stmmac: dwmac_socfpga: This platform has GMAC Date: Wed, 6 Nov 2024 10:03:30 +0100 Message-ID: <20241106090331.56519-10-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106090331.56519-1-maxime.chevallier@bootlin.com> References: <20241106090331.56519-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 Reviewed-by: Daniel Machon --- 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