From: Paul Burton <paul.burton@imgtec.com>
To: <linux-mips@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>,
Rusty Russell <rusty@rustcorp.com.au>,
"Steven J. Hill" <Steven.Hill@imgtec.com>,
"Andrew Bresticker" <abrestic@chromium.org>,
Bjorn Helgaas <bhelgaas@google.com>,
David Hildenbrand <dahi@linux.vnet.ibm.com>,
<linux-kernel@vger.kernel.org>,
Aaro Koskinen <aaro.koskinen@iki.fi>,
James Hogan <james.hogan@imgtec.com>,
Markos Chandras <markos.chandras@imgtec.com>,
Ingo Molnar <mingo@kernel.org>,
Ralf Baechle <ralf@linux-mips.org>,
Alex Smith <alex.smith@imgtec.com>
Subject: [PATCH 2/2] MIPS: initialise MAARs on secondary CPUs
Date: Tue, 22 Sep 2015 12:08:48 -0700 [thread overview]
Message-ID: <1442948929-15862-3-git-send-email-paul.burton@imgtec.com> (raw)
In-Reply-To: <1442948929-15862-1-git-send-email-paul.burton@imgtec.com>
MAARs should be initialised on each CPU (or rather, core) in the system
in order to achieve consistent behaviour & performance. Previously they
have only been initialised on the boot CPU which leads to performance
problems if tasks are later scheduled on a secondary CPU, particularly
if those tasks make use of unaligned vector accesses where some CPUs
don't handle any cases in hardware for non-speculative memory regions.
Fix this by recording the MAAR configuration from the boot CPU and
applying it to secondary CPUs as part of their bringup.
Reported-by: Doug Gilmore <doug.gilmore@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/include/asm/maar.h | 9 +++++++++
arch/mips/kernel/smp.c | 2 ++
arch/mips/mm/init.c | 28 +++++++++++++++++++++++++---
3 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/arch/mips/include/asm/maar.h b/arch/mips/include/asm/maar.h
index b02891f..21d9607 100644
--- a/arch/mips/include/asm/maar.h
+++ b/arch/mips/include/asm/maar.h
@@ -66,6 +66,15 @@ static inline void write_maar_pair(unsigned idx, phys_addr_t lower,
}
/**
+ * maar_init() - initialise MAARs
+ *
+ * Performs initialisation of MAARs for the current CPU, making use of the
+ * platforms implementation of platform_maar_init where necessary and
+ * duplicating the setup it provides on secondary CPUs.
+ */
+extern void maar_init(void);
+
+/**
* struct maar_config - MAAR configuration data
* @lower: The lowest address that the MAAR pair will affect. Must be
* aligned to a 2^16 byte boundary.
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index a31896c..bd4385a 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -42,6 +42,7 @@
#include <asm/mmu_context.h>
#include <asm/time.h>
#include <asm/setup.h>
+#include <asm/maar.h>
cpumask_t cpu_callin_map; /* Bitmask of started secondaries */
@@ -157,6 +158,7 @@ asmlinkage void start_secondary(void)
mips_clockevent_init();
mp_ops->init_secondary();
cpu_report();
+ maar_init();
/*
* XXX parity protection should be folded in here when it's converted
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index cbef5c2..5f3c5b1 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -44,6 +44,7 @@
#include <asm/pgalloc.h>
#include <asm/tlb.h>
#include <asm/fixmap.h>
+#include <asm/maar.h>
/*
* We have up to 8 empty zeroed pages so we can map one of the right colour
@@ -370,10 +371,14 @@ unsigned __weak platform_maar_init(unsigned num_pairs)
return num_configured;
}
-static void maar_init(void)
+void maar_init(void)
{
unsigned num_maars, used, i;
phys_addr_t lower, upper, attr;
+ static struct {
+ struct maar_config cfgs[3];
+ unsigned used;
+ } recorded = { { { 0 } }, 0 };
if (!cpu_has_maar)
return;
@@ -386,8 +391,14 @@ static void maar_init(void)
/* MAARs should be in pairs */
WARN_ON(num_maars % 2);
- /* Configure the required MAARs */
- used = platform_maar_init(num_maars / 2);
+ /* Set MAARs using values we recorded already */
+ if (recorded.used) {
+ used = maar_config(recorded.cfgs, recorded.used, num_maars / 2);
+ BUG_ON(used != recorded.used);
+ } else {
+ /* Configure the required MAARs */
+ used = platform_maar_init(num_maars / 2);
+ }
/* Disable any further MAARs */
for (i = (used * 2); i < num_maars; i++) {
@@ -397,6 +408,9 @@ static void maar_init(void)
back_to_back_c0_hazard();
}
+ if (recorded.used)
+ return;
+
pr_info("MAAR configuration:\n");
for (i = 0; i < num_maars; i += 2) {
write_c0_maari(i);
@@ -423,6 +437,14 @@ static void maar_init(void)
pr_cont(" speculate");
pr_cont("\n");
+
+ /* Record the setup for use on secondary CPUs */
+ if (used <= ARRAY_SIZE(recorded.cfgs)) {
+ recorded.cfgs[recorded.used].lower = lower;
+ recorded.cfgs[recorded.used].upper = upper;
+ recorded.cfgs[recorded.used].attrs = attr;
+ recorded.used++;
+ }
}
}
--
2.5.3
next prev parent reply other threads:[~2015-09-22 19:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 19:08 [PATCH 0/2] MAAR SMP fix Paul Burton
2015-09-22 19:08 ` [PATCH 1/2] MIPS: print MAAR configuration during boot Paul Burton
2015-09-22 19:08 ` Paul Burton [this message]
2015-09-24 8:23 ` [PATCH 2/2] MIPS: initialise MAARs on secondary CPUs Markos Chandras
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=1442948929-15862-3-git-send-email-paul.burton@imgtec.com \
--to=paul.burton@imgtec.com \
--cc=Steven.Hill@imgtec.com \
--cc=aaro.koskinen@iki.fi \
--cc=abrestic@chromium.org \
--cc=alex.smith@imgtec.com \
--cc=bhelgaas@google.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=james.hogan@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=markos.chandras@imgtec.com \
--cc=mingo@kernel.org \
--cc=ralf@linux-mips.org \
--cc=rusty@rustcorp.com.au \
/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
all inboxes | Powered by JetHome®