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)