From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7ECA1A76AD; Tue, 30 Jul 2024 17:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722360634; cv=none; b=gtrs6oCmOrIOKkL7udT0hx5AjvTibREj+NWUNzpuh+unZbRlnOscMwaNvYyosUe7X2YEFqAgR3Zq0zWjlq4UVO3zvkhWCwuA62umJSoOSLI6o2vs1GIKaPk1sQmQNP3K1N5dsKzFL44M6lVsxkZtvGPW8I6ErSoD4fP6BtR1G9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722360634; c=relaxed/simple; bh=/iVjvd2G1kBmKeTOelCValeRUOC2H6tDZE+XSGnS5jI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HY5ShsVUPobYUIu/0zXrSmM54PGQUpiRBP2fXTM6NmfcVuf/Pe/xMaOp2jgcb4tFpo0QFEKjTGFKaA3HJoY8G4nFh/zlO1EuOchdCyamjFbYf/L4jBifPXDC2OTayNs8OJxlLekUMqbbXnpZZvGaqZ/97zmJuIzDxCMe0Y56d7s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=l77l4j3a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="l77l4j3a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FCB7C4AF0A; Tue, 30 Jul 2024 17:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722360634; bh=/iVjvd2G1kBmKeTOelCValeRUOC2H6tDZE+XSGnS5jI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l77l4j3aQJu0c81MYi/UzDQKG+WSTD8t9bqbJLbzWahhEVwUapDK8sa0TdHzacTXr f5lZSED8dIEWGMF4TTiZHAqWzT2ZYjCTyV65Xuw+oV4suy8vYQkCx4SNafuWbj1nob ByN3fh0q7NlX+3jUiHYKnpSxz80FkRkOYFFuqRQc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiaxun Yang , Thomas Bogendoerfer Subject: [PATCH 6.10 728/809] MIPS: Loongson64: Test register availability before use Date: Tue, 30 Jul 2024 17:50:04 +0200 Message-ID: <20240730151753.692924838@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151724.637682316@linuxfoundation.org> References: <20240730151724.637682316@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiaxun Yang commit c04366b1207a036b7de02dfcc1ac7138d3343c9b upstream. Some global register address variable may be missing on specific CPU type, test them before use them. Cc: stable@vger.kernel.org Signed-off-by: Jiaxun Yang Signed-off-by: Thomas Bogendoerfer Signed-off-by: Greg Kroah-Hartman --- arch/mips/loongson64/smp.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) --- a/arch/mips/loongson64/smp.c +++ b/arch/mips/loongson64/smp.c @@ -466,12 +466,25 @@ static void loongson3_smp_finish(void) static void __init loongson3_smp_setup(void) { int i = 0, num = 0; /* i: physical id, num: logical id */ + int max_cpus = 0; init_cpu_possible(cpu_none_mask); + for (i = 0; i < ARRAY_SIZE(smp_group); i++) { + if (!smp_group[i]) + break; + max_cpus += loongson_sysconf.cores_per_node; + } + + if (max_cpus < loongson_sysconf.nr_cpus) { + pr_err("SMP Groups are less than the number of CPUs\n"); + loongson_sysconf.nr_cpus = max_cpus ? max_cpus : 1; + } + /* For unified kernel, NR_CPUS is the maximum possible value, * loongson_sysconf.nr_cpus is the really present value */ + i = 0; while (i < loongson_sysconf.nr_cpus) { if (loongson_sysconf.reserved_cpus_mask & (1<