Skip to content

Commit

Permalink
net: fec: reduce spin lock time in fec_ptp_adjfreq
Browse files Browse the repository at this point in the history
move below calculate out of spin lock section
	diff = fep->cc.mult;
	diff *= ppb;
	diff = div_u64(diff, 1000000000ULL);

diff is local variable and not neccesary in spin lock

Signed-off-by: Frank Li <Frank.Li@freescale.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Frank Li authored and David S. Miller committed Nov 7, 2012
1 parent 0f2f7a4 commit 7da716a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/net/ethernet/freescale/fec_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ static int fec_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
u64 diff;
unsigned long flags;
int neg_adj = 0;
u32 mult = FEC_CC_MULT;

struct fec_enet_private *fep =
container_of(ptp, struct fec_enet_private, ptp_caps);
Expand All @@ -154,22 +155,19 @@ static int fec_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
neg_adj = 1;
}

diff = mult;
diff *= ppb;
diff = div_u64(diff, 1000000000ULL);

spin_lock_irqsave(&fep->tmreg_lock, flags);
/*
* dummy read to set cycle_last in tc to now.
* So use adjusted mult to calculate when next call
* timercounter_read.
*/
timecounter_read(&fep->tc);
fep->cc.mult = FEC_CC_MULT;
diff = fep->cc.mult;
diff *= ppb;
diff = div_u64(diff, 1000000000ULL);

if (neg_adj)
fep->cc.mult -= diff;
else
fep->cc.mult += diff;
fep->cc.mult = neg_adj ? mult - diff : mult + diff;

spin_unlock_irqrestore(&fep->tmreg_lock, flags);

Expand Down

0 comments on commit 7da716a

Please sign in to comment.