From nobody Sat Jul 25 18:53:57 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 5543C2641EE for ; Tue, 14 Jul 2026 18:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784055430; cv=none; b=dzavye9Mid3D+D1wioQzoiAj8d5B14JzmNV/PslhOuQ4+dKmLOw8XsL2QRWylXrmymv/eDtF4aDgfWsbDJOxZ+43cexOqxsaxJyTWCgsB/IdugzNTzdu6+O4jUYYHTCOwmZgid1Cd4dqTfXiu1MKOgdRGK85UjRIySQhOymIr7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784055430; c=relaxed/simple; bh=o5jwp8BQbdLP5nIylB4BY7hawmvBBew2tsWUSjU9UfQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EdhGD0uAYMZBLVkw+y7d4TvIHquQfyfX0oc1xMghbC4CsqJmQ8Yb0L92Sn0OeRjR4QWCp2UjYclFEdhvFjVt83hIhSW3GQzQC0CVqgHm5E3TqU0nrfd5oYfrProS7BYarN190ucugdMfdJmqFHcqMfvvtn60dWYGXBUPAg7myWY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Dr1tXQHn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Dr1tXQHn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784055428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=RfsI6HLQGXe6K3Z7dJ8d5kqjISwd3J2Qdz2e+YoCrRA=; b=Dr1tXQHnlBrx00RCCVVRmzxGZINDqYeL6umY2QnOsWFnFpvUXlHMKOoHsQ7ulIgxUfzVfj a/U4RM1OVWtGh3CDdzkn5onsW1pDO6rknqfHclGnFipwciYKMVCJpJf4DV4nkPwA1hze32 xuJsjnvgsqtd1IrZfM+vJFY8olK/7Qs= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-198--3G9Xf4oMe2KES4EIy5AxA-1; Tue, 14 Jul 2026 14:57:04 -0400 X-MC-Unique: -3G9Xf4oMe2KES4EIy5AxA-1 X-Mimecast-MFC-AGG-ID: -3G9Xf4oMe2KES4EIy5AxA_1784055423 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D72E6195606E; Tue, 14 Jul 2026 18:57:02 +0000 (UTC) Received: from ezulian-p1gen7.rmtde.csb (unknown [10.44.48.131]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2D4DD30002DD; Tue, 14 Jul 2026 18:56:59 +0000 (UTC) From: Eder Zulian To: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Eder Zulian Subject: [PATCH] riscv: mm: Move dma_contiguous_reserve() after NUMA initialization Date: Tue, 14 Jul 2026 20:56:48 +0200 Message-ID: <20260714185648.1082483-1-ezulian@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Move the dma_contiguous_reserve() call from setup_bootmem() to misc_mem_init(), placing it after arch_numa_init(). This ensures that NUMA topology is initialized when reserving contiguous memory for DMA. Tested with CMA_SIZE_PERNUMA enabled and two NUMA nodes on QEMU: qemu-system-riscv64 \ -machine virt \ -nographic \ -smp 2 -m 512M \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dm0 \ -numa node,nodeid=3D1,cpus=3D1,memdev=3Dm1 \ -object memory-backend-ram,id=3Dm0,size=3D256M \ -object memory-backend-ram,id=3Dm1,size=3D256M \ -kernel arch/riscv/boot/Image \ -append "console=3DttyS0 earlycon loglevel=3D7 cma=3D16M" Unpatched kernel's log (one global CMA pool and no per-nodepools, 16 MiB cma-reserved): [ 0.000000] cma: Reserved 16 MiB at 0x000000009ee00000 ... [ 0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x000000008fff= ffff] [ 0.000000] Initmem setup node 1 [mem 0x0000000090000000-0x000000009fff= ffff] ... [ 0.056397] smp: Brought up 2 nodes, 2 CPUs [ 0.066135] Memory: 449288K/524288K available (12279K kernel code, 5980= K rwdata, 6144K rodata, 2467K init, 482K bss, 54504K reserved, 16384K cma-r= eserved) Patched kernel's log (three CMA pools are created, 48 MiB total), [ 0.000000] cma: Reserved 16 MiB at 0x000000009ee00000 [ 0.000000] cma: Reserved 16 MiB at 0x000000008ee00000 [ 0.000000] cma: Reserved 16 MiB at 0x000000009de00000 ... [ 0.054251] smp: Brought up 2 nodes, 2 CPUs [ 0.064082] Memory: 416520K/524288K available (12279K kernel code, 5980= K rwdata, 6144K rodata, 2467K init, 482K bss, 54504K reserved, 49152K cma-r= eserved) Signed-off-by: Eder Zulian --- arch/riscv/mm/init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 85bdcce63a3e..79a658ebe74d 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -295,8 +295,6 @@ static void __init setup_bootmem(void) */ if (!IS_ENABLED(CONFIG_BUILTIN_DTB)) memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); - - dma_contiguous_reserve(dma32_phys_limit); } =20 #ifdef CONFIG_RELOCATABLE @@ -1349,6 +1347,7 @@ void __init misc_mem_init(void) { early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT); arch_numa_init(); + dma_contiguous_reserve(dma32_phys_limit); #ifdef CONFIG_SPARSEMEM_VMEMMAP /* The entire VMEMMAP region has been populated. Flush TLB for this regio= n */ local_flush_tlb_kernel_range(VMEMMAP_START, VMEMMAP_END); --=20 2.55.0