]> xenbits.xensource.com Git - xen.git/commitdiff
PCI: move pdev_list field to common structure
authorJan Beulich <jbeulich@suse.com>
Thu, 6 Jun 2019 09:14:58 +0000 (11:14 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 6 Jun 2019 09:14:58 +0000 (11:14 +0200)
Its management shouldn't be arch-specific, and in particular there
should be no need for special precautions when creating the special
domains.

At this occasion
- correct parenthesization of for_each_pdev(),
- stop open-coding for_each_pdev() in vPCI code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/domain.c
xen/arch/x86/mm.c
xen/common/domain.c
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/drivers/passthrough/pci.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/vpci/header.c
xen/drivers/vpci/msi.c
xen/include/asm-x86/domain.h
xen/include/xen/pci.h
xen/include/xen/sched.h

index 9485a17dddd0e7d02bcbe35b90fbc796ffbcbd5a..d505d2e456ea3a8dc9abf31c790e1018df8f5f1d 100644 (file)
@@ -496,7 +496,6 @@ int arch_domain_create(struct domain *d,
     uint32_t emflags;
     int rc;
 
-    INIT_LIST_HEAD(&d->arch.pdev_list);
     INIT_PAGE_LIST_HEAD(&d->arch.relmem_list);
 
     spin_lock_init(&d->arch.e820_lock);
index 2f620d9aebc8e946d96c53179192ca5fb4f1b4d1..8b933da35a5106fc9e4f2a78d0b0a86654907cc2 100644 (file)
@@ -291,7 +291,6 @@ void __init arch_init_memory(void)
      */
     dom_xen = domain_create(DOMID_XEN, NULL, false);
     BUG_ON(IS_ERR(dom_xen));
-    INIT_LIST_HEAD(&dom_xen->arch.pdev_list);
 
     /*
      * Initialise our DOMID_IO domain.
index 90c66079f93038cc9a397b879a3aa90b9e665427..29cd44ac2789b29f4ffa5440cb2624c76855099c 100644 (file)
@@ -389,6 +389,10 @@ struct domain *domain_create(domid_t domid,
 
     rwlock_init(&d->vnuma_rwlock);
 
+#ifdef CONFIG_HAS_PCI
+    INIT_LIST_HEAD(&d->pdev_list);
+#endif
+
     err = -ENOMEM;
     if ( !zalloc_cpumask_var(&d->dirty_cpumask) )
         goto fail;
index 6ddeb790a0f17c4b88177ab750ace9598cd7c623..dc51d667698e2c0236722b075cd3487732e28744 100644 (file)
@@ -315,7 +315,7 @@ static int reassign_device(struct domain *source, struct domain *target,
 
     if ( devfn == pdev->devfn )
     {
-        list_move(&pdev->domain_list, &target->arch.pdev_list);
+        list_move(&pdev->domain_list, &target->pdev_list);
         pdev->domain = target;
     }
 
index 061b20103fc387707d8c7410b6da09d0ed58b10f..20bfa971a98af3ab977c6c93339fc9215d7eb8a1 100644 (file)
@@ -467,7 +467,7 @@ static void _pci_hide_device(struct pci_dev *pdev)
     if ( pdev->domain )
         return;
     pdev->domain = dom_xen;
-    list_add(&pdev->domain_list, &dom_xen->arch.pdev_list);
+    list_add(&pdev->domain_list, &dom_xen->pdev_list);
 }
 
 int __init pci_hide_device(unsigned int seg, unsigned int bus,
@@ -803,7 +803,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
             goto out;
         }
 
-        list_add(&pdev->domain_list, &hardware_domain->arch.pdev_list);
+        list_add(&pdev->domain_list, &hardware_domain->pdev_list);
     }
     else
         iommu_enable_device(pdev);
@@ -1153,7 +1153,7 @@ static int __hwdom_init _setup_hwdom_pci_devices(struct pci_seg *pseg, void *arg
             if ( !pdev->domain )
             {
                 pdev->domain = ctxt->d;
-                list_add(&pdev->domain_list, &ctxt->d->arch.pdev_list);
+                list_add(&pdev->domain_list, &ctxt->d->pdev_list);
                 setup_one_hwdom_device(ctxt, pdev);
             }
             else if ( pdev->domain == dom_xen )
index 4caf63c7fa4a01df6df07a68d9173be42ff1ecc7..8b27d7e77535d3a47b252695a9e9bd4ae6af9d39 100644 (file)
@@ -2453,7 +2453,7 @@ static int reassign_device_ownership(
 
     if ( devfn == pdev->devfn )
     {
-        list_move(&pdev->domain_list, &target->arch.pdev_list);
+        list_move(&pdev->domain_list, &target->pdev_list);
         pdev->domain = target;
     }
 
index efb6ca90e370042b91ab5bb73fd3a4efb0b134cb..94094f55795de9fe9becde84b2b285b79f796463 100644 (file)
@@ -267,7 +267,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
      * Check for overlaps with other BARs. Note that only BARs that are
      * currently mapped (enabled) are checked for overlaps.
      */
-    list_for_each_entry(tmp, &pdev->domain->arch.pdev_list, domain_list)
+    for_each_pdev ( pdev->domain, tmp )
     {
         if ( tmp == pdev )
         {
index 8f15ad7bf2788dac1a40f1a7f47bfa89d8e82068..c4e1d2a4112563dc5189b70a45b1bd0b1c07e9ba 100644 (file)
@@ -282,7 +282,7 @@ void vpci_dump_msi(void)
 
         printk("vPCI MSI/MSI-X d%d\n", d->domain_id);
 
-        list_for_each_entry ( pdev, &d->arch.pdev_list, domain_list )
+        for_each_pdev ( d, pdev )
         {
             const struct vpci_msi *msi;
             const struct vpci_msix *msix;
index 72dea80b7cbb10ebbbbb7d608a69bdf0e8520b47..933b85901fd12c720a10a97ac6aee717eae0df37 100644 (file)
@@ -298,8 +298,6 @@ struct arch_domain
 
     bool_t s3_integrity;
 
-    struct list_head pdev_list;
-
     union {
         struct pv_domain pv;
         struct hvm_domain hvm;
@@ -476,8 +474,6 @@ struct arch_domain
 #define has_pirq(d)        (!!((d)->arch.emulation_flags & X86_EMU_USE_PIRQ))
 #define has_vpci(d)        (!!((d)->arch.emulation_flags & X86_EMU_VPCI))
 
-#define has_arch_pdevs(d)    (!list_empty(&(d)->arch.pdev_list))
-
 #define gdt_ldt_pt_idx(v) \
       ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT))
 #define pv_gdt_ptes(v) \
index 8b21e8dc8483dc3d107fcd70f5557ac0d9eb3ce0..53f50d89e7b58b86f876aa4e9406391923a2c8d5 100644 (file)
@@ -121,7 +121,9 @@ struct pci_dev {
 };
 
 #define for_each_pdev(domain, pdev) \
-    list_for_each_entry(pdev, &(domain->arch.pdev_list), domain_list)
+    list_for_each_entry(pdev, &(domain)->pdev_list, domain_list)
+
+#define has_arch_pdevs(d) (!list_empty(&(d)->pdev_list))
 
 /*
  * The pcidevs_lock protect alldevs_list, and the assignment for the 
index b9691fc96ec9abcc815c6aba084a5e1c9da062af..ccd5347303b70c957a32d70f0b69e58726897021 100644 (file)
@@ -369,6 +369,10 @@ struct domain
 
     int64_t          time_offset_seconds;
 
+#ifdef CONFIG_HAS_PCI
+    struct list_head pdev_list;
+#endif
+
 #ifdef CONFIG_HAS_PASSTHROUGH
     struct domain_iommu iommu;
 #endif