From patchwork Wed Jul 22 21:39:50 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: 498841 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 D7034140B0D for ; Thu, 23 Jul 2015 07:54:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753494AbbGVVyG (ORCPT ); Wed, 22 Jul 2015 17:54:06 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:2971 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbbGVVyE (ORCPT ); Wed, 22 Jul 2015 17:54:04 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Wed, 22 Jul 2015 14:54:41 -0700 Received: from HQMAIL107.nvidia.com ([172.20.12.94]) by hqnvupgp08.nvidia.com (PGP Universal service); Wed, 22 Jul 2015 14:54:03 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Wed, 22 Jul 2015 14:54:03 -0700 Received: from HQMAIL103.nvidia.com (172.20.187.11) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Wed, 22 Jul 2015 21:54:03 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server id 15.0.1044.25 via Frontend Transport; Wed, 22 Jul 2015 21:54:03 +0000 Received: from wdavis-lt.nvidia.com (Not Verified[10.20.168.59]) by hqnvemgw01.nvidia.com with MailMarshal (v7, 1, 2, 5326) id ; Wed, 22 Jul 2015 14:54:03 -0700 From: Will Davis To: Bjorn Helgaas , Alex Williamson , Joerg Roedel CC: , , Konrad Wilk , Mark Hounschell , "David S. Miller" , Jonathan Corbet , Terence Ripperda , John Hubbard , Jerome Glisse Subject: [PATCH v4 05/12] dma-mapping: pci: add pci_(un)map_peer_resource Date: Wed, 22 Jul 2015 16:39:50 -0500 Message-ID: <1437601197-6481-6-git-send-email-wdavis@nvidia.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1437601197-6481-1-git-send-email-wdavis@nvidia.com> References: <1437601197-6481-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)