public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 05/13] add domain flag DOMAIN_FLAG_VIRTUAL_MACHINE
@ 2008-12-02 14:22 Han, Weidong
  2008-12-04 17:12 ` Mark McLoughlin
  0 siblings, 1 reply; 3+ messages in thread
From: Han, Weidong @ 2008-12-02 14:22 UTC (permalink / raw)
  To: 'Avi Kivity', Woodhouse, David, 'Jesse Barnes'
  Cc: 'Joerg Roedel', Kay, Allen M, Yu, Fenghua,
	'kvm@vger.kernel.org',
	'iommu@lists.linux-foundation.org'

[-- Attachment #1: Type: text/plain, Size: 2215 bytes --]

By default, one domain owns one device, like native VT-d usage.

For kvm VT-d usage, more than one devices across iommus may be assigned to one domain, flag DOMAIN_FLAG_VIRTUAL_MACHINE is for this usage.

Signed-off-by: Weidong Han <weidong.han@intel.com>
---
 drivers/pci/intel-iommu.c     |    3 ++-
 include/linux/dma_remapping.h |   11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index fa1507b..09a5150 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -989,6 +989,7 @@ static struct dmar_domain * iommu_alloc_domain(struct intel_iommu *iommu)
 		domain->iommu_coherency = 0;
 
 	iommu->domains[num] = domain;
+	domain->flags = 0;
 	spin_unlock_irqrestore(&iommu->lock, flags);
 
 	return domain;
@@ -1387,7 +1388,7 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
 		info->dev = NULL;
 		info->domain = domain;
 		/* This domain is shared by devices under p2p bridge */
-		domain->flags |= DOMAIN_FLAG_MULTIPLE_DEVICES;
+		domain->flags |= DOMAIN_FLAG_P2P_MULTIPLE_DEVICES;
 
 		/* pcie-to-pci bridge already has a domain, uses it */
 		found = NULL;
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index add2111..9e39c99 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -159,6 +159,16 @@ struct dma_pte {
 
 struct intel_iommu;
 
+/* domain flags, one domain owns one device by default */
+
+/* devices under the same p2p bridge are owned in one domain */
+#define DOMAIN_FLAG_P2P_MULTIPLE_DEVICES	(1 << 0)
+
+/* domain represents a virtual machine, more than one devices
+ * across iommus may be owned in one domain, e.g. kvm guest.
+ */
+#define DOMAIN_FLAG_VIRTUAL_MACHINE		(1 << 1)
+
 struct dmar_domain {
 	int	id;			/* domain id */
 	unsigned long iommu_bmp;	/* bitmap of iommus this domain uses*/
@@ -173,7 +183,6 @@ struct dmar_domain {
 	/* adjusted guest address width, 0 is level 2 30-bit */
 	int		agaw;
 
-#define DOMAIN_FLAG_MULTIPLE_DEVICES 1
 	int		flags;
 
 	int		iommu_coherency;/* iommu access is coherent or not */
-- 
1.5.1

[-- Attachment #2: 0005-add-domain-flag-DOMAIN_FLAG_VIRTUAL_MACHINE.patch --]
[-- Type: application/octet-stream, Size: 2366 bytes --]

From 054c2019d4a368faf1c15674b0ad63ba24335c51 Mon Sep 17 00:00:00 2001
From: Weidong Han <weidong.han@intel.com>
Date: Tue, 2 Dec 2008 14:52:55 +0800
Subject: [PATCH] add domain flag DOMAIN_FLAG_VIRTUAL_MACHINE

By default, one domain owns one device, like native VT-d usage.

For kvm VT-d usage, more than one devices across iommus may be assigned to one domain, flag DOMAIN_FLAG_VIRTUAL_MACHINE is for this usage.

Signed-off-by: Weidong Han <weidong.han@intel.com>
---
 drivers/pci/intel-iommu.c     |    3 ++-
 include/linux/dma_remapping.h |   11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index fa1507b..09a5150 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -989,6 +989,7 @@ static struct dmar_domain * iommu_alloc_domain(struct intel_iommu *iommu)
 		domain->iommu_coherency = 0;
 
 	iommu->domains[num] = domain;
+	domain->flags = 0;
 	spin_unlock_irqrestore(&iommu->lock, flags);
 
 	return domain;
@@ -1387,7 +1388,7 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
 		info->dev = NULL;
 		info->domain = domain;
 		/* This domain is shared by devices under p2p bridge */
-		domain->flags |= DOMAIN_FLAG_MULTIPLE_DEVICES;
+		domain->flags |= DOMAIN_FLAG_P2P_MULTIPLE_DEVICES;
 
 		/* pcie-to-pci bridge already has a domain, uses it */
 		found = NULL;
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index add2111..9e39c99 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -159,6 +159,16 @@ struct dma_pte {
 
 struct intel_iommu;
 
+/* domain flags, one domain owns one device by default */
+
+/* devices under the same p2p bridge are owned in one domain */
+#define DOMAIN_FLAG_P2P_MULTIPLE_DEVICES	(1 << 0)
+
+/* domain represents a virtual machine, more than one devices
+ * across iommus may be owned in one domain, e.g. kvm guest.
+ */
+#define DOMAIN_FLAG_VIRTUAL_MACHINE		(1 << 1)
+
 struct dmar_domain {
 	int	id;			/* domain id */
 	unsigned long iommu_bmp;	/* bitmap of iommus this domain uses*/
@@ -173,7 +183,6 @@ struct dmar_domain {
 	/* adjusted guest address width, 0 is level 2 30-bit */
 	int		agaw;
 
-#define DOMAIN_FLAG_MULTIPLE_DEVICES 1
 	int		flags;
 
 	int		iommu_coherency;/* iommu access is coherent or not */
-- 
1.5.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-05  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-02 14:22 [PATCH 05/13] add domain flag DOMAIN_FLAG_VIRTUAL_MACHINE Han, Weidong
2008-12-04 17:12 ` Mark McLoughlin
2008-12-05  1:06   ` Han, Weidong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox