Message ID | 20240218151403.2206980-1-chenhuacai@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-70425-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp824833dyc; Sun, 18 Feb 2024 07:15:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW5eeTFhoP/kP1kdj8I/a2O06CYT3oiRknULB9NEyEdu3DlUwdN43fz14Opu/0BEdNDi02y6LJ5CPZrwVEMFd/XMs6VpQ== X-Google-Smtp-Source: AGHT+IFE8Fza0o1oqptLn+GOtcahCAU/7+4yKPNyZQZphecOoYqetqTSuPJqGOeBNCilgc1T01Z4 X-Received: by 2002:a05:6214:21ad:b0:68f:1608:1b0d with SMTP id t13-20020a05621421ad00b0068f16081b0dmr12229872qvc.0.1708269302561; Sun, 18 Feb 2024 07:15:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708269302; cv=pass; d=google.com; s=arc-20160816; b=XA0S5tV9dU2AOHsEbYgITHxyjDKGE/ptNgl00wH5XG99atC2ADarLcH05yuDxEtbwm hDLLHytRpQ7ESo8/SB8V7iukcYbV5BPRrntmpP3e/qyJjgbqFPdkhtq2JNYPkbLM4Xqc h0h6H9r8c355gGKIGRLaHh8DgIvArqU7Jc8LYpMUI7EHAThkh8m4M6bJmJIKGI7BIbv5 W9sVXBEtzOCqOTuQqkZE7jcSDqWJ46ztGVUvWvcZTy6XhT53Acg4dY+K1vjIiFoYA9+Z iFTEppHHf67tFLZS1UKOKetKnHk55BfH0sOQVCoh3ov/oj3Ow0/ktjeT0ZSiEmaKFM5x 764A== ARC-Message-Signature: i=2; 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=Le4m4CWY0XtC9emFngAbORk1oMklFDQEtTAkCPJAxIQ=; fh=SBD80WeawXr722XjCU5oTbTOUCI6KNg64gd9JqXytEI=; b=u6peujIwZvDqJnObvODj5I8f2og2D0h3kYruHlnWXw7Hn2O5O4vONymR+2lGx0kios fernjK8Lckn9mK1nuAe8KLMBTb7jtjvPRnQWziyxnMvxk4TmJBaGybKzjBh1QeUrdP3P ASLScWx3ljLOiG+RMt3fhGpbdpxqvpzb1yTrWxcRn52maUZ5kheoq9HB8Sxk4nChRCRU ZLqZjWyGIhT2Ib4RaLP4zPjMl9cQog89+ucCJbeVqjnwB/zTYKkyLI+6m5O03wObmYD2 WYZ/uz4hFheol6IAFPppe2GZVARwZIIcuV8oaR8Dom9Taz8W1dGTl6yIfODACvdnWiLK 9Rsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-70425-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70425-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 iu1-20020ad45cc1000000b0068f62ba06dfsi892891qvb.551.2024.02.18.07.15.02 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 07:15:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70425-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-70425-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70425-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 5B1EB1C20AC9 for <ouuuleilei@gmail.com>; Sun, 18 Feb 2024 15:15:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F23F96D1B5; Sun, 18 Feb 2024 15:14:29 +0000 (UTC) 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 73A066BFC7; Sun, 18 Feb 2024 15:14:28 +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=1708269268; cv=none; b=t3AiYMaMkyk7r4yGSTihp47nRhSZUSdsYH8gZdpX/pQ7JUN/Ooy0eHqKVw/W5CPU09tWnJfsZ3D6bkO40S0tRYMhZza6KHyC+6FxiUN3FBr/RR5IDAh6NVksK3gCptjpYrEMGH79ZGovvnLhkOfBeJCrm5PjQ+pOF7BuQZ/bOf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708269268; c=relaxed/simple; bh=7ND1cr7GPflsn+fS87oYZAJbbZxVUvL0DV2PFVsYsnw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ls7yawe1zQJ9nZ7kWaRNn+5mtlgx/prp8rQzPkTaf4OnBU1Vzw1tUqU/n1WmE2MXAvZm/+Bj5+/FuP/G+69uhqSUJTjofSgSKQltfZAz8EPdbnYeIO8WPN3t4u3WCFm1Q922Tm8OANEf/aGGQQsr4ju0826axoMAYqleuRK5vnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 698DEC433C7; Sun, 18 Feb 2024 15:14:25 +0000 (UTC) From: Huacai Chen <chenhuacai@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org> Cc: loongarch@lists.linux.dev, Xuefeng Li <lixuefeng@loongson.cn>, Guo Ren <guoren@kernel.org>, Xuerui Wang <kernel@xen0n.name>, Jiaxun Yang <jiaxun.yang@flygoat.com>, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen <chenhuacai@loongson.cn>, Oreoluwa Babatunde <quic_obabatun@quicinc.com> Subject: [PATCH] LoongArch: Call early_init_fdt_scan_reserved_mem() earlier Date: Sun, 18 Feb 2024 23:14:03 +0800 Message-ID: <20240218151403.2206980-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791250192018901642 X-GMAIL-MSGID: 1791250192018901642 |
Series |
LoongArch: Call early_init_fdt_scan_reserved_mem() earlier
|
|
Commit Message
Huacai Chen
Feb. 18, 2024, 3:14 p.m. UTC
The unflatten_and_copy_device_tree() function contains a call to memblock_alloc(). This means that memblock is allocating memory before any of the reserved memory regions are set aside in the arch_mem_init() function which calls early_init_fdt_scan_reserved_mem(). Therefore, there is a possibility for memblock to allocate from any of the reserved memory regions. Hence, move the call to early_init_fdt_scan_reserved_mem() to be earlier in the init sequence, so that the reserved memory regions are set aside before any allocations are done using memblock. Signed-off-by: Oreoluwa Babatunde <quic_obabatun@quicinc.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> --- arch/loongarch/kernel/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 2/18/2024 7:14 AM, Huacai Chen wrote: > The unflatten_and_copy_device_tree() function contains a call to > memblock_alloc(). This means that memblock is allocating memory before > any of the reserved memory regions are set aside in the arch_mem_init() > function which calls early_init_fdt_scan_reserved_mem(). Therefore, > there is a possibility for memblock to allocate from any of the > reserved memory regions. > > Hence, move the call to early_init_fdt_scan_reserved_mem() to be earlier > in the init sequence, so that the reserved memory regions are set aside > before any allocations are done using memblock. > > Signed-off-by: Oreoluwa Babatunde <quic_obabatun@quicinc.com> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > --- > arch/loongarch/kernel/setup.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c > index edf2bba80130..634ef17fd38b 100644 > --- a/arch/loongarch/kernel/setup.c > +++ b/arch/loongarch/kernel/setup.c > @@ -357,6 +357,8 @@ void __init platform_init(void) > acpi_gbl_use_default_register_widths = false; > acpi_boot_table_init(); > #endif > + > + early_init_fdt_scan_reserved_mem(); > unflatten_and_copy_device_tree(); > > #ifdef CONFIG_NUMA > @@ -390,8 +392,6 @@ static void __init arch_mem_init(char **cmdline_p) > > check_kernel_sections_mem(); > > - early_init_fdt_scan_reserved_mem(); > - > /* > * In order to reduce the possibility of kernel panic when failed to > * get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate Hi Huacai, Thank you! This change looks good to me. Regards, Oreoluwa
diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index edf2bba80130..634ef17fd38b 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -357,6 +357,8 @@ void __init platform_init(void) acpi_gbl_use_default_register_widths = false; acpi_boot_table_init(); #endif + + early_init_fdt_scan_reserved_mem(); unflatten_and_copy_device_tree(); #ifdef CONFIG_NUMA @@ -390,8 +392,6 @@ static void __init arch_mem_init(char **cmdline_p) check_kernel_sections_mem(); - early_init_fdt_scan_reserved_mem(); - /* * In order to reduce the possibility of kernel panic when failed to * get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate