[PATCH] [Zesty] UBUNTU: SAUCE: powerpc/powernv: Tell OPAL about our MMU mode on POWER9

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] [Zesty] UBUNTU: SAUCE: powerpc/powernv: Tell OPAL about our MMU mode on POWER9

Breno Leitao
From: Benjamin Herrenschmidt <[hidden email]>

BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1702159

That will allow OPAL to configure the CPU in an optimal way.

Signed-off-by: Benjamin Herrenschmidt <[hidden email]>
Signed-off-by: Michael Neuling <[hidden email]>
Signed-off-by: Breno Leitao <[hidden email]>
---
 arch/powerpc/include/asm/opal-api.h    |  9 +++++++++
 arch/powerpc/platforms/powernv/opal.c  | 19 +++++++++++++++++--
 arch/powerpc/platforms/powernv/setup.c | 11 ++++++++++-
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
index cb3e6242a78c..85e6d8817fd1 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -805,6 +805,15 @@ struct OpalIoPhb3ErrorData {
 enum {
  OPAL_REINIT_CPUS_HILE_BE = (1 << 0),
  OPAL_REINIT_CPUS_HILE_LE = (1 << 1),
+
+ /* These two define the base MMU mode of the host on P9
+ *
+ * On P9 Nimbus DD2.0 and Cumlus (and later), KVM can still
+ * create hash guests in "radix" mode with care (full core
+ * switch only).
+ */
+ OPAL_REINIT_CPUS_MMU_HASH = (1 << 2),
+ OPAL_REINIT_CPUS_MMU_RADIX = (1 << 3),
 };
 
 typedef struct oppanel_line {
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index e0f856bfbfe8..a3b6de84f49c 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -59,6 +59,8 @@ static struct task_struct *kopald_tsk;
 
 void opal_configure_cores(void)
 {
+ uint64_t reinit_flags = 0;
+
  /* Do the actual re-init, This will clobber all FPRs, VRs, etc...
  *
  * It will preserve non volatile GPRs and HSPRG0/1. It will
@@ -66,11 +68,24 @@ void opal_configure_cores(void)
  * but it might clobber a bunch.
  */
 #ifdef __BIG_ENDIAN__
- opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
+ reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
 #else
- opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_LE);
+ reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
 #endif
 
+ /*
+ * POWER9 always support running hash:
+ *  ie. Host hash  supports  hash guests
+ *      Host radix supports  hash/radix guests
+ */
+ if (cpu_has_feature(CPU_FTR_ARCH_300)) {
+ reinit_flags |= OPAL_REINIT_CPUS_MMU_HASH;
+ if (early_radix_enabled())
+ reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX;
+ }
+
+ opal_reinit_cpus(reinit_flags);
+
  /* Restore some bits */
  if (cur_cpu_spec->cpu_restore)
  cur_cpu_spec->cpu_restore();
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index adceac978d18..dfe03d14ec55 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -221,6 +221,8 @@ static void pnv_kexec_wait_secondaries_down(void)
 
 static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
 {
+ uint64_t reinit_flags;
+
  if (xive_enabled())
  xive_kexec_teardown_cpu(secondary);
  else
@@ -250,8 +252,15 @@ static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
  * We might be running as little-endian - now that interrupts
  * are disabled, reset the HILE bit to big-endian so we don't
  * take interrupts in the wrong endian later
+ *
+ * We reinit to enable both radix and hash on P9 to ensure
+ * the mode used by the next kernel is always supported.
  */
- opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
+ reinit_flags = OPAL_REINIT_CPUS_HILE_BE;
+ if (cpu_has_feature(CPU_FTR_ARCH_300))
+ reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX |
+ OPAL_REINIT_CPUS_MMU_HASH;
+ opal_reinit_cpus(reinit_flags);
  }
 }
 #endif /* CONFIG_KEXEC_CORE */
--
2.11.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK/cmt / APPLIED[artful] : [PATCH] [Zesty] UBUNTU: SAUCE: powerpc/powernv: Tell OPAL about our MMU mode on POWER9

Seth Forshee
On Thu, Jul 06, 2017 at 11:43:15AM -0300, Breno Leitao wrote:
> From: Benjamin Herrenschmidt <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1702159
>
> That will allow OPAL to configure the CPU in an optimal way.
>
> Signed-off-by: Benjamin Herrenschmidt <[hidden email]>
> Signed-off-by: Michael Neuling <[hidden email]>
> Signed-off-by: Breno Leitao <[hidden email]>

Bug needs SRU justification added, but the patch looks okay and scope is
limited to powerpc.

Acked-by: Seth Forshee <[hidden email]>

Applied to artful/master-next and unstable/master.

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK/cmnt: [PATCH] [Zesty] UBUNTU: SAUCE: powerpc/powernv: Tell OPAL about our MMU mode on POWER9

Stefan Bader-2
In reply to this post by Breno Leitao
On 06.07.2017 16:43, Breno Leitao wrote:
> From: Benjamin Herrenschmidt <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1702159
>
> That will allow OPAL to configure the CPU in an optimal way.
>
> Signed-off-by: Benjamin Herrenschmidt <[hidden email]>
> Signed-off-by: Michael Neuling <[hidden email]>
> Signed-off-by: Breno Leitao <[hidden email]>

Acked-by: Stefan Bader <[hidden email]>

> ---

Bug report still pending SRU justification. Code looks self contained. Will this
go upstream, too?

-Stefan

>  arch/powerpc/include/asm/opal-api.h    |  9 +++++++++
>  arch/powerpc/platforms/powernv/opal.c  | 19 +++++++++++++++++--
>  arch/powerpc/platforms/powernv/setup.c | 11 ++++++++++-
>  3 files changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
> index cb3e6242a78c..85e6d8817fd1 100644
> --- a/arch/powerpc/include/asm/opal-api.h
> +++ b/arch/powerpc/include/asm/opal-api.h
> @@ -805,6 +805,15 @@ struct OpalIoPhb3ErrorData {
>  enum {
>   OPAL_REINIT_CPUS_HILE_BE = (1 << 0),
>   OPAL_REINIT_CPUS_HILE_LE = (1 << 1),
> +
> + /* These two define the base MMU mode of the host on P9
> + *
> + * On P9 Nimbus DD2.0 and Cumlus (and later), KVM can still
> + * create hash guests in "radix" mode with care (full core
> + * switch only).
> + */
> + OPAL_REINIT_CPUS_MMU_HASH = (1 << 2),
> + OPAL_REINIT_CPUS_MMU_RADIX = (1 << 3),
>  };
>  
>  typedef struct oppanel_line {
> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> index e0f856bfbfe8..a3b6de84f49c 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -59,6 +59,8 @@ static struct task_struct *kopald_tsk;
>  
>  void opal_configure_cores(void)
>  {
> + uint64_t reinit_flags = 0;
> +
>   /* Do the actual re-init, This will clobber all FPRs, VRs, etc...
>   *
>   * It will preserve non volatile GPRs and HSPRG0/1. It will
> @@ -66,11 +68,24 @@ void opal_configure_cores(void)
>   * but it might clobber a bunch.
>   */
>  #ifdef __BIG_ENDIAN__
> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
> + reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
>  #else
> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_LE);
> + reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
>  #endif
>  
> + /*
> + * POWER9 always support running hash:
> + *  ie. Host hash  supports  hash guests
> + *      Host radix supports  hash/radix guests
> + */
> + if (cpu_has_feature(CPU_FTR_ARCH_300)) {
> + reinit_flags |= OPAL_REINIT_CPUS_MMU_HASH;
> + if (early_radix_enabled())
> + reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX;
> + }
> +
> + opal_reinit_cpus(reinit_flags);
> +
>   /* Restore some bits */
>   if (cur_cpu_spec->cpu_restore)
>   cur_cpu_spec->cpu_restore();
> diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
> index adceac978d18..dfe03d14ec55 100644
> --- a/arch/powerpc/platforms/powernv/setup.c
> +++ b/arch/powerpc/platforms/powernv/setup.c
> @@ -221,6 +221,8 @@ static void pnv_kexec_wait_secondaries_down(void)
>  
>  static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
>  {
> + uint64_t reinit_flags;
> +
>   if (xive_enabled())
>   xive_kexec_teardown_cpu(secondary);
>   else
> @@ -250,8 +252,15 @@ static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
>   * We might be running as little-endian - now that interrupts
>   * are disabled, reset the HILE bit to big-endian so we don't
>   * take interrupts in the wrong endian later
> + *
> + * We reinit to enable both radix and hash on P9 to ensure
> + * the mode used by the next kernel is always supported.
>   */
> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
> + reinit_flags = OPAL_REINIT_CPUS_HILE_BE;
> + if (cpu_has_feature(CPU_FTR_ARCH_300))
> + reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX |
> + OPAL_REINIT_CPUS_MMU_HASH;
> + opal_reinit_cpus(reinit_flags);
>   }
>  }
>  #endif /* CONFIG_KEXEC_CORE */
>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ACK/cmnt: [PATCH] [Zesty] UBUNTU: SAUCE: powerpc/powernv: Tell OPAL about our MMU mode on POWER9

Michael Ellerman-2
Stefan Bader <[hidden email]> writes:

> On 06.07.2017 16:43, Breno Leitao wrote:
>> From: Benjamin Herrenschmidt <[hidden email]>
>>
>> BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1702159
>>
>> That will allow OPAL to configure the CPU in an optimal way.
>>
>> Signed-off-by: Benjamin Herrenschmidt <[hidden email]>
>> Signed-off-by: Michael Neuling <[hidden email]>
>> Signed-off-by: Breno Leitao <[hidden email]>
>
> Acked-by: Stefan Bader <[hidden email]>
>
>> ---
>
> Bug report still pending SRU justification. Code looks self contained. Will this
> go upstream, too?

It's in my fixes branch as of today:

  https://git.kernel.org/powerpc/c/1c0eaf0f56d6


Will go to Linus probably later this week.

cheers

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED/cmnt: [PATCH] [Zesty] UBUNTU: SAUCE: powerpc/powernv: Tell OPAL about our MMU mode on POWER9

Kleber Souza
In reply to this post by Breno Leitao
Applied to zesty/master-next branch.

The patch is already on Linus' tree, so I added the 'cherry picked from'
info to the commit message and removed the 'UBUNTU: SAUCE:' tags from
the subject.

I also fixed the BugLink to the format
http://bugs.launchpad.net/bugs/<bug-id>


Thanks,
Kleber

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] [Zesty] UBUNTU: SAUCE: powerpc/powernv: Tell OPAL about our MMU mode on POWER9

Michael Ellerman-2
In reply to this post by Breno Leitao
Breno Leitao <[hidden email]> writes:

> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> index e0f856bfbfe8..a3b6de84f49c 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -66,11 +68,24 @@ void opal_configure_cores(void)
>   * but it might clobber a bunch.
>   */
>  #ifdef __BIG_ENDIAN__
> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
> + reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
>  #else
> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_LE);
> + reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
>  #endif
>  
> + /*
> + * POWER9 always support running hash:
> + *  ie. Host hash  supports  hash guests
> + *      Host radix supports  hash/radix guests
> + */
> + if (cpu_has_feature(CPU_FTR_ARCH_300)) {

This is wrong. It can break booting on bare-metal Power8 machines with
some versions of firmware.

Fix here:

https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=fixes&id=a70b487b07cf4201bc6702e7f646fa593b23009f

http://patchwork.ozlabs.org/patch/789381/


cheers

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] [Zesty] UBUNTU: SAUCE: powerpc/powernv: Tell OPAL about our MMU mode on POWER9

Stefan Bader-2
On 18.07.2017 03:05, Michael Ellerman wrote:

> Breno Leitao <[hidden email]> writes:
>
>> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
>> index e0f856bfbfe8..a3b6de84f49c 100644
>> --- a/arch/powerpc/platforms/powernv/opal.c
>> +++ b/arch/powerpc/platforms/powernv/opal.c
>> @@ -66,11 +68,24 @@ void opal_configure_cores(void)
>>   * but it might clobber a bunch.
>>   */
>>  #ifdef __BIG_ENDIAN__
>> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
>> + reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
>>  #else
>> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_LE);
>> + reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
>>  #endif
>>  
>> + /*
>> + * POWER9 always support running hash:
>> + *  ie. Host hash  supports  hash guests
>> + *      Host radix supports  hash/radix guests
>> + */
>> + if (cpu_has_feature(CPU_FTR_ARCH_300)) {
>
> This is wrong. It can break booting on bare-metal Power8 machines with
> some versions of firmware.
>
> Fix here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=fixes&id=a70b487b07cf4201bc6702e7f646fa593b23009f
>
> http://patchwork.ozlabs.org/patch/789381/
Ok, that is in linux-next by now (see attached).

-Stefan
>
>
> cheers
>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

0001-powerpc-powernv-Fix-boot-on-Power8-bare-metal-due-to.patch (2K) Download Attachment
signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

ACK/APPLIED: [PATCH] [Zesty] powerpc/powernv: Fix boot on Power8 bare metal due to opal_configure_cores()

Kleber Souza
On 07/18/17 09:11, Stefan Bader wrote:

> On 18.07.2017 03:05, Michael Ellerman wrote:
>> Breno Leitao <[hidden email]> writes:
>>
>>> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
>>> index e0f856bfbfe8..a3b6de84f49c 100644
>>> --- a/arch/powerpc/platforms/powernv/opal.c
>>> +++ b/arch/powerpc/platforms/powernv/opal.c
>>> @@ -66,11 +68,24 @@ void opal_configure_cores(void)
>>>   * but it might clobber a bunch.
>>>   */
>>>  #ifdef __BIG_ENDIAN__
>>> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
>>> + reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
>>>  #else
>>> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_LE);
>>> + reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
>>>  #endif
>>>  
>>> + /*
>>> + * POWER9 always support running hash:
>>> + *  ie. Host hash  supports  hash guests
>>> + *      Host radix supports  hash/radix guests
>>> + */
>>> + if (cpu_has_feature(CPU_FTR_ARCH_300)) {
>>
>> This is wrong. It can break booting on bare-metal Power8 machines with
>> some versions of firmware.
>>
>> Fix here:
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=fixes&id=a70b487b07cf4201bc6702e7f646fa593b23009f
>>
>> http://patchwork.ozlabs.org/patch/789381/
>
> Ok, that is in linux-next by now (see attached).
>
> -Stefan

Attached patch (powerpc/powernv: Fix boot on Power8 bare metal due to
opal_configure_cores()) acked and applied to zesty/master-next branch.

Acked-by: Kleber Sacilotto de Souza <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED[artful]: [PATCH] [Zesty] powerpc/powernv: Fix boot on Power8 bare metal due to opal_configure_cores()

Seth Forshee
On Tue, Jul 18, 2017 at 09:42:59AM +0200, Kleber Souza wrote:

> On 07/18/17 09:11, Stefan Bader wrote:
> > On 18.07.2017 03:05, Michael Ellerman wrote:
> >> Breno Leitao <[hidden email]> writes:
> >>
> >>> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> >>> index e0f856bfbfe8..a3b6de84f49c 100644
> >>> --- a/arch/powerpc/platforms/powernv/opal.c
> >>> +++ b/arch/powerpc/platforms/powernv/opal.c
> >>> @@ -66,11 +68,24 @@ void opal_configure_cores(void)
> >>>   * but it might clobber a bunch.
> >>>   */
> >>>  #ifdef __BIG_ENDIAN__
> >>> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
> >>> + reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
> >>>  #else
> >>> - opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_LE);
> >>> + reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
> >>>  #endif
> >>>  
> >>> + /*
> >>> + * POWER9 always support running hash:
> >>> + *  ie. Host hash  supports  hash guests
> >>> + *      Host radix supports  hash/radix guests
> >>> + */
> >>> + if (cpu_has_feature(CPU_FTR_ARCH_300)) {
> >>
> >> This is wrong. It can break booting on bare-metal Power8 machines with
> >> some versions of firmware.
> >>
> >> Fix here:
> >>
> >> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=fixes&id=a70b487b07cf4201bc6702e7f646fa593b23009f
> >>
> >> http://patchwork.ozlabs.org/patch/789381/
> >
> > Ok, that is in linux-next by now (see attached).
> >
> > -Stefan
>
> Attached patch (powerpc/powernv: Fix boot on Power8 bare metal due to
> opal_configure_cores()) acked and applied to zesty/master-next branch.

Also applied to artful/master-next and unstable/master.

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team