From: Frank Li <Frank.Li@freescale.com>
To: <lznuaa@gmail.com>, <richardcochran@gmail.com>,
<shawn.guo@linaro.org>, <linux-arm-kernel@lists.infradead.or>,
<netdev@vger.kernel.org>, <davem@davemloft.net>,
<bhutchings@solarflare.com>
Cc: Frank Li <Frank.Li@freescale.com>
Subject: [PATCH 2/2] net: fec: reduce spin lock time in fec_ptp_adjfreq
Date: Wed, 7 Nov 2012 14:14:49 +0800 [thread overview]
Message-ID: <1352268889-16836-1-git-send-email-Frank.Li@freescale.com> (raw)
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>
---
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);
--
1.7.1
next reply other threads:[~2012-11-07 6:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-07 6:14 Frank Li [this message]
2012-11-07 8:33 ` [PATCH 2/2] net: fec: reduce spin lock time in fec_ptp_adjfreq Richard Cochran
2012-11-07 23:53 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352268889-16836-1-git-send-email-Frank.Li@freescale.com \
--to=frank.li@freescale.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=linux-arm-kernel@lists.infradead.or \
--cc=lznuaa@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=shawn.guo@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).