lan966x_ptp_del_trap() looks up a PTP trap rule with vcap_get_rule() and removes the port from it, or deletes the rule when no other port needs it. The traps are removed whenever timestamping is configured with HWTSTAMP_FILTER_NONE. Before this patch, every vcap_get_rule() error is returned as -EEXIST, including the -ENOENT for a trap rule that does not exist, so disabling timestamping on a port that has no traps installed fails. This breaks moving the hardware timestamp provider of a port from its PHY to the MAC. Return 0 for -ENOENT, as there is nothing to remove. Pass any other error from vcap_get_rule() on, as the rule may still be installed with this port in its ingress port mask. Triggered during test development, without kernel modifications, on a lan9668 board whose LAN8814 PHYs are the default timestamp provider: "ethtool --set-hwtimestamp-cfg index qualifier precise" failed with "File exists". With the fix the same command moves the provider to the MAC. Fixes: 72df3489fb10 ("net: lan966x: Add ptp trap rules") Signed-off-by: Daniel Machon --- drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c index 9be2cfe6feeb7..e3af7831a10c3 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c @@ -110,7 +110,7 @@ static int lan966x_ptp_del_trap(struct lan966x_port *port, vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id); if (IS_ERR(vrule)) - return -EEXIST; + return PTR_ERR(vrule) == -ENOENT ? 0 : PTR_ERR(vrule); vcap_rule_get_key_u32(vrule, VCAP_KF_IF_IGR_PORT_MASK, &value, &mask); mask |= BIT(port->chip_port); --- base-commit: af6737b9066832a2017c281159950ba92385ce00 change-id: 20261123-lan966x-ptp-del-trap-98dde01c5f7b Best regards, -- Daniel Machon