[PATCH net-next 0/4] net: macb: Rework hardware timestamp configuration

Kim Wooseok via B4 Relay posted 4 patches 2 days, 6 hours ago
There is a newer version of this series
drivers/net/ethernet/cadence/macb_ptp.c | 63 ++++++++++++---------------------
1 file changed, 23 insertions(+), 40 deletions(-)
[PATCH net-next 0/4] net: macb: Rework hardware timestamp configuration
Posted by Kim Wooseok via B4 Relay 2 days, 6 hours ago
This started with two problems I found while using PTP hardware
timestamping on a Raspberry Pi 5. A rejected RX filter could still
change the TX one-step setting, and the PTPv1 Sync and Delay_Req filters
returned success without enabling RX timestamps.

This series reworks gem_set_hwtst() to validate the whole request before
programming the hardware. It calculates the settings locally, then
updates the registers and saved configuration under bp->lock. With the
register writes now in the setter, the two helpers are no longer needed.

The remaining patches use the existing ALL fallback for the specific
PTPv1 filters, turn off one-step mode for TX_OFF, and clear SRTSM when
switching away from a PTPv2 filter. Each change is kept in its own patch.

I compared the old and new behavior on the Pi 5. When I requested a TX
mode change together with an invalid RX filter, the patched driver
rejected the request without changing the saved settings or NCR. I
also switched from one-step TX and PTPv2 RX to other settings and back.
Only the relevant bits changed, and restoring the original settings
restored NCR.

For the PTPv1 filters, I checked the effect by sending Sync and Delay_Req
packets over Ethernet. Before the change, the packets arrived without
hardware timestamps. With the patches, the driver returned ALL and I
could read the hardware timestamps from the received packets. PTPv2
multicast reception continued to provide hardware timestamps, and
selecting NONE disabled timestamping. I ran these tests with the changes
backported to the Pi's existing Linux 6.18.46 RT kernel.

On net-next, I built the series with ARM64 allyesconfig and allmodconfig,
both with W=1. Sparse reported no diagnostics in macb_ptp.c.

Assisted-by: GPT-6 Astra
Signed-off-by: Kim Wooseok <5mghybrid@khu.ac.kr>
---
Kim Wooseok (4):
      net: macb: Preserve timestamp settings on rejected requests
      net: macb: Enable RX timestamping for specific PTPv1 filters
      net: macb: Disable one-step mode when TX timestamping is off
      net: macb: Clear SRTSM outside PTPv2 receive filters

 drivers/net/ethernet/cadence/macb_ptp.c | 63 ++++++++++++---------------------
 1 file changed, 23 insertions(+), 40 deletions(-)
---
base-commit: 8830e65ed46de41f849eefb8ba227d4852c460f6
change-id: 20260922-codex-macb-hwtstamp-submit-25ab4a2e6b94

Best regards,
--  
Kim Wooseok <5mghybrid@khu.ac.kr>
Re: [PATCH net-next 0/4] net: macb: Rework hardware timestamp configuration
Posted by Nicolai Buchwitz 2 days, 3 hours ago
Hi Kim

On 22.9.2026 11:10, Kim Wooseok via B4 Relay wrote:
> This started with two problems I found while using PTP hardware
> timestamping on a Raspberry Pi 5. A rejected RX filter could still
> change the TX one-step setting, and the PTPv1 Sync and Delay_Req 
> filters
> returned success without enabling RX timestamps.
> 
> This series reworks gem_set_hwtst() to validate the whole request 
> before
> programming the hardware. It calculates the settings locally, then
> updates the registers and saved configuration under bp->lock. With the
> register writes now in the setter, the two helpers are no longer 
> needed.
> 
> The remaining patches use the existing ALL fallback for the specific
> PTPv1 filters, turn off one-step mode for TX_OFF, and clear SRTSM when
> switching away from a PTPv2 filter. Each change is kept in its own 
> patch.
> 
> I compared the old and new behavior on the Pi 5. When I requested a TX
> mode change together with an invalid RX filter, the patched driver
> rejected the request without changing the saved settings or NCR. I
> also switched from one-step TX and PTPv2 RX to other settings and back.
> Only the relevant bits changed, and restoring the original settings
> restored NCR.
> 
> For the PTPv1 filters, I checked the effect by sending Sync and 
> Delay_Req
> packets over Ethernet. Before the change, the packets arrived without
> hardware timestamps. With the patches, the driver returned ALL and I
> could read the hardware timestamps from the received packets. PTPv2
> multicast reception continued to provide hardware timestamps, and
> selecting NONE disabled timestamping. I ran these tests with the 
> changes
> backported to the Pi's existing Linux 6.18.46 RT kernel.
> 
> On net-next, I built the series with ARM64 allyesconfig and 
> allmodconfig,
> both with W=1. Sparse reported no diagnostics in macb_ptp.c.
> 
> Assisted-by: GPT-6 Astra
> Signed-off-by: Kim Wooseok <5mghybrid@khu.ac.kr>
> ---
> Kim Wooseok (4):
>       net: macb: Preserve timestamp settings on rejected requests
>       net: macb: Enable RX timestamping for specific PTPv1 filters
>       net: macb: Disable one-step mode when TX timestamping is off
>       net: macb: Clear SRTSM outside PTPv2 receive filters
> 
>  drivers/net/ethernet/cadence/macb_ptp.c | 63 
> ++++++++++++---------------------
>  1 file changed, 23 insertions(+), 40 deletions(-)
> ---
> base-commit: 8830e65ed46de41f849eefb8ba227d4852c460f6
> change-id: 20260922-codex-macb-hwtstamp-submit-25ab4a2e6b94
> 
> Best regards,
> --
> Kim Wooseok <5mghybrid@khu.ac.kr>

For the series:

Tested-by: Nicolai Buchwitz <nb@tipi-net.de> # Raspberry Pi CM5 (macb 
rp1 with BCM54210PE)

Regards
Nicolai