linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Redfearn <matt.redfearn@mips.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: <linux-mips@linux-mips.org>,
	Matt Redfearn <matt.redfearn@mips.com>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] clocksource/mips-gic-timer: Ensure IRQs disabled for read-update-write
Date: Wed, 11 Oct 2017 15:01:13 +0100	[thread overview]
Message-ID: <1507730474-8577-2-git-send-email-matt.redfearn@mips.com> (raw)
In-Reply-To: <1507730474-8577-1-git-send-email-matt.redfearn@mips.com>

The sequence of reading the current count, adding an offset and writing
back to the compare register is timing critical.
Commit e07127a077c7 ("clocksource: mips-gic-timer: Use new GIC accessor
functions") added a local_irq_save / local_irq_restore to protect the
mapping of another VPs registers through the VP redirect region, but
given the timing critical nature of this code it just feels right to
protect the whole read-update-write section, so move the local_irq_save
before the current count is read.

Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
---

 drivers/clocksource/mips-gic-timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c
index 6c94a74682a2..dadac9f3e9c4 100644
--- a/drivers/clocksource/mips-gic-timer.c
+++ b/drivers/clocksource/mips-gic-timer.c
@@ -43,9 +43,9 @@ static int gic_next_event(unsigned long delta, struct clock_event_device *evt)
 	u64 cnt;
 	int res;
 
+	local_irq_save(flags);
 	cnt = gic_read_count();
 	cnt += (u64)delta;
-	local_irq_save(flags);
 	write_gic_vl_other(mips_cm_vp_id(cpumask_first(evt->cpumask)));
 	write_gic_vo_compare(cnt);
 	local_irq_restore(flags);
-- 
2.7.4

  reply	other threads:[~2017-10-11 14:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 14:01 [PATCH 1/3] clocksource/mips-gic-timer: Fix rcu_sched timeouts from multithreading Matt Redfearn
2017-10-11 14:01 ` Matt Redfearn [this message]
2017-10-11 14:01 ` [PATCH 3/3] clocksource: mips-gic-timer: Add fastpath for local timer updates Matt Redfearn
2017-10-17 18:15 ` [PATCH 1/3] clocksource/mips-gic-timer: Fix rcu_sched timeouts from multithreading Daniel Lezcano
2017-10-18 20:34 ` Thomas Gleixner
2017-10-19  8:08   ` Matt Redfearn
2017-10-19  8:22     ` Thomas Gleixner
2017-10-19  9:15   ` Daniel Lezcano
2017-10-19  9:18     ` Thomas Gleixner
2017-10-19  9:27       ` Daniel Lezcano
2017-10-19  9:09 ` Daniel Lezcano
2017-10-19  9:21   ` Matt Redfearn

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=1507730474-8577-2-git-send-email-matt.redfearn@mips.com \
    --to=matt.redfearn@mips.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --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).