Commit 6be06307 authored by Wei Fang's avatar Wei Fang Committed by Jakub Kicinski
Browse files

net: fec: don't save PTP state if PTP is unsupported



Some platforms (such as i.MX25 and i.MX27) do not support PTP, so on
these platforms fec_ptp_init() is not called and the related members
in fep are not initialized. However, fec_ptp_save_state() is called
unconditionally, which causes the kernel to panic. Therefore, add a
condition so that fec_ptp_save_state() is not called if PTP is not
supported.

Fixes: a1477dc8 ("net: fec: Restart PPS after link state change")
Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
Closes: https://lore.kernel.org/lkml/353e41fe-6bb4-4ee9-9980-2da2a9c1c508@roeck-us.net/


Signed-off-by: default avatarWei Fang <wei.fang@nxp.com>
Reviewed-by: default avatarCsókás, Bence <csokas.bence@prolan.hu>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://patch.msgid.link/20241008061153.1977930-1-wei.fang@nxp.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 080ddc22
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1077,6 +1077,7 @@ fec_restart(struct net_device *ndev)
	u32 rcntl = OPT_FRAME_SIZE | 0x04;
	u32 ecntl = FEC_ECR_ETHEREN;

	if (fep->bufdesc_ex)
		fec_ptp_save_state(fep);

	/* Whack a reset.  We should wait for this.
@@ -1340,6 +1341,7 @@ fec_stop(struct net_device *ndev)
			netdev_err(ndev, "Graceful transmit stop did not complete!\n");
	}

	if (fep->bufdesc_ex)
		fec_ptp_save_state(fep);

	/* Whack a reset.  We should wait for this.