public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: iommu@lists.linux-foundation.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
	Will Deacon <will.deacon@arm.com>,
	linux-kernel@vger.kernel.org, Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 2/8] iommu: Export and rename iommu_group_get_for_pci_dev()
Date: Wed, 21 Oct 2015 23:51:37 +0200	[thread overview]
Message-ID: <1445464303-18206-3-git-send-email-joro@8bytes.org> (raw)
In-Reply-To: <1445464303-18206-1-git-send-email-joro@8bytes.org>

From: Joerg Roedel <jroedel@suse.de>

Rename that function to pci_device_group() and export it, so
that IOMMU drivers can use it as their device_group
call-back.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/iommu.c | 8 ++++++--
 include/linux/iommu.h | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 5637463..fdea700 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -731,13 +731,17 @@ static int get_pci_alias_or_group(struct pci_dev *pdev, u16 alias, void *opaque)
  * Use standard PCI bus topology, isolation features, and DMA alias quirks
  * to find or create an IOMMU group for a device.
  */
-static struct iommu_group *iommu_group_get_for_pci_dev(struct pci_dev *pdev)
+struct iommu_group *pci_device_group(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct group_for_pci_data data;
 	struct pci_bus *bus;
 	struct iommu_group *group = NULL;
 	u64 devfns[4] = { 0 };
 
+	if (WARN_ON(!dev_is_pci(dev)))
+		return ERR_PTR(-EINVAL);
+
 	/*
 	 * Find the upstream DMA alias for the device.  A device must not
 	 * be aliased due to topology in order to have its own IOMMU group.
@@ -827,7 +831,7 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
 	if (ops && ops->device_group)
 		group = ops->device_group(dev);
 	else if (dev_is_pci(dev))
-		group = iommu_group_get_for_pci_dev(to_pci_dev(dev));
+		group = pci_device_group(dev);
 
 	if (IS_ERR(group))
 		return group;
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 5a19952..8026e6a 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -316,6 +316,9 @@ static inline size_t iommu_map_sg(struct iommu_domain *domain,
 	return domain->ops->map_sg(domain, iova, sg, nents, prot);
 }
 
+/* PCI device grouping function */
+extern struct iommu_group *pci_device_group(struct device *dev);
+
 #else /* CONFIG_IOMMU_API */
 
 struct iommu_ops {};
-- 
1.9.1


  parent reply	other threads:[~2015-10-21 21:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-21 21:51 [PATCH 0/8] iommu: Make core iommu-groups code more generic Joerg Roedel
2015-10-21 21:51 ` [PATCH 1/8] iommu: Revive device_group iommu-ops call-back Joerg Roedel
2015-10-21 21:51 ` Joerg Roedel [this message]
2015-10-21 21:51 ` [PATCH 3/8] iommu: Add generic_device_group() function Joerg Roedel
2015-10-21 21:51 ` [PATCH 4/8] iommu: Add device_group call-back to x86 iommu drivers Joerg Roedel
2015-10-21 21:51 ` [PATCH 5/8] iommu/fsl: Convert to device_group call-back Joerg Roedel
2015-10-21 21:51 ` [PATCH 6/8] iommu/arm-smmu: Switch " Joerg Roedel
2015-10-21 21:51 ` [PATCH 7/8] iommu: Remove is_pci_dev() fall-back from iommu_group_get_for_dev Joerg Roedel
2015-10-21 21:51 ` [PATCH 8/8] iommu: Move default domain allocation to iommu_group_get_for_dev() Joerg Roedel
2015-10-29 18:22   ` Will Deacon
2015-10-30 14:13     ` Joerg Roedel
2015-11-19  9:06 ` [PATCH 0/8] iommu: Make core iommu-groups code more generic Yong Wu
     [not found] ` <1447920801.27650.49.camel@mhfsdcap03>
2015-11-19 13:41   ` Joerg Roedel
2015-12-01 11:29     ` Yong Wu
2015-12-01 15:15       ` Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445464303-18206-3-git-send-email-joro@8bytes.org \
    --to=joro@8bytes.org \
    --cc=alex.williamson@redhat.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox