From patchwork Mon Aug 1 08:04:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12933609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FAB5C3F6B0 for ; Mon, 1 Aug 2022 08:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tnteJ5UBzzdd2eIYtuvN6ZCZaIKQGhsrabcJ5hirr6Q=; b=Bv9ATt0PTjmHI2 fUP2c50qjkuMcCLadzn3lh9pUoW8q+dmc+ZJ0zYYvfiVsjZZWY3u1MN0igYQ8Xh68TcPDKL8bMJYe CeQUpz+rd7YJ2WRxw3eo/nxcy6IoWUZTY5996huxOdT0FnHpJKcisnQuY8BGrHQaB8p3S1guB6pVu PSH0gM+keOSx66+98PX3VWDUQ6WeKLva+hxJiuMsLTInjGjuwm3iMC+1to0rtF6oTvUPw0C+OCUMC gApnOQp89QBNgWBxhCmxGGdJcDcYbs5dYbtxQ5m0nBeTZFBRhrcSJdsYS0CIQe4L+tPrUymR3PGBm A00PRqTZyy9Hn+hwNWPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oIQPz-003krV-Q1; Mon, 01 Aug 2022 08:04:51 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oIQPp-003kjL-8o for linux-arm-kernel@lists.infradead.org; Mon, 01 Aug 2022 08:04:42 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9EE45B80DD0; Mon, 1 Aug 2022 08:04:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17DC3C4347C; Mon, 1 Aug 2022 08:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659341078; bh=OjCzYsGS4fOFkbuq211CjFLG8Lt6vwd7g0byaHHcDJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZ8U61ks8p3bY6UnJTlV0sMIHMJR3KU/pSpKF94ESgUOOoyaZo9Lio1IUp8BiH9x8 aGslZfie20B+ioHRav4LyrO8FhehUSgocWmlqNUkSvSMdHMD9VQcpui75A/uznScRj 8Ex0MngjTHn8FEFoF3rOHQcp6OwtYt3ia3FTQHxGZu1Ty/fxNISLhrQI/vjOzncJRX jK3aLNLeCm8PocPHOaxZ1lcsOdVdUu2Qf/FfTBL4I0zFqcjEkt7dQyKMoqSG/VAmfT evBSBD1z0Z2glj2FDjtxYuHoLgEDYYsDWxfV3ykJd9byXFf08g0AIBwp3yEGIbGCaY vwG+oSO1H4vqg== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Guanghui Feng , Mark Rutland , Mike Rapoport , Mike Rapoport , Will Deacon , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 1/4] arm64: introduce have_zone_dma() helper Date: Mon, 1 Aug 2022 11:04:15 +0300 Message-Id: <20220801080418.120311-2-rppt@kernel.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220801080418.120311-1-rppt@kernel.org> References: <20220801080418.120311-1-rppt@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220801_010441_642059_E0A0F1CF X-CRM114-Status: GOOD ( 15.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Mike Rapoport rather than open-code the check whether CONFIG_ZONE_DMA or CONFIG_ZONE_DMA32 are enabled. Signed-off-by: Mike Rapoport --- arch/arm64/include/asm/memory.h | 8 ++++++++ arch/arm64/mm/init.c | 4 ++-- arch/arm64/mm/mmu.c | 6 ++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 0af70d9abede..fa89d3bded8b 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -351,6 +351,14 @@ static inline void *phys_to_virt(phys_addr_t x) }) void dump_mem_limit(void); + +static inline bool have_zone_dma(void) +{ + if (IS_ENABLED(CONFIG_ZONE_DMA) || IS_ENABLED(CONFIG_ZONE_DMA32)) + return true; + + return false; +} #endif /* !ASSEMBLY */ /* diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 339ee84e5a61..fa2260040c0f 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -389,7 +389,7 @@ void __init arm64_memblock_init(void) early_init_fdt_scan_reserved_mem(); - if (!IS_ENABLED(CONFIG_ZONE_DMA) && !IS_ENABLED(CONFIG_ZONE_DMA32)) + if (!have_zone_dma()) reserve_crashkernel(); high_memory = __va(memblock_end_of_DRAM() - 1) + 1; @@ -438,7 +438,7 @@ void __init bootmem_init(void) * request_standard_resources() depends on crashkernel's memory being * reserved, so do it here. */ - if (IS_ENABLED(CONFIG_ZONE_DMA) || IS_ENABLED(CONFIG_ZONE_DMA32)) + if (have_zone_dma()) reserve_crashkernel(); memblock_dump_all(); diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 626ec32873c6..d170b7956b01 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -529,8 +529,7 @@ static void __init map_mem(pgd_t *pgdp) #ifdef CONFIG_KEXEC_CORE if (crash_mem_map) { - if (IS_ENABLED(CONFIG_ZONE_DMA) || - IS_ENABLED(CONFIG_ZONE_DMA32)) + if (have_zone_dma()) flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; else if (crashk_res.end) memblock_mark_nomap(crashk_res.start, @@ -571,8 +570,7 @@ static void __init map_mem(pgd_t *pgdp) * through /sys/kernel/kexec_crash_size interface. */ #ifdef CONFIG_KEXEC_CORE - if (crash_mem_map && - !IS_ENABLED(CONFIG_ZONE_DMA) && !IS_ENABLED(CONFIG_ZONE_DMA32)) { + if (crash_mem_map && !have_zone_dma()) { if (crashk_res.end) { __map_memblock(pgdp, crashk_res.start, crashk_res.end + 1,