From: alex.bennee@linaro•org (Alex Bennée)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v10 11/18] arm64/sve: Move read_zcr_features() out of cpufeature.h
Date: Thu, 24 May 2018 11:12:09 +0100 [thread overview]
Message-ID: <87603dtlae.fsf@linaro.org> (raw)
In-Reply-To: <1527005119-6842-12-git-send-email-Dave.Martin@arm.com>
Dave Martin <Dave.Martin@arm•com> writes:
> Having read_zcr_features() inline in cpufeature.h results in that
> header requiring #includes which make it hard to include
> <asm/fpsimd.h> elsewhere without triggering header inclusion
> cycles.
>
> This is not a hot-path function and arguably should not be in
> cpufeature.h in the first place, so this patch moves it to
> fpsimd.c, compiled conditionally if CONFIG_ARM64_SVE=y.
>
> This allows some SVE-related #includes to be dropped from
> cpufeature.h, which will ease future maintenance.
>
> A couple of missing #includes of <asm/fpsimd.h> are exposed by this
> change under arch/arm64/. This patch adds the missing #includes as
> necessary.
>
> No functional change.
>
> Signed-off-by: Dave Martin <Dave.Martin@arm•com>
> Acked-by: Catalin Marinas <catalin.marinas@arm•com>
> Acked-by: Marc Zyngier <marc.zyngier@arm•com>
Reviewed-by: Alex Benn?e <alex.bennee@linaro•org>
> ---
> arch/arm64/include/asm/cpufeature.h | 29 -----------------------------
> arch/arm64/include/asm/fpsimd.h | 2 ++
> arch/arm64/include/asm/processor.h | 1 +
> arch/arm64/kernel/fpsimd.c | 28 ++++++++++++++++++++++++++++
> arch/arm64/kernel/ptrace.c | 1 +
> 5 files changed, 32 insertions(+), 29 deletions(-)
>
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index 09b0f2a..0a6b713 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -11,9 +11,7 @@
>
> #include <asm/cpucaps.h>
> #include <asm/cputype.h>
> -#include <asm/fpsimd.h>
> #include <asm/hwcap.h>
> -#include <asm/sigcontext.h>
> #include <asm/sysreg.h>
>
> /*
> @@ -510,33 +508,6 @@ static inline bool system_supports_sve(void)
> cpus_have_const_cap(ARM64_SVE);
> }
>
> -/*
> - * Read the pseudo-ZCR used by cpufeatures to identify the supported SVE
> - * vector length.
> - *
> - * Use only if SVE is present.
> - * This function clobbers the SVE vector length.
> - */
> -static inline u64 read_zcr_features(void)
> -{
> - u64 zcr;
> - unsigned int vq_max;
> -
> - /*
> - * Set the maximum possible VL, and write zeroes to all other
> - * bits to see if they stick.
> - */
> - sve_kernel_enable(NULL);
> - write_sysreg_s(ZCR_ELx_LEN_MASK, SYS_ZCR_EL1);
> -
> - zcr = read_sysreg_s(SYS_ZCR_EL1);
> - zcr &= ~(u64)ZCR_ELx_LEN_MASK; /* find sticky 1s outside LEN field */
> - vq_max = sve_vq_from_vl(sve_get_vl());
> - zcr |= vq_max - 1; /* set LEN field to maximum effective value */
> -
> - return zcr;
> -}
> -
> #endif /* __ASSEMBLY__ */
>
> #endif
> diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
> index 3e00f70..fb60b22 100644
> --- a/arch/arm64/include/asm/fpsimd.h
> +++ b/arch/arm64/include/asm/fpsimd.h
> @@ -69,6 +69,8 @@ extern unsigned int sve_get_vl(void);
> struct arm64_cpu_capabilities;
> extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused);
>
> +extern u64 read_zcr_features(void);
> +
> extern int __ro_after_init sve_max_vl;
>
> #ifdef CONFIG_ARM64_SVE
> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 7675989..f902b6d 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -40,6 +40,7 @@
>
> #include <asm/alternative.h>
> #include <asm/cpufeature.h>
> +#include <asm/fpsimd.h>
> #include <asm/hw_breakpoint.h>
> #include <asm/lse.h>
> #include <asm/pgtable-hwdef.h>
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index ded7ffd..5152bbc 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -37,6 +37,7 @@
> #include <linux/sched/task_stack.h>
> #include <linux/signal.h>
> #include <linux/slab.h>
> +#include <linux/stddef.h>
> #include <linux/sysctl.h>
>
> #include <asm/esr.h>
> @@ -754,6 +755,33 @@ void sve_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p)
> isb();
> }
>
> +/*
> + * Read the pseudo-ZCR used by cpufeatures to identify the supported SVE
> + * vector length.
> + *
> + * Use only if SVE is present.
> + * This function clobbers the SVE vector length.
> + */
> +u64 read_zcr_features(void)
> +{
> + u64 zcr;
> + unsigned int vq_max;
> +
> + /*
> + * Set the maximum possible VL, and write zeroes to all other
> + * bits to see if they stick.
> + */
> + sve_kernel_enable(NULL);
> + write_sysreg_s(ZCR_ELx_LEN_MASK, SYS_ZCR_EL1);
> +
> + zcr = read_sysreg_s(SYS_ZCR_EL1);
> + zcr &= ~(u64)ZCR_ELx_LEN_MASK; /* find sticky 1s outside LEN field */
> + vq_max = sve_vq_from_vl(sve_get_vl());
> + zcr |= vq_max - 1; /* set LEN field to maximum effective value */
> +
> + return zcr;
> +}
> +
> void __init sve_setup(void)
> {
> u64 zcr;
> diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
> index 7ff81fe..78889c4 100644
> --- a/arch/arm64/kernel/ptrace.c
> +++ b/arch/arm64/kernel/ptrace.c
> @@ -44,6 +44,7 @@
> #include <asm/compat.h>
> #include <asm/cpufeature.h>
> #include <asm/debug-monitors.h>
> +#include <asm/fpsimd.h>
> #include <asm/pgtable.h>
> #include <asm/stacktrace.h>
> #include <asm/syscall.h>
--
Alex Benn?e
next prev parent reply other threads:[~2018-05-24 10:12 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-22 16:05 [PATCH v10 00/18] KVM: arm64: Optimise FPSIMD context switching Dave Martin
2018-05-22 16:05 ` [PATCH v10 01/18] arm64: fpsimd: Fix TIF_FOREIGN_FPSTATE after invalidating cpu regs Dave Martin
2018-05-23 11:33 ` Christoffer Dall
2018-05-23 13:44 ` Alex Bennée
2018-05-23 13:46 ` Catalin Marinas
2018-05-22 16:05 ` [PATCH v10 02/18] thread_info: Add update_thread_flag() helpers Dave Martin
2018-05-23 13:46 ` Alex Bennée
2018-05-23 13:57 ` Dave Martin
2018-05-23 14:35 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 03/18] arm64: Use update{,_tsk}_thread_flag() Dave Martin
2018-05-23 13:48 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 04/18] KVM: arm/arm64: Introduce kvm_arch_vcpu_run_pid_change Dave Martin
2018-05-23 14:34 ` Alex Bennée
2018-05-23 14:40 ` Dave Martin
2018-05-24 8:11 ` Christoffer Dall
2018-05-24 9:18 ` Alex Bennée
2018-05-24 10:04 ` Dave Martin
2018-05-22 16:05 ` [PATCH v10 05/18] KVM: arm64: Convert lazy FPSIMD context switch trap to C Dave Martin
2018-05-23 19:35 ` Alex Bennée
2018-05-24 8:12 ` Christoffer Dall
2018-05-24 8:54 ` Dave Martin
2018-05-24 9:14 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 06/18] arm64: fpsimd: Generalise context saving for non-task contexts Dave Martin
2018-05-23 20:15 ` Alex Bennée
2018-05-24 9:03 ` Dave Martin
2018-05-24 9:41 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 07/18] arm64: fpsimd: Eliminate task->mm checks Dave Martin
2018-05-23 11:48 ` Christoffer Dall
2018-05-23 13:31 ` Dave Martin
2018-05-23 14:56 ` Catalin Marinas
2018-05-23 15:03 ` Dave Martin
2018-05-23 16:42 ` Catalin Marinas
2018-05-24 8:33 ` Christoffer Dall
2018-05-24 9:16 ` Alex Bennée
2018-05-24 9:50 ` Dave Martin
2018-05-24 10:06 ` Christoffer Dall
2018-05-24 14:37 ` Dave Martin
2018-05-25 9:00 ` Christoffer Dall
2018-05-25 9:45 ` Dave Martin
2018-05-25 11:28 ` Christoffer Dall
2018-05-24 9:19 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 08/18] arm64/sve: Refactor user SVE trap maintenance for external use Dave Martin
2018-05-23 20:16 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 09/18] KVM: arm64: Repurpose vcpu_arch.debug_flags for general-purpose flags Dave Martin
2018-05-24 9:21 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 10/18] KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing Dave Martin
2018-05-24 10:09 ` Alex Bennée
2018-05-24 10:18 ` Dave Martin
2018-05-22 16:05 ` [PATCH v10 11/18] arm64/sve: Move read_zcr_features() out of cpufeature.h Dave Martin
2018-05-24 10:12 ` Alex Bennée [this message]
2018-05-22 16:05 ` [PATCH v10 12/18] arm64/sve: Switch sve_pffr() argument from task to thread Dave Martin
2018-05-24 10:12 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 13/18] arm64/sve: Move sve_pffr() to fpsimd.h and make inline Dave Martin
2018-05-24 10:20 ` Alex Bennée
2018-05-24 11:22 ` Dave Martin
2018-05-22 16:05 ` [PATCH v10 14/18] KVM: arm64: Save host SVE context as appropriate Dave Martin
2018-05-23 14:59 ` Catalin Marinas
2018-05-24 9:11 ` Christoffer Dall
2018-05-24 14:49 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 15/18] KVM: arm64: Remove eager host SVE state saving Dave Martin
2018-05-24 14:54 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 16/18] KVM: arm64: Remove redundant *exit_code changes in fpsimd_guest_exit() Dave Martin
2018-05-24 9:11 ` Christoffer Dall
2018-05-24 15:02 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 17/18] KVM: arm64: Fold redundant exit code checks out of fixup_guest_exit() Dave Martin
2018-05-24 9:12 ` Christoffer Dall
2018-05-24 15:06 ` Alex Bennée
2018-05-22 16:05 ` [PATCH v10 18/18] KVM: arm64: Invoke FPSIMD context switch trap from C Dave Martin
2018-05-24 15:09 ` Alex Bennée
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=87603dtlae.fsf@linaro.org \
--to=alex.bennee@linaro$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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