From patchwork Thu Sep 30 01:30:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12527081 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF5ADC433EF for ; Thu, 30 Sep 2021 01:32:53 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B05EE615E6 for ; Thu, 30 Sep 2021 01:32:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B05EE615E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=P5TOgiiD7KeGQX4t+at/Aq9l+GgpxZ8/dStUeH8GS7A=; b=Wnig/h9CcfSrgI FDlim+ju2356ptSZP3vu6WJll5/3Va1LAsc7KNkgrS4P9wWVw7a4ad6DA7p0NkWUJ7x01tCJ1rXMJ 4hcMxPuaJjMDH5AuE9u/rzuNhQb+wAsNmmEyUL0JhCD+vr6YsqkQD87M2BcF7ra/eEpdCHw9Le/w6 VhmyQIyIJosHNGpwtkgpLkyB27NCsaFk+rYUDSQEjfbzIsPsAJFUtW/NXjlVr3pQRmTpJD/T1AWey XcVX/bIMzVXYJsezxy8oidpoCMtoOdy8zjz0kBBQVP5t2oeU0KTq5a/MotCezNiljKwq7K9ORPhb4 pWYReT0aEGMZi+soLaLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVkuZ-00CiHF-R0; Thu, 30 Sep 2021 01:30:59 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVkuP-00CiFO-SH for linux-arm-kernel@lists.infradead.org; Thu, 30 Sep 2021 01:30:51 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2260F615A4; Thu, 30 Sep 2021 01:30:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632965449; bh=wbV6F8K1YktqcMeI72zuNPMPZDIFwa82A8AaD7ODLuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fXjfarfg3fUv2muoaPe42X68dGkHzYxP7+Rx+dfcEIwPVEEXYb3YujSrGkuwYaEyR RBviPEQVigL46cTnV30o1q9UuVwTnlEwM80bxFwI0dOYDPqd5h7OeNGds+KwCdHbth aNRhbH1JLXBtYJx+1W0V35Y7MM53cDmE0dhYqLU+DoKzLo9As2V6bZ62L1VPBx0oeB TpDkkGOxFvmsRoFajPHO+DBJGWr3puqmzrHfMTxvzzZXwnPUNwr3MxrXFqkgyrJk4J 4Lxnxb5c3SAbWRdBXITuXM7EnTl92PVstb9AIKyQn9fbKOLR2V3j1XNg6flwXR2eTU t0TgXntvfJYTw== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Alex Bee , Andrew Morton , Anshuman Khandual , Catalin Marinas , Christoph Hellwig , David Hildenbrand , Linux Kernel Mailing List , Marek Szyprowski , Mike Rapoport , Mike Rapoport , Robin Murphy , Will Deacon , iommu@lists.linux-foundation.org Subject: [PATCH 1/2] dma-mapping: remove bogus test for pfn_valid from dma_map_resource Date: Thu, 30 Sep 2021 04:30:38 +0300 Message-Id: <20210930013039.11260-2-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210930013039.11260-1-rppt@kernel.org> References: <20210930013039.11260-1-rppt@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_183049_958661_DDD228B8 X-CRM114-Status: GOOD ( 13.62 ) 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 dma_map_resource() uses pfn_valid() to ensure the range is not RAM. However, pfn_valid() only checks for availability of the memory map for a PFN but it does not ensure that the PFN is actually backed by RAM. As dma_map_resource() is the only method in DMA mapping APIs that has this check, simply drop the pfn_valid() test from dma_map_resource(). Link: https://lore.kernel.org/all/20210824173741.GC623@arm.com/ Signed-off-by: Mike Rapoport Reviewed-by: Christoph Hellwig Acked-by: David Hildenbrand --- kernel/dma/mapping.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index 06fec5547e7c..dda8d8b84a55 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -296,10 +296,6 @@ dma_addr_t dma_map_resource(struct device *dev, phys_addr_t phys_addr, if (WARN_ON_ONCE(!dev->dma_mask)) return DMA_MAPPING_ERROR; - /* Don't allow RAM to be mapped */ - if (WARN_ON_ONCE(pfn_valid(PHYS_PFN(phys_addr)))) - return DMA_MAPPING_ERROR; - if (dma_map_direct(dev, ops)) addr = dma_direct_map_resource(dev, phys_addr, size, dir, attrs); else if (ops->map_resource) From patchwork Thu Sep 30 01:30:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12527083 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6187C433F5 for ; Thu, 30 Sep 2021 01:32:57 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 732D6613D3 for ; Thu, 30 Sep 2021 01:32:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 732D6613D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=48zBSRk2vmK5hP6ww80Y9sY/CXZAbbAV/00llbhYXj4=; b=V4nmVbTQE4NkY0 MZHhUVbrk70CD236JG7JhEGeaRmZd8+m/HbI+KnaLrYP0xnVbMdcZ+fU8fjjNyTvfSSWUOkLdDTwQ zEKAxt8KJgM6kj1XVcj41SHX3fB3asVKNepzbnZMAHLwtVZNgTIW0AOf0RJBV/LGPmBOJhKYBVmja S63Kv7/Vh9RbjQmerkWUy/qvER1cA1WXNtdd16Hur5N2ZRK9giE1ZgrLLZnitIsJQvWjWzSnYw1Sh 06jPS432DHEpRu50TFI21B8FhlSQ2SPtFv/D5+H/cfec24nth55M706TpKS16AF5Iqrn0gW/KDV/9 47wLDJKd0YpbbB/3pABA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVkuj-00CiHs-Le; Thu, 30 Sep 2021 01:31:09 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVkuT-00CiGG-Sz for linux-arm-kernel@lists.infradead.org; Thu, 30 Sep 2021 01:30:55 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 21223617E1; Thu, 30 Sep 2021 01:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632965453; bh=ceqtqe3tP8kT4fg537bLiHXDr0BuBFKtfv/SdnOFWF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Po73306dW6G81QDX5q/qliETh5BHru1OilAP6EVgDEwr1x0WTKdIjoQ/a5ZIbrC5W JMWlojaoOycA2omq3R4Tea6hhMQLhRpeDpLDIVO1Q8C8F3k3en6jFiGy1mT1v1qCMw TdYj7obzUvSVlibusHtBGcA3EqDuIEdj0G96JVDTEb6jtcDoxqMyiFFS1irl9n4nE+ oN25IBa6cMVNQsmqdEsYwgtkJjx43TQFYOXGkzr7dhAfjIN5zTwXpm7nttashO28yF 54Bdy1/HqjaFF89qYAjZX2qRdC8ZO28REvYFwbWApFTEGJI2sO1K8TccHUsFinF9sM Sn1Sk5r6Z04tw== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Alex Bee , Andrew Morton , Anshuman Khandual , Catalin Marinas , Christoph Hellwig , David Hildenbrand , Linux Kernel Mailing List , Marek Szyprowski , Mike Rapoport , Mike Rapoport , Robin Murphy , Will Deacon , iommu@lists.linux-foundation.org Subject: [PATCH 2/2] arm64/mm: drop HAVE_ARCH_PFN_VALID Date: Thu, 30 Sep 2021 04:30:39 +0300 Message-Id: <20210930013039.11260-3-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210930013039.11260-1-rppt@kernel.org> References: <20210930013039.11260-1-rppt@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_183054_010570_23C5DD50 X-CRM114-Status: GOOD ( 17.28 ) 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: Anshuman Khandual CONFIG_SPARSEMEM_VMEMMAP is now the only available memory model on arm64 platforms and free_unused_memmap() would just return without creating any holes in the memmap mapping. There is no need for any special handling in pfn_valid() and HAVE_ARCH_PFN_VALID can just be dropped. This also moves the pfn upper bits sanity check into generic pfn_valid(). [rppt: rebased on v5.15-rc3] Link: https://lkml.kernel.org/r/1621947349-25421-1-git-send-email-anshuman.khandual@arm.com Signed-off-by: Anshuman Khandual Acked-by: David Hildenbrand Acked-by: Mike Rapoport Cc: Catalin Marinas Cc: Will Deacon Cc: David Hildenbrand Cc: Mike Rapoport Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Mike Rapoport --- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/page.h | 1 - arch/arm64/mm/init.c | 37 ----------------------------------- 3 files changed, 39 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 5c7ae4c3954b..53dd23f305be 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -154,7 +154,6 @@ config ARM64 select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT - select HAVE_ARCH_PFN_VALID select HAVE_ARCH_PREL32_RELOCATIONS select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET select HAVE_ARCH_SECCOMP_FILTER diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h index f98c91bbd7c1..993a27ea6f54 100644 --- a/arch/arm64/include/asm/page.h +++ b/arch/arm64/include/asm/page.h @@ -41,7 +41,6 @@ void tag_clear_highpage(struct page *to); typedef struct page *pgtable_t; -int pfn_valid(unsigned long pfn); int pfn_is_map_memory(unsigned long pfn); #include diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 37a81754d9b6..e60c6eb813b7 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -160,43 +160,6 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) free_area_init(max_zone_pfns); } -int pfn_valid(unsigned long pfn) -{ - phys_addr_t addr = PFN_PHYS(pfn); - struct mem_section *ms; - - /* - * Ensure the upper PAGE_SHIFT bits are clear in the - * pfn. Else it might lead to false positives when - * some of the upper bits are set, but the lower bits - * match a valid pfn. - */ - if (PHYS_PFN(addr) != pfn) - return 0; - - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) - return 0; - - ms = __pfn_to_section(pfn); - if (!valid_section(ms)) - return 0; - - /* - * ZONE_DEVICE memory does not have the memblock entries. - * memblock_is_map_memory() check for ZONE_DEVICE based - * addresses will always fail. Even the normal hotplugged - * memory will never have MEMBLOCK_NOMAP flag set in their - * memblock entries. Skip memblock search for all non early - * memory sections covering all of hotplug memory including - * both normal and ZONE_DEVICE based. - */ - if (!early_section(ms)) - return pfn_section_valid(ms, pfn); - - return memblock_is_memory(addr); -} -EXPORT_SYMBOL(pfn_valid); - int pfn_is_map_memory(unsigned long pfn) { phys_addr_t addr = PFN_PHYS(pfn);