From patchwork Fri Jul 25 13:31:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 373705 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 7B0EE140108 for ; Fri, 25 Jul 2014 23:31:53 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760134AbaGYNbv (ORCPT ); Fri, 25 Jul 2014 09:31:51 -0400 Received: from mga02.intel.com ([134.134.136.20]:60526 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759908AbaGYNbu (ORCPT ); Fri, 25 Jul 2014 09:31:50 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 25 Jul 2014 06:31:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,731,1400050800"; d="scan'208";a="548976030" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.73]) by orsmga001.jf.intel.com with ESMTP; 25 Jul 2014 06:31:46 -0700 Received: from andy by smile with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1XAfb7-0005Ec-1s; Fri, 25 Jul 2014 16:31:45 +0300 From: Andy Shevchenko To: Alex Williamson , linux-pci@vger.kernel.org, Bjorn Helgaas , Mark Brown , Greg Kroah-Hartman , linux-spi@vger.kernel.org, linux-serial@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users Date: Fri, 25 Jul 2014 16:31:42 +0300 Message-Id: <1406295104-20082-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.0.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some chipsets use the function 0 for DMA on other functions of a multifunctional device. One of the example is Intel EG20T PCH. This is also applicable to Lynxpoint PCH when LPSS devices are switched to PCI mode. This patch exports a useful helper to get a device of the DMA. This device is needed to request a DMA channel from a proper controller. Signed-off-by: Andy Shevchenko --- drivers/pci/quirks.c | 2 +- include/linux/pci.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 80c2d01..8352e5b 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -3517,7 +3517,7 @@ static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev) if (!PCI_FUNC(dev->devfn)) return pci_dev_get(dev); - return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); + return pci_get_dma_device(dev); } static const struct pci_dev_dma_source { diff --git a/include/linux/pci.h b/include/linux/pci.h index 61978a4..86caab7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1575,6 +1575,15 @@ static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev, static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { } #endif +/* + * Some chipsets use the function 0 for DMA on other functions of a + * multifunctional device. + */ +static inline struct pci_dev *pci_get_dma_device(struct pci_dev *dev) +{ + return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); +} + void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);