lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1513323522-15021-15-git-send-email-sagar.a.kamble@intel.com>
Date:   Fri, 15 Dec 2017 13:08:29 +0530
From:   Sagar Arun Kamble <sagar.a.kamble@...el.com>
To:     linux-kernel@...r.kernel.org
Cc:     Sagar Arun Kamble <sagar.a.kamble@...el.com>,
        "David S. Miller" <davem@...emloft.net>,
        Grygorii Strashko <grygorii.strashko@...com>,
        Richard Cochran <richardcochran@...il.com>,
        Bhumika Goyal <bhumirks@...il.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ivan Khoronzhuk <ivan.khoronzhuk@...aro.org>,
        netdev@...r.kernel.org
Subject: [PATCH 14/27] net: cpts: Use timecounter_initialize interface

With new interface timecounter_initialize we can initialize timecounter
fields and underlying cyclecounter together. Update cpts timecounter
init with this new function.

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@...el.com>
Cc: "David S. Miller" <davem@...emloft.net>
Cc: Grygorii Strashko <grygorii.strashko@...com>
Cc: Richard Cochran <richardcochran@...il.com>
Cc: Bhumika Goyal <bhumirks@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ivan Khoronzhuk <ivan.khoronzhuk@...aro.org>
Cc: netdev@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
---
 drivers/net/ethernet/ti/cpts.c | 29 +++++++++++++++++------------
 drivers/net/ethernet/ti/cpts.h |  3 +++
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
index b8fe843..e6afc94 100644
--- a/drivers/net/ethernet/ti/cpts.c
+++ b/drivers/net/ethernet/ti/cpts.c
@@ -447,7 +447,12 @@ int cpts_register(struct cpts *cpts)
 	cpts_write32(cpts, CPTS_EN, control);
 	cpts_write32(cpts, TS_PEND_EN, int_enable);
 
-	timecounter_init(&cpts->tc, ktime_to_ns(ktime_get_real()));
+	timecounter_initialize(&cpts->tc,
+			       cpts_systim_read,
+			       cpts->mask,
+			       cpts->mult,
+			       cpts->shift,
+			       ktime_to_ns(ktime_get_real()));
 
 	cpts->clock = ptp_clock_register(&cpts->info, cpts->dev);
 	if (IS_ERR(cpts->clock)) {
@@ -484,7 +489,8 @@ void cpts_unregister(struct cpts *cpts)
 }
 EXPORT_SYMBOL_GPL(cpts_unregister);
 
-static void cpts_calc_mult_shift(struct cpts *cpts)
+static void cpts_calc_mult_shift(struct cpts *cpts, u64 mask,
+				 u32 *mult, u32 *shift)
 {
 	struct cyclecounter *cc = &cpts->tc.cc;
 	u64 frac, maxsec, ns;
@@ -495,7 +501,7 @@ static void cpts_calc_mult_shift(struct cpts *cpts)
 	/* Calc the maximum number of seconds which we can run before
 	 * wrapping around.
 	 */
-	maxsec = cc->mask;
+	maxsec = mask;
 	do_div(maxsec, freq);
 	/* limit conversation rate to 10 sec as higher values will produce
 	 * too small mult factors and so reduce the conversion accuracy
@@ -508,18 +514,18 @@ static void cpts_calc_mult_shift(struct cpts *cpts)
 	dev_info(cpts->dev, "cpts: overflow check period %lu (jiffies)\n",
 		 cpts->ov_check_period);
 
-	if (cc->mult || cc->shift)
+	if (*mult || *shift)
 		return;
 
-	clocks_calc_mult_shift(&cc->mult, &cc->shift,
+	clocks_calc_mult_shift(mult, shift,
 			       freq, NSEC_PER_SEC, maxsec);
 
 	frac = 0;
-	ns = cyclecounter_cyc2ns(cc, freq, cc->mask, &frac);
+	ns = cyclecounter_cyc2ns(cc, freq, mask, &frac);
 
 	dev_info(cpts->dev,
 		 "CPTS: ref_clk_freq:%u calc_mult:%u calc_shift:%u error:%lld nsec/sec\n",
-		 freq, cc->mult, cc->shift,
+		 freq, *mult, *shift,
 		 (ns - NSEC_PER_SEC));
 }
 
@@ -571,15 +577,14 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs,
 
 	clk_prepare(cpts->refclk);
 
-	cpts->tc.cc.read = cpts_systim_read;
-	cpts->tc.cc.mask = CLOCKSOURCE_MASK(32);
+	cpts->mask = CLOCKSOURCE_MASK(32);
 	cpts->info = cpts_info;
 
-	cpts_calc_mult_shift(cpts);
-	/* save tc.cc.mult original value as it can be modified
+	cpts_calc_mult_shift(cpts, cpts->mask, &cpts->mult, &cpts->shift);
+	/* save mult original value as it can be modified
 	 * by cpts_ptp_adjfreq().
 	 */
-	cpts->cc_mult = cpts->tc.cc.mult;
+	cpts->cc_mult = cpts->mult;
 
 	return cpts;
 }
diff --git a/drivers/net/ethernet/ti/cpts.h b/drivers/net/ethernet/ti/cpts.h
index a7174eb..da50d34 100644
--- a/drivers/net/ethernet/ti/cpts.h
+++ b/drivers/net/ethernet/ti/cpts.h
@@ -118,6 +118,9 @@ struct cpts {
 	spinlock_t lock; /* protects time registers */
 	u32 cc_mult; /* for the nominal frequency */
 	struct timecounter tc;
+	u64 mask;
+	u32 mult;
+	u32 shift;
 	int phc_index;
 	struct clk *refclk;
 	struct list_head events;
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ