From patchwork Tue Nov 12 17:06:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872622 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 E5EAF2076D5; Tue, 12 Nov 2024 17:07:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431227; cv=none; b=dwcj0/9SPibFFuE1SGZsEd2Si92SyE9IVlpV2RMYwvLsP4geEWyxPJG08w1ryW2lczq4ZSgP0oSAYAs+QxyA/CrThMcouo0yOH9s0lFubcgTh8jGJitM6Iv76D2G434CG0m8eZ72s4oDOFXRY8BDDzYj8z801ZgoFd/gnI9UBi8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431227; c=relaxed/simple; bh=vsBKz9P3aXcIkDkNHgjbl6t9R5yXoxKtjWQKWV2NGPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hf0P5mJPtgvCrTXOqVxTgjNXEhCqmkFu97ePkey/0+VetVOgeubQaSYKQUCPo+g/3olrg0lF2VOXGCOx8UH+Lq4xhbvjOTZSzPsAavcsHQFHZZhTdqjrRokqsUF16JysZyHdbwFyJ010gBaav+lBwfMGBwmSAQx89mcwfi/53N4= 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=ZdRuqB6L; arc=none smtp.client-ip=217.70.183.196 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="ZdRuqB6L" Received: by mail.gandi.net (Postfix) with ESMTPSA id 4F093E0004; Tue, 12 Nov 2024 17:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431223; 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=LZw9t9ICWMYTWiUjhgkRGFqANmNYJTvr2/KWvvFKqHo=; b=ZdRuqB6L+RSgkn6gJdetR5a//9ZEmm5dAtN5Y6Hzy52DpESNjKNM55X63uMNNMpHOmryNP b8IzA/heHgjBiJtwmoGiQshyNtHJIxc7/Dvrr8c2f3/9S2YYnabTrnPD3e4f6WxFumiM2s 0KyBM4wzec6A6nwUawnFC4JPukLkZlbza/iJaGaTvbrjXm5twEE+Wc/J78h15bNyfJgQND gg4LbUGSSp4conVDdSjRQWHVg8sfAKaI5EAd/UrDHmiCzFV4iaROc2/nCd17iXAG1Fn/RU EQ2AQBCtQQQzdmjPVAOvnsy8+KAEP8MTlNaaII8X4RjtblkApLYxCxP0sx32gg== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 1/9] net: stmmac: Don't modify the global ptp ops directly Date: Tue, 12 Nov 2024 18:06:49 +0100 Message-ID: <20241112170658.2388529-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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. Reviewed-by: Daniel Machon Signed-off-by: Maxime Chevallier --- 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 = true; } - if (priv->plat->ptp_max_adj) - stmmac_ptp_clock_ops.max_adj = priv->plat->ptp_max_adj; - /* Calculate the clock domain crossing (CDC) error if necessary */ priv->plat->cdc_error_adj = 0; if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate) priv->plat->cdc_error_adj = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate; - stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; - stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; + priv->ptp_clock_ops = stmmac_ptp_clock_ops; + + priv->ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; + priv->ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; + + if (priv->plat->ptp_max_adj) + priv->ptp_clock_ops.max_adj = priv->plat->ptp_max_adj; rwlock_init(&priv->ptp_lock); mutex_init(&priv->aux_ts_lock); - priv->ptp_clock_ops = stmmac_ptp_clock_ops; priv->ptp_clock = ptp_clock_register(&priv->ptp_clock_ops, priv->device); From patchwork Tue Nov 12 17:06:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872624 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 E75D82076D2; Tue, 12 Nov 2024 17:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431229; cv=none; b=MzdvPVOfnj7v4ipijiUHfWe09UgiT3o6v+3Z1iF0rj4wGPZmnJmIhm4yCwosMfM0VhtLvSvthQavuNy4rspvMwBwqQExg4alKRwAOjhIvKjMZWP4+kW/5SyiZ8pzp4/QVpUI1L8ZzzCiFiTXoOzQj30gZgE3A7B31NqVaIQUiQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431229; c=relaxed/simple; bh=RNS8OS44VA3qZ7FOchNv1YRfFwIzzNzs2xyH7AstGYY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFnBIVBAfgE9y5WS3wJBMVV32Q5NfrEsfuJAyWTLvY/Sbhp7pH4HxPtPCAh5IP9mpbz7Xf/peI63OVQJT0eEfYnbBRTInVxNiReQMFrW/x4CxCnnB3Pi/wOIk9eaR7ebusYAMOURO7hk7sMxXizyrUCEzh1SEIiTULhoC+Hh0Uc= 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=fcSBz1Gr; arc=none smtp.client-ip=217.70.183.196 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="fcSBz1Gr" Received: by mail.gandi.net (Postfix) with ESMTPSA id 341ADE0005; Tue, 12 Nov 2024 17:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431224; 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=Q5euAD6mvMtoI8FBmagdROpF4KMX7Rxgrb+7EFp/no4=; b=fcSBz1GrzADukN6xLwU6Gqk8+OPPUxrk7kfxs0YK3n4Ea7Co4G3bTtTz6Ua5Q2RjnIVdIJ 3IeYRuYwwlrGYSaJTzJe9+gwBaBtfF4vbpAHxgeR8zka4jduvrIGErnOSvxaPQuPN0mo/o H3nlthG5bwg+MR8ZCj1oMwjfpGeCK9Kwhk9GfUrVCo7jCaSQj8FSxfu2bwRRQsXqziX1CZ 4kqEEy2hO2bU3+OoUH6C4BpCN18/s5nfq62Kdpz4tOItR7gOkGvhJPfDsU0Mx5E/O2vUDs Hvm9PpHFB2l1vtlfFSyqRCdOIbPsXrGjA/2LTRVIrwSoEf9WnU/pkQAOsk0L9A== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 2/9] net: stmmac: Use per-hw ptp clock ops Date: Tue, 12 Nov 2024 18:06:50 +0100 Message-ID: <20241112170658.2388529-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Daniel Machon Signed-off-by: Maxime Chevallier --- 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/ethernet/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; +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/ethernet/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 = &dwmac100_dma_ops, .mac = &dwmac100_ops, .hwtimestamp = &stmmac_ptp, + .ptp = &stmmac_ptp_clock_ops, .mode = NULL, .tc = NULL, .mmc = &dwmac_mmc_ops, @@ -152,6 +154,7 @@ static const struct stmmac_hwif_entry { .dma = &dwmac1000_dma_ops, .mac = &dwmac1000_ops, .hwtimestamp = &stmmac_ptp, + .ptp = &stmmac_ptp_clock_ops, .mode = NULL, .tc = NULL, .mmc = &dwmac_mmc_ops, @@ -171,6 +174,7 @@ static const struct stmmac_hwif_entry { .dma = &dwmac4_dma_ops, .mac = &dwmac4_ops, .hwtimestamp = &stmmac_ptp, + .ptp = &stmmac_ptp_clock_ops, .mode = NULL, .tc = &dwmac4_tc_ops, .mmc = &dwmac_mmc_ops, @@ -192,6 +196,7 @@ static const struct stmmac_hwif_entry { .dma = &dwmac4_dma_ops, .mac = &dwmac410_ops, .hwtimestamp = &stmmac_ptp, + .ptp = &stmmac_ptp_clock_ops, .mode = &dwmac4_ring_mode_ops, .tc = &dwmac510_tc_ops, .mmc = &dwmac_mmc_ops, @@ -213,6 +218,7 @@ static const struct stmmac_hwif_entry { .dma = &dwmac410_dma_ops, .mac = &dwmac410_ops, .hwtimestamp = &stmmac_ptp, + .ptp = &stmmac_ptp_clock_ops, .mode = &dwmac4_ring_mode_ops, .tc = &dwmac510_tc_ops, .mmc = &dwmac_mmc_ops, @@ -234,6 +240,7 @@ static const struct stmmac_hwif_entry { .dma = &dwmac410_dma_ops, .mac = &dwmac510_ops, .hwtimestamp = &stmmac_ptp, + .ptp = &stmmac_ptp_clock_ops, .mode = &dwmac4_ring_mode_ops, .tc = &dwmac510_tc_ops, .mmc = &dwmac_mmc_ops, @@ -256,6 +263,7 @@ static const struct stmmac_hwif_entry { .dma = &dwxgmac210_dma_ops, .mac = &dwxgmac210_ops, .hwtimestamp = &stmmac_ptp, + .ptp = &stmmac_ptp_clock_ops, .mode = NULL, .tc = &dwxgmac_tc_ops, .mmc = &dwxgmac_mmc_ops, @@ -278,6 +286,7 @@ static const struct stmmac_hwif_entry { .dma = &dwxgmac210_dma_ops, .mac = &dwxlgmac2_ops, .hwtimestamp = &stmmac_ptp, + .ptp = &stmmac_ptp_clock_ops, .mode = NULL, .tc = &dwxgmac_tc_ops, .mmc = &dwxgmac_mmc_ops, @@ -362,6 +371,8 @@ int stmmac_hwif_init(struct stmmac_priv *priv) priv->fpe_cfg.reg = entry->regs.fpe_reg; priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off; priv->mmcaddr = priv->ioaddr + entry->regs.mmc_off; + memcpy(&priv->ptp_clock_ops, entry->ptp, + sizeof(struct ptp_clock_info)); if (entry->est) priv->estaddr = priv->ioaddr + entry->regs.est_off; 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, } /* structure describing a PTP hardware clock */ -static struct ptp_clock_info stmmac_ptp_clock_ops = { +const struct ptp_clock_info stmmac_ptp_clock_ops = { .owner = THIS_MODULE, .name = "stmmac ptp", .max_adj = 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 = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate; - priv->ptp_clock_ops = stmmac_ptp_clock_ops; - priv->ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; priv->ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; From patchwork Tue Nov 12 17:06:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872623 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 8732E2076DA; Tue, 12 Nov 2024 17:07:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431228; cv=none; b=YKRfhV1DR/OPtNxhD0NdS1Fg2a85QmzkircdTrBtEJbEPDFcCi6f19UoyXmXCNlVnV7WvzW5u7UjQrkrPCBP1I5qK1NymkxLfQQc2oYXmLw1TFmTKSMXmM3C8tpK/ZMPLB70JzZTJMbWHUKZQbfrA0efWc97olAvPIU1rIT12es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431228; c=relaxed/simple; bh=ZLPGj6WXN3BuJOMamN+Guq8mn419X2Ks1A7V+nRX0UY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eIRcQOF4f3hFTxFuIUpXJZWd0KOo/35VnNdFaArAg8wDd0cLDPX1i2nSKpBhH8pxf8wqqJUjOfD2CuRFP51s9Jh8p3oAw/HemuenOoCPH6x54El2ndMsxeyExIBe6ub5Szwg1W6DB8tb3S1fp8V29vEgjpXSMBfy7/CN6KApF10= 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=VUs0vHrq; arc=none smtp.client-ip=217.70.183.196 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="VUs0vHrq" Received: by mail.gandi.net (Postfix) with ESMTPSA id 11CE5E0003; Tue, 12 Nov 2024 17:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431224; 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=nVtphm0cd92uCNrWWJUGo3RJLZx12bWCtkJrrYfGlSo=; b=VUs0vHrqRT6gmNV+qM2o7SK4Ufz4FuiWZfazvKngkJCFOIrp8DAR467nZvLpRLUDTMgxF1 9NYrLw4ZBXUQL0Z2jBDyyosH1V9svrfMsrK7vwagKF3md+65xJCHEEjUDyL2x4mAvnglqJ zQRmMUG2Wh2CaRPJrG/VL85p0REl0tg17l3xvH+6Yv/bpSXvQPLWqyVxRtxviazfGEk0Zb v9NTzIN5S+RYa5frnahoNQg4gewc/k3RGIDhhKLiW0ZE1l5xOpZZgH31tLzns3bIho03ov vLFtKABvz4Od8wvpUoW25wH7B6akGQJXHhUFJ3Dz8VXSN9BaQ11BOHZIVhyLeA== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 3/9] net: stmmac: Only update the auto-discovered PTP clock features Date: Tue, 12 Nov 2024 18:06:51 +0100 Message-ID: <20241112170658.2388529-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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. Reviewed-by: Daniel Machon Signed-off-by: Maxime Chevallier --- 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 = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate; - priv->ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; - priv->ptp_clock_ops.n_ext_ts = 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 = priv->dma_cap.pps_out_num; + + if (priv->dma_cap.aux_snapshot_n) + priv->ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; if (priv->plat->ptp_max_adj) priv->ptp_clock_ops.max_adj = priv->plat->ptp_max_adj; From patchwork Tue Nov 12 17:06:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872625 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 65CB521314C; Tue, 12 Nov 2024 17:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431229; cv=none; b=LomTXilyDd1FNqNxF18Iw+QiaEz13j4WilPoWp872RG7MI0Ifr2KAkEnPt0xDn5MN0aMjHwKbsOManZehsRxzDGVX2JmEQG9csXPrynri5VjtWom70rb0Z886q4+wAhajcdiTNmNDllG65sqrMUoMHSBtbMVrg/IEbM8GRKZP2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431229; c=relaxed/simple; bh=NnEu20TOM8sLjElKmgKPjojJx4DHs+DqdR87nJrtq2Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yl3/KY0BkfOSE0Piy9hxKeF6sMD8sJypLIP8wThC43/PidHX28SBsGEhnoTzz3QdCdPaTPjt8yixQAlqkd5aFV0y4LP9Aa/TcaSFRE15mJgWD7S7WuccUQwiHlKsJc6wyXgqI5mcm9ht+6auy259OHM4AJa1udUPiYenFBQIFGg= 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=OUusYAzL; arc=none smtp.client-ip=217.70.183.196 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="OUusYAzL" Received: by mail.gandi.net (Postfix) with ESMTPSA id DFC7BE0009; Tue, 12 Nov 2024 17:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431225; 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=I3/LWbqaZazKEq6VjLV38cT+A/nEiHKr3Hh/DPkJ5IA=; b=OUusYAzLhJIGjnOTUZrSSirN0cK3O4T/9HfKDJBniYnd0ror2gkJQf/iVT+ab/jc1OgY3T RjtVl1v5/Bju7bcnFAm2ib6YYHJi6VDGYw9wRpnsrCkjRaqW/5cyIc4Ha5SxT60iQvZ245 loAJHMu0ZxTPnuBt1hREMPKeyei4wnc1SwFBbChoqpKKdFZ+8SRFNa/8AbjtXlQXQuXbg9 KRbWJ2FG6xSTKQHs3OVwVZUAM30QaLAGji2AsTOakjrHp8r41r7x8pkqDTEDOSRSFnTmY+ QitpLUMhfAXbSQ8ueo42d3RtZG9FSdSjNP7h5s6W6ayuBpRz3U+lSScc/ct64w== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 4/9] net: stmmac: Introduce dwmac1000 ptp_clock_info and operations Date: Tue, 12 Nov 2024 18:06:52 +0100 Message-ID: <20241112170658.2388529-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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 --- V4: Moved waiting for the FIFO drain within the mutex 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/ethernet/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; extern const struct ptp_clock_info stmmac_ptp_clock_ops; +extern const struct ptp_clock_info dwmac1000_ptp_clock_ops; 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 +/* 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..a14509d88fe7 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" static void dwmac1000_core_init(struct mac_device_info *hw, @@ -551,3 +552,47 @@ int dwmac1000_setup(struct stmmac_priv *priv) 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 = + container_of(ptp, struct stmmac_priv, ptp_clock_ops); + void __iomem *ptpaddr = priv->ptpaddr; + int ret = -EOPNOTSUPP; + u32 tcr_val; + + switch (rq->type) { + case PTP_CLK_REQ_EXTTS: + mutex_lock(&priv->aux_ts_lock); + tcr_val = readl(ptpaddr + PTP_TCR); + + if (on) { + tcr_val |= GMAC_PTP_TCR_ATSEN0; + tcr_val |= GMAC_PTP_TCR_ATSFC; + priv->plat->flags |= STMMAC_FLAG_EXT_SNAPSHOT_EN; + } else { + tcr_val &= ~GMAC_PTP_TCR_ATSEN0; + priv->plat->flags &= ~STMMAC_FLAG_EXT_SNAPSHOT_EN; + } + + netdev_dbg(priv->dev, "Auxiliary Snapshot %s.\n", + on ? "enabled" : "disabled"); + writel(tcr_val, ptpaddr + PTP_TCR); + + /* wait for auxts fifo clear to finish */ + ret = readl_poll_timeout(ptpaddr + PTP_TCR, tcr_val, + !(tcr_val & GMAC_PTP_TCR_ATSFC), + 10, 10000); + + mutex_unlock(&priv->aux_ts_lock); + break; + + default: + break; + } + + return ret; +} diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/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 = &dwmac100_dma_ops, .mac = &dwmac100_ops, .hwtimestamp = &stmmac_ptp, - .ptp = &stmmac_ptp_clock_ops, + .ptp = &dwmac1000_ptp_clock_ops, .mode = NULL, .tc = NULL, .mmc = &dwmac_mmc_ops, @@ -154,7 +154,7 @@ static const struct stmmac_hwif_entry { .dma = &dwmac1000_dma_ops, .mac = &dwmac1000_ops, .hwtimestamp = &stmmac_ptp, - .ptp = &stmmac_ptp_clock_ops, + .ptp = &dwmac1000_ptp_clock_ops, .mode = NULL, .tc = NULL, .mmc = &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 = { .getcrosststamp = stmmac_getcrosststamp, }; +/* structure describing a PTP hardware clock */ +const struct ptp_clock_info dwmac1000_ptp_clock_ops = { + .owner = THIS_MODULE, + .name = "stmmac ptp", + .max_adj = 62500000, + .n_alarm = 0, + .n_ext_ts = 1, + .n_per_out = 0, + .n_pins = 0, + .pps = 0, + .adjfine = stmmac_adjust_freq, + .adjtime = stmmac_adjust_time, + .gettime64 = stmmac_get_time, + .settime64 = stmmac_set_time, + .enable = dwmac1000_ptp_enable, + .getcrosststamp = 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 = 0x80, }; +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__ */ From patchwork Tue Nov 12 17:06:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872626 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 500EE21766E; Tue, 12 Nov 2024 17:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431230; cv=none; b=AjxGZvEbQQ+Ks+3lg+j5wAtktwJOqXJRTh75owhguvhjzlP7ZvXAkHAvSUKI+dUCTn+81HhbJVdskJES5WN0IGIFlKB0I4HgDYVBti9GeX7sEBzYaSQ4cbFOEO/0lPLWw377CcoEgVTKYBSIAa2KUZEQLne25uUXmIvDVGNJfBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431230; c=relaxed/simple; bh=ge44t+vzpP25czJImRogfd9RR1tJ/LLzjMZ/sfTNePc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GJMafyOFNJDChD9YlgNzYn42G6MPTaPe6eV3fcKdZf7o3QTlagw7sJZVbgxOeqBBH8dsdRQLvAhZ6TENd1PSL7B4TLBjqxNqSJI8B2fwm6ApnxfYQY2Y0MLT5NDZJxthOe+otI4s9t3wbc6tA00m9FgTGFkQqSTgOpckiCNhSVg= 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=JgRQEOsU; arc=none smtp.client-ip=217.70.183.196 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="JgRQEOsU" Received: by mail.gandi.net (Postfix) with ESMTPSA id CD6CDE000A; Tue, 12 Nov 2024 17:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431226; 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=T6ZnuAFb2F+oFFiAGtEbZ+Rtj/nO6gtpyoJAEgh84h8=; b=JgRQEOsUMb0pC3JEQ8hY6gK/a4XiZW9SPLrMbjiDhfmhOXC7r7kryo09tYUqS2Zg6v+YmN zonw8S15Mc3c9qhtBzuC2+v2jPZvfxyH4FYDoPKhD8rvQntwx5xiN3WiRg5xZMKtPPZGsG jU2bOs1upL/tSPsDH3ZKbAmTP7+Omt02QdD89+3kSeAuddbiBoE/CUObI+wf0veoq8sQda mQafaxikUfkrlLuOeZ1yQz4tLA/xCMl5GdF6l4WmNOvRnZSSDUS2dZp7QZ60OgCH0LMKlC BikOEAaDOmGFbOtHyR6lwZYV7FiT+ylgThNe/M2yvc44FE39QPyJu6LPDdyXqA== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 5/9] net: stmmac: Introduce dwmac1000 timestamping operations Date: Tue, 12 Nov 2024 18:06:53 +0100 Message-ID: <20241112170658.2388529-6-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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. Reviewed-by: Daniel Machon Signed-off-by: Maxime Chevallier --- 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/ethernet/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; extern const struct stmmac_hwtimestamp stmmac_ptp; +extern const struct stmmac_hwtimestamp dwmac1000_ptp; extern const struct stmmac_mode_ops dwmac4_ring_mode_ops; 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 { /* PTP and timestamping registers */ +#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) +#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 a14509d88fe7..73bba4fdc2e4 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; } +/* DWMAC 1000 HW Timestaming ops */ + +void dwmac1000_get_ptptime(void __iomem *ptpaddr, u64 *ptp_time) +{ + u64 ns; + + ns = readl(ptpaddr + GMAC_PTP_ATNR); + ns += readl(ptpaddr + GMAC_PTP_ATSR) * NSEC_PER_SEC; + + *ptp_time = 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 = readl(priv->ptpaddr + GMAC3_X_TIMESTAMP_STATUS); + + if (!(priv->plat->flags & STMMAC_FLAG_EXT_SNAPSHOT_EN)) + return; + + num_snapshot = (ts_status & GMAC3_X_ATSNS) >> GMAC3_X_ATSNS_SHIFT; + + for (i = 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 = PTP_CLOCK_EXTTS; + event.index = 0; + event.timestamp = ptp_time; + ptp_clock_event(priv->ptp_clock, &event); + } +} + /* DWMAC 1000 ptp_clock_info ops */ int dwmac1000_ptp_enable(struct ptp_clock_info *ptp, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/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 = NULL, .dma = &dwmac100_dma_ops, .mac = &dwmac100_ops, - .hwtimestamp = &stmmac_ptp, + .hwtimestamp = &dwmac1000_ptp, .ptp = &dwmac1000_ptp_clock_ops, .mode = NULL, .tc = NULL, @@ -153,7 +153,7 @@ static const struct stmmac_hwif_entry { .desc = NULL, .dma = &dwmac1000_dma_ops, .mac = &dwmac1000_ops, - .hwtimestamp = &stmmac_ptp, + .hwtimestamp = &dwmac1000_ptp, .ptp = &dwmac1000_ptp_clock_ops, .mode = NULL, .tc = NULL, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/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 = { .timestamp_interrupt = timestamp_interrupt, .hwtstamp_correct_latency = hwtstamp_correct_latency, }; + +const struct stmmac_hwtimestamp dwmac1000_ptp = { + .config_hw_tstamping = config_hw_tstamping, + .init_systime = init_systime, + .config_sub_second_increment = config_sub_second_increment, + .config_addend = config_addend, + .adjust_systime = adjust_systime, + .get_systime = get_systime, + .get_ptptime = dwmac1000_get_ptptime, + .timestamp_interrupt = 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 { struct ptp_clock_info; struct ptp_clock_request; +struct stmmac_priv; int dwmac1000_ptp_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *rq, int on); +void dwmac1000_get_ptptime(void __iomem *ptpaddr, u64 *ptp_time); +void dwmac1000_timestamp_interrupt(struct stmmac_priv *priv); + #endif /* __STMMAC_PTP_H__ */ From patchwork Tue Nov 12 17:06:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872627 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 1D29E217905; Tue, 12 Nov 2024 17:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431231; cv=none; b=CP43rzJmgLc66OD6DJZlGx3rwJdGD5NErI/4yi6taqo+0YP6Mt7Zuk7+zc7LFTRrvgR/g2/jRQRwmegbqw1jaFnKsDpR9zzL5T7UAJT0EF9Ke5R87xWiJZIsS6EZpUZSB5yQOEYRfTBHGqnFFFkfbLBN+IqPrhsQCVEfR+mOlFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431231; c=relaxed/simple; bh=eLjWcDHkfciiegfslYMvZGgOofNetPEeUABVo92Xx/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f2t9G+UT2gGuyNMHVBxv+P0+Sg4UfE//PJIcYNoVxo7XZxVTiDmbB6PsSZa0nz5uvqEJ9OybwExbzqv5suy2IAU8XSQu42v/GjhnQmuO4Jzx6yd4VSD6mLjP/p6t2lha8V7J7hNVhaVNQsF+VPbSN/nFzXaM9TRxlKp6jGrSeMs= 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=Ytekury5; arc=none smtp.client-ip=217.70.183.196 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="Ytekury5" Received: by mail.gandi.net (Postfix) with ESMTPSA id BC671E000D; Tue, 12 Nov 2024 17:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431227; 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=JpUCuhSkHtWF9OeH4XyNxAJf2CxJ+XC2B1fk8Kli6Z0=; b=Ytekury5gdFXSXmU+zzqb3irnJBxDuDcnfrJdrj4fdYJXDSebxzyEp/hsM5/kagAJqaJfO EyCXhyj8U4qBc8txVs8HkBrkRCca1uhLekoBlSF64Hyu7Ui/toUTbcw93d4fwzcemrj2sW 15f+YJ72AYKqXXLFse8o5gIvmPVgI2Ykjdj9CvxfR5lgRoiu8BrQRoBf7o7R4OrfYzXe14 s8Gj9mq8+GBgVPJ45ikw9plxtWgM1v0kQdZ23QL0BK8z1DUxBZlUwamarEldeiluiYtYt8 lx4abxj5c42AfQQYDWRl61ZDtKZjaawT5No03O6ZH+lkfIv3UuiZIFMV+iSUdA== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 6/9] net: stmmac: Enable timestamping interrupt on dwmac1000 Date: Tue, 12 Nov 2024 18:06:54 +0100 Message-ID: <20241112170658.2388529-7-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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. Reviewed-by: Daniel Machon Signed-off-by: Maxime Chevallier --- .../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 73bba4fdc2e4..96bcda0856ec 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) /* DWMAC 1000 ptp_clock_info ops */ +static void dwmac1000_timestamp_interrupt_cfg(struct stmmac_priv *priv, bool en) +{ + void __iomem *ioaddr = priv->ioaddr; + + u32 intr_mask = readl(ioaddr + GMAC_INT_MASK); + + if (en) + intr_mask &= ~GMAC_INT_DISABLE_TIMESTAMP; + else + intr_mask |= 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, 10, 10000); mutex_unlock(&priv->aux_ts_lock); + + dwmac1000_timestamp_interrupt_cfg(priv, on); break; default: From patchwork Tue Nov 12 17:06:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872628 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 3510C2194BE; Tue, 12 Nov 2024 17:07:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431232; cv=none; b=i+O6O8gUx/HPFKbjW3iFaKpsbk1WUYD1v7m+R0MdVDy6E5CnYDWC2hOYguxfcnZh/LLsRKdbDLdcnRWjUzuS1bgE0CfrX6aBxBHX5+BQypmkRDSIcTsNCMbF5X5/8XQ+t/6aVlUIuRENt+vtbaTDbTffsj0NGwO6bhWOFp9ZuZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431232; c=relaxed/simple; bh=bet8NvkH1uCnuHOjXChUask37g3j8KJesxq8Pe/nu7w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UFy5WwAxk6QBdXCZ+lETUEVk1/a94i8B1C6M72DDEmAzskJC7KZfxm9cy4IilCI8GeJmZdWn0eDODXfBZEydI2djsgY+rVk2SFVLBTbCsFJksAwNKBTBbhGBtGXiq2FOsdh90uqpQGnxAwTwQI/9DpnPXFr84ber3FQvta6s7Z8= 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=pCZ3G208; arc=none smtp.client-ip=217.70.183.196 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="pCZ3G208" Received: by mail.gandi.net (Postfix) with ESMTPSA id AE45BE0006; Tue, 12 Nov 2024 17:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431228; 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=m/dDOU3IXt6wqdCpft8g2WA+gm1F7IyRLWSAkath9us=; b=pCZ3G208S6C7+vr6FbnjjLuPSZn1hB6+bG/Sw0rV2pLS3RY+60iMBN+iTvTtFc3YGhaY4U eKYsJYIVbwmY0fkH1W8W84zLs0HUTcPkAoLr55oVXgM7z/MOrpqy379XMdpFtmIcm2jF5m 8MRuw1Ste6W3uavBZqWPYDfzv+Nb1mJ4Uew/7GCyU0Q9n64sNBGbfnevPA9jnCZtCu8Lvd J+HJWr/SKdVRgJsbFYfV+ix4TKeslx12ZcBtcrsi4VqzRU90bb8E5LV7CcTY4HLQ4blmA/ dA5o/VBcl9EDyGxch8efc1c2LkADJMGF67rF2Nt358z36JcXn43TO8MTN+MAHg== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 7/9] net: stmmac: Don't include dwmac4 definitions in stmmac_ptp Date: Tue, 12 Nov 2024 18:06:55 +0100 Message-ID: <20241112170658.2388529-8-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org The stmmac_ptp code doesn't need the dwmac4 register definitions, remove the inclusion. Reviewed-by: Daniel Machon Signed-off-by: Maxime Chevallier --- 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" /** * stmmac_adjust_freq From patchwork Tue Nov 12 17:06:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872629 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 1FA49219E23; Tue, 12 Nov 2024 17:07:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431233; cv=none; b=eLbE5YIUTJijaCZZMrhEvUjgXKS7oSPlEeRmIwbvyEInJL9YSVaQOmvVCiM0uGG01v467q83SB2etvrHJU+mICZZ6J519YNr4acwcnMGLb6D4c1NuBXD9qIAnbUjVqeFURyI4z/L7OvjoQ3nCbhIaBlTiXqIebwYRH28rVwNeow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431233; c=relaxed/simple; bh=QKZIsiG1W6OLDPkpY3/P7o6n4z4Z1M/nJkWNGlqucxY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SmO3+fpqR3KjfzuLxt4ygtEnZ5AxqGAH0r4Ocns4P4SFwbSGBPhrp6k/YzjuEGMI5FmsVD7jvWshGqJ4of+POeG+v/AtOQNzl7E8lSkmqXQnz6vMSqsMRF5yBJKjlYsrz756uvhQ5EzLa1ukSb1DSXAHhQr8ylbH47j69F99NRE= 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=b7JZkzQ4; arc=none smtp.client-ip=217.70.183.196 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="b7JZkzQ4" Received: by mail.gandi.net (Postfix) with ESMTPSA id 9A03CE0004; Tue, 12 Nov 2024 17:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431229; 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=EItfCXpyQ9SbyuhvhonsXakXTzV8T8EN3PjTEaNk6PI=; b=b7JZkzQ4ljBkleE5Yy+NKv3WgCE+j8KI+op45holACfyYm/+RV7tbnKmx57+0Dny8UM0oN ksT5Uu0dPt+vKDZc/8xaGJyMm615ic4EpJ54+TyWvoWe/vTiXE4/qw2qt7hXvWnCsvDV+p eYf96z75fG+7QH8lcqP08KE3wGD0YNHOP0ovBTq5RuEUH1FVgjVO4rTBA3TPt95goaaGME XL17YjUL9BWBm+ifh01OFsivFnOpGtG/nT7dRxJnxfm4SXq5jHK0XXlwgQ2Vh5qQFMLEP3 1va3xCvl+uJCXEq8XugnaWy8S4sLei4VPj8MM0xsoac7N9bD7BoNR6ur1MMCEA== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 8/9] net: stmmac: Configure only the relevant bits for timestamping setup Date: Tue, 12 Nov 2024 18:06:56 +0100 Message-ID: <20241112170658.2388529-9-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org The PTP_TCR (Timestamp Control Register) is used to configure several features related to packet timestamping. On one hand, it configures the 1588 packet processing, to indicate what types of frames should be timestamped (all, only 1588v1 or 1588v2, using L2 or L4 timestamping, on IPv4 or IPv6, etc.). This is congfigured usually through the ioctl / ndo dedicated for such setup. This configuration is done by setting some fields in that register, that seem to behave the same way on all dwmac variants, including DWMAC1000. On the other hand, and only on DWMAC1000 apparently, some fields in that register are used to configure external snapshots (bits 24/25). On DWMAC4 and others, these fields are reserved and external snapshots are configured through a dedicated register that simply doesn't seem to exist on DWMAC1000. This configuration is done in the dwmac1000-specific ptp_clock_info ops (cf dwmac1000_ptp_enable()). So to avoid the timestamping configuration interfering with the external snapshots, this commit makes sure that the config_hw_tstamping only configures the relevant bits in PTP_TCR, so that the DWMAC1000 timestamping can correctly rely on these otherwise reserved fields. Reviewed-by: Daniel Machon Signed-off-by: Maxime Chevallier --- .../net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index a94829ef8cfb..0f59aa982604 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -18,9 +18,22 @@ #include "dwmac4.h" #include "stmmac.h" +#define STMMAC_HWTS_CFG_MASK (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | \ + PTP_TCR_TSINIT | PTP_TCR_TSUPDT | \ + PTP_TCR_TSCTRLSSR | PTP_TCR_SNAPTYPSEL_1 | \ + PTP_TCR_TSIPV4ENA | PTP_TCR_TSIPV6ENA | \ + PTP_TCR_TSEVNTENA | PTP_TCR_TSMSTRENA | \ + PTP_TCR_TSVER2ENA | PTP_TCR_TSIPENA | \ + PTP_TCR_TSTRIG | PTP_TCR_TSENALL) + static void config_hw_tstamping(void __iomem *ioaddr, u32 data) { - writel(data, ioaddr + PTP_TCR); + u32 regval = readl(ioaddr + PTP_TCR); + + regval &= ~STMMAC_HWTS_CFG_MASK; + regval |= data; + + writel(regval, ioaddr + PTP_TCR); } static void config_sub_second_increment(void __iomem *ioaddr, From patchwork Tue Nov 12 17:06:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13872630 X-Patchwork-Delegate: kuba@kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 DF55921A4CB; Tue, 12 Nov 2024 17:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431234; cv=none; b=NtiPlmpdek+NDG9DymHwf4U1NPPk8P6eBAZVaTHXdGTsQwy2Qlk/2rn4R08whxgmC/Xf+uhUqODxxNUy96JUQ/YATprk1F859piD4xjjkJZhbKBcpN89eFLf56eL14LLh3wyGCJ1PnPx7qjxHgo9R+O7RHj5QoEN1URvYsuZU4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731431234; c=relaxed/simple; bh=xaj5KmROuHDs6V1pAE8F+BMNjL9ORFgFyK/RbeoRB2A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ChhJbKVMadounNoSfQbTxjedYenkpo7vUxFk0Q4iFHeRwFTatLS+pYu5reHgHindySw4fGL+hig5o87180UhRqnSd/bvDXLhfkFWuDHnPmgAjpRrFQuak6vRuif0jKNZEqAj7ld4g0595amGDPERB+zVUW5dNyl9rdok9LmnlWI= 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=Hn4L25KJ; arc=none smtp.client-ip=217.70.183.196 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="Hn4L25KJ" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8597AE0002; Tue, 12 Nov 2024 17:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731431230; 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=KmB45n0EFDDxVFATGrPwAYkLgt0gPIeYSjIsRXHFoik=; b=Hn4L25KJ6Bk4NzyNodJ2N99gxYyx6ubpJJGX7MCAK3Z3L+1TpHWP+CqFqNoz/FXGe6ixKK FFsatBb6wPQtSbA2DVpmOVpK94HUpgvj8XYYlwK0nSPXphisXAUEeGRsz84iXDKDRUz5Vz wva2wuIa+NGeR7/r9FQsi9Qx6UT7sHPqGVIJxfZfRGym0AJujFs55fpLJdJuksF4UbGeH6 ByE9mD8mojXQiM1BlkR2n6PC0WqN1g9yl1tFf0uZqiJXH0OBz+DgK5kWgrGqSlL+nR/6k3 UyJIUYuc+VxnaW8QEPmPZ4hZuuKDvp1d+1JpAYblzQK2WNMuug4k1ZDK7VZePw== From: Maxime Chevallier To: Alexandre Torgue , Jose Abreu , Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: Maxime Chevallier , =?utf-8?q?Alexis_Loth?= =?utf-8?q?or=C3=A9?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Daniel Machon , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 9/9] net: stmmac: dwmac_socfpga: This platform has GMAC Date: Tue, 12 Nov 2024 18:06:57 +0100 Message-ID: <20241112170658.2388529-10-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> References: <20241112170658.2388529-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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. Reviewed-by: Daniel Machon Signed-off-by: Maxime Chevallier --- 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 = socfpga_dwmac_pcs_init; plat_dat->pcs_exit = socfpga_dwmac_pcs_exit; plat_dat->select_pcs = socfpga_dwmac_select_pcs; + plat_dat->has_gmac = true; ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret)