Thread (5 messages) flat view 5 messages, 2 authors, 3d ago

Re: [PATCH net RESEND 1/2] net: macb: Preserve one-step mode on rejected timestamp requests

From: Nicolai Buchwitz <hidden>
Date: 2026-09-11 09:51:18
Also in: lkml

Hi Kimwoo

On 11.9.2026 10:04, kimwooseok wrote:
quoted hunk ↗ jump to hunk
gem_set_hwtst() programs NCR.OSSMODE while processing tx_type, before
validating rx_filter. An unsupported receive filter can therefore cause
the operation to return -ERANGE after changing the active transmit 
mode.
The cached configuration is not updated, so a subsequent SIOCGHWTSTAMP
reports the previous transmit mode even though the hardware has 
changed.

For example, configure HWTSTAMP_TX_ON with HWTSTAMP_FILTER_ALL, then
request HWTSTAMP_TX_ONESTEP_SYNC with HWTSTAMP_FILTER_NTP_ALL. The 
latter
request fails but enables one-step synchronization. The reverse
transition can clear one-step mode despite returning the same error.

Defer programming the one-step mode until both the transmit type and
receive filter have been validated. Rejected receive filters then leave
the active transmit mode unchanged.

Fixes: ab91f0a9b5f4 ("net: macb: Add hardware PTP support")
Assisted-by: GPT-6 Astra
Signed-off-by: kimwooseok <redacted>
---
Resending as plain text because the previous webmail submission 
included
HTML and quoted and rewrapped the patch. No code changes; the 
Assisted-by
trailer now names the tool.

 drivers/net/ethernet/cadence/macb_ptp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c 
b/drivers/net/ethernet/cadence/macb_ptp.c
index e5195d7..51659bb 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -418,11 +418,9 @@ int gem_set_hwtst(struct net_device *netdev,
 	case HWTSTAMP_TX_OFF:
 		break;
 	case HWTSTAMP_TX_ONESTEP_SYNC:
-		gem_ptp_set_one_step_sync(bp, 1);
 		tx_bd_control = TSTAMP_ALL_FRAMES;
 		break;
 	case HWTSTAMP_TX_ON:
-		gem_ptp_set_one_step_sync(bp, 0);
 		tx_bd_control = TSTAMP_ALL_FRAMES;
 		break;
 	default:
@@ -460,6 +458,11 @@ int gem_set_hwtst(struct net_device *netdev,
 		return -ERANGE;
 	}

+	if (tstamp_config->tx_type == HWTSTAMP_TX_ONESTEP_SYNC)
+		gem_ptp_set_one_step_sync(bp, 1);
+	else if (tstamp_config->tx_type == HWTSTAMP_TX_ON)
+		gem_ptp_set_one_step_sync(bp, 0);
+
 	bp->tstamp_config = *tstamp_config;

 	if (gem_ptp_set_ts_mode(bp, tx_bd_control, rx_bd_control) != 0)
Reviewed-by: Nicolai Buchwitz <redacted>
Tested-by: Nicolai Buchwitz <redacted> # Raspberry Pi CM5

Thanks,
Nicolai
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help