On Fri, Aug 02, 2019 at 06:32:48PM +0200, Hubert Feurstein wrote: > diff --git a/drivers/net/ethernet/freescale/fec_main.c > b/drivers/net/ethernet/freescale/fec_main.c > index 2f6057e7335d..20f589dc5b8b 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -1814,11 +1814,25 @@ static int fec_enet_mdio_write(struct mii_bus *bus, > int mii_id, int regnum, > > reinit_completion(&fep->mdio_done); > > - /* start a write op */ > - writel(FEC_MMFR_ST | FEC_MMFR_OP_WRITE | > - FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) | > - FEC_MMFR_TA | FEC_MMFR_DATA(value), > - fep->hwp + FEC_MII_DATA); > + if (bus->ptp_sts) { > + unsigned long flags = 0; > + local_irq_save(flags); > + __iowmb(); > + /* >Take the timestamp *after* the memory barrier */ > + ptp_read_system_prets(bus->ptp_sts); > + writel_relaxed(FEC_MMFR_ST | FEC_MMFR_OP_WRITE | > + FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) | > + FEC_MMFR_TA | FEC_MMFR_DATA(value), > + fep->hwp + FEC_MII_DATA); > + ptp_read_system_postts(bus->ptp_sts);
Regarding generic support of this, see if you can't place the ptp_read_system_prets/postts() calls at the mii_bus layer. This could mean, for example, offering a two-part write API, to split this write operation from... > + local_irq_restore(flags); > + } else { > + /* start a write op */ > + writel(FEC_MMFR_ST | FEC_MMFR_OP_WRITE | > + FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) | > + FEC_MMFR_TA | FEC_MMFR_DATA(value), > + fep->hwp + FEC_MII_DATA); > + } > > /* wait for end of transfer */ > time_left = wait_for_completion_timeout(&fep->mdio_done, ...this kind of thing ^^^ Thanks, Richard