stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: intel: powerclamp: Fix cpumask and max_idle module parameters
@ 2023-03-30 13:42 David Arcari
  2023-03-30 17:36 ` srinivas pandruvada
  0 siblings, 1 reply; 3+ messages in thread
From: David Arcari @ 2023-03-30 13:42 UTC (permalink / raw)
  To: linux-pm
  Cc: David Arcari, Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria,
	Zhang Rui, Srinivas Pandruvada, Chen Yu, linux-kernel, stable

When cpumask is specified as a module parameter the value is
overwritten by the module init routine.  This can easily be fixed
by checking to see if the mask has already been allocated in the
init routine.

When max_idle is specified as a module parameter a panic will occur.
The problem is that the idle_injection_cpu_mask is not allocated until
the module init routine executes. This can easily be fixed by allocating
the cpumask if it's not already allocated.

Fixes: ebf519710218 ("thermal: intel: powerclamp: Add two module parameters")

Signed-off-by: David Arcari <darcari@redhat.com>

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: David Arcari <darcari@redhat.com>
Cc: Chen Yu <yu.c.chen@intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org

---
 drivers/thermal/intel/intel_powerclamp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index c7ba5680cd48..91fc7e239497 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -235,6 +235,12 @@ static int max_idle_set(const char *arg, const struct kernel_param *kp)
 		goto skip_limit_set;
 	}
 
+	if (!cpumask_available(idle_injection_cpu_mask)) {
+		ret = allocate_copy_idle_injection_mask(cpu_present_mask);
+		if (ret)
+			goto skip_limit_set;
+	}
+
 	if (check_invalid(idle_injection_cpu_mask, new_max_idle)) {
 		ret = -EINVAL;
 		goto skip_limit_set;
@@ -791,7 +797,8 @@ static int __init powerclamp_init(void)
 		return retval;
 
 	mutex_lock(&powerclamp_lock);
-	retval = allocate_copy_idle_injection_mask(cpu_present_mask);
+	if (!cpumask_available(idle_injection_cpu_mask))
+		retval = allocate_copy_idle_injection_mask(cpu_present_mask);
 	mutex_unlock(&powerclamp_lock);
 
 	if (retval)
-- 
2.27.0


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

* Re: [PATCH] thermal: intel: powerclamp: Fix cpumask and max_idle module parameters
  2023-03-30 13:42 [PATCH] thermal: intel: powerclamp: Fix cpumask and max_idle module parameters David Arcari
@ 2023-03-30 17:36 ` srinivas pandruvada
  2023-03-30 18:06   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: srinivas pandruvada @ 2023-03-30 17:36 UTC (permalink / raw)
  To: David Arcari, linux-pm
  Cc: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
	Chen Yu, linux-kernel, stable

On Thu, 2023-03-30 at 09:42 -0400, David Arcari wrote:
Reviewed-by: Srinivas Pandruvada <>> When cpumask is specified as a module parameter the value is
> overwritten by the module init routine.  This can easily be fixed
> by checking to see if the mask has already been allocated in the
> init routine.
> 
> When max_idle is specified as a module parameter a panic will occur.
> The problem is that the idle_injection_cpu_mask is not allocated
> until
> the module init routine executes. This can easily be fixed by
> allocating
> the cpumask if it's not already allocated.
> 
> Fixes: ebf519710218 ("thermal: intel: powerclamp: Add two module
> parameters")
> 
> Signed-off-by: David Arcari <darcari@redhat.com>
Reviewed-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com>

> 
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Amit Kucheria <amitk@kernel.org>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: David Arcari <darcari@redhat.com>
> Cc: Chen Yu <yu.c.chen@intel.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> 
> ---
>  drivers/thermal/intel/intel_powerclamp.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/intel/intel_powerclamp.c
> b/drivers/thermal/intel/intel_powerclamp.c
> index c7ba5680cd48..91fc7e239497 100644
> --- a/drivers/thermal/intel/intel_powerclamp.c
> +++ b/drivers/thermal/intel/intel_powerclamp.c
> @@ -235,6 +235,12 @@ static int max_idle_set(const char *arg, const
> struct kernel_param *kp)
>                 goto skip_limit_set;
>         }
>  
> +       if (!cpumask_available(idle_injection_cpu_mask)) {
> +               ret =
> allocate_copy_idle_injection_mask(cpu_present_mask);
> +               if (ret)
> +                       goto skip_limit_set;
> +       }
> +
>         if (check_invalid(idle_injection_cpu_mask, new_max_idle)) {
>                 ret = -EINVAL;
>                 goto skip_limit_set;
> @@ -791,7 +797,8 @@ static int __init powerclamp_init(void)
>                 return retval;
>  
>         mutex_lock(&powerclamp_lock);
> -       retval = allocate_copy_idle_injection_mask(cpu_present_mask);
> +       if (!cpumask_available(idle_injection_cpu_mask))
> +               retval =
> allocate_copy_idle_injection_mask(cpu_present_mask);
>         mutex_unlock(&powerclamp_lock);
>  
>         if (retval)


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

* Re: [PATCH] thermal: intel: powerclamp: Fix cpumask and max_idle module parameters
  2023-03-30 17:36 ` srinivas pandruvada
@ 2023-03-30 18:06   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2023-03-30 18:06 UTC (permalink / raw)
  To: srinivas pandruvada, David Arcari
  Cc: linux-pm, Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria,
	Zhang Rui, Chen Yu, linux-kernel, stable

On Thu, Mar 30, 2023 at 7:36 PM srinivas pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> On Thu, 2023-03-30 at 09:42 -0400, David Arcari wrote:
> Reviewed-by: Srinivas Pandruvada <>> When cpumask is specified as a module parameter the value is
> > overwritten by the module init routine.  This can easily be fixed
> > by checking to see if the mask has already been allocated in the
> > init routine.
> >
> > When max_idle is specified as a module parameter a panic will occur.
> > The problem is that the idle_injection_cpu_mask is not allocated
> > until
> > the module init routine executes. This can easily be fixed by
> > allocating
> > the cpumask if it's not already allocated.
> >
> > Fixes: ebf519710218 ("thermal: intel: powerclamp: Add two module
> > parameters")
> >
> > Signed-off-by: David Arcari <darcari@redhat.com>
> Reviewed-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com>

Applied as 6.3-rc material, thanks!

> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: Amit Kucheria <amitk@kernel.org>
> > Cc: Zhang Rui <rui.zhang@intel.com>
> > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> > Cc: David Arcari <darcari@redhat.com>
> > Cc: Chen Yu <yu.c.chen@intel.com>
> > Cc: linux-kernel@vger.kernel.org
> > Cc: stable@vger.kernel.org
> >
> > ---
> >  drivers/thermal/intel/intel_powerclamp.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/intel/intel_powerclamp.c
> > b/drivers/thermal/intel/intel_powerclamp.c
> > index c7ba5680cd48..91fc7e239497 100644
> > --- a/drivers/thermal/intel/intel_powerclamp.c
> > +++ b/drivers/thermal/intel/intel_powerclamp.c
> > @@ -235,6 +235,12 @@ static int max_idle_set(const char *arg, const
> > struct kernel_param *kp)
> >                 goto skip_limit_set;
> >         }
> >
> > +       if (!cpumask_available(idle_injection_cpu_mask)) {
> > +               ret =
> > allocate_copy_idle_injection_mask(cpu_present_mask);
> > +               if (ret)
> > +                       goto skip_limit_set;
> > +       }
> > +
> >         if (check_invalid(idle_injection_cpu_mask, new_max_idle)) {
> >                 ret = -EINVAL;
> >                 goto skip_limit_set;
> > @@ -791,7 +797,8 @@ static int __init powerclamp_init(void)
> >                 return retval;
> >
> >         mutex_lock(&powerclamp_lock);
> > -       retval = allocate_copy_idle_injection_mask(cpu_present_mask);
> > +       if (!cpumask_available(idle_injection_cpu_mask))
> > +               retval =
> > allocate_copy_idle_injection_mask(cpu_present_mask);
> >         mutex_unlock(&powerclamp_lock);
> >
> >         if (retval)
>

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

end of thread, other threads:[~2023-03-30 18:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 13:42 [PATCH] thermal: intel: powerclamp: Fix cpumask and max_idle module parameters David Arcari
2023-03-30 17:36 ` srinivas pandruvada
2023-03-30 18:06   ` Rafael J. Wysocki

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