From patchwork Tue Sep 15 17:10:55 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: 518038 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 60463140157 for ; Wed, 16 Sep 2015 03:11:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751532AbbIORLm (ORCPT ); Tue, 15 Sep 2015 13:11:42 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:13419 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751005AbbIORLm (ORCPT ); Tue, 15 Sep 2015 13:11:42 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Tue, 15 Sep 2015 10:11:31 -0700 Received: from HQMAIL104.nvidia.com ([172.18.146.11]) by hqnvupgp07.nvidia.com (PGP Universal service); Tue, 15 Sep 2015 10:06:29 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 15 Sep 2015 10:06:29 -0700 Received: from HQMAIL104.nvidia.com (172.18.146.11) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 15 Sep 2015 17:11:41 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server id 15.0.1044.25 via Frontend Transport; Tue, 15 Sep 2015 17:11:41 +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:11:41 -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 10/22] PCI: Add pci_resource_to_peer() Date: Tue, 15 Sep 2015 12:10:55 -0500 Message-ID: <1442337067-22964-11-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 helper to convert a struct resource to a peer DMA address. Signed-off-by: Will Davis --- include/linux/pci.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index db0cb51..2a9deff 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1508,6 +1508,22 @@ static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, } #endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */ +#ifdef CONFIG_HAS_DMA_P2P +static inline bool pci_resource_to_peer(struct pci_dev *dev, + struct pci_dev *peer, + struct resource *res, + dma_peer_addr_t *peer_addr) { + if (pci_peer_traffic_supported(dev, peer)) { + struct pci_bus_region region; + + pcibios_resource_to_bus(dev->bus, ®ion, res); + *peer_addr = region.start; + return true; + } + + return false; +} +#endif /* CONFIG_HAS_DMA_P2P */ /* * The world is not perfect and supplies us with broken PCI devices.