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 <[EMAIL PROTECTED]>
---
 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: 0005-add-domain-flag-DOMAIN_FLAG_VIRTUAL_MACHINE.patch
Description: 0005-add-domain-flag-DOMAIN_FLAG_VIRTUAL_MACHINE.patch

Reply via email to