Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4866812imm; Tue, 9 Oct 2018 06:29:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV62r36ODmhO4o57265FN0ybTxLYd8AuZ+vvrXDCj0SvtXHS9BVI2nODaZSqmhDbjW+dKm1eQ X-Received: by 2002:a62:1655:: with SMTP id 82-v6mr29754910pfw.11.1539091783856; Tue, 09 Oct 2018 06:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091783; cv=none; d=google.com; s=arc-20160816; b=uSB4c/nMFDjt5JBCBIDdJuv0hrRSm2aLztxEHCH2R+Qv6Y5QGShHEshUT9jVpxhHWp e9qiI+dctCLQfOvf5SuZbky7TaAH4G4+I4Zf/LEE/1X1SQLukZUrggpDPKPecIzmQxuK 3zhWCNeWTNrndJ34RUWn8xuYRLYICh8ZGzqUXSO6r7FaIDOGjQEciw9Cn66Ha33WEDZZ Na0aS1J0SMBTuzoiWFD1cKQlTViy/9+cBM9rMjyooMaUNAQGps67uXopDk66M/cSpxkN inJMTVZeYHUNh/rLo3bDIroLJ09nR+1Q3nuRroCr7eI/qPHq2KYC5iWThhOwL0TXfNiL ybzQ== 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=hhwdg0p6cD+tBZ2LvXC+nRssqLc7D1MCrzZuVKtcd0k=; b=Fj6xvhq9ZzgCmJfs0ekePqwXKj8x2/R0E4NEon4fUdWLC24qPW/QPY9uxVR0S4D6l0 f8bqvVLtq2xeHwzSClpHfWWJqyh8c94rFXE+wsKSsfSXeqf9AeLuzkmzCC96HRMIirXA h5+4xOMneqGZhbJ1AgY5oDV5Cq7VuLVZabIHBdIjDm8eQ6c1DRRtMpeN8PU4D42h3rVR C8xAwO+siTaXdR58U5O9pbq72wf8VpPCdeeuWRpbpm5wciLAUz6jME/fc7DyNKrSb820 5sIWV5t6ileX/4XLLJ9mD0p47sAMBt/n1GXS8YgMayUBkq+qma/4pZr4vsP0mPQ+hRSE og5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=L7giyn18; 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 u13-v6si21898200pfl.129.2018.10.09.06.29.29; Tue, 09 Oct 2018 06:29:43 -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=L7giyn18; 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 S1727467AbeJIUnJ (ORCPT + 99 others); Tue, 9 Oct 2018 16:43:09 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49496 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727376AbeJIUnH (ORCPT ); Tue, 9 Oct 2018 16:43:07 -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=hhwdg0p6cD+tBZ2LvXC+nRssqLc7D1MCrzZuVKtcd0k=; b=L7giyn18J6TxYDQfxVkMj3gVH0 Ew5szJrxKfbV8637Zyd7t+IvyFu01/sTfwQoJXXPYHsjeVSN7AJVLrm78NpBozF9m95TIAg3rAHTG DMehxdVSNaIpP/YiAYToVnZif0ptzHQZOZUgDrsqtlskp3Ce6JvS4mGseSB8jxoe72IfS3MdzGye0 9yiMTmZdkZIos2z1Ldn5zJMstPlRJuGdlPjfLagCcNYC0i6dezrYl0iLUyXImOVMYC+pJbuFZnEyV IF4SegwaByNeKspz2z1zC6fAejtlQzyFPWjOjCAdT4IJLfjj2Iqd+6h96fed9QAkiieHe+TcliUab jOZlftXg==; 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 1g9s11-0001Bk-GY; Tue, 09 Oct 2018 13:25:35 +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 14/33] powerpc/dart: use the generic iommu bypass code Date: Tue, 9 Oct 2018 15:24:41 +0200 Message-Id: <20181009132500.17643-15-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 Use the generic iommu bypass code instead of overriding set_dma_mask. Signed-off-by: Christoph Hellwig --- arch/powerpc/sysdev/dart_iommu.c | 45 +++++++++++--------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c index ce5dd2048f57..e7d1645a2d2e 100644 --- a/arch/powerpc/sysdev/dart_iommu.c +++ b/arch/powerpc/sysdev/dart_iommu.c @@ -360,13 +360,6 @@ static void iommu_table_dart_setup(void) set_bit(iommu_table_dart.it_size - 1, iommu_table_dart.it_map); } -static void pci_dma_dev_setup_dart(struct pci_dev *dev) -{ - if (dart_is_u4) - set_dma_offset(&dev->dev, DART_U4_BYPASS_BASE); - set_iommu_table_base(&dev->dev, &iommu_table_dart); -} - static void pci_dma_bus_setup_dart(struct pci_bus *bus) { if (!iommu_table_dart_inited) { @@ -390,27 +383,16 @@ static bool dart_device_on_pcie(struct device *dev) return false; } -static int dart_dma_set_mask(struct device *dev, u64 dma_mask) +static void pci_dma_dev_setup_dart(struct pci_dev *dev) { - if (!dev->dma_mask || !dma_supported(dev, dma_mask)) - return -EIO; - - /* U4 supports a DART bypass, we use it for 64-bit capable - * devices to improve performances. However, that only works - * for devices connected to U4 own PCIe interface, not bridged - * through hypertransport. We need the device to support at - * least 40 bits of addresses. - */ - if (dart_device_on_pcie(dev) && dma_mask >= DMA_BIT_MASK(40)) { - dev_info(dev, "Using 64-bit DMA iommu bypass\n"); - set_dma_ops(dev, &dma_nommu_ops); - } else { - dev_info(dev, "Using 32-bit DMA via iommu\n"); - set_dma_ops(dev, &dma_iommu_ops); - } + if (dart_is_u4 && dart_device_on_pcie(&dev->dev)) + set_dma_offset(&dev->dev, DART_U4_BYPASS_BASE); + set_iommu_table_base(&dev->dev, &iommu_table_dart); +} - *dev->dma_mask = dma_mask; - return 0; +static bool iommu_bypass_supported_dart(struct pci_dev *dev, u64 mask) +{ + return dart_is_u4 && dart_device_on_pcie(&dev->dev); } void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) @@ -430,12 +412,15 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) if (dart_init(dn) != 0) return; - /* Setup bypass if supported */ - if (dart_is_u4) - ppc_md.dma_set_mask = dart_dma_set_mask; - + /* + * U4 supports a DART bypass, we use it for 64-bit capable devices to + * improve performance. However, that only works for devices connected + * to the U4 own PCIe interface, not bridged through hypertransport. + * We need the device to support at least 40 bits of addresses. + */ controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; + controller_ops->iommu_bypass_supported = iommu_bypass_supported_dart; /* Setup pci_dma ops */ set_pci_dma_ops(&dma_iommu_ops); -- 2.19.0