@@ -597,7 +597,7 @@ struct fec_enet_private {
unsigned int next_counter;
struct {
- struct timespec64 ts_phc;
+ u64 ns_phc;
u64 ns_sys;
u32 at_corr;
u8 at_inc_corr;
@@ -613,7 +613,7 @@ int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr);
int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr);
void fec_ptp_save_state(struct fec_enet_private *fep);
-int fec_ptp_restore_state(struct fec_enet_private *fep);
+void fec_ptp_restore_state(struct fec_enet_private *fep);
/****************************************************************************/
#endif /* FEC_H */
@@ -636,7 +636,7 @@ void fec_ptp_save_state(struct fec_enet_private *fep)
{
u32 atime_inc_corr;
- fec_ptp_gettime(&fep->ptp_caps, &fep->ptp_saved_state.ts_phc);
+ fep->ptp_saved_state.ns_phc = timecounter_read(&fep->tc);
fep->ptp_saved_state.ns_sys = ktime_get_ns();
fep->ptp_saved_state.at_corr = readl(fep->hwp + FEC_ATIME_CORR);
@@ -644,16 +644,17 @@ void fec_ptp_save_state(struct fec_enet_private *fep)
fep->ptp_saved_state.at_inc_corr = (u8)(atime_inc_corr >> FEC_T_INC_CORR_OFFSET);
}
-int fec_ptp_restore_state(struct fec_enet_private *fep)
+void fec_ptp_restore_state(struct fec_enet_private *fep)
{
u32 atime_inc = readl(fep->hwp + FEC_ATIME_INC) & FEC_T_INC_MASK;
- u64 ns_sys;
+ u64 ns;
writel(fep->ptp_saved_state.at_corr, fep->hwp + FEC_ATIME_CORR);
atime_inc |= ((u32)fep->ptp_saved_state.at_inc_corr) << FEC_T_INC_CORR_OFFSET;
writel(atime_inc, fep->hwp + FEC_ATIME_INC);
- ns_sys = ktime_get_ns() - fep->ptp_saved_state.ns_sys;
- timespec64_add_ns(&fep->ptp_saved_state.ts_phc, ns_sys);
- return fec_ptp_settime(&fep->ptp_caps, &fep->ptp_saved_state.ts_phc);
+ ns = ktime_get_ns() - fep->ptp_saved_state.ns_sys + fep->ptp_saved_state.ns_phc;
+
+ writel(ns & fep->cc.mask, fep->hwp + FEC_ATIME);
+ timecounter_init(&fep->tc, &fep->cc, ns);
}
`fec_ptp_save_state()` may be called from an atomic context, which makes `fec_ptp_gettime()` unable to acquire a mutex. Using the lower-level timecounter ops remedies the problem. Reported-by: Marc Kleine-Budde <mkl@pengutronix.de> Fixes: f79959220fa5 Signed-off-by: Csókás Bence <csokas.bence@prolan.hu> --- drivers/net/ethernet/freescale/fec.h | 4 ++-- drivers/net/ethernet/freescale/fec_ptp.c | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-)