From patchwork Wed Sep 16 08:59:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Song Bao Hua (Barry Song)" X-Patchwork-Id: 11779393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4438C6CA for ; Wed, 16 Sep 2020 09:03:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E1DC20738 for ; Wed, 16 Sep 2020 09:03:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xOQssRHf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E1DC20738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=BHE/9/gDTZz+HOx9GKN1hU+WeDcD50gnFato8ObrCPw=; b=xOQssRHfF6HKoWHydu7feWVg90 2AX4LRuC7GLnciPy2Zkk9yVLSjAbr95mE2QLqTbQ4VQus/FAzq71EkZMukk2VYwxj1uIpsErOhCUX UsHPQfZzFjEqt4Z0Flg3NZqZnLNUlKWjEgWkzqeZYoS5u9PtExWZVyiB/JTtK6F0XcTWJsFTWxVr/ Tb5UERCAEUAzW7K+BZoUZ5Qw3pbuTZjgtAR7G1PqWQR1wJR6Jm9spqRpL4NXTBScEVuRiuIH3fSlg BDCIDqAo6CRjlUW0GXktbaGX6IbJnoFWi2EDz+rvQJSraNA1Sl7A7WjEu9VkZZqObjzjJm6xC82Zp 91b/oPSQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kITL0-0006UO-6j; Wed, 16 Sep 2020 09:02:50 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kITKx-0006Te-0C for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 09:02:48 +0000 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 7C1E2F76F57E9C0AD266; Wed, 16 Sep 2020 17:02:44 +0800 (CST) Received: from SWX921481.china.huawei.com (10.126.203.18) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Wed, 16 Sep 2020 17:02:37 +0800 From: Barry Song To: , Subject: [PATCH] arm64: mm: move dma_contiguous_reserve() to be after paging_init() Date: Wed, 16 Sep 2020 20:59:33 +1200 Message-ID: <20200916085933.25220-1-song.bao.hua@hisilicon.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.126.203.18] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_050247_305143_3B8647BE X-CRM114-Status: GOOD ( 13.01 ) X-Spam-Score: -1.0 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [45.249.212.32 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 1.3 AC_FROM_MANY_DOTS Multiple periods in From user name X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Barry Song , Stephen Rothwell , linuxarm@huawei.com, Andrew Morton , Will Deacon , Roman Gushchin , Mike Kravetz Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Recent CMA change "cma: make number of CMA areas dynamic, remove CONFIG_CMA_AREAS" breaks the boot of arm64 kernel in linux-next. Knic is like: Unable to handle kernel paging request at virtual address ffff0000438fff70 Mem abort info: ESR = 0x96000044 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000044 CM = 0, WnR = 1 swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000041f61000 [ffff0000438fff70] pgd=0000000000000000, p4d=0000000000000000 Internal error: Oops: 96000044 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 5.9.0-rc3-00020-ge1bce3d64c48 #2 Hardware name: linux,dummy-virt (DT) pstate: 20000085 (nzCv daIf -PAN -UAO BTYPE=--) pc : __memset+0x148/0x188 lr : memblock_alloc_try_nid+0xbc/0xd4 sp : ffff800011ab3d10 x29: ffff800011ab3d10 x28: 0000000041710018 x27: 0000000040000000 x26: ffff8000115d1000 x25: 0000000000000000 x24: ffff800011300428 x23: ffff800011d1bd60 x22: 0000000000000000 x21: 00000000ffffffff x20: ffff0000438fff70 x19: 0000000000000090 x18: 0000000000000010 x17: 0000000000001400 x16: 0000000000001c00 x15: ffff800011ac3530 x14: ffff800011ac3530 x13: fffffdfffe600000 x12: ffff800011ab3e44 x11: 0000000000000004 x10: 0000000000000018 x9 : 0000000000000000 x8 : ffff0000438fff70 x7 : 0000000000000000 x6 : 000000000000003f x5 : 0000000000000040 x4 : 0000000000000010 x3 : 0000000000000080 x2 : 0000000000000080 x1 : 0000000000000000 x0 : ffff0000438fff70 Call trace: __memset+0x148/0x188 cma_init_reserved_mem+0x94/0x154 cma_declare_contiguous_nid+0x240/0x2bc dma_contiguous_reserve_area+0x48/0x78 dma_contiguous_reserve+0x78/0x88 arm64_memblock_init+0x424/0x45c setup_arch+0x270/0x5f0 start_kernel+0x84/0x4dc Code: f101007f fa45a068 54fffc0b aa0303e2 (a9001d07) random: get_random_bytes called from print_oops_end_marker+0x2c/0x68 with crng_init=0 ---[ end trace 0000000000000000 ]--- Kernel panic - not syncing: Attempted to kill the idle task! ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]--- The virtual address returned from memblock_alloc() is not ready till paging_init() is done. Cc: Roman Gushchin Cc: Mike Kravetz Cc: Andrew Morton Cc: Will Deacon Cc: Stephen Rothwell Signed-off-by: Barry Song Tested-by: Anders Roxell --- -v1: to fix the knic during boot after applying Mike's patch: https://lore.kernel.org/linux-mm/20200915205703.34572-1-mike.kravetz@oracle.com/ arch/arm64/mm/init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index f1c75957ff3c..8dd61d07fff5 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -402,8 +402,6 @@ void __init arm64_memblock_init(void) reserve_elfcorehdr(); high_memory = __va(memblock_end_of_DRAM() - 1) + 1; - - dma_contiguous_reserve(arm64_dma32_phys_limit); } void __init bootmem_init(void) @@ -415,6 +413,13 @@ void __init bootmem_init(void) early_memtest(min << PAGE_SHIFT, max << PAGE_SHIFT); + /* + * CMA is using memblock_alloc(), the virtual address returned + * from memblock_alloc() isn't ready till paging_init(). + * So this has to happen after paging_init() + */ + dma_contiguous_reserve(arm64_dma32_phys_limit); + max_pfn = max_low_pfn = max; min_low_pfn = min;