diff mbox series

cpufreq: dt: always allocate zeroed cpumask

Message ID 20240314125457.186678-1-m.szyprowski@samsung.com (mailing list archive)
State New
Delegated to: viresh kumar
Headers show
Series cpufreq: dt: always allocate zeroed cpumask | expand

Commit Message

Marek Szyprowski March 14, 2024, 12:54 p.m. UTC
Commit 0499a78369ad ("ARM64: Dynamically allocate cpumasks and increase
supported CPUs to 512") changed the handling of cpumasks on ARM 64bit,
what resulted in the strange issues and warnings during cpufreq-dt
initialization on some big.LITTLE platforms.

This was caused by mixing OPPs between big and LITTLE cores, because
OPP-sharing information between big and LITTLE cores is computed on
cpumask, which in turn was not zeroed on allocation. Fix this by
switching to zalloc_cpumask_var() call.

Fixes: dc279ac6e5b4 ("cpufreq: dt: Refactor initialization to handle probe deferral properly")
CC: stable@vger.kernel.org # v5.10+
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/cpufreq/cpufreq-dt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Lameter (Ampere) March 14, 2024, 5:18 p.m. UTC | #1
On Thu, 14 Mar 2024, Marek Szyprowski wrote:

> -	if (!alloc_cpumask_var(&priv->cpus, GFP_KERNEL))
> +	if (!zalloc_cpumask_var(&priv->cpus, GFP_KERNEL))
> 		return -ENOMEM;

Reviewed-by: Christoph Lameter (Ampere) <cl@linux.com>
Dhruva Gole March 15, 2024, 5:27 a.m. UTC | #2
On Mar 14, 2024 at 13:54:57 +0100, Marek Szyprowski wrote:
> Commit 0499a78369ad ("ARM64: Dynamically allocate cpumasks and increase
> supported CPUs to 512") changed the handling of cpumasks on ARM 64bit,
> what resulted in the strange issues and warnings during cpufreq-dt
> initialization on some big.LITTLE platforms.
> 
> This was caused by mixing OPPs between big and LITTLE cores, because
> OPP-sharing information between big and LITTLE cores is computed on
> cpumask, which in turn was not zeroed on allocation. Fix this by
> switching to zalloc_cpumask_var() call.
> 
> Fixes: dc279ac6e5b4 ("cpufreq: dt: Refactor initialization to handle probe deferral properly")
> CC: stable@vger.kernel.org # v5.10+
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  drivers/cpufreq/cpufreq-dt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index 8bd6e5e8f121..2d83bbc65dd0 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -208,7 +208,7 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)
>  	if (!priv)
>  		return -ENOMEM;
>  
> -	if (!alloc_cpumask_var(&priv->cpus, GFP_KERNEL))
> +	if (!zalloc_cpumask_var(&priv->cpus, GFP_KERNEL))
>  		return -ENOMEM;

Good catch!

Reviewed-by: Dhruva Gole <d-gole@ti.com>
Viresh Kumar March 15, 2024, 5:50 a.m. UTC | #3
On 14-03-24, 13:54, Marek Szyprowski wrote:
> Commit 0499a78369ad ("ARM64: Dynamically allocate cpumasks and increase
> supported CPUs to 512") changed the handling of cpumasks on ARM 64bit,
> what resulted in the strange issues and warnings during cpufreq-dt
> initialization on some big.LITTLE platforms.
> 
> This was caused by mixing OPPs between big and LITTLE cores, because
> OPP-sharing information between big and LITTLE cores is computed on
> cpumask, which in turn was not zeroed on allocation. Fix this by
> switching to zalloc_cpumask_var() call.
> 
> Fixes: dc279ac6e5b4 ("cpufreq: dt: Refactor initialization to handle probe deferral properly")
> CC: stable@vger.kernel.org # v5.10+
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  drivers/cpufreq/cpufreq-dt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index 8bd6e5e8f121..2d83bbc65dd0 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -208,7 +208,7 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)
>  	if (!priv)
>  		return -ENOMEM;
>  
> -	if (!alloc_cpumask_var(&priv->cpus, GFP_KERNEL))
> +	if (!zalloc_cpumask_var(&priv->cpus, GFP_KERNEL))
>  		return -ENOMEM;
>  
>  	cpumask_set_cpu(cpu, priv->cpus);

Applied. Thanks.
diff mbox series

Patch

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 8bd6e5e8f121..2d83bbc65dd0 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -208,7 +208,7 @@  static int dt_cpufreq_early_init(struct device *dev, int cpu)
 	if (!priv)
 		return -ENOMEM;
 
-	if (!alloc_cpumask_var(&priv->cpus, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&priv->cpus, GFP_KERNEL))
 		return -ENOMEM;
 
 	cpumask_set_cpu(cpu, priv->cpus);