netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: ravb: Correct bad check of timestamp control flags
@ 2025-11-07 20:01 Niklas Söderlund
  2025-11-08  5:14 ` Niklas Söderlund
  2025-11-11  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Niklas Söderlund @ 2025-11-07 20:01 UTC (permalink / raw)
  To: Simon Horman, Paul Barker, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Yoshihiro Shimoda,
	Geert Uytterhoeven, Magnus Damm, Richard Cochran, netdev,
	linux-renesas-soc
  Cc: Niklas Söderlund

When converting the Renesas network drivers to use flags from enum
hwtstamp_rx_filters to control when to timestamp packages instead of a
driver specific schema with bit-wise flags an error was made.

The bit-wise driver specific flags correct logic to set get_ts was:

  q: RAVB_BE + tstamp_rx_ctrl: 0 => 0
  q: RAVB_NC + tstamp_rx_ctrl: 0 => 0
  q: RAVB_BE + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_V2_L2_EVENT => 0
  q: RAVB_NC + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_V2_L2_EVENT => 1
  q: RAVB_BE + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_ALL => 1
  q: RAVB_NC + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_ALL => 1

The converted logic to use enum flags mapped tstamp_rx_ctrl as

  0 to HWTSTAMP_FILTER_NONE
  RAVB_RXTSTAMP_TYPE_V2_L2_EVENT to HWTSTAMP_FILTER_PTP_V2_L2_EVENT
  RAVB_RXTSTAMP_TYPE_ALL to HWTSTAMP_FILTER_ALL

But the logic was incorrectly changed to:

  q: RAVB_BE + tstamp_rx_ctrl: HWTSTAMP_FILTER_NONE => 1 (error)
  q: RAVB_NC + tstamp_rx_ctrl: HWTSTAMP_FILTER_NONE => 0
  q: RAVB_BE + tstamp_rx_ctrl: HWTSTAMP_FILTER_PTP_V2_L2_EVENT => 0
  q: RAVB_NC + tstamp_rx_ctrl: HWTSTAMP_FILTER_PTP_V2_L2_EVENT => 1
  q: RAVB_BE + tstamp_rx_ctrl: HWTSTAMP_FILTER_ALL => 1
  q: RAVB_NC + tstamp_rx_ctrl: HWTSTAMP_FILTER_ALL => 0 (error)

This change restores the converted flag check to the correct logic of
the bit-wise driver specific flags.

Reported-by: Simon Horman <horms@kernel.org>
Closes: https://lore.kernel.org/linux-renesas-soc/aQ4xSv9629XF-Bt3@horms.kernel.org/
Fixes: 16e2e6cf75e6 ("net: ravb: Use common defines for time stamping control")
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
Hi,

See link in the closes tag for details on how this was found.

I added a fixes tag to this patch, however the patch that introduces the
error is in net-next, so there is no stable tree to port this fix to.

I'm sorry I made such a clumsy mistake. I'm happy Simon happened to try
out a new tool on this one commit so this issue could be fixed quickly.

Thanks Simon!
---
 drivers/net/ethernet/renesas/ravb_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 1680e94b9242..57b0db314fb5 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -955,9 +955,9 @@ static void ravb_rx_rcar_hwstamp(struct ravb_private *priv, int q,
 	bool get_ts;
 
 	if (q == RAVB_NC)
-		get_ts = priv->tstamp_rx_ctrl == HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
+		get_ts = priv->tstamp_rx_ctrl != HWTSTAMP_FILTER_NONE;
 	else
-		get_ts = priv->tstamp_rx_ctrl != HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
+		get_ts = priv->tstamp_rx_ctrl == HWTSTAMP_FILTER_ALL;
 
 	if (!get_ts)
 		return;
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: ravb: Correct bad check of timestamp control flags
  2025-11-07 20:01 [PATCH] net: ravb: Correct bad check of timestamp control flags Niklas Söderlund
@ 2025-11-08  5:14 ` Niklas Söderlund
  2025-11-11  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Söderlund @ 2025-11-08  5:14 UTC (permalink / raw)
  To: Simon Horman, Paul Barker, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Yoshihiro Shimoda,
	Geert Uytterhoeven, Magnus Damm, Richard Cochran, netdev,
	linux-renesas-soc

Hi,

Obviously this should have been tagged to target net-next. Will wait a 
few days and resend.

On 2025-11-07 21:01:00 +0100, Niklas Söderlund wrote:
> When converting the Renesas network drivers to use flags from enum
> hwtstamp_rx_filters to control when to timestamp packages instead of a
> driver specific schema with bit-wise flags an error was made.
> 
> The bit-wise driver specific flags correct logic to set get_ts was:
> 
>   q: RAVB_BE + tstamp_rx_ctrl: 0 => 0
>   q: RAVB_NC + tstamp_rx_ctrl: 0 => 0
>   q: RAVB_BE + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_V2_L2_EVENT => 0
>   q: RAVB_NC + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_V2_L2_EVENT => 1
>   q: RAVB_BE + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_ALL => 1
>   q: RAVB_NC + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_ALL => 1
> 
> The converted logic to use enum flags mapped tstamp_rx_ctrl as
> 
>   0 to HWTSTAMP_FILTER_NONE
>   RAVB_RXTSTAMP_TYPE_V2_L2_EVENT to HWTSTAMP_FILTER_PTP_V2_L2_EVENT
>   RAVB_RXTSTAMP_TYPE_ALL to HWTSTAMP_FILTER_ALL
> 
> But the logic was incorrectly changed to:
> 
>   q: RAVB_BE + tstamp_rx_ctrl: HWTSTAMP_FILTER_NONE => 1 (error)
>   q: RAVB_NC + tstamp_rx_ctrl: HWTSTAMP_FILTER_NONE => 0
>   q: RAVB_BE + tstamp_rx_ctrl: HWTSTAMP_FILTER_PTP_V2_L2_EVENT => 0
>   q: RAVB_NC + tstamp_rx_ctrl: HWTSTAMP_FILTER_PTP_V2_L2_EVENT => 1
>   q: RAVB_BE + tstamp_rx_ctrl: HWTSTAMP_FILTER_ALL => 1
>   q: RAVB_NC + tstamp_rx_ctrl: HWTSTAMP_FILTER_ALL => 0 (error)
> 
> This change restores the converted flag check to the correct logic of
> the bit-wise driver specific flags.
> 
> Reported-by: Simon Horman <horms@kernel.org>
> Closes: https://lore.kernel.org/linux-renesas-soc/aQ4xSv9629XF-Bt3@horms.kernel.org/
> Fixes: 16e2e6cf75e6 ("net: ravb: Use common defines for time stamping control")
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> Hi,
> 
> See link in the closes tag for details on how this was found.
> 
> I added a fixes tag to this patch, however the patch that introduces the
> error is in net-next, so there is no stable tree to port this fix to.
> 
> I'm sorry I made such a clumsy mistake. I'm happy Simon happened to try
> out a new tool on this one commit so this issue could be fixed quickly.
> 
> Thanks Simon!
> ---
>  drivers/net/ethernet/renesas/ravb_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 1680e94b9242..57b0db314fb5 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -955,9 +955,9 @@ static void ravb_rx_rcar_hwstamp(struct ravb_private *priv, int q,
>  	bool get_ts;
>  
>  	if (q == RAVB_NC)
> -		get_ts = priv->tstamp_rx_ctrl == HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
> +		get_ts = priv->tstamp_rx_ctrl != HWTSTAMP_FILTER_NONE;
>  	else
> -		get_ts = priv->tstamp_rx_ctrl != HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
> +		get_ts = priv->tstamp_rx_ctrl == HWTSTAMP_FILTER_ALL;
>  
>  	if (!get_ts)
>  		return;
> -- 
> 2.51.1
> 

-- 
Kind Regards,
Niklas Söderlund

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: ravb: Correct bad check of timestamp control flags
  2025-11-07 20:01 [PATCH] net: ravb: Correct bad check of timestamp control flags Niklas Söderlund
  2025-11-08  5:14 ` Niklas Söderlund
@ 2025-11-11  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-11  0:30 UTC (permalink / raw)
  To: =?utf-8?q?Niklas_S=C3=B6derlund_=3Cniklas=2Esoderlund+renesas=40ragnatech=2E?=,
	=?utf-8?q?se=3E?=
  Cc: horms, paul, andrew+netdev, davem, edumazet, kuba, pabeni,
	yoshihiro.shimoda.uh, geert+renesas, magnus.damm, richardcochran,
	netdev, linux-renesas-soc

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri,  7 Nov 2025 21:01:00 +0100 you wrote:
> When converting the Renesas network drivers to use flags from enum
> hwtstamp_rx_filters to control when to timestamp packages instead of a
> driver specific schema with bit-wise flags an error was made.
> 
> The bit-wise driver specific flags correct logic to set get_ts was:
> 
>   q: RAVB_BE + tstamp_rx_ctrl: 0 => 0
>   q: RAVB_NC + tstamp_rx_ctrl: 0 => 0
>   q: RAVB_BE + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_V2_L2_EVENT => 0
>   q: RAVB_NC + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_V2_L2_EVENT => 1
>   q: RAVB_BE + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_ALL => 1
>   q: RAVB_NC + tstamp_rx_ctrl: RAVB_RXTSTAMP_TYPE_ALL => 1
> 
> [...]

Here is the summary with links:
  - net: ravb: Correct bad check of timestamp control flags
    https://git.kernel.org/netdev/net-next/c/38f073a71e85

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-11  0:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07 20:01 [PATCH] net: ravb: Correct bad check of timestamp control flags Niklas Söderlund
2025-11-08  5:14 ` Niklas Söderlund
2025-11-11  0:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).