linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang@marvell.com>
To: <daniel.lezcano@linaro.org>, <tglx@linutronix.de>,
	<linux@arm.linux.org.uk>, <arnd@arndb.de>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	Jisheng Zhang <jszhang@marvell.com>
Subject: [PATCH v2 1/3] ARM: delay: choose the highest rating delay timer
Date: Tue, 3 Nov 2015 22:28:35 +0800	[thread overview]
Message-ID: <1446560917-6318-2-git-send-email-jszhang@marvell.com> (raw)
In-Reply-To: <1446560917-6318-1-git-send-email-jszhang@marvell.com>

In case there are several possible delay timers, we purely base the
selection on the frequency, which is suboptimal in some cases. Take
one Marvell Berlin platform for example: we have arch timer and dw-apb
timer. The arch timer freq is 25MHZ while the dw-apb timer freq is
100MHZ, current selection would choose the dw-apb timer. But the dw
apb timer is on the APB bus while arch timer sits in CPU, the cost
of accessing the apb timer is higher than the arch timer.

This patch introduces rating concept to the delay timer and use it
as a primary indication, we fall back to comparing the frequency if
the rating is not set or the same.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
---
 arch/arm/include/asm/delay.h |  1 +
 arch/arm/lib/delay.c         | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
index dff714d..cb445d7 100644
--- a/arch/arm/include/asm/delay.h
+++ b/arch/arm/include/asm/delay.h
@@ -18,6 +18,7 @@
 struct delay_timer {
 	unsigned long (*read_current_timer)(void);
 	unsigned long freq;
+	int rating;
 };
 
 extern struct arm_delay_ops {
diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
index 8044591..91cee12 100644
--- a/arch/arm/lib/delay.c
+++ b/arch/arm/lib/delay.c
@@ -38,6 +38,7 @@ struct arm_delay_ops arm_delay_ops = {
 static const struct delay_timer *delay_timer;
 static bool delay_calibrated;
 static u64 delay_res;
+static int delay_rating;
 
 int read_current_timer(unsigned long *timer_val)
 {
@@ -78,6 +79,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
 {
 	u32 new_mult, new_shift;
 	u64 res;
+	bool update_delay_ops = false;
 
 	clocks_calc_mult_shift(&new_mult, &new_shift, timer->freq,
 			       NSEC_PER_SEC, 3600);
@@ -89,11 +91,23 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
 		return;
 	}
 
-	if (!delay_calibrated && (!delay_res || (res < delay_res))) {
+	if (!delay_calibrated) {
+		if (delay_rating && timer->rating &&
+				delay_rating != timer->rating) {
+			if (timer->rating > delay_rating)
+				update_delay_ops = true;
+		} else {
+			if (!delay_res || (res < delay_res))
+				update_delay_ops = true;
+		}
+	}
+
+	if (update_delay_ops) {
 		pr_info("Switching to timer-based delay loop, resolution %lluns\n", res);
 		delay_timer			= timer;
 		lpj_fine			= timer->freq / HZ;
 		delay_res			= res;
+		delay_rating			= timer->rating;
 
 		/* cpufreq may scale loops_per_jiffy, so keep a private copy */
 		arm_delay_ops.ticks_per_jiffy	= lpj_fine;
-- 
2.6.2


  reply	other threads:[~2015-11-03 14:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03 14:28 [PATCH v2 0/3] let Marvell Berlin SoCs make use of the best delay timer Jisheng Zhang
2015-11-03 14:28 ` Jisheng Zhang [this message]
2015-11-03 14:28 ` [PATCH v2 2/3] ARM: arch_timer: set the arch_delay_timer rating as 400 Jisheng Zhang
2015-11-03 14:28 ` [PATCH v2 3/3] clocksource/drivers/dw_apb_timer_of: Implement ARM delay timer Jisheng Zhang
2015-11-04  9:46 ` [PATCH v2 0/3] let Marvell Berlin SoCs make use of the best " Daniel Lezcano
2015-11-04 10:30   ` Arnd Bergmann
2015-11-04 11:19     ` Daniel Lezcano
2015-11-04 12:19       ` Arnd Bergmann
2015-11-05  2:36         ` Jisheng Zhang

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=1446560917-6318-2-git-send-email-jszhang@marvell.com \
    --to=jszhang@marvell.com \
    --cc=arnd@arndb.de \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=tglx@linutronix.de \
    /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).