Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp688032rdb; Sun, 18 Feb 2024 07:14:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWIiH5eUrXFlpnzW/EQeH/jPx3zVKKk0UtPIdnFd6Nhb9s/C/iXtCYomP/NJ14WxM0+KbkthemWQECdRW7a6wRCqfMOhIUN91hkQ0nHYg== X-Google-Smtp-Source: AGHT+IHg3wemVPoyVy0WoyiIllZOkbDHloDN8UGkej0mr/gxEPPCeANxTK4c2UPNjnQo7kV54/c6 X-Received: by 2002:a05:6602:4b0f:b0:7c4:95ed:bbe9 with SMTP id eo15-20020a0566024b0f00b007c495edbbe9mr11580211iob.0.1708269294803; Sun, 18 Feb 2024 07:14:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708269294; cv=pass; d=google.com; s=arc-20160816; b=vlPNHOs/p5yPOKhCdt/Q4LIeMUo6wZIQNMLf/i5r8JWllybWHDCDuJ2FMCaOkVuprb rrdTaAkq02dIzqprLzHKyFVt/qwSSpq+CvVejVQh7O4ybnF1kEbVJ+Aag0HdXcS5sUcp LLnlSFRZ5yW0oAzCKeOgdEEyMaOXmzjRi6FDEMUGA+/cYEDQzSx4JvhSFL46aU9a+qjd dun7huwBgH8o9mSADR0vZoEwhaqfAs7t8e070OTqMzfma6ya/pEywCNy/qBKqV3bjHFk hPVUE87okl2dCZS8VQtb81rxlrihpsyPRpmMM+zTOgpl9xr48Is3LzORcORPNGTn24vr UMEg== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70425-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k29-20020a63ba1d000000b005dc4e366f63si3040688pgf.787.2024.02.18.07.14.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 07:14:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70425-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-70425-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70425-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7AC35281293 for ; Sun, 18 Feb 2024 15:14:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEAA66BFC6; Sun, 18 Feb 2024 15:14:28 +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 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 , Oreoluwa Babatunde 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Huacai Chen --- 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 -- 2.43.0