Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4865441imm; Tue, 9 Oct 2018 06:28:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV62bj23iyGkGlw7ODhCtmHtW93E0riaklgbTAvS7TiErV/AfseZ8ibPAplVCGbPqfVbP4NIq X-Received: by 2002:a62:384c:: with SMTP id f73-v6mr30059123pfa.242.1539091722783; Tue, 09 Oct 2018 06:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091722; cv=none; d=google.com; s=arc-20160816; b=YznEFwjqrMUhPpyAbSm/r9AmiJEnh85yC/U0/EdYyLb23Ty80Vn3UJMEUZj5s9v0EX kQ9WENuqUsV2yPwA9ScwmG86+ehFi0bfYBI+rFuMVFeDNgkFcBJrFDMgyTxJ3WjGbi7y a+sdI5ubxSREV9OKbfH21UpkNO1T6C3PXONTVDH/c9rdrUii3S6Qqgc9Z9Dcd1bRO71N MCbGX7ZC491xK9K3mPaF3b+WiVUBZj6xDPonqsFsJiBFmsBNCNTl9RcFAFo1r0l4Uh2N N1II7eqONdUyYcYJmCo8+b0Q2woVlCvkHlBrBpowCuvpC/ctfjSwa8a6amOdDEk496US zNqw== 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=Ql7aNHvXxzTTeGCBs2l+3pR2u55du0W8IqjAoV6Ofu0=; b=Y0I9EHNSB3nxjSpLKJFOV2UPW64FecF4DGdfIl8OOqeZ0nd09Gb5f7oZikrvGFbAJR fHDnovppBxQqJzsp306BC+a906bJUn36PElIfhj0WAKXcknGZTsVfNbT6qfWfOLF/sXA smfWiCjHoKVOMFt8s6Og48pbnQB5i4Hrw2ROnN8kGeQgRuU3JpxogZgnmZNMDNnrIunJ X3UUS5eQWubKmw0JspnVicgNQzb0iFmolM3UEakCwZs+eABGSf8BP07yk7Tqa2g5BDU3 HWxGs2RblzvV2kJIFbeV9IDalGD2LqTTMjTQezbEhDgglCcixNCx9c9AlT6JqsfOiJVu vyIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=VhBM8FnV; 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 q29-v6si20388356pgm.295.2018.10.09.06.28.27; Tue, 09 Oct 2018 06:28:42 -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=VhBM8FnV; 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 S1727860AbeJIUnc (ORCPT + 99 others); Tue, 9 Oct 2018 16:43:32 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50450 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbeJIUnb (ORCPT ); Tue, 9 Oct 2018 16:43:31 -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=Ql7aNHvXxzTTeGCBs2l+3pR2u55du0W8IqjAoV6Ofu0=; b=VhBM8FnV/Qb+hJcAxNWpyw9fjs 6Q0QpkQut2T2b2x7zH2vBrGPoBZ7Nddazm5NgWlGmEITQuh/VYiWFXAgEFmdG2tFGTp1XTNf4xule QvTfYZnRF035flgMM6Zlgs40ULWxeyO72tDCMRb/k8HL6h2mW5DnASyOnevYy6Z/gJJ9OV5imIhLO qiW9dwSI1vDt+rx3oM7OeCTS9CWUXBMcKitKCyIkg36gRE8UzpDCLxlDaanT1k3jpSCHKIVMWw4Do hfp7AF2F70U9I5gFCs7JlLzGtuCNeZ2iuVRs6zqNwIJCahrt5+e+/NUl2esH4mmei2gIY0GuAc0P1 0tZPIB3A==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1b-0001Wk-6c; Tue, 09 Oct 2018 13:26:11 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 27/33] dma-mapping, powerpc: simplify the arch dma_set_mask override Date: Tue, 9 Oct 2018 15:24:54 +0200 Message-Id: <20181009132500.17643-28-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-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 Instead of letting the architecture supply all of dma_set_mask just give it an additional hook selected by Kconfig. Signed-off-by: Christoph Hellwig --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/dma-mapping.h | 3 --- arch/powerpc/kernel/dma-swiotlb.c | 8 ++++++++ arch/powerpc/kernel/dma.c | 12 ------------ arch/powerpc/sysdev/fsl_pci.c | 4 ---- include/linux/dma-mapping.h | 11 ++++++++--- kernel/dma/Kconfig | 3 +++ 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 7097019d8907..7ea01687995d 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -126,6 +126,7 @@ config PPC # Please keep this list sorted alphabetically. # select ARCH_HAS_DEVMEM_IS_ALLOWED + select ARCH_HAS_DMA_SET_MASK if SWIOTLB select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index b1999880fc61..7694985f05ee 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -109,8 +109,5 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off) dev->archdata.dma_offset = off; } -#define HAVE_ARCH_DMA_SET_MASK 1 -extern int dma_set_mask(struct device *dev, u64 dma_mask); - #endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */ diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index e05d95ff50ad..dba216dd70fd 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -22,6 +22,14 @@ #include #include +bool arch_dma_set_mask(struct device *dev, u64 dma_mask) +{ + if (!ppc_md.dma_set_mask) + return 0; + return ppc_md.dma_set_mask(dev, dma_mask); +} +EXPORT_SYMBOL(arch_dma_set_mask); + unsigned int ppc_swiotlb_enable; /* diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index e3d2c15b209c..795afe387c91 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -197,18 +197,6 @@ const struct dma_map_ops dma_nommu_ops = { }; EXPORT_SYMBOL(dma_nommu_ops); -int dma_set_mask(struct device *dev, u64 dma_mask) -{ - if (ppc_md.dma_set_mask) - return ppc_md.dma_set_mask(dev, dma_mask); - - if (!dev->dma_mask || !dma_supported(dev, dma_mask)) - return -EIO; - *dev->dma_mask = dma_mask; - return 0; -} -EXPORT_SYMBOL(dma_set_mask); - static int __init dma_init(void) { #ifdef CONFIG_IBMVIO diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index 296ffabc9386..cb91a3d113d1 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -135,9 +135,6 @@ static inline void setup_swiotlb_ops(struct pci_controller *hose) {} static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask) { - if (!dev->dma_mask || !dma_supported(dev, dma_mask)) - return -EIO; - /* * Fix up PCI devices that are able to DMA to the large inbound * mapping that allows addressing any RAM address from across PCI. @@ -147,7 +144,6 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask) set_dma_offset(dev, pci64_dma_offset); } - *dev->dma_mask = dma_mask; return 0; } diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 15bd41447025..8dd19e66c0e5 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -598,18 +598,23 @@ static inline int dma_supported(struct device *dev, u64 mask) return ops->dma_supported(dev, mask); } -#ifndef HAVE_ARCH_DMA_SET_MASK +#ifdef CONFIG_ARCH_HAS_DMA_SET_MASK +bool arch_dma_set_mask(struct device *dev, u64 mask); +#else +#define arch_dma_set_mask(dev, mask) true +#endif + static inline int dma_set_mask(struct device *dev, u64 mask) { if (!dev->dma_mask || !dma_supported(dev, mask)) return -EIO; - + if (!arch_dma_set_mask(dev, mask)) + return -EIO; dma_check_mask(dev, mask); *dev->dma_mask = mask; return 0; } -#endif static inline u64 dma_get_mask(struct device *dev) { diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig index 645c7a2ecde8..951045c90c2c 100644 --- a/kernel/dma/Kconfig +++ b/kernel/dma/Kconfig @@ -16,6 +16,9 @@ config ARCH_DMA_ADDR_T_64BIT config ARCH_HAS_DMA_COHERENCE_H bool +config ARCH_HAS_DMA_SET_MASK + bool + config HAVE_GENERIC_DMA_COHERENT bool -- 2.19.0