]> xenbits.xensource.com Git - people/hx242/xen.git/commitdiff
x86/vtd: Drop struct intel_iommu
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 27 Nov 2018 15:27:41 +0000 (15:27 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 5 Sep 2019 10:45:00 +0000 (11:45 +0100)
The sole remaining member of struct intel_iommu is the drhd backpointer.  Move
this into struct vtd_iommu, replacing the the 'intel' pointer.

This removes one dynamic memory allocation per IOMMU on the system.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/vtd/iommu.h
xen/drivers/passthrough/vtd/quirks.c
xen/drivers/passthrough/vtd/utils.c

index 2fa0e743e2dc6f7635d67f5bdec1fc412f4d06d0..04d46f7eaba576fc001d9dc2f16e973836cd3484 100644 (file)
@@ -139,22 +139,6 @@ static int context_get_domain_id(struct context_entry *context,
     return domid;
 }
 
-static struct intel_iommu *__init alloc_intel_iommu(void)
-{
-    struct intel_iommu *intel;
-
-    intel = xzalloc(struct intel_iommu);
-    if ( intel == NULL )
-        return NULL;
-
-    return intel;
-}
-
-static void __init free_intel_iommu(struct intel_iommu *intel)
-{
-    xfree(intel);
-}
-
 static int iommus_incoherent;
 static void __iommu_flush_cache(void *addr, unsigned int size)
 {
@@ -850,7 +834,7 @@ static int iommu_page_fault_do_one(struct vtd_iommu *iommu, int type,
 {
     const char *reason, *kind;
     enum faulttype fault_type;
-    u16 seg = iommu->intel->drhd->segment;
+    u16 seg = iommu->drhd->segment;
 
     reason = iommu_get_fault_reason(fault_reason, &fault_type);
     switch ( fault_type )
@@ -963,7 +947,7 @@ static void __do_iommu_page_fault(struct vtd_iommu *iommu)
         iommu_page_fault_do_one(iommu, type, fault_reason,
                                 source_id, guest_addr);
 
-        pci_check_disable_device(iommu->intel->drhd->segment,
+        pci_check_disable_device(iommu->drhd->segment,
                                  PCI_BUS(source_id), PCI_DEVFN2(source_id));
 
         fault_index++;
@@ -1162,13 +1146,7 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd)
     INIT_LIST_HEAD(&iommu->ats_devices);
     spin_lock_init(&iommu->intremap.lock);
 
-    iommu->intel = alloc_intel_iommu();
-    if ( iommu->intel == NULL )
-    {
-        xfree(iommu);
-        return -ENOMEM;
-    }
-    iommu->intel->drhd = drhd;
+    iommu->drhd = drhd;
     drhd->iommu = iommu;
 
     iommu->reg = ioremap(drhd->address, PAGE_SIZE);
@@ -1258,7 +1236,6 @@ void __init iommu_free(struct acpi_drhd_unit *drhd)
     xfree(iommu->domid_bitmap);
     xfree(iommu->domid_map);
 
-    free_intel_iommu(iommu->intel);
     if ( iommu->msi.irq >= 0 )
         destroy_irq(iommu->msi.irq);
     xfree(iommu);
@@ -1308,7 +1285,7 @@ int domain_context_mapping_one(
     struct domain_iommu *hd = dom_iommu(domain);
     struct context_entry *context, *context_entries;
     u64 maddr, pgd_maddr;
-    u16 seg = iommu->intel->drhd->segment;
+    u16 seg = iommu->drhd->segment;
     int agaw, rc, ret;
     bool_t flush_dev_iotlb;
 
@@ -1608,7 +1585,7 @@ int domain_context_unmap_one(
     spin_unlock(&iommu->lock);
     unmap_vtd_domain_page(context_entries);
 
-    if ( !iommu->intel->drhd->segment && !rc )
+    if ( !iommu->drhd->segment && !rc )
         rc = me_wifi_quirk(domain, bus, devfn, UNMAP_ME_PHANTOM_FUNC);
 
     return rc;
index ae2369ca55151af485acfe51a7acbb8f96aa35ac..216791b3d63498137b56c3231478007ddef9746a 100644 (file)
@@ -505,10 +505,6 @@ extern struct list_head acpi_drhd_units;
 extern struct list_head acpi_rmrr_units;
 extern struct list_head acpi_ioapic_units;
 
-struct intel_iommu {
-    struct acpi_drhd_unit *drhd;
-};
-
 struct vtd_iommu {
     struct list_head list;
     void __iomem *reg; /* Pointer to hardware regs, virtual addr */
@@ -521,7 +517,7 @@ struct vtd_iommu {
     u64 root_maddr; /* root entry machine address */
     nodeid_t node;
     struct msi_desc msi;
-    struct intel_iommu *intel;
+    struct acpi_drhd_unit *drhd;
 
     uint64_t qinval_maddr;   /* queue invalidation page machine address */
 
index 30c6234845313183a04c471f8d219ef189bfcc4d..e7e326fe8cb5b8601a0e87280135bf2014e11a5e 100644 (file)
@@ -139,8 +139,7 @@ static void __init map_igd_reg(void)
  */
 static int cantiga_vtd_ops_preamble(struct vtd_iommu *iommu)
 {
-    struct intel_iommu *intel = iommu->intel;
-    struct acpi_drhd_unit *drhd = intel ? intel->drhd : NULL;
+    struct acpi_drhd_unit *drhd = iommu->drhd;
 
     if ( !is_igd_drhd(drhd) || !is_cantiga_b3 )
         return 0;
@@ -174,8 +173,7 @@ static int cantiga_vtd_ops_preamble(struct vtd_iommu *iommu)
  */
 static void snb_vtd_ops_preamble(struct vtd_iommu *iommu)
 {
-    struct intel_iommu *intel = iommu->intel;
-    struct acpi_drhd_unit *drhd = intel ? intel->drhd : NULL;
+    struct acpi_drhd_unit *drhd = iommu->drhd;
     s_time_t start_time;
 
     if ( !is_igd_drhd(drhd) || !is_snb_gfx )
@@ -204,8 +202,7 @@ static void snb_vtd_ops_preamble(struct vtd_iommu *iommu)
 
 static void snb_vtd_ops_postamble(struct vtd_iommu *iommu)
 {
-    struct intel_iommu *intel = iommu->intel;
-    struct acpi_drhd_unit *drhd = intel ? intel->drhd : NULL;
+    struct acpi_drhd_unit *drhd = iommu->drhd;
 
     if ( !is_igd_drhd(drhd) || !is_snb_gfx )
         return;
index 9fdbd52ec14bb9234b48f31ab118a169378e974d..7552dd8e0c561e5181747f341d8b2963c88b0ceb 100644 (file)
@@ -96,7 +96,7 @@ void print_vtd_entries(struct vtd_iommu *iommu, int bus, int devfn, u64 gmfn)
     u32 l_index, level;
 
     printk("print_vtd_entries: iommu #%u dev %04x:%02x:%02x.%u gmfn %"PRI_gfn"\n",
-           iommu->index, iommu->intel->drhd->segment, bus,
+           iommu->index, iommu->drhd->segment, bus,
            PCI_SLOT(devfn), PCI_FUNC(devfn), gmfn);
 
     if ( iommu->root_maddr == 0 )