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: 12933603 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C042CC00144 for ; Mon, 1 Aug 2022 08:04:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 584598E0003; Mon, 1 Aug 2022 04:04:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 533AB8E0001; Mon, 1 Aug 2022 04:04:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FC5B8E0003; Mon, 1 Aug 2022 04:04:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 31F288E0001 for ; Mon, 1 Aug 2022 04:04:42 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 03B19120865 for ; Mon, 1 Aug 2022 08:04:41 +0000 (UTC) X-FDA: 79750287204.28.CD5CBA5 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf14.hostedemail.com (Postfix) with ESMTP id 7251D10003C for ; Mon, 1 Aug 2022 08:04:41 +0000 (UTC) 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659341081; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9x896leJROK//5ZI7YDe1Burx2kjHnA4Fd1YKRhr6SM=; b=I5IV9H0vjiZB/0RA2auKrSgXkXez1/fTdStD9xqMVytgfEJI2XNdMQj0q0fiOE53PSl4El /qizLtYxVx1LoPheoV5iAzryE0qvIY8QVtpY9VljH9d6pusCpCJwSUZ2XFNJBDjXuFb1Fm 6HwRFwhVwM/FWmqdKfdZ9Svy4fit/Zg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OZ8U61ks; spf=pass (imf14.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659341081; a=rsa-sha256; cv=none; b=DBl+81pz7Ox148tIU8RSs+AqDoz7GQ2TPk4MTOYOcNMbT0W+CLHBNkqwcVPJVuJhakXBd+ U7pvfdaxl+Mtr+O1bzbcBiPrjIA7+z1jbcV78JRE/+w5/IyT7R0BBtxxmgHKF8YqO+Kny7 Do2R4MEMiBZhhpfptI8xcRtDDOi3G3k= X-Rspam-User: X-Stat-Signature: z98zuqq5dtajru5shx4j4dcmni5tsw7m X-Rspamd-Queue-Id: 7251D10003C Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OZ8U61ks; spf=pass (imf14.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam08 X-HE-Tag: 1659341081-127951 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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,