diff mbox series

Tie tm-suspend fw-feature and opal_reinit_cpus() together

Message ID 20180302030809.19122-1-mikey@neuling.org
State Superseded
Headers show
Series Tie tm-suspend fw-feature and opal_reinit_cpus() together | expand

Commit Message

Michael Neuling March 2, 2018, 3:08 a.m. UTC
Currently opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED)
always returns OPAL_UNSUPPORTED.

This ties the tm suspend fw-feature to the
opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) so that when tm
suspend is disabled, we correctly report it to the kernel.  For
backwards compatibility, it's assumed tm suspend is available if the
fw-feature is not present.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 core/cpu.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

Comments

Cyril Bur March 4, 2018, 11:21 p.m. UTC | #1
On Fri, 2018-03-02 at 14:08 +1100, Michael Neuling wrote:
> Currently opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED)
> always returns OPAL_UNSUPPORTED.

I wonder if more of a mention of how the mode is set by hostboot on IPL
. I seem unable to actually come up with that I feel is missing.

> 
> This ties the tm suspend fw-feature to the
> opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) so that when tm
> suspend is disabled, we correctly report it to the kernel.  For
> backwards compatibility, it's assumed tm suspend is available if the
> fw-feature is not present.
> 
> Signed-off-by: Michael Neuling <mikey@neuling.org>

Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>

> ---
>  core/cpu.c | 27 ++++++++++++++++++++++-----
>  1 file changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/core/cpu.c b/core/cpu.c
> index 2eab522553..7a9dbe5d70 100644
> --- a/core/cpu.c
> +++ b/core/cpu.c
> @@ -57,6 +57,7 @@ static bool ipi_enabled;
>  static bool pm_enabled;
>  static bool current_hile_mode;
>  static bool current_radix_mode;
> +static bool tm_suspend_enabled;
>  
>  unsigned long cpu_secondary_start __force_data = 0;
>  
> @@ -1012,6 +1013,21 @@ static int find_dec_bits(void)
>  	return bits;
>  }
>  
> +static void init_tm_suspend_mode_property(void)
> +{
> +	struct dt_node *node;
> +
> +	/* If we don't find anything, assume TM suspend is enabled */
> +	tm_suspend_enabled = true;
> +
> +	node = dt_find_by_path(dt_root, "/ibm,opal/fw-features/tm-suspend-mode");
> +	if (!node)
> +		return;
> +
> +	if (dt_find_property(node, "disabled"))
> +		tm_suspend_enabled = false;
> +}
> +
>  void init_all_cpus(void)
>  {
>  	struct dt_node *cpus, *cpu;
> @@ -1021,6 +1037,8 @@ void init_all_cpus(void)
>  	cpus = dt_find_by_path(dt_root, "/cpus");
>  	assert(cpus);
>  
> +	init_tm_suspend_mode_property();
> +
>  	/* Iterate all CPUs in the device-tree */
>  	dt_for_each_child(cpus, cpu) {
>  		unsigned int pir, server_no, chip_id;
> @@ -1436,11 +1454,10 @@ static int64_t opal_reinit_cpus(uint64_t flags)
>  	if (flags & OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) {
>  		flags &= ~OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED;
>  
> -		/*
> -		 * Pending a hostboot change we can't determine the status of
> -		 * this, so it always fails.
> -		 */
> -		rc = OPAL_UNSUPPORTED;
> +		if (tm_suspend_enabled)
> +			rc = OPAL_UNSUPPORTED;
> +		else
> +			rc = OPAL_SUCCESS;
>  	}
>  
>  	/* Handle P8 DD1 SLW reinit */
Michael Neuling March 4, 2018, 11:40 p.m. UTC | #2
On Mon, 2018-03-05 at 10:21 +1100, Cyril Bur wrote:
> On Fri, 2018-03-02 at 14:08 +1100, Michael Neuling wrote:
> > Currently opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED)
> > always returns OPAL_UNSUPPORTED.
> 
> I wonder if more of a mention of how the mode is set by hostboot on IPL
> . I seem unable to actually come up with that I feel is missing.

Currently it's an IPL time init setting which is tied to the DD revision of the
chip.  It's only on for DD2.1 currently.

Long term, we'd like to be able to switch this dynamically, but we are not there
yet.

I can add something like that if you like?

> > 
> > This ties the tm suspend fw-feature to the
> > opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) so that when tm
> > suspend is disabled, we correctly report it to the kernel.  For
> > backwards compatibility, it's assumed tm suspend is available if the
> > fw-feature is not present.
> > 
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
> 
> Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>

Thanks

Mikey

> 
> > ---
> >  core/cpu.c | 27 ++++++++++++++++++++++-----
> >  1 file changed, 22 insertions(+), 5 deletions(-)
> > 
> > diff --git a/core/cpu.c b/core/cpu.c
> > index 2eab522553..7a9dbe5d70 100644
> > --- a/core/cpu.c
> > +++ b/core/cpu.c
> > @@ -57,6 +57,7 @@ static bool ipi_enabled;
> >  static bool pm_enabled;
> >  static bool current_hile_mode;
> >  static bool current_radix_mode;
> > +static bool tm_suspend_enabled;
> >  
> >  unsigned long cpu_secondary_start __force_data = 0;
> >  
> > @@ -1012,6 +1013,21 @@ static int find_dec_bits(void)
> >  	return bits;
> >  }
> >  
> > +static void init_tm_suspend_mode_property(void)
> > +{
> > +	struct dt_node *node;
> > +
> > +	/* If we don't find anything, assume TM suspend is enabled */
> > +	tm_suspend_enabled = true;
> > +
> > +	node = dt_find_by_path(dt_root, "/ibm,opal/fw-features/tm-suspend-
> > mode");
> > +	if (!node)
> > +		return;
> > +
> > +	if (dt_find_property(node, "disabled"))
> > +		tm_suspend_enabled = false;
> > +}
> > +
> >  void init_all_cpus(void)
> >  {
> >  	struct dt_node *cpus, *cpu;
> > @@ -1021,6 +1037,8 @@ void init_all_cpus(void)
> >  	cpus = dt_find_by_path(dt_root, "/cpus");
> >  	assert(cpus);
> >  
> > +	init_tm_suspend_mode_property();
> > +
> >  	/* Iterate all CPUs in the device-tree */
> >  	dt_for_each_child(cpus, cpu) {
> >  		unsigned int pir, server_no, chip_id;
> > @@ -1436,11 +1454,10 @@ static int64_t opal_reinit_cpus(uint64_t flags)
> >  	if (flags & OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) {
> >  		flags &= ~OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED;
> >  
> > -		/*
> > -		 * Pending a hostboot change we can't determine the status
> > of
> > -		 * this, so it always fails.
> > -		 */
> > -		rc = OPAL_UNSUPPORTED;
> > +		if (tm_suspend_enabled)
> > +			rc = OPAL_UNSUPPORTED;
> > +		else
> > +			rc = OPAL_SUCCESS;
> >  	}
> >  
> >  	/* Handle P8 DD1 SLW reinit */
> 
>
Oliver O'Halloran March 4, 2018, 11:56 p.m. UTC | #3
On Mon, Mar 5, 2018 at 10:40 AM, Michael Neuling <mikey@neuling.org> wrote:
> On Mon, 2018-03-05 at 10:21 +1100, Cyril Bur wrote:
>> On Fri, 2018-03-02 at 14:08 +1100, Michael Neuling wrote:
>> > Currently opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED)
>> > always returns OPAL_UNSUPPORTED.
>>
>> I wonder if more of a mention of how the mode is set by hostboot on IPL
>> . I seem unable to actually come up with that I feel is missing.
>
> Currently it's an IPL time init setting which is tied to the DD revision of the
> chip.  It's only on for DD2.1 currently.
>
> Long term, we'd like to be able to switch this dynamically, but we are not there
> yet.

IIRC the plan was the have some call to PRD that would patch the core
inits in the HCODE image to allow this sort of tweaking. I have no
idea what the ETA on that would be.

> I can add something like that if you like?

Add what?

>
>> >
>> > This ties the tm suspend fw-feature to the
>> > opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) so that when tm
>> > suspend is disabled, we correctly report it to the kernel.  For
>> > backwards compatibility, it's assumed tm suspend is available if the
>> > fw-feature is not present.
>> >
>> > Signed-off-by: Michael Neuling <mikey@neuling.org>
>>
>> Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
>
> Thanks
>
> Mikey
>
>>
>> > ---
>> >  core/cpu.c | 27 ++++++++++++++++++++++-----
>> >  1 file changed, 22 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/core/cpu.c b/core/cpu.c
>> > index 2eab522553..7a9dbe5d70 100644
>> > --- a/core/cpu.c
>> > +++ b/core/cpu.c
>> > @@ -57,6 +57,7 @@ static bool ipi_enabled;
>> >  static bool pm_enabled;
>> >  static bool current_hile_mode;
>> >  static bool current_radix_mode;
>> > +static bool tm_suspend_enabled;
>> >
>> >  unsigned long cpu_secondary_start __force_data = 0;
>> >
>> > @@ -1012,6 +1013,21 @@ static int find_dec_bits(void)
>> >     return bits;
>> >  }
>> >
>> > +static void init_tm_suspend_mode_property(void)
>> > +{
>> > +   struct dt_node *node;
>> > +
>> > +   /* If we don't find anything, assume TM suspend is enabled */
>> > +   tm_suspend_enabled = true;
>> > +
>> > +   node = dt_find_by_path(dt_root, "/ibm,opal/fw-features/tm-suspend-
>> > mode");
>> > +   if (!node)
>> > +           return;
>> > +
>> > +   if (dt_find_property(node, "disabled"))
>> > +           tm_suspend_enabled = false;
>> > +}
>> > +
>> >  void init_all_cpus(void)
>> >  {
>> >     struct dt_node *cpus, *cpu;
>> > @@ -1021,6 +1037,8 @@ void init_all_cpus(void)
>> >     cpus = dt_find_by_path(dt_root, "/cpus");
>> >     assert(cpus);
>> >
>> > +   init_tm_suspend_mode_property();
>> > +
>> >     /* Iterate all CPUs in the device-tree */
>> >     dt_for_each_child(cpus, cpu) {
>> >             unsigned int pir, server_no, chip_id;
>> > @@ -1436,11 +1454,10 @@ static int64_t opal_reinit_cpus(uint64_t flags)
>> >     if (flags & OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) {
>> >             flags &= ~OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED;
>> >
>> > -           /*
>> > -            * Pending a hostboot change we can't determine the status
>> > of
>> > -            * this, so it always fails.
>> > -            */
>> > -           rc = OPAL_UNSUPPORTED;
>> > +           if (tm_suspend_enabled)
>> > +                   rc = OPAL_UNSUPPORTED;
>> > +           else
>> > +                   rc = OPAL_SUCCESS;
>> >     }
>> >
>> >     /* Handle P8 DD1 SLW reinit */
>>
>>
Cyril Bur March 4, 2018, 11:57 p.m. UTC | #4
On Mon, 2018-03-05 at 10:40 +1100, Michael Neuling wrote:
> On Mon, 2018-03-05 at 10:21 +1100, Cyril Bur wrote:
> > On Fri, 2018-03-02 at 14:08 +1100, Michael Neuling wrote:
> > > Currently opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED)
> > > always returns OPAL_UNSUPPORTED.
> > 
> > I wonder if more of a mention of how the mode is set by hostboot on IPL
> > . I seem unable to actually come up with that I feel is missing.
> 
> Currently it's an IPL time init setting which is tied to the DD revision of the
> chip.  It's only on for DD2.1 currently.
> 
> Long term, we'd like to be able to switch this dynamically, but we are not there
> yet.
> 
> I can add something like that if you like?
> 

Big thumbs up.

> > > 
> > > This ties the tm suspend fw-feature to the
> > > opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) so that when tm
> > > suspend is disabled, we correctly report it to the kernel.  For
> > > backwards compatibility, it's assumed tm suspend is available if the
> > > fw-feature is not present.
> > > 
> > > Signed-off-by: Michael Neuling <mikey@neuling.org>
> > 
> > Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
> 
> Thanks
> 
> Mikey
> 
> > 
> > > ---
> > >  core/cpu.c | 27 ++++++++++++++++++++++-----
> > >  1 file changed, 22 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/core/cpu.c b/core/cpu.c
> > > index 2eab522553..7a9dbe5d70 100644
> > > --- a/core/cpu.c
> > > +++ b/core/cpu.c
> > > @@ -57,6 +57,7 @@ static bool ipi_enabled;
> > >  static bool pm_enabled;
> > >  static bool current_hile_mode;
> > >  static bool current_radix_mode;
> > > +static bool tm_suspend_enabled;
> > >  
> > >  unsigned long cpu_secondary_start __force_data = 0;
> > >  
> > > @@ -1012,6 +1013,21 @@ static int find_dec_bits(void)
> > >  	return bits;
> > >  }
> > >  
> > > +static void init_tm_suspend_mode_property(void)
> > > +{
> > > +	struct dt_node *node;
> > > +
> > > +	/* If we don't find anything, assume TM suspend is enabled */
> > > +	tm_suspend_enabled = true;
> > > +
> > > +	node = dt_find_by_path(dt_root, "/ibm,opal/fw-features/tm-suspend-
> > > mode");
> > > +	if (!node)
> > > +		return;
> > > +
> > > +	if (dt_find_property(node, "disabled"))
> > > +		tm_suspend_enabled = false;
> > > +}
> > > +
> > >  void init_all_cpus(void)
> > >  {
> > >  	struct dt_node *cpus, *cpu;
> > > @@ -1021,6 +1037,8 @@ void init_all_cpus(void)
> > >  	cpus = dt_find_by_path(dt_root, "/cpus");
> > >  	assert(cpus);
> > >  
> > > +	init_tm_suspend_mode_property();
> > > +
> > >  	/* Iterate all CPUs in the device-tree */
> > >  	dt_for_each_child(cpus, cpu) {
> > >  		unsigned int pir, server_no, chip_id;
> > > @@ -1436,11 +1454,10 @@ static int64_t opal_reinit_cpus(uint64_t flags)
> > >  	if (flags & OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) {
> > >  		flags &= ~OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED;
> > >  
> > > -		/*
> > > -		 * Pending a hostboot change we can't determine the status
> > > of
> > > -		 * this, so it always fails.
> > > -		 */
> > > -		rc = OPAL_UNSUPPORTED;
> > > +		if (tm_suspend_enabled)
> > > +			rc = OPAL_UNSUPPORTED;
> > > +		else
> > > +			rc = OPAL_SUCCESS;
> > >  	}
> > >  
> > >  	/* Handle P8 DD1 SLW reinit */
> > 
> >
Michael Neuling March 5, 2018, 12:33 a.m. UTC | #5
On Mon, 2018-03-05 at 10:56 +1100, Oliver wrote:
> On Mon, Mar 5, 2018 at 10:40 AM, Michael Neuling <mikey@neuling.org> wrote:
> > On Mon, 2018-03-05 at 10:21 +1100, Cyril Bur wrote:
> > > On Fri, 2018-03-02 at 14:08 +1100, Michael Neuling wrote:
> > > > Currently opal_reinit_cpus(OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED)
> > > > always returns OPAL_UNSUPPORTED.
> > > 
> > > I wonder if more of a mention of how the mode is set by hostboot on IPL
> > > . I seem unable to actually come up with that I feel is missing.
> > 
> > Currently it's an IPL time init setting which is tied to the DD revision of
> > the
> > chip.  It's only on for DD2.1 currently.
> > 
> > Long term, we'd like to be able to switch this dynamically, but we are not
> > there
> > yet.
> 
> IIRC the plan was the have some call to PRD that would patch the core
> inits in the HCODE image to allow this sort of tweaking. I have no
> idea what the ETA on that would be.
> 
> > I can add something like that if you like?
> 
> Add what?

Just the comment to the commit message.

Mikey
diff mbox series

Patch

diff --git a/core/cpu.c b/core/cpu.c
index 2eab522553..7a9dbe5d70 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -57,6 +57,7 @@  static bool ipi_enabled;
 static bool pm_enabled;
 static bool current_hile_mode;
 static bool current_radix_mode;
+static bool tm_suspend_enabled;
 
 unsigned long cpu_secondary_start __force_data = 0;
 
@@ -1012,6 +1013,21 @@  static int find_dec_bits(void)
 	return bits;
 }
 
+static void init_tm_suspend_mode_property(void)
+{
+	struct dt_node *node;
+
+	/* If we don't find anything, assume TM suspend is enabled */
+	tm_suspend_enabled = true;
+
+	node = dt_find_by_path(dt_root, "/ibm,opal/fw-features/tm-suspend-mode");
+	if (!node)
+		return;
+
+	if (dt_find_property(node, "disabled"))
+		tm_suspend_enabled = false;
+}
+
 void init_all_cpus(void)
 {
 	struct dt_node *cpus, *cpu;
@@ -1021,6 +1037,8 @@  void init_all_cpus(void)
 	cpus = dt_find_by_path(dt_root, "/cpus");
 	assert(cpus);
 
+	init_tm_suspend_mode_property();
+
 	/* Iterate all CPUs in the device-tree */
 	dt_for_each_child(cpus, cpu) {
 		unsigned int pir, server_no, chip_id;
@@ -1436,11 +1454,10 @@  static int64_t opal_reinit_cpus(uint64_t flags)
 	if (flags & OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED) {
 		flags &= ~OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED;
 
-		/*
-		 * Pending a hostboot change we can't determine the status of
-		 * this, so it always fails.
-		 */
-		rc = OPAL_UNSUPPORTED;
+		if (tm_suspend_enabled)
+			rc = OPAL_UNSUPPORTED;
+		else
+			rc = OPAL_SUCCESS;
 	}
 
 	/* Handle P8 DD1 SLW reinit */