diff mbox series

[net,v1,1/1] net: stmmac: Assign configured channel value to EXTTS event

Message ID 20240618073821.619751-1-o.rempel@pengutronix.de (mailing list archive)
State Accepted
Commit 8851346912a1fa33e7a5966fe51f07313b274627
Delegated to: Netdev Maintainers
Headers show
Series [net,v1,1/1] net: stmmac: Assign configured channel value to EXTTS event | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 859 this patch: 859
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: linux-stm32@st-md-mailman.stormreply.com linux-arm-kernel@lists.infradead.org
netdev/build_clang success Errors and warnings before: 863 this patch: 863
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 863 this patch: 863
netdev/checkpatch warning WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: f4da56529da6 ("net: stmmac: Add support for external trigger timestamping")'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-20--03-00 (tests: 659)

Commit Message

Oleksij Rempel June 18, 2024, 7:38 a.m. UTC
Assign the configured channel value to the EXTTS event in the timestamp
interrupt handler. Without assigning the correct channel, applications
like ts2phc will refuse to accept the event, resulting in errors such
as:
...
ts2phc[656.834]: config item end1.ts2phc.pin_index is 0
ts2phc[656.834]: config item end1.ts2phc.channel is 3
ts2phc[656.834]: config item end1.ts2phc.extts_polarity is 2
ts2phc[656.834]: config item end1.ts2phc.extts_correction is 0
...
ts2phc[656.862]: extts on unexpected channel
ts2phc[658.141]: extts on unexpected channel
ts2phc[659.140]: extts on unexpected channel

Fixes: f4da56529da60 ("net: stmmac: Add support for external trigger timestamping")
Cc: stable@vger.kernel.org
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Wojciech Drewek June 18, 2024, 1:07 p.m. UTC | #1
On 18.06.2024 09:38, Oleksij Rempel wrote:
> Assign the configured channel value to the EXTTS event in the timestamp
> interrupt handler. Without assigning the correct channel, applications
> like ts2phc will refuse to accept the event, resulting in errors such
> as:
> ...
> ts2phc[656.834]: config item end1.ts2phc.pin_index is 0
> ts2phc[656.834]: config item end1.ts2phc.channel is 3
> ts2phc[656.834]: config item end1.ts2phc.extts_polarity is 2
> ts2phc[656.834]: config item end1.ts2phc.extts_correction is 0
> ...
> ts2phc[656.862]: extts on unexpected channel
> ts2phc[658.141]: extts on unexpected channel
> ts2phc[659.140]: extts on unexpected channel
> 
> Fixes: f4da56529da60 ("net: stmmac: Add support for external trigger timestamping")
> Cc: stable@vger.kernel.org
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---

Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
> index f05bd757dfe52..5ef52ef2698fb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
> @@ -218,6 +218,7 @@ static void timestamp_interrupt(struct stmmac_priv *priv)
>  {
>  	u32 num_snapshot, ts_status, tsync_int;
>  	struct ptp_clock_event event;
> +	u32 acr_value, channel;
>  	unsigned long flags;
>  	u64 ptp_time;
>  	int i;
> @@ -243,12 +244,15 @@ static void timestamp_interrupt(struct stmmac_priv *priv)
>  	num_snapshot = (ts_status & GMAC_TIMESTAMP_ATSNS_MASK) >>
>  		       GMAC_TIMESTAMP_ATSNS_SHIFT;
>  
> +	acr_value = readl(priv->ptpaddr + PTP_ACR);
> +	channel = ilog2(FIELD_GET(PTP_ACR_MASK, acr_value));
> +
>  	for (i = 0; i < num_snapshot; i++) {
>  		read_lock_irqsave(&priv->ptp_lock, flags);
>  		get_ptptime(priv->ptpaddr, &ptp_time);
>  		read_unlock_irqrestore(&priv->ptp_lock, flags);
>  		event.type = PTP_CLOCK_EXTTS;
> -		event.index = 0;
> +		event.index = channel;
>  		event.timestamp = ptp_time;
>  		ptp_clock_event(priv->ptp_clock, &event);
>  	}
Paolo Abeni June 20, 2024, 9:55 a.m. UTC | #2
On Tue, 2024-06-18 at 09:38 +0200, Oleksij Rempel wrote:
> @@ -243,12 +244,15 @@ static void timestamp_interrupt(struct stmmac_priv *priv)
>  	num_snapshot = (ts_status & GMAC_TIMESTAMP_ATSNS_MASK) >>
>  		       GMAC_TIMESTAMP_ATSNS_SHIFT;
>  
> +	acr_value = readl(priv->ptpaddr + PTP_ACR);
> +	channel = ilog2(FIELD_GET(PTP_ACR_MASK, acr_value));

Side note for a possible net-next follow-up: as the driver already has
an equal snippet in stmmac_enable(), you con consider factor it out in
a common, more readable helper.

Cheers,

Paolo
patchwork-bot+netdevbpf@kernel.org June 20, 2024, 10 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 18 Jun 2024 09:38:21 +0200 you wrote:
> Assign the configured channel value to the EXTTS event in the timestamp
> interrupt handler. Without assigning the correct channel, applications
> like ts2phc will refuse to accept the event, resulting in errors such
> as:
> ...
> ts2phc[656.834]: config item end1.ts2phc.pin_index is 0
> ts2phc[656.834]: config item end1.ts2phc.channel is 3
> ts2phc[656.834]: config item end1.ts2phc.extts_polarity is 2
> ts2phc[656.834]: config item end1.ts2phc.extts_correction is 0
> ...
> ts2phc[656.862]: extts on unexpected channel
> ts2phc[658.141]: extts on unexpected channel
> ts2phc[659.140]: extts on unexpected channel
> 
> [...]

Here is the summary with links:
  - [net,v1,1/1] net: stmmac: Assign configured channel value to EXTTS event
    https://git.kernel.org/netdev/net/c/8851346912a1

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index f05bd757dfe52..5ef52ef2698fb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -218,6 +218,7 @@  static void timestamp_interrupt(struct stmmac_priv *priv)
 {
 	u32 num_snapshot, ts_status, tsync_int;
 	struct ptp_clock_event event;
+	u32 acr_value, channel;
 	unsigned long flags;
 	u64 ptp_time;
 	int i;
@@ -243,12 +244,15 @@  static void timestamp_interrupt(struct stmmac_priv *priv)
 	num_snapshot = (ts_status & GMAC_TIMESTAMP_ATSNS_MASK) >>
 		       GMAC_TIMESTAMP_ATSNS_SHIFT;
 
+	acr_value = readl(priv->ptpaddr + PTP_ACR);
+	channel = ilog2(FIELD_GET(PTP_ACR_MASK, acr_value));
+
 	for (i = 0; i < num_snapshot; i++) {
 		read_lock_irqsave(&priv->ptp_lock, flags);
 		get_ptptime(priv->ptpaddr, &ptp_time);
 		read_unlock_irqrestore(&priv->ptp_lock, flags);
 		event.type = PTP_CLOCK_EXTTS;
-		event.index = 0;
+		event.index = channel;
 		event.timestamp = ptp_time;
 		ptp_clock_event(priv->ptp_clock, &event);
 	}