linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed
@ 2014-06-26 17:34 Will Deacon
  2014-06-26 21:10 ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2014-06-26 17:34 UTC (permalink / raw)
  To: linux-arm-kernel

Writing to the FPCR is commonly implemented as a self-synchronising
operation in the CPU, so avoid writing to the register when the saved
value matches that in the hardware already.

Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/fpsimdmacros.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/include/asm/fpsimdmacros.h b/arch/arm64/include/asm/fpsimdmacros.h
index 768414d55e64..137c0f45b0a8 100644
--- a/arch/arm64/include/asm/fpsimdmacros.h
+++ b/arch/arm64/include/asm/fpsimdmacros.h
@@ -40,6 +40,7 @@
 	str	w\tmpnr, [\state, #16 * 2 + 4]
 .endm
 
+/* Clobbers \state */
 .macro fpsimd_restore state, tmpnr
 	ldp	q0, q1, [\state, #16 * 0]
 	ldp	q2, q3, [\state, #16 * 2]
@@ -60,7 +61,15 @@
 	ldr	w\tmpnr, [\state, #16 * 2]
 	msr	fpsr, x\tmpnr
 	ldr	w\tmpnr, [\state, #16 * 2 + 4]
+	/*
+	 * Writes to fpcr may be self-synchronising, so avoid restoring
+	 * the register if it hasn't changed.
+	 */
+	mrs	\state, fpcr
+	cmp	x\tmpnr, \state
+	b.eq	9999f
 	msr	fpcr, x\tmpnr
+9999:
 .endm
 
 .altmacro
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed
  2014-06-26 17:34 [PATCH] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed Will Deacon
@ 2014-06-26 21:10 ` Ard Biesheuvel
  2014-06-27  8:58   ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2014-06-26 21:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hey Will,

On 26 June 2014 19:34, Will Deacon <will.deacon@arm.com> wrote:
> Writing to the FPCR is commonly implemented as a self-synchronising
> operation in the CPU, so avoid writing to the register when the saved
> value matches that in the hardware already.
>
> Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm64/include/asm/fpsimdmacros.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/arch/arm64/include/asm/fpsimdmacros.h b/arch/arm64/include/asm/fpsimdmacros.h
> index 768414d55e64..137c0f45b0a8 100644
> --- a/arch/arm64/include/asm/fpsimdmacros.h
> +++ b/arch/arm64/include/asm/fpsimdmacros.h
> @@ -40,6 +40,7 @@
>         str     w\tmpnr, [\state, #16 * 2 + 4]
>  .endm
>
> +/* Clobbers \state */
>  .macro fpsimd_restore state, tmpnr
>         ldp     q0, q1, [\state, #16 * 0]
>         ldp     q2, q3, [\state, #16 * 2]
> @@ -60,7 +61,15 @@
>         ldr     w\tmpnr, [\state, #16 * 2]
>         msr     fpsr, x\tmpnr
>         ldr     w\tmpnr, [\state, #16 * 2 + 4]
> +       /*
> +        * Writes to fpcr may be self-synchronising, so avoid restoring
> +        * the register if it hasn't changed.
> +        */
> +       mrs     \state, fpcr
> +       cmp     x\tmpnr, \state
> +       b.eq    9999f
>         msr     fpcr, x\tmpnr
> +9999:
>  .endm
>

I would assume the same would apply to the partial restore that was
merged during the last window?

-- 
Ard.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed
  2014-06-26 21:10 ` Ard Biesheuvel
@ 2014-06-27  8:58   ` Will Deacon
  0 siblings, 0 replies; 3+ messages in thread
From: Will Deacon @ 2014-06-27  8:58 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 26, 2014 at 10:10:00PM +0100, Ard Biesheuvel wrote:
> Hey Will,

Hi Ard,

> On 26 June 2014 19:34, Will Deacon <will.deacon@arm.com> wrote:
> > Writing to the FPCR is commonly implemented as a self-synchronising
> > operation in the CPU, so avoid writing to the register when the saved
> > value matches that in the hardware already.
> >
> > Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> > Signed-off-by: Will Deacon <will.deacon@arm.com>
> > ---
> >  arch/arm64/include/asm/fpsimdmacros.h | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/arch/arm64/include/asm/fpsimdmacros.h b/arch/arm64/include/asm/fpsimdmacros.h
> > index 768414d55e64..137c0f45b0a8 100644
> > --- a/arch/arm64/include/asm/fpsimdmacros.h
> > +++ b/arch/arm64/include/asm/fpsimdmacros.h
> > @@ -40,6 +40,7 @@
> >         str     w\tmpnr, [\state, #16 * 2 + 4]
> >  .endm
> >
> > +/* Clobbers \state */
> >  .macro fpsimd_restore state, tmpnr
> >         ldp     q0, q1, [\state, #16 * 0]
> >         ldp     q2, q3, [\state, #16 * 2]
> > @@ -60,7 +61,15 @@
> >         ldr     w\tmpnr, [\state, #16 * 2]
> >         msr     fpsr, x\tmpnr
> >         ldr     w\tmpnr, [\state, #16 * 2 + 4]
> > +       /*
> > +        * Writes to fpcr may be self-synchronising, so avoid restoring
> > +        * the register if it hasn't changed.
> > +        */
> > +       mrs     \state, fpcr
> > +       cmp     x\tmpnr, \state
> > +       b.eq    9999f
> >         msr     fpcr, x\tmpnr
> > +9999:
> >  .endm
> >
> 
> I would assume the same would apply to the partial restore that was
> merged during the last window?

Good point; I'll take a look.

Cheers,

Will

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-27  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-26 17:34 [PATCH] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed Will Deacon
2014-06-26 21:10 ` Ard Biesheuvel
2014-06-27  8:58   ` Will Deacon

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).