Move the functions that reference x86 hvm data structures to its own
file. Rename pci_clean_dpci_irqs to arch_pci_clean_irqs.
There is still one location in that file which references
arch.hvm_domain, but it is fine because ARM guest is HVM.
Signed-off-by: Wei Liu
---
Cc: Stefano Stabellini
Cc: Julien Grall
Cc: Jan Beulich
Cc: Andrew Cooper
ARM doesn't select HAS_PCI, that's why ARM build is not broken by
this. AIUI ARM will select HAS_PCI at some point, hence I only move
the x86 bits.
---
xen/drivers/passthrough/pci.c| 51 +
xen/drivers/passthrough/x86/Makefile | 1 +
xen/drivers/passthrough/x86/pci.c| 62
xen/include/xen/pci.h| 2 ++
4 files changed, 66 insertions(+), 50 deletions(-)
create mode 100644 xen/drivers/passthrough/x86/pci.c
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 2b976ade62..bf83d07279 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -22,7 +22,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -798,54 +797,6 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
return ret;
}
-static int pci_clean_dpci_irq(struct domain *d,
- struct hvm_pirq_dpci *pirq_dpci, void *arg)
-{
-struct dev_intx_gsi_link *digl, *tmp;
-
-pirq_guest_unbind(d, dpci_pirq(pirq_dpci));
-
-if ( pt_irq_need_timer(pirq_dpci->flags) )
-kill_timer(&pirq_dpci->timer);
-
-list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list )
-{
-list_del(&digl->list);
-xfree(digl);
-}
-
-return pt_pirq_softirq_active(pirq_dpci) ? -ERESTART : 0;
-}
-
-static int pci_clean_dpci_irqs(struct domain *d)
-{
-struct hvm_irq_dpci *hvm_irq_dpci = NULL;
-
-if ( !iommu_enabled )
-return 0;
-
-if ( !is_hvm_domain(d) )
-return 0;
-
-spin_lock(&d->event_lock);
-hvm_irq_dpci = domain_get_irq_dpci(d);
-if ( hvm_irq_dpci != NULL )
-{
-int ret = pt_pirq_iterate(d, pci_clean_dpci_irq, NULL);
-
-if ( ret )
-{
-spin_unlock(&d->event_lock);
-return ret;
-}
-
-hvm_domain_irq(d)->dpci = NULL;
-free_hvm_irq_dpci(hvm_irq_dpci);
-}
-spin_unlock(&d->event_lock);
-return 0;
-}
-
int pci_release_devices(struct domain *d)
{
struct pci_dev *pdev;
@@ -853,7 +804,7 @@ int pci_release_devices(struct domain *d)
int ret;
pcidevs_lock();
-ret = pci_clean_dpci_irqs(d);
+ret = arch_pci_clean_irqs(d);
if ( ret )
{
pcidevs_unlock();
diff --git a/xen/drivers/passthrough/x86/Makefile
b/xen/drivers/passthrough/x86/Makefile
index 06971707f8..0a21b60b5a 100644
--- a/xen/drivers/passthrough/x86/Makefile
+++ b/xen/drivers/passthrough/x86/Makefile
@@ -4,3 +4,4 @@ subdir-y += amd
obj-y += ats.o
obj-y += io.o
obj-y += iommu.o
+obj-y += pci.o
diff --git a/xen/drivers/passthrough/x86/pci.c
b/xen/drivers/passthrough/x86/pci.c
new file mode 100644
index 00..e0a7e473b1
--- /dev/null
+++ b/xen/drivers/passthrough/x86/pci.c
@@ -0,0 +1,62 @@
+#include
+#include
+#include
+
+#include
+
+static int pci_clean_dpci_irq(struct domain *d,
+ struct hvm_pirq_dpci *pirq_dpci, void *arg)
+{
+struct dev_intx_gsi_link *digl, *tmp;
+
+pirq_guest_unbind(d, dpci_pirq(pirq_dpci));
+
+if ( pt_irq_need_timer(pirq_dpci->flags) )
+kill_timer(&pirq_dpci->timer);
+
+list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list )
+{
+list_del(&digl->list);
+xfree(digl);
+}
+
+return pt_pirq_softirq_active(pirq_dpci) ? -ERESTART : 0;
+}
+
+int arch_pci_clean_irqs(struct domain *d)
+{
+struct hvm_irq_dpci *hvm_irq_dpci = NULL;
+
+if ( !iommu_enabled )
+return 0;
+
+if ( !is_hvm_domain(d) )
+return 0;
+
+spin_lock(&d->event_lock);
+hvm_irq_dpci = domain_get_irq_dpci(d);
+if ( hvm_irq_dpci != NULL )
+{
+int ret = pt_pirq_iterate(d, pci_clean_dpci_irq, NULL);
+
+if ( ret )
+{
+spin_unlock(&d->event_lock);
+return ret;
+}
+
+hvm_domain_irq(d)->dpci = NULL;
+free_hvm_irq_dpci(hvm_irq_dpci);
+}
+spin_unlock(&d->event_lock);
+return 0;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index dd5ec43a70..2d3bdf386f 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -153,6 +153,8 @@ struct pci_dev *pci_get_pdev_by_domain(const struct domain
*, int seg,
int bus, int devfn);
void pci_check_disable_device(u16 seg, u8 bus, u8 devfn);
+int arch_pci_clean_irqs(struct domain *d);
+
uint8_t pci_conf_read8(
unsigned int seg, unsigned int bus, u