linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Shawn Landden <shawn@git.icu>
Cc: linuxppc-dev@lists.ozlabs.org, Paul Mackerras <paulus@samba.org>
Subject: Re: [v4 PATCH 1/2] [PowerPC] Add simd.h implementation
Date: Wed, 15 May 2019 08:27:07 +0200	[thread overview]
Message-ID: <568f62f6-7810-7179-f9aa-03f9df198fb6@c-s.fr> (raw)
In-Reply-To: <20190515013725.2198-1-shawn@git.icu>



Le 15/05/2019 à 03:37, Shawn Landden a écrit :
> Based off the x86 one.
> 
> WireGuard really wants to be able to do SIMD in interrupts,
> so it can accelerate its in-bound path.
> 
> Signed-off-by: Shawn Landden <shawn@git.icu>
> ---

Could you please as usual list here the changes provided by each version 
to ease the review ?

Thanks
Christophe

>   arch/powerpc/include/asm/simd.h | 17 +++++++++++++++++
>   arch/powerpc/kernel/process.c   | 30 ++++++++++++++++++++++++++++++
>   2 files changed, 47 insertions(+)
>   create mode 100644 arch/powerpc/include/asm/simd.h
> 
> diff --git a/arch/powerpc/include/asm/simd.h b/arch/powerpc/include/asm/simd.h
> new file mode 100644
> index 000000000..2fe26f258
> --- /dev/null
> +++ b/arch/powerpc/include/asm/simd.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +
> +/*
> + * may_use_simd - whether it is allowable at this time to issue SIMD
> + *                instructions or access the SIMD register file
> + *
> + * It's always ok in process context (ie "not interrupt")
> + * but it is sometimes ok even from an irq.
> + */
> +#ifdef CONFIG_PPC_FPU
> +extern bool may_use_simd(void);
> +#else
> +static inline bool may_use_simd(void)
> +{
> +	return false;
> +}
> +#endif
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index dd9e0d538..ef534831f 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -345,6 +345,36 @@ static int restore_altivec(struct task_struct *tsk)
>   	}
>   	return 0;
>   }
> +
> +/*
> + * Were we in user mode when we were
> + * interrupted?
> + *
> + * Doing kernel_altivec/vsx_begin/end() is ok if we are running
> + * in an interrupt context from user mode - we'll just
> + * save the FPU state as required.
> + */
> +static bool interrupted_user_mode(void)
> +{
> +	struct pt_regs *regs = get_irq_regs();
> +
> +	return regs && user_mode(regs);
> +}
> +
> +/*
> + * Can we use FPU in kernel mode with the
> + * whole "kernel_fpu/altivec/vsx_begin/end()" sequence?
> + *
> + * It's always ok in process context (ie "not interrupt")
> + * but it is sometimes ok even from an irq.
> + */
> +bool may_use_simd(void)
> +{
> +	return !in_interrupt() ||
> +		interrupted_user_mode();
> +}
> +EXPORT_SYMBOL(may_use_simd);
> +
>   #else
>   #define loadvec(thr) 0
>   static inline int restore_altivec(struct task_struct *tsk) { return 0; }
> 

  parent reply	other threads:[~2019-05-15  6:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-12 16:50 [PATCH] powerpc: add simd.h implementation specific to PowerPC Shawn Landden
2019-05-13  0:51 ` [PATCH RESEND] " Shawn Landden
2019-05-13 11:53   ` Michael Ellerman
2019-05-14  1:44   ` [PATCH 1/2] [PowerPC] Add simd.h implementation Shawn Landden
2019-05-14  1:44     ` [PATCH 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden
2019-05-14  5:43     ` [PATCH 1/2] [PowerPC] Add simd.h implementation Benjamin Herrenschmidt
2019-05-14 15:44       ` Shawn Landden
2019-05-14 15:46     ` [v3 " Shawn Landden
2019-05-14 15:46       ` [v3 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden
2019-05-15  1:03         ` kbuild test robot
2019-05-14  2:23   ` [v2 1/2] [PowerPC] Add simd.h implementation Shawn Landden
2019-05-14  2:23     ` [v2 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden
2019-05-14  7:22       ` Russell Currey
2019-05-14 15:35         ` Shawn Landden
2019-05-14 12:49   ` [PATCH] powerpc: Allow may_use_simd() to function as feature detection Shawn Landden
2019-05-14 18:06     ` Segher Boessenkool
2019-05-14 19:00       ` Shawn Landden
2019-05-15  1:36   ` [PATCH 1/2] [PowerPC] Add simd.h implementation Shawn Landden
2019-05-15  1:37   ` [v4 PATCH " Shawn Landden
2019-05-15  1:37     ` [v4 PATCH 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden
2019-05-15  6:27     ` Christophe Leroy [this message]
2019-05-16  1:12       ` [v4 PATCH 1/2] [PowerPC] Add simd.h implementation Shawn Landden
2019-05-18 16:04     ` [RESEND v4 " Shawn Landden
2019-05-18 16:04       ` [RESEND v4 PATCH 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden

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=568f62f6-7810-7179-f9aa-03f9df198fb6@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=shawn@git.icu \
    /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).