From patchwork Tue Sep 15 17:11:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wdavis@nvidia.com X-Patchwork-Id: 518046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7F655140134 for ; Wed, 16 Sep 2015 03:12:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751834AbbIORMG (ORCPT ); Tue, 15 Sep 2015 13:12:06 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:7936 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbbIORMD (ORCPT ); Tue, 15 Sep 2015 13:12:03 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com id ; Tue, 15 Sep 2015 10:12:10 -0700 Received: from HQMAIL103.nvidia.com ([172.20.12.94]) by hqnvupgp07.nvidia.com (PGP Universal service); Tue, 15 Sep 2015 10:06:51 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 15 Sep 2015 10:06:51 -0700 Received: from HQMAIL108.nvidia.com (172.18.146.13) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 15 Sep 2015 17:12:03 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server id 15.0.1044.25 via Frontend Transport; Tue, 15 Sep 2015 17:12:02 +0000 Received: from wdavis-lt.nvidia.com (Not Verified[10.20.168.59]) by hqnvemgw01.nvidia.com with MailMarshal (v7, 1, 2, 5326) id ; Tue, 15 Sep 2015 10:12:02 -0700 From: Will Davis To: Bjorn Helgaas CC: Alex Williamson , Joerg Roedel , , , Konrad Wilk , Mark Hounschell , "David S. Miller" , Jonathan Corbet , Terence Ripperda , John Hubbard , Jerome Glisse , Will Davis Subject: [PATCH 18/22] x86: add pci-nommu implementation of map_peer_resource Date: Tue, 15 Sep 2015 12:11:03 -0500 Message-ID: <1442337067-22964-19-git-send-email-wdavis@nvidia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1442337067-22964-1-git-send-email-wdavis@nvidia.com> References: <1442337067-22964-1-git-send-email-wdavis@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Add Intel nommu implementation of 'map_peer_resource'. Add behind CONFIG_HAS_DMA_P2P guards, since the dma_map_ops members are behind them as well. Signed-off-by: Will Davis --- arch/x86/kernel/pci-nommu.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c index da15918..135ed1b 100644 --- a/arch/x86/kernel/pci-nommu.c +++ b/arch/x86/kernel/pci-nommu.c @@ -38,6 +38,33 @@ static dma_addr_t nommu_map_page(struct device *dev, struct page *page, return bus; } +#ifdef CONFIG_HAS_DMA_P2P +static dma_peer_addr_t nommu_map_peer_resource(struct device *dev, + struct device *peer, + struct resource *res, + unsigned long offset, + size_t size, + enum dma_data_direction dir, + struct dma_attrs *attrs) +{ + dma_peer_addr_t dma_address; + + if (!dev_is_pci(dev) || !dev_is_pci(peer)) + return DMA_ERROR_CODE; + + if (!pci_resource_to_peer(to_pci_dev(dev), to_pci_dev(peer), res, + &dma_address)) + return DMA_ERROR_CODE; + + dma_address += offset; + WARN_ON(size == 0); + if (!check_addr("map_peer_resource", dev, dma_address, size)) + return DMA_ERROR_CODE; + flush_write_buffers(); + return dma_address; +} +#endif + /* Map a set of buffers described by scatterlist in streaming * mode for DMA. This is the scatter-gather version of the * above pci_map_single interface. Here the scatter gather list @@ -93,6 +120,9 @@ struct dma_map_ops nommu_dma_ops = { .free = dma_generic_free_coherent, .map_sg = nommu_map_sg, .map_page = nommu_map_page, +#ifdef CONFIG_HAS_DMA_P2P + .map_peer_resource = nommu_map_peer_resource, +#endif .sync_single_for_device = nommu_sync_single_for_device, .sync_sg_for_device = nommu_sync_sg_for_device, .is_phys = 1,