From patchwork Mon Dec 25 14:50:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 183207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp424674dyb; Mon, 25 Dec 2023 06:51:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFO3QKfWWgNfIVdIDOPVbR3wfQL93SFPKcOsvnKd4GbJ2dvl5uwGJ83aPmmduLyfx64j3o7 X-Received: by 2002:a05:620a:17a7:b0:781:214f:4052 with SMTP id ay39-20020a05620a17a700b00781214f4052mr8667295qkb.152.1703515862453; Mon, 25 Dec 2023 06:51:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703515862; cv=none; d=google.com; s=arc-20160816; b=csHxcG2Np0y4z+ZVrhfbBKNiEgop+VTfM1mpop3WX61omK0lWEr+WQ6GLReoZMn/vy ec9W3RWWPLUoBS/7ncXmAcxdobYxi6Lu943mVPoscS8bYAXWPQSRq6L/VrJRKzeDKti9 J3SzRrB/956q1tLQ6QSFhkFDqrBglRG7GOiPjMDyhCzqi8ilacL+ImqcS1Mh/4oMoWHq RbBMwTJIjY4IM1005V5UlnLXUbhIoWSMehTGG3qw6zRQoeCEerCTE+xtIvh21IQklFul x4aoEEdNlfU2MQl6q0Wc4JDPVeTxbVOsl8SNdUnHi1GywBof3w/7cnwDqlsCyaOy/icb z2/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=TzZpJaFM2t/qYbIOihx1bcdMlYrSy3lEHAU4/Rturzc=; fh=y7VKX694VLH2eb03/y0ljujQLJGtNdYVa6lu5bfy0Mc=; b=00YiX7tL+nYssXhPVJwJMvgEBRMSYnwVbwYsGcrC5qRsSTM10R46EcQfRnTuBE/Iay Y3mezdU0AJbFoYGQLkWroxMkDZIQzy+WQfKCsDFMdqGjFw4+2VccKANwWhpybVqhzMRR +MzlGdIjp8s3vg0J1BiPch78llg0hPBrv1c71sJhxrc4bQ0P58XMwIzGA/jM9NZvQBis XJS94axaEZXpgTUTNISeBZPhjf4sk0DTmcRfd/HN+1o+wgtL5MbPpXf+B1eHQPyS6t8v o5Zqgmk6A9XSYi5o/HwjPgUoLWgyN+OgPrv57r2WageatG9s8AyRPJeqvh8JrNbY6/S+ kA0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11090-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11090-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f6-20020a05620a280600b0077f5f8a0d84si10890428qkp.550.2023.12.25.06.51.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 06:51:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11090-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11090-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11090-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4113E1C211C1 for ; Mon, 25 Dec 2023 14:51:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CA5552F64; Mon, 25 Dec 2023 14:50:49 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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 110DA52F62; Mon, 25 Dec 2023 14:50:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 070CBC433C7; Mon, 25 Dec 2023 14:50:43 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen Subject: [PATCH V2] LoongArch: Let cores_io_master cover the largest NR_CPUS Date: Mon, 25 Dec 2023 22:50:23 +0800 Message-Id: <20231225145023.1505439-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786265848582350148 X-GMAIL-MSGID: 1786265848582350148 Now loongson_system_configuration::cores_io_master only covers 64 cpus, if NR_CPUS > 64 there will be memory corruption. So let cores_io_master cover the largest NR_CPUS (256). Signed-off-by: Huacai Chen --- arch/loongarch/include/asm/bootinfo.h | 6 ++++-- arch/loongarch/kernel/acpi.c | 2 +- arch/loongarch/kernel/smp.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h index c60796869b2b..6d5846dd075c 100644 --- a/arch/loongarch/include/asm/bootinfo.h +++ b/arch/loongarch/include/asm/bootinfo.h @@ -24,13 +24,15 @@ struct loongson_board_info { const char *board_vendor; }; +#define NR_WORDS DIV_ROUND_UP(NR_CPUS, BITS_PER_LONG) + struct loongson_system_configuration { int nr_cpus; int nr_nodes; int boot_cpu_id; int cores_per_node; int cores_per_package; - unsigned long cores_io_master; + unsigned long cores_io_master[NR_WORDS]; unsigned long suspend_addr; const char *cpuname; }; @@ -42,7 +44,7 @@ extern struct loongson_system_configuration loongson_sysconf; static inline bool io_master(int cpu) { - return test_bit(cpu, &loongson_sysconf.cores_io_master); + return test_bit(cpu, loongson_sysconf.cores_io_master); } #endif /* _ASM_BOOTINFO_H */ diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c index 8e00a754e548..b6b097bbf866 100644 --- a/arch/loongarch/kernel/acpi.c +++ b/arch/loongarch/kernel/acpi.c @@ -119,7 +119,7 @@ acpi_parse_eio_master(union acpi_subtable_headers *header, const unsigned long e return -EINVAL; core = eiointc->node * CORES_PER_EIO_NODE; - set_bit(core, &(loongson_sysconf.cores_io_master)); + set_bit(core, loongson_sysconf.cores_io_master); return 0; } diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c index 5bca12d16e06..33e583303652 100644 --- a/arch/loongarch/kernel/smp.c +++ b/arch/loongarch/kernel/smp.c @@ -208,7 +208,7 @@ static void __init fdt_smp_setup(void) } loongson_sysconf.nr_cpus = num_processors; - set_bit(0, &(loongson_sysconf.cores_io_master)); + set_bit(0, loongson_sysconf.cores_io_master); #endif }