Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2681504yba; Mon, 22 Apr 2019 11:03:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhFSY03T3Jh/CH6pw7Oa9aMWiCBVGcjj9VBrXMOJYMgqv14pSgcXli1T7HYn/SZTtx/1Do X-Received: by 2002:a63:f64f:: with SMTP id u15mr11803188pgj.192.1555956185490; Mon, 22 Apr 2019 11:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555956185; cv=none; d=google.com; s=arc-20160816; b=RoGuJNvzL3yqWeIu4H+asH9QnxYX4+d7ovVjStUu1R5Wa+st5hYo9eG7hK9t/3KXD5 fgEJ0jd5m2z+kewA3zDmTZqt1gt0Mp3P+w1N4bJx1dFpsp//zfH60mJicWPeyDcq71qp n5iwzCw/G+1F1xnZ5VdCzhZ8gUoNKT3xRNilMF9UlhZxyWqCPq3zdBg5MxU6+leLhVU9 wocyb3kHzz/FNeQg0sHA9XgCM9lIMVlbMVea2lYro+zlmIaiRSod3QM0JYE9sxhCp66D yBTTXTptdEH1dAD5c4sDh1NXS9WlHS9gqf+Vp43+YvJF6l5STj3pyDYPONqqa7M6OtN4 DA3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KNBSxELbXU0pku+vbXf0mb5CVZS4m7+aLZgrSaKjimg=; b=mfQXbAoBjj/xbsgo/Dfh82TQrlblNhSJiAk9+VcI6xtc3DyOCAshZZ6th7iNcdtVbL Ze+Sc8k9u0uLXbR9+JVvTYw6ARS6TMaLAsigeqyHHOsPum6lSIbnpZDaLuwcmvLcKf1t shtd+Y5IkqAp9e6ahSPtzCIOKFh8lnLOgnr01786AHZtyzf1wWAzM9HWWKEAfmgGaEvt 4kt/e5hGtLJf6+AVPA+1leKOP3rBI7Ky1EOybGlEd7U6LV3ovm9sWjqYuw2v5THRV+yr JQ6M0mrfunGnPXsD3sRq0QRTkABhN7bnX5Bwfzxlw3rZ7uiHbyS8VxJCtFWpJFVNjHoa LCuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=O0ioONp6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f18si13142320pgg.361.2019.04.22.11.02.50; Mon, 22 Apr 2019 11:03:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=O0ioONp6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728679AbfDVSBS (ORCPT + 99 others); Mon, 22 Apr 2019 14:01:18 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40900 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728639AbfDVSBQ (ORCPT ); Mon, 22 Apr 2019 14:01:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KNBSxELbXU0pku+vbXf0mb5CVZS4m7+aLZgrSaKjimg=; b=O0ioONp68hRSEfHTIvDbiBW+UG 6xt9MiBDMbZdcEyZKNvizAjpXal9ZI9GDFJZ2JfQ+8kiBmXr6TZFiOngdD3TyFrdgPum5i2ilOllA 5RGyskhfAghx9+0HAgERrj4mw8+QrJ1uwDr0W+6Ft/19cUThg7FiDRc2PCneNNh0HRQd1W0lmteUy JqMO+ZaOgXq3MAwCAdwZjriNwQa8ZEhq9PX1A7Q4UvepVGLXVPCjgMRRkjOXtMdTF0AAo/GM4pbzx +3JCJGL0WPLMf5wW02NEg6jE7MNZho+irCTuQtuRnHDAIUBT9VcKbhUHUlOTJBJMUmSxiZyMp1QfK MOPp332w==; Received: from 213-225-37-80.nat.highway.a1.net ([213.225.37.80] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIdFc-0002ed-0p; Mon, 22 Apr 2019 18:01:08 +0000 From: Christoph Hellwig To: Robin Murphy Cc: Joerg Roedel , Catalin Marinas , Will Deacon , Tom Lendacky , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 23/26] iommu/dma: Don't depend on CONFIG_DMA_DIRECT_REMAP Date: Mon, 22 Apr 2019 19:59:39 +0200 Message-Id: <20190422175942.18788-24-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190422175942.18788-1-hch@lst.de> References: <20190422175942.18788-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For entirely dma coherent architectures there is no requirement to ever remap dma coherent allocation. Move all the remap and pool code under IS_ENABLED() checks and drop the Kconfig dependency. Signed-off-by: Christoph Hellwig --- drivers/iommu/Kconfig | 1 - drivers/iommu/dma-iommu.c | 16 +++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index bdc14baf2ee5..6f07f3b21816 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -95,7 +95,6 @@ config IOMMU_DMA select IOMMU_API select IOMMU_IOVA select NEED_SG_DMA_LENGTH - depends on DMA_DIRECT_REMAP config FSL_PAMU bool "Freescale IOMMU support" diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 8fc6098c1eeb..278a9a960107 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -923,10 +923,11 @@ static void __iommu_dma_free(struct device *dev, size_t size, void *cpu_addr) struct page *page = NULL; /* Non-coherent atomic allocation? Easy */ - if (dma_free_from_pool(cpu_addr, alloc_size)) + if (IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) && + dma_free_from_pool(cpu_addr, alloc_size)) return; - if (is_vmalloc_addr(cpu_addr)) { + if (IS_ENABLED(CONFIG_DMA_REMAP) && is_vmalloc_addr(cpu_addr)) { /* * If it the address is remapped, then it's either non-coherent * or highmem CMA, or an iommu_dma_alloc_remap() construction. @@ -972,7 +973,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size, if (!page) return NULL; - if (!coherent || PageHighMem(page)) { + if (IS_ENABLED(CONFIG_DMA_REMAP) && (!coherent || PageHighMem(page))) { pgprot_t prot = arch_dma_mmap_pgprot(dev, PAGE_KERNEL, attrs); cpu_addr = dma_common_contiguous_remap(page, alloc_size, @@ -1005,11 +1006,12 @@ static void *iommu_dma_alloc(struct device *dev, size_t size, gfp |= __GFP_ZERO; - if (gfpflags_allow_blocking(gfp) && + if (IS_ENABLED(CONFIG_DMA_REMAP) && gfpflags_allow_blocking(gfp) && !(attrs & DMA_ATTR_FORCE_CONTIGUOUS)) return iommu_dma_alloc_remap(dev, size, handle, gfp, attrs); - if (!gfpflags_allow_blocking(gfp) && !coherent) + if (IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) && + !gfpflags_allow_blocking(gfp) && !coherent) cpu_addr = dma_alloc_from_pool(PAGE_ALIGN(size), &page, gfp); else cpu_addr = iommu_dma_alloc_pages(dev, size, &page, gfp, attrs); @@ -1041,7 +1043,7 @@ static int iommu_dma_mmap(struct device *dev, struct vm_area_struct *vma, if (off >= nr_pages || vma_pages(vma) > nr_pages - off) return -ENXIO; - if (is_vmalloc_addr(cpu_addr)) { + if (IS_ENABLED(CONFIG_DMA_REMAP) && is_vmalloc_addr(cpu_addr)) { struct page **pages = __iommu_dma_get_pages(cpu_addr); if (pages) @@ -1063,7 +1065,7 @@ static int iommu_dma_get_sgtable(struct device *dev, struct sg_table *sgt, struct page *page; int ret; - if (is_vmalloc_addr(cpu_addr)) { + if (IS_ENABLED(CONFIG_DMA_REMAP) && is_vmalloc_addr(cpu_addr)) { struct page **pages = __iommu_dma_get_pages(cpu_addr); if (pages) { -- 2.20.1