[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 1/3] VT-d: tidy <X>_to_<Y>() functions



Drop iommu_to_drhd() altogether - there's no need for a loop here, the
corresponding DRHD is a field in struct intel_iommu.

Constify drhd_to_rhsa()'s parameter and adjust style.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/drivers/passthrough/vtd/dmar.c
+++ b/xen/drivers/passthrough/vtd/dmar.c
@@ -128,7 +128,7 @@ static int acpi_ioapic_device_match(
     return 0;
 }
 
-struct acpi_drhd_unit * ioapic_to_drhd(unsigned int apic_id)
+struct acpi_drhd_unit *ioapic_to_drhd(unsigned int apic_id)
 {
     struct acpi_drhd_unit *drhd;
     list_for_each_entry( drhd, &acpi_drhd_units, list )
@@ -137,21 +137,7 @@ struct acpi_drhd_unit * ioapic_to_drhd(u
     return NULL;
 }
 
-struct acpi_drhd_unit * iommu_to_drhd(struct iommu *iommu)
-{
-    struct acpi_drhd_unit *drhd;
-
-    if ( iommu == NULL )
-        return NULL;
-
-    list_for_each_entry( drhd, &acpi_drhd_units, list )
-        if ( drhd->iommu == iommu )
-            return drhd;
-
-    return NULL;
-}
-
-struct iommu * ioapic_to_iommu(unsigned int apic_id)
+struct iommu *ioapic_to_iommu(unsigned int apic_id)
 {
     struct acpi_drhd_unit *drhd;
 
@@ -265,7 +251,7 @@ struct acpi_atsr_unit *acpi_find_matched
     return all_ports;
 }
 
-struct acpi_rhsa_unit * drhd_to_rhsa(struct acpi_drhd_unit *drhd)
+struct acpi_rhsa_unit *drhd_to_rhsa(const struct acpi_drhd_unit *drhd)
 {
     struct acpi_rhsa_unit *rhsa;
 
--- a/xen/drivers/passthrough/vtd/extern.h
+++ b/xen/drivers/passthrough/vtd/extern.h
@@ -52,12 +52,11 @@ int iommu_flush_iec_global(struct iommu
 int iommu_flush_iec_index(struct iommu *iommu, u8 im, u16 iidx);
 void clear_fault_bits(struct iommu *iommu);
 
-struct iommu * ioapic_to_iommu(unsigned int apic_id);
-struct iommu * hpet_to_iommu(unsigned int hpet_id);
-struct acpi_drhd_unit * ioapic_to_drhd(unsigned int apic_id);
-struct acpi_drhd_unit * hpet_to_drhd(unsigned int hpet_id);
-struct acpi_drhd_unit * iommu_to_drhd(struct iommu *iommu);
-struct acpi_rhsa_unit * drhd_to_rhsa(struct acpi_drhd_unit *drhd);
+struct iommu *ioapic_to_iommu(unsigned int apic_id);
+struct iommu *hpet_to_iommu(unsigned int hpet_id);
+struct acpi_drhd_unit *ioapic_to_drhd(unsigned int apic_id);
+struct acpi_drhd_unit *hpet_to_drhd(unsigned int hpet_id);
+struct acpi_rhsa_unit *drhd_to_rhsa(const struct acpi_drhd_unit *drhd);
 
 struct acpi_drhd_unit * find_ats_dev_drhd(struct iommu *iommu);
 
--- a/xen/drivers/passthrough/vtd/intremap.c
+++ b/xen/drivers/passthrough/vtd/intremap.c
@@ -760,7 +760,6 @@ int __init intel_setup_hpet_msi(struct m
 
 int enable_intremap(struct iommu *iommu, int eim)
 {
-    struct acpi_drhd_unit *drhd;
     struct ir_ctrl *ir_ctrl;
     u32 sts, gcmd;
     unsigned long flags;
@@ -796,8 +795,8 @@ int enable_intremap(struct iommu *iommu,
 
     if ( ir_ctrl->iremap_maddr == 0 )
     {
-        drhd = iommu_to_drhd(iommu);
-        ir_ctrl->iremap_maddr = alloc_pgtable_maddr(drhd, IREMAP_ARCH_PAGE_NR);
+        ir_ctrl->iremap_maddr = alloc_pgtable_maddr(iommu->intel->drhd,
+                                                    IREMAP_ARCH_PAGE_NR);
         if ( ir_ctrl->iremap_maddr == 0 )
         {
             dprintk(XENLOG_WARNING VTDPREFIX,
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -224,7 +224,6 @@ void free_pgtable_maddr(u64 maddr)
 /* context entry handling */
 static u64 bus_to_context_maddr(struct iommu *iommu, u8 bus)
 {
-    struct acpi_drhd_unit *drhd;
     struct root_entry *root, *root_entries;
     u64 maddr;
 
@@ -233,8 +232,7 @@ static u64 bus_to_context_maddr(struct i
     root = &root_entries[bus];
     if ( !root_present(*root) )
     {
-        drhd = iommu_to_drhd(iommu);
-        maddr = alloc_pgtable_maddr(drhd, 1);
+        maddr = alloc_pgtable_maddr(iommu->intel->drhd, 1);
         if ( maddr == 0 )
         {
             unmap_vtd_domain_page(root_entries);
--- a/xen/drivers/passthrough/vtd/qinval.c
+++ b/xen/drivers/passthrough/vtd/qinval.c
@@ -397,7 +397,6 @@ static int __must_check flush_iotlb_qi(v
 
 int enable_qinval(struct iommu *iommu)
 {
-    struct acpi_drhd_unit *drhd;
     struct qi_ctrl *qi_ctrl;
     struct iommu_flush *flush;
     u32 sts;
@@ -416,8 +415,8 @@ int enable_qinval(struct iommu *iommu)
 
     if ( qi_ctrl->qinval_maddr == 0 )
     {
-        drhd = iommu_to_drhd(iommu);
-        qi_ctrl->qinval_maddr = alloc_pgtable_maddr(drhd, QINVAL_ARCH_PAGE_NR);
+        qi_ctrl->qinval_maddr = alloc_pgtable_maddr(iommu->intel->drhd,
+                                                    QINVAL_ARCH_PAGE_NR);
         if ( qi_ctrl->qinval_maddr == 0 )
         {
             dprintk(XENLOG_WARNING VTDPREFIX,


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.