From: Paolo Bonzini <pbonzini@redhat.com>
To: Andrew Jones <drjones@redhat.com>,
kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH 2/3] arm/arm64: drop mmu_set_enabled
Date: Fri, 3 Jul 2015 19:39:13 +0200 [thread overview]
Message-ID: <5596C8C1.7060809@redhat.com> (raw)
In-Reply-To: <1435257911-9715-3-git-send-email-drjones@redhat.com>
On 25/06/2015 20:45, Andrew Jones wrote:
> The mmu is enabled automatically for all cpus, they must disable it
> themselves if they don't want it on. Switch from managing a cpumask
> of enabled cpus to one of disabled cpus. This allows us to remove
> the mmu_set_enabled call from secondary_cinit, and the function all
> together.
>
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
> lib/arm/asm/mmu-api.h | 1 -
> lib/arm/mmu.c | 21 ++++++++++-----------
> lib/arm/smp.c | 1 -
> 3 files changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/lib/arm/asm/mmu-api.h b/lib/arm/asm/mmu-api.h
> index c46c4b08b14cc..12fdc57918c27 100644
> --- a/lib/arm/asm/mmu-api.h
> +++ b/lib/arm/asm/mmu-api.h
> @@ -2,7 +2,6 @@
> #define __ASMARM_MMU_API_H_
> extern pgd_t *mmu_idmap;
> extern bool mmu_enabled(void);
> -extern void mmu_set_enabled(void);
> extern void mmu_enable(pgd_t *pgtable);
> extern void mmu_disable(void);
> extern void mmu_enable_idmap(void);
> diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c
> index 5966b408cb455..ad558e177dd1c 100644
> --- a/lib/arm/mmu.c
> +++ b/lib/arm/mmu.c
> @@ -14,32 +14,31 @@ extern unsigned long etext;
>
> pgd_t *mmu_idmap;
>
> -static cpumask_t mmu_enabled_cpumask;
> +static cpumask_t mmu_disabled_cpumask;
> +
> bool mmu_enabled(void)
> {
> - struct thread_info *ti = current_thread_info();
> - return cpumask_test_cpu(ti->cpu, &mmu_enabled_cpumask);
> -}
> + int cpu = current_thread_info()->cpu;
>
> -void mmu_set_enabled(void)
> -{
> - struct thread_info *ti = current_thread_info();
> - cpumask_set_cpu(ti->cpu, &mmu_enabled_cpumask);
> + return !cpumask_test_cpu(cpu, &mmu_disabled_cpumask);
> }
>
> extern void asm_mmu_enable(phys_addr_t pgtable);
> void mmu_enable(pgd_t *pgtable)
> {
> + int cpu = current_thread_info()->cpu;
> +
> asm_mmu_enable(__pa(pgtable));
> flush_tlb_all();
> - mmu_set_enabled();
> + cpumask_clear_cpu(cpu, &mmu_disabled_cpumask);
> }
>
> extern void asm_mmu_disable(void);
> void mmu_disable(void)
> {
> - struct thread_info *ti = current_thread_info();
> - cpumask_clear_cpu(ti->cpu, &mmu_enabled_cpumask);
> + int cpu = current_thread_info()->cpu;
> +
> + cpumask_set_cpu(cpu, &mmu_disabled_cpumask);
> asm_mmu_disable();
> }
>
> diff --git a/lib/arm/smp.c b/lib/arm/smp.c
> index f389ba6598faa..ca435dcd5f4a2 100644
> --- a/lib/arm/smp.c
> +++ b/lib/arm/smp.c
> @@ -23,7 +23,6 @@ secondary_entry_fn secondary_cinit(void)
> secondary_entry_fn entry;
>
> thread_info_init(ti, 0);
> - mmu_set_enabled();
>
> /*
> * Save secondary_data.entry locally to avoid opening a race
>
This is needed too on a Cubietruck:
diff --git a/lib/arm/asm/mmu-api.h b/lib/arm/asm/mmu-api.h
index 12fdc57..73bac70 100644
--- a/lib/arm/asm/mmu-api.h
+++ b/lib/arm/asm/mmu-api.h
@@ -3,6 +3,7 @@
extern pgd_t *mmu_idmap;
extern bool mmu_enabled(void);
extern void mmu_enable(pgd_t *pgtable);
+extern void mmu_mark_disabled(int cpu);
extern void mmu_disable(void);
extern void mmu_enable_idmap(void);
extern void mmu_init_io_sect(pgd_t *pgtable, unsigned long virt_offset);
diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c
index ad558e1..8ff659b 100644
--- a/lib/arm/mmu.c
+++ b/lib/arm/mmu.c
@@ -14,7 +14,8 @@ extern unsigned long etext;
pgd_t *mmu_idmap;
-static cpumask_t mmu_disabled_cpumask;
+/* CPU 0 starts with disabled MMU */
+static cpumask_t mmu_disabled_cpumask = { {1} };
bool mmu_enabled(void)
{
@@ -33,6 +34,11 @@ void mmu_enable(pgd_t *pgtable)
cpumask_clear_cpu(cpu, &mmu_disabled_cpumask);
}
+void mmu_mark_disabled(int cpu)
+{
+ cpumask_set_cpu(cpu, &mmu_disabled_cpumask);
+}
+
extern void asm_mmu_disable(void);
void mmu_disable(void)
{
diff --git a/lib/arm/psci.c b/lib/arm/psci.c
index aca8885..c4469c9 100644
--- a/lib/arm/psci.c
+++ b/lib/arm/psci.c
@@ -9,6 +9,7 @@
#include <asm/psci.h>
#include <asm/setup.h>
#include <asm/page.h>
+#include <asm/mmu-api.h>
#define T PSCI_INVOKE_ARG_TYPE
__attribute__((noinline))
@@ -29,6 +30,7 @@ int psci_cpu_on(unsigned long cpuid, unsigned long
entry_point)
extern void secondary_entry(void);
int cpu_psci_cpu_boot(unsigned int cpu)
{
+ mmu_mark_disabled(cpu);
int err = psci_cpu_on(cpus[cpu], __pa(secondary_entry));
if (err)
printf("failed to boot CPU%d (%d)\n", cpu, err);
next prev parent reply other threads:[~2015-07-03 17:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 18:45 [PATCH 0/3] arm/arm64: rework mmu_enabled, for spinlock speedup Andrew Jones
2015-06-25 18:45 ` [PATCH 1/3] arm/arm64: Introduce mmu_disable Andrew Jones
2015-07-03 17:42 ` Paolo Bonzini
2015-06-25 18:45 ` [PATCH 2/3] arm/arm64: drop mmu_set_enabled Andrew Jones
2015-07-03 17:39 ` Paolo Bonzini [this message]
2015-07-06 12:41 ` Andrew Jones
2015-06-25 18:45 ` [PATCH 3/3] arm/arm64: speed up spinlocks and atomic ops Andrew Jones
2015-07-03 17:43 ` Paolo Bonzini
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=5596C8C1.7060809@redhat.com \
--to=pbonzini@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
/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).