Patchwork [2/2] net: fec: reduce spin lock time in fec_ptp_adjfreq

login
register
mail settings
Submitter Frank Li
Date Nov. 7, 2012, 6:14 a.m.
Message ID <1352268889-16836-1-git-send-email-Frank.Li@freescale.com>
Download mbox | patch
Permalink /patch/197626/
State Accepted
Delegated to: David Miller
Headers show

Comments

Frank Li - Nov. 7, 2012, 6:14 a.m.
move below calculate out of spin lock section
	diff = fep->cc.mult;
	diff *= ppb;
	diff = div_u64(diff, 1000000000ULL);
Richard Cochran - Nov. 7, 2012, 8:33 a.m.
On Wed, Nov 07, 2012 at 02:14:49PM +0800, Frank Li wrote:
> 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>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Nov. 7, 2012, 11:53 p.m.
From: Frank Li <Frank.Li@freescale.com>
Date: Wed, 7 Nov 2012 14:14:49 +0800

> 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>

Also applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff is local variable and not neccesary in spin lock

Signed-off-by: Frank Li <Frank.Li@freescale.com>
---
 drivers/net/ethernet/freescale/fec_ptp.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 5352140..c40526c 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -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);
@@ -154,6 +155,10 @@  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.
@@ -161,15 +166,8 @@  static int fec_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
 	 * 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);