From patchwork Tue Aug 18 19:04:01 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: 508436 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 676B814030F for ; Wed, 19 Aug 2015 05:19:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753495AbbHRTTO (ORCPT ); Tue, 18 Aug 2015 15:19:14 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:5859 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753388AbbHRTTN (ORCPT ); Tue, 18 Aug 2015 15:19:13 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com id ; Tue, 18 Aug 2015 12:18:25 -0700 Received: from HQMAIL104.nvidia.com ([172.18.146.11]) by hqnvupgp08.nvidia.com (PGP Universal service); Tue, 18 Aug 2015 12:19:12 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Tue, 18 Aug 2015 12:19:12 -0700 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 18 Aug 2015 19:19:12 +0000 Received: from HQMAIL104.nvidia.com (172.18.146.11) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 18 Aug 2015 19:19:12 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server id 15.0.1044.25 via Frontend Transport; Tue, 18 Aug 2015 19:19:12 +0000 Received: from wdavis-lt.nvidia.com (Not Verified[10.20.168.59]) by hqnvemgw02.nvidia.com with MailMarshal (v7, 1, 2, 5326) id ; Tue, 18 Aug 2015 12:19:11 -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 v5 05/13] dma-mapping: pci: add pci_(un)map_peer_resource Date: Tue, 18 Aug 2015 14:04:01 -0500 Message-ID: <1439924649-29698-6-git-send-email-wdavis@nvidia.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1439924649-29698-1-git-send-email-wdavis@nvidia.com> References: <1439924649-29698-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 Simply route these through to the new dma_(un)map_peer_resource APIs. Also route pci_peer_mapping_error through to the new dma_peer_mapping_error API. Guard these new functions behind CONFIG_HAS_DMA_P2P. Signed-off-by: Will Davis Reviewed-by: Terence Ripperda Reviewed-by: John Hubbard --- include/asm-generic/pci-dma-compat.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/asm-generic/pci-dma-compat.h b/include/asm-generic/pci-dma-compat.h index c110843..7baf09e 100644 --- a/include/asm-generic/pci-dma-compat.h +++ b/include/asm-generic/pci-dma-compat.h @@ -61,6 +61,29 @@ pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction); } +#ifdef CONFIG_HAS_DMA_P2P +static inline dma_peer_addr_t +pci_map_peer_resource(struct pci_dev *hwdev, struct pci_dev *peer, + int res, unsigned long offset, size_t size, + int direction) +{ + return dma_map_peer_resource(hwdev == NULL ? NULL : &hwdev->dev, peer == NULL ? NULL : &peer->dev, peer == NULL ? NULL : &peer->resource[res], offset, size, (enum dma_data_direction)direction); +} + +static inline int +pci_dma_peer_mapping_error(struct pci_dev *pdev, dma_peer_addr_t dma_addr) +{ + return dma_peer_mapping_error(&pdev->dev, dma_addr); +} + +static inline void +pci_unmap_peer_resource(struct pci_dev *hwdev, dma_peer_addr_t dma_address, + size_t size, int direction) +{ + dma_unmap_peer_resource(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction); +} +#endif + static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)