From: <Sergey.Semin@baikalelectronics.ru>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Serge Semin <Sergey.Semin@baikalelectronics.ru>,
Serge Semin <fancer.lancer@gmail.com>,
Paul Burton <paulburton@kernel.org>,
Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Ralf Baechle <ralf@linux-mips.org>, Arnd Bergmann <arnd@arndb.de>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH v2 5/6] clocksource: mips-gic-timer: Register as sched_clock
Date: Tue, 24 Mar 2020 20:43:24 +0300 [thread overview]
Message-ID: <20200324174325.14213-6-Sergey.Semin@baikalelectronics.ru> (raw)
In-Reply-To: <20200324174325.14213-1-Sergey.Semin@baikalelectronics.ru>
From: Paul Burton <paulburton@kernel.org>
The MIPS GIC timer is well suited for use as sched_clock, so register it
as such.
Whilst the existing gic_read_count() function matches the prototype
needed by sched_clock_register() already, we split it into 2 functions
in order to remove the need to evaluate the mips_cm_is64 condition
within each call since sched_clock should be as fast as possible.
Signed-off-by: Paul Burton <paulburton@kernel.org>
Cc: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: devicetree@vger.kernel.org
---
drivers/clocksource/mips-gic-timer.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c
index 37671a5d4ed9..8239ff99cfe4 100644
--- a/drivers/clocksource/mips-gic-timer.c
+++ b/drivers/clocksource/mips-gic-timer.c
@@ -16,6 +16,7 @@
#include <linux/notifier.h>
#include <linux/of_irq.h>
#include <linux/percpu.h>
+#include <linux/sched_clock.h>
#include <linux/smp.h>
#include <linux/time.h>
#include <asm/mips-cps.h>
@@ -24,13 +25,10 @@ static DEFINE_PER_CPU(struct clock_event_device, gic_clockevent_device);
static int gic_timer_irq;
static unsigned int gic_frequency;
-static u64 notrace gic_read_count(void)
+static u64 notrace gic_read_count_2x32(void)
{
unsigned int hi, hi2, lo;
- if (mips_cm_is64)
- return read_gic_counter();
-
do {
hi = read_gic_counter_32h();
lo = read_gic_counter_32l();
@@ -40,6 +38,19 @@ static u64 notrace gic_read_count(void)
return (((u64) hi) << 32) + lo;
}
+static u64 notrace gic_read_count_64(void)
+{
+ return read_gic_counter();
+}
+
+static u64 notrace gic_read_count(void)
+{
+ if (mips_cm_is64)
+ return gic_read_count_64();
+
+ return gic_read_count_2x32();
+}
+
static int gic_next_event(unsigned long delta, struct clock_event_device *evt)
{
int cpu = cpumask_first(evt->cpumask);
@@ -228,6 +239,10 @@ static int __init gic_clocksource_of_init(struct device_node *node)
/* And finally start the counter */
clear_gic_config(GIC_CONFIG_COUNTSTOP);
+ sched_clock_register(mips_cm_is64 ?
+ gic_read_count_64 : gic_read_count_2x32,
+ 64, gic_frequency);
+
return 0;
}
TIMER_OF_DECLARE(mips_gic_timer, "mti,gic-timer",
--
2.25.1
next prev parent reply other threads:[~2020-03-24 17:45 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-06 12:56 [PATCH 0/4] clocksource: Fix MIPS GIC and DW APB Timer for Baikal-T1 SoC support Sergey.Semin
2020-03-24 17:43 ` [PATCH v2 0/6] " Sergey.Semin
2020-03-24 17:43 ` [PATCH v2 1/6] dt-bindings: rtc: Convert snps,dw-apb-timer to DT schema Sergey.Semin
2020-03-24 18:07 ` Alexandre Belloni
2020-03-24 18:20 ` Serge Semin
2020-03-31 20:14 ` Rob Herring
2020-03-24 17:43 ` [PATCH v2 2/6] dt-bindings: interrupt-controller: Convert mti,gic " Sergey.Semin
2020-03-31 21:02 ` Rob Herring
2020-04-01 10:19 ` Sergey Semin
2020-04-01 14:13 ` Rob Herring
2020-04-01 22:07 ` Sergey Semin
2020-03-24 17:43 ` [PATCH v2 3/6] clocksource: dw_apb_timer: Set clockevent any-possible-CPU mask Sergey.Semin
2020-03-24 17:43 ` [PATCH v2 4/6] clocksource: dw_apb_timer_of: Fix missing clockevent timers Sergey.Semin
2020-03-24 17:43 ` Sergey.Semin [this message]
2020-03-24 17:43 ` [PATCH v2 6/6] clocksource: mips-gic-timer: Set limitations on clocksource/sched-clocks usage Sergey.Semin
2020-05-06 21:41 ` [PATCH v3 0/7] clocksource: Fix MIPS GIC and DW APB Timer for Baikal-T1 SoC support Serge Semin
2020-05-06 21:41 ` [PATCH v3 1/7] dt-bindings: rtc: Convert snps,dw-apb-timer to DT schema Serge Semin
2020-05-06 21:41 ` [PATCH v3 2/7] dt-bindings: timer: Move snps,dw-apb-timer DT schema from rtc Serge Semin
2020-05-07 12:03 ` Alexandre Belloni
2020-05-14 19:04 ` Rob Herring
2020-05-06 21:41 ` [PATCH v3 3/7] dt-bindings: interrupt-controller: Convert mti,gic to DT schema Serge Semin
2020-05-14 19:06 ` Rob Herring
2020-05-18 14:51 ` Serge Semin
2020-05-06 21:41 ` [PATCH v3 4/7] clocksource: dw_apb_timer: Set clockevent any-possible-CPU mask Serge Semin
2020-05-06 21:41 ` [PATCH v3 5/7] clocksource: dw_apb_timer_of: Fix missing clockevent timers Serge Semin
2020-05-06 21:41 ` [PATCH v3 6/7] clocksource: mips-gic-timer: Register as sched_clock Serge Semin
2020-05-06 21:41 ` [PATCH v3 7/7] clocksource: mips-gic-timer: Set limitations on clocksource/sched-clocks usage Serge Semin
2020-05-15 17:10 ` Daniel Lezcano
2020-05-16 12:16 ` Serge Semin
2020-05-18 13:59 ` Daniel Lezcano
2020-05-18 14:40 ` Serge Semin
2020-05-18 14:45 ` Serge Semin
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=20200324174325.14213-6-Sergey.Semin@baikalelectronics.ru \
--to=sergey.semin@baikalelectronics.ru \
--cc=Alexey.Malahov@baikalelectronics.ru \
--cc=andy.shevchenko@gmail.com \
--cc=arnd@arndb.de \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=paulburton@kernel.org \
--cc=ralf@linux-mips.org \
--cc=robh+dt@kernel.org \
--cc=tglx@linutronix.de \
--cc=tsbogend@alpha.franken.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).