Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4840542imj; Wed, 13 Feb 2019 01:55:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IYBWICMfn6MSO1TeOeilMILRGtS0wG4mGB46DQCP0bfPKu94dfmlL7ghVpolvP97WNGbpep X-Received: by 2002:a62:931a:: with SMTP id b26mr9113111pfe.65.1550051736897; Wed, 13 Feb 2019 01:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550051736; cv=none; d=google.com; s=arc-20160816; b=g2dPtomxMCO4zVPYKkxdW5Z4xRrVCZeEtms0QwY5Bc6nrrNDKBC/RkJ6JP65XNrOxf 6sgdpCZfz3A3zMObb7+j/37TAKFjGeRYr2G8JaxBojBZkqLtTcHpHIsUfoxanMmzUk4A izNT0Tv5P4VW84V3C1pJGPtJhqLdLXdqJMCaeE80TSYyq/IfpiYVjVTGp6DYGOkGXmv6 nR2kPY9w/y6HawfWU/Odugg32E5Z6YxEsuF2Ve5z66V29ioBgwnyFo2cbm8KO6Z0OLvl yaiJcRf8YZA+Drt9AtsWu9gm1rfD1uTzKLCoUnhuQ4kGlHsLXSyhT7TYSbxSPTonzQjM T1sg== 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=CT47ruOaxyleNFC3cJ9kW9qdod5JWWtEWyjzfLMthJ4=; b=RIOb9dN9zwFQJG7DF/KhDKz8PcDvYBZek/H8JmJlGjZcnT0qIu7jb2hMo7JphkgPi5 CzctBwG/qrwlRbCpG0+os2TVkEsqmJtm02ty2htrp2POZVpRhZ/t0jM0VPoWKp7X2YIM dIF+ohMoYgYkhnzVRBF3uaPxE09JSRqkiz6aoxuqrwv8d3pzbJApe6SKNFCrR0tcBBxp hHV+9Lu2QK6icBLow/KqWB0nloqDSS+h1qY6VqPvJDL8Rh4XPXM4tSd2NIGlc+DIQxXj s7nT48O52hb4nGwEHSB1RvsJMe4wkq15A4qe3mLUGy3Bbce50l8E53Y+5GZpd3WWpXvN vrKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=K0Dpsi4o; 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 k69si12968479pga.176.2019.02.13.01.55.21; Wed, 13 Feb 2019 01:55:36 -0800 (PST) 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=K0Dpsi4o; 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 S2388544AbfBMHCg (ORCPT + 99 others); Wed, 13 Feb 2019 02:02:36 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:51156 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388415AbfBMHCb (ORCPT ); Wed, 13 Feb 2019 02:02:31 -0500 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=CT47ruOaxyleNFC3cJ9kW9qdod5JWWtEWyjzfLMthJ4=; b=K0Dpsi4om9iZL6zqJQh18ijlRJ EFrsNWbWpzYiE/781oX+a3O9C9mdrjtKrM63kGLIuojg2jRESJ4g19MSNQYK7FM6VTqTKCG2OHl7W 34jawgIXJ5Qi1SorZ3CWDjpYmHaCx9HEY2CePgn4FVzUtLsRZmaOMpC5kWkzVBbVTwsa26EaDFtrn ABsIFJBYGBAHDt6unf16EPz0eqm2za0jjsgFSnguJ794JcMQTC5iRerCnp0zqrNQl5ZhGrK34r2ON T07n2Fr/gUexbGvuqsQmDjPWErW4JzMle90kxyJ+H3JWHWLsVdFHkSzAEUiJD6C5A2RQS8Jl7W7lb bGbsD+5g==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtoYe-0000LO-MW; Wed, 13 Feb 2019 07:02:13 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Olof Johansson Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Christian Zigotzky Subject: [PATCH 16/32] powerpc/dma: remove the iommu fallback for coherent allocations Date: Wed, 13 Feb 2019 08:01:17 +0100 Message-Id: <20190213070133.11259-17-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213070133.11259-1-hch@lst.de> References: <20190213070133.11259-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 All iommu capable platforms now always use the iommu code with the internal bypass, so there is not need for this magic anymore. Signed-off-by: Christoph Hellwig Tested-by: Christian Zigotzky --- arch/powerpc/Kconfig | 4 --- arch/powerpc/kernel/dma.c | 68 ++------------------------------------- 2 files changed, 2 insertions(+), 70 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 08908219fba9..8a4ae675c9ba 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -119,9 +119,6 @@ config GENERIC_HWEIGHT bool default y -config ARCH_HAS_DMA_SET_COHERENT_MASK - bool - config PPC bool default y @@ -130,7 +127,6 @@ config PPC # select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEVMEM_IS_ALLOWED - select ARCH_HAS_DMA_SET_COHERENT_MASK select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 5eca02315b2e..9def69c8f602 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -115,51 +115,6 @@ void __dma_nommu_free_coherent(struct device *dev, size_t size, } #endif /* !CONFIG_NOT_COHERENT_CACHE */ -static void *dma_nommu_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag, - unsigned long attrs) -{ - struct iommu_table *iommu; - - /* The coherent mask may be smaller than the real mask, check if - * we can really use the direct ops - */ - if (dma_nommu_dma_supported(dev, dev->coherent_dma_mask)) - return __dma_nommu_alloc_coherent(dev, size, dma_handle, - flag, attrs); - - /* Ok we can't ... do we have an iommu ? If not, fail */ - iommu = get_iommu_table_base(dev); - if (!iommu) - return NULL; - - /* Try to use the iommu */ - return iommu_alloc_coherent(dev, iommu, size, dma_handle, - dev->coherent_dma_mask, flag, - dev_to_node(dev)); -} - -static void dma_nommu_free_coherent(struct device *dev, size_t size, - void *vaddr, dma_addr_t dma_handle, - unsigned long attrs) -{ - struct iommu_table *iommu; - - /* See comments in dma_nommu_alloc_coherent() */ - if (dma_nommu_dma_supported(dev, dev->coherent_dma_mask)) - return __dma_nommu_free_coherent(dev, size, vaddr, dma_handle, - attrs); - /* Maybe we used an iommu ... */ - iommu = get_iommu_table_base(dev); - - /* If we hit that we should have never allocated in the first - * place so how come we are freeing ? - */ - if (WARN_ON(!iommu)) - return; - iommu_free_coherent(iommu, size, vaddr, dma_handle); -} - int dma_nommu_mmap_coherent(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, dma_addr_t handle, size_t size, unsigned long attrs) @@ -262,8 +217,8 @@ static inline void dma_nommu_sync_single(struct device *dev, #endif const struct dma_map_ops dma_nommu_ops = { - .alloc = dma_nommu_alloc_coherent, - .free = dma_nommu_free_coherent, + .alloc = __dma_nommu_alloc_coherent, + .free = __dma_nommu_free_coherent, .mmap = dma_nommu_mmap_coherent, .map_sg = dma_nommu_map_sg, .unmap_sg = dma_nommu_unmap_sg, @@ -280,25 +235,6 @@ const struct dma_map_ops dma_nommu_ops = { }; EXPORT_SYMBOL(dma_nommu_ops); -int dma_set_coherent_mask(struct device *dev, u64 mask) -{ - if (!dma_supported(dev, mask)) { - /* - * We need to special case the direct DMA ops which can - * support a fallback for coherent allocations. There - * is no dma_op->set_coherent_mask() so we have to do - * things the hard way: - */ - if (get_dma_ops(dev) != &dma_nommu_ops || - get_iommu_table_base(dev) == NULL || - !dma_iommu_dma_supported(dev, mask)) - return -EIO; - } - dev->coherent_dma_mask = mask; - return 0; -} -EXPORT_SYMBOL(dma_set_coherent_mask); - int dma_set_mask(struct device *dev, u64 dma_mask) { if (ppc_md.dma_set_mask) -- 2.20.1