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

[PATCH v5 04/11] x86/passthrough: Extract pt_irq_dpci_setup() from pt_irq_create_bind()



The setup preamble in pt_irq_create_bind() (lazily allocating
hvm_irq_dpci, looking up the struct pirq, and spinning until any pending
hvm_dirq_assist softirq has drained) is needed by the MSI bind path as
well. Move it into a static helper pt_irq_dpci_setup() that returns with
d->event_lock write-locked on success and hands the three looked-up
pointers back through out parameters. No functional change.

Signed-off-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
---
Changes in v5:
- The goto-to-loop conversion is now in the preceding patch, so this one
  just moves code around.
- Commit message reworded.

Signed-off-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
---
 xen/drivers/passthrough/x86/hvm.c | 32 +++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/passthrough/x86/hvm.c 
b/xen/drivers/passthrough/x86/hvm.c
index a74521fb57..7fcd3cc046 100644
--- a/xen/drivers/passthrough/x86/hvm.c
+++ b/xen/drivers/passthrough/x86/hvm.c
@@ -217,16 +217,14 @@ static struct vcpu *vector_hashing_dest(const struct 
domain *d,
     return dest;
 }
 
-int pt_irq_create_bind(
-    struct domain *d, const struct xen_domctl_bind_pt_irq *pt_irq_bind)
+static int pt_irq_dpci_setup(struct domain *d, unsigned int pirq,
+                             struct hvm_irq_dpci **hvm_irq_dpci_out,
+                             struct hvm_pirq_dpci **pirq_dpci_out,
+                             struct pirq **info_out)
 {
     struct hvm_irq_dpci *hvm_irq_dpci;
     struct hvm_pirq_dpci *pirq_dpci;
     struct pirq *info;
-    int rc, pirq = pt_irq_bind->machine_irq;
-
-    if ( pirq < 0 || pirq >= d->nr_pirqs )
-        return -EINVAL;
 
     for ( ; ; )
     {
@@ -282,6 +280,28 @@ int pt_irq_create_bind(
         break;
     }
 
+    *hvm_irq_dpci_out = hvm_irq_dpci;
+    *pirq_dpci_out = pirq_dpci;
+    *info_out = info;
+
+    return 0;
+}
+
+int pt_irq_create_bind(
+    struct domain *d, const struct xen_domctl_bind_pt_irq *pt_irq_bind)
+{
+    struct hvm_irq_dpci *hvm_irq_dpci;
+    struct hvm_pirq_dpci *pirq_dpci;
+    struct pirq *info;
+    int rc, pirq = pt_irq_bind->machine_irq;
+
+    if ( pirq < 0 || pirq >= d->nr_pirqs )
+        return -EINVAL;
+
+    rc = pt_irq_dpci_setup(d, pirq, &hvm_irq_dpci, &pirq_dpci, &info);
+    if ( rc )
+        return rc;
+
     switch ( pt_irq_bind->irq_type )
     {
     case PT_IRQ_TYPE_MSI:
-- 
2.53.0



--
Julian Vetter | Vates Hypervisor & Kernel Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

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