Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1729162pxb; Thu, 16 Sep 2021 14:09:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWtwp+A6BI3jpVD3ZAcG0Xk4nHJA4tDazYPVp9Lemcj+iQztQA70KRBEN7xY+ykZRFPOZa X-Received: by 2002:a6b:3e89:: with SMTP id l131mr5953191ioa.74.1631826567309; Thu, 16 Sep 2021 14:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631826567; cv=none; d=google.com; s=arc-20160816; b=nHMdY+6n2V9r2uW0BHv0xvHMP4r5b8KvVtbfKjJZUF3YsVlZYgKYdrNO27KhILZnTI IV2hBVp0wRsXNa76oxK96UK2RKyAPqfcjeBItQDib4505OG6piEXQ18qCgfkbU9KxJ3Z vnBvwX3o8nq1QHnCZ/FG1cQUM/6xFVid5hBrrtsYRMKbdPsxtuA8H1kZ/Zr8xcavdvFI xk6wumLvwCeC+H8Y4aBfsqC+8SXJiGaQisaEoYKB3MyY9YrubSjJtI7CtHb3P9cmZGjR ap4ygK1456kn5GmImZI4/bVu0Sxg0eGvRBPp5dxIGyQ4WRPt3vuPLrq0Vpc7VYFuWYvT ePGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KBAkCW98I1fxzekaUx4gkIov2bSOtCXxQppvdYeX0Jg=; b=q8yolcaKI0rOho98hAv+IgmTsZG5bl9ACY1AdvyuAceLfJIIv+P/MNuo1klyiMloK6 kgIGQH9tksvZeF5pKKGQcg5Qd59rFMvErmxT191WvCHVjI9fFNpawSHTcA7h6vTAZtL2 GMfUohKZuhgkJsRo0wsGgSk4mNA050DjAJIUC7B2wY1ZD2Dawyi3AsfVWHeUWx9/m5q6 Czqwh0eGmBkxjW8HY6SfuNgjwY0+0jYQaDZUw2ycYRlAfcMyK5MC6VOXMELL/8pmbeyw DicN6ELY7ucWU6hU2dRoCTwQUuGg/7H/nRmxsM0Ft8W0is03k+aQzgbEYYL+GuKOtcSL goFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uovTOALO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si3431101iol.46.2021.09.16.14.09.05; Thu, 16 Sep 2021 14:09:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uovTOALO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243783AbhIPQeU (ORCPT + 99 others); Thu, 16 Sep 2021 12:34:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:38910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241885AbhIPQ0Y (ORCPT ); Thu, 16 Sep 2021 12:26:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7161461526; Thu, 16 Sep 2021 16:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809026; bh=+bY31dPJFtqpT+8jYpHZApMb6m8ON71lfddpGc5hhac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uovTOALOatsbOUMA8n/klkHp7h1HNiTVdXvO/mjK2ch188lePibmuXpDs86iCwzSi 9GET00AaLtfC1GP5JHuyADdN7X1nbtWNT5nAjPkavH29Ws5IIiUIhV1yJ/uYQEfwRF 3cIkcmr+VVFhLy/YZj6E0JRY++mK0vXe56UD+1EI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shirisha Ganta , "Pratik R. Sampat" , "Gautham R. Shenoy" , Michael Ellerman Subject: [PATCH 5.10 285/306] cpufreq: powernv: Fix init_chip_info initialization in numa=off Date: Thu, 16 Sep 2021 18:00:30 +0200 Message-Id: <20210916155803.812810929@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pratik R. Sampat commit f34ee9cb2c5ac5af426fee6fa4591a34d187e696 upstream. In the numa=off kernel command-line configuration init_chip_info() loops around the number of chips and attempts to copy the cpumask of that node which is NULL for all iterations after the first chip. Hence, store the cpu mask for each chip instead of derving cpumask from node while populating the "chips" struct array and copy that to the chips[i].mask Fixes: 053819e0bf84 ("cpufreq: powernv: Handle throttling due to Pmax capping at chip level") Cc: stable@vger.kernel.org # v4.3+ Reported-by: Shirisha Ganta Signed-off-by: Pratik R. Sampat Reviewed-by: Gautham R. Shenoy [mpe: Rename goto label to out_free_chip_cpu_mask] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210728120500.87549-2-psampat@linux.ibm.com Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/powernv-cpufreq.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -36,6 +36,7 @@ #define MAX_PSTATE_SHIFT 32 #define LPSTATE_SHIFT 48 #define GPSTATE_SHIFT 56 +#define MAX_NR_CHIPS 32 #define MAX_RAMP_DOWN_TIME 5120 /* @@ -1051,12 +1052,20 @@ static int init_chip_info(void) unsigned int *chip; unsigned int cpu, i; unsigned int prev_chip_id = UINT_MAX; + cpumask_t *chip_cpu_mask; int ret = 0; chip = kcalloc(num_possible_cpus(), sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; + /* Allocate a chip cpu mask large enough to fit mask for all chips */ + chip_cpu_mask = kcalloc(MAX_NR_CHIPS, sizeof(cpumask_t), GFP_KERNEL); + if (!chip_cpu_mask) { + ret = -ENOMEM; + goto free_and_return; + } + for_each_possible_cpu(cpu) { unsigned int id = cpu_to_chip_id(cpu); @@ -1064,22 +1073,25 @@ static int init_chip_info(void) prev_chip_id = id; chip[nr_chips++] = id; } + cpumask_set_cpu(cpu, &chip_cpu_mask[nr_chips-1]); } chips = kcalloc(nr_chips, sizeof(struct chip), GFP_KERNEL); if (!chips) { ret = -ENOMEM; - goto free_and_return; + goto out_free_chip_cpu_mask; } for (i = 0; i < nr_chips; i++) { chips[i].id = chip[i]; - cpumask_copy(&chips[i].mask, cpumask_of_node(chip[i])); + cpumask_copy(&chips[i].mask, &chip_cpu_mask[i]); INIT_WORK(&chips[i].throttle, powernv_cpufreq_work_fn); for_each_cpu(cpu, &chips[i].mask) per_cpu(chip_info, cpu) = &chips[i]; } +out_free_chip_cpu_mask: + kfree(chip_cpu_mask); free_and_return: kfree(chip); return ret;