|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v5 06/11] x86/passthrough: Re-indent pt_irq_bind_msi() body
Purely mechanical follow-up to the previous patch: drop the compound
block that preserved the original switch/case indentation, shift the
body one level left, move the block-local declarations to the top of the
function, and add the missing blank line before the dest_vcpu_id
calculation. No functional change. 'git show --ignore-all-space' is
empty apart from the declaration move and the removed brackets.
Signed-off-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
---
Changes in v5:
- New patch: the re-indent half of the v4 extraction. Drops the compound
block, shifts the body one level left, move the block-local
declarations and adds the missing blank line.
Signed-off-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
---
xen/drivers/passthrough/x86/hvm.c | 224 +++++++++++++++---------------
1 file changed, 111 insertions(+), 113 deletions(-)
diff --git a/xen/drivers/passthrough/x86/hvm.c
b/xen/drivers/passthrough/x86/hvm.c
index ed368a7fdb..5fdb885311 100644
--- a/xen/drivers/passthrough/x86/hvm.c
+++ b/xen/drivers/passthrough/x86/hvm.c
@@ -295,146 +295,144 @@ static int pt_irq_bind_msi(struct domain *d, unsigned
int machine_irq,
struct hvm_pirq_dpci *pirq_dpci;
struct pirq *info;
int rc;
+ uint8_t dest, delivery_mode;
+ bool dest_mode;
+ int dest_vcpu_id;
+ const struct vcpu *vcpu;
rc = pt_irq_dpci_setup(d, machine_irq, &hvm_irq_dpci, &pirq_dpci, &info);
if ( rc )
return rc;
+ if ( !(pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) )
{
- uint8_t dest, delivery_mode;
- bool dest_mode;
- int dest_vcpu_id;
- const struct vcpu *vcpu;
-
- if ( !(pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) )
+ pirq_dpci->flags = HVM_IRQ_DPCI_MAPPED | HVM_IRQ_DPCI_MACH_MSI |
+ HVM_IRQ_DPCI_GUEST_MSI;
+ pirq_dpci->gmsi.gvec = gvec;
+ pirq_dpci->gmsi.gflags = gflags;
+ /*
+ * 'pt_irq_bind_msi' can be called after 'pt_irq_destroy_bind'.
+ * The 'pirq_cleanup_check' which would free the structure is only
+ * called if the event channel for the PIRQ is active. However
+ * OS-es that use event channels usually bind PIRQs to eventds
+ * and unbind them before calling 'pt_irq_destroy_bind' - with the
+ * result that we re-use the 'dpci' structure. This can be
+ * reproduced with unloading and loading the driver for a device.
+ *
+ * As such on every 'pt_irq_bind_msi' call we MUST set it.
+ */
+ pirq_dpci->dom = d;
+ /* Bind after hvm_irq_dpci is setup to avoid race with irq handler. */
+ rc = pirq_guest_bind(d->vcpu[0], info, 0);
+ if ( rc == 0 && gtable )
{
- pirq_dpci->flags = HVM_IRQ_DPCI_MAPPED | HVM_IRQ_DPCI_MACH_MSI |
- HVM_IRQ_DPCI_GUEST_MSI;
- pirq_dpci->gmsi.gvec = gvec;
- pirq_dpci->gmsi.gflags = gflags;
- /*
- * 'pt_irq_bind_msi' can be called after 'pt_irq_destroy_bind'.
- * The 'pirq_cleanup_check' which would free the structure is only
- * called if the event channel for the PIRQ is active. However
- * OS-es that use event channels usually bind PIRQs to eventds
- * and unbind them before calling 'pt_irq_destroy_bind' - with the
- * result that we re-use the 'dpci' structure. This can be
- * reproduced with unloading and loading the driver for a device.
- *
- * As such on every 'pt_irq_bind_msi' call we MUST set it.
- */
- pirq_dpci->dom = d;
- /* Bind after hvm_irq_dpci is setup to avoid race with irq
handler. */
- rc = pirq_guest_bind(d->vcpu[0], info, 0);
- if ( rc == 0 && gtable )
- {
- rc = msixtbl_pt_register(d, info, gtable);
- if ( unlikely(rc) )
- {
- pirq_guest_unbind(d, info);
- /*
- * Between 'pirq_guest_bind' and before 'pirq_guest_unbind'
- * an interrupt can be scheduled. No more of them are going
- * to be scheduled but we must deal with the one that may
be
- * in the queue.
- */
- pt_pirq_softirq_reset(pirq_dpci);
- }
- }
+ rc = msixtbl_pt_register(d, info, gtable);
if ( unlikely(rc) )
{
- pirq_dpci->gmsi.gflags = 0;
- pirq_dpci->gmsi.gvec = 0;
- pirq_dpci->dom = NULL;
- pirq_dpci->flags = 0;
- if ( !info->evtchn )
- pirq_cleanup_check(info, d);
- write_unlock(&d->event_lock);
- return rc;
+ pirq_guest_unbind(d, info);
+ /*
+ * Between 'pirq_guest_bind' and before 'pirq_guest_unbind'
+ * an interrupt can be scheduled. No more of them are going
+ * to be scheduled but we must deal with the one that may be
+ * in the queue.
+ */
+ pt_pirq_softirq_reset(pirq_dpci);
}
}
- else
+ if ( unlikely(rc) )
{
- uint32_t mask = HVM_IRQ_DPCI_MACH_MSI | HVM_IRQ_DPCI_GUEST_MSI;
-
- if ( (pirq_dpci->flags & mask) != mask )
- {
- write_unlock(&d->event_lock);
- return -EBUSY;
- }
-
- /* If pirq is already mapped as vmsi, update guest data/addr. */
- if ( pirq_dpci->gmsi.gvec != gvec ||
- pirq_dpci->gmsi.gflags != gflags )
- {
- /* Directly clear pending EOIs before enabling new MSI info. */
- pirq_guest_eoi(info);
-
- pirq_dpci->gmsi.gvec = gvec;
- pirq_dpci->gmsi.gflags = gflags;
- }
+ pirq_dpci->gmsi.gflags = 0;
+ pirq_dpci->gmsi.gvec = 0;
+ pirq_dpci->dom = NULL;
+ pirq_dpci->flags = 0;
+ if ( !info->evtchn )
+ pirq_cleanup_check(info, d);
+ write_unlock(&d->event_lock);
+ return rc;
}
- /* Calculate dest_vcpu_id for MSI-type pirq migration. */
- dest = MASK_EXTR(pirq_dpci->gmsi.gflags,
- XEN_DOMCTL_VMSI_X86_DEST_ID_MASK);
- dest_mode = pirq_dpci->gmsi.gflags & XEN_DOMCTL_VMSI_X86_DM_MASK;
- delivery_mode = MASK_EXTR(pirq_dpci->gmsi.gflags,
- XEN_DOMCTL_VMSI_X86_DELIV_MASK);
-
- dest_vcpu_id = hvm_girq_dest_2_vcpu_id(d, dest, dest_mode);
- pirq_dpci->gmsi.dest_vcpu_id = dest_vcpu_id;
- write_unlock(&d->event_lock);
+ }
+ else
+ {
+ uint32_t mask = HVM_IRQ_DPCI_MACH_MSI | HVM_IRQ_DPCI_GUEST_MSI;
- pirq_dpci->gmsi.posted = false;
- vcpu = (dest_vcpu_id >= 0) ? d->vcpu[dest_vcpu_id] : NULL;
- if ( iommu_intpost )
+ if ( (pirq_dpci->flags & mask) != mask )
{
- if ( delivery_mode == dest_LowestPrio )
- vcpu = vector_hashing_dest(d, dest, dest_mode,
- pirq_dpci->gmsi.gvec);
- if ( vcpu )
- pirq_dpci->gmsi.posted = true;
+ write_unlock(&d->event_lock);
+ return -EBUSY;
}
- if ( vcpu && is_iommu_enabled(d) )
- hvm_migrate_pirq(pirq_dpci, vcpu);
- /* Use interrupt posting if it is supported. */
- if ( iommu_intpost )
+ /* If pirq is already mapped as vmsi, update guest data/addr. */
+ if ( pirq_dpci->gmsi.gvec != gvec ||
+ pirq_dpci->gmsi.gflags != gflags )
{
- struct xen_domctl_bind_pt_irq pt_irq_bind = {
- .machine_irq = machine_irq,
- .irq_type = PT_IRQ_TYPE_MSI,
- };
+ /* Directly clear pending EOIs before enabling new MSI info. */
+ pirq_guest_eoi(info);
- rc = hvm_pi_update_irte(vcpu, info, pirq_dpci->gmsi.gvec);
- if ( rc )
- {
- pt_irq_destroy_bind(d, &pt_irq_bind);
- return rc;
- }
+ pirq_dpci->gmsi.gvec = gvec;
+ pirq_dpci->gmsi.gflags = gflags;
}
+ }
+
+ /* Calculate dest_vcpu_id for MSI-type pirq migration. */
+ dest = MASK_EXTR(pirq_dpci->gmsi.gflags,
+ XEN_DOMCTL_VMSI_X86_DEST_ID_MASK);
+ dest_mode = pirq_dpci->gmsi.gflags & XEN_DOMCTL_VMSI_X86_DM_MASK;
+ delivery_mode = MASK_EXTR(pirq_dpci->gmsi.gflags,
+ XEN_DOMCTL_VMSI_X86_DELIV_MASK);
+
+ dest_vcpu_id = hvm_girq_dest_2_vcpu_id(d, dest, dest_mode);
+ pirq_dpci->gmsi.dest_vcpu_id = dest_vcpu_id;
+ write_unlock(&d->event_lock);
+
+ pirq_dpci->gmsi.posted = false;
+ vcpu = (dest_vcpu_id >= 0) ? d->vcpu[dest_vcpu_id] : NULL;
+ if ( iommu_intpost )
+ {
+ if ( delivery_mode == dest_LowestPrio )
+ vcpu = vector_hashing_dest(d, dest, dest_mode,
+ pirq_dpci->gmsi.gvec);
+ if ( vcpu )
+ pirq_dpci->gmsi.posted = true;
+ }
+ if ( vcpu && is_iommu_enabled(d) )
+ hvm_migrate_pirq(pirq_dpci, vcpu);
+
+ /* Use interrupt posting if it is supported. */
+ if ( iommu_intpost )
+ {
+ struct xen_domctl_bind_pt_irq pt_irq_bind = {
+ .machine_irq = machine_irq,
+ .irq_type = PT_IRQ_TYPE_MSI,
+ };
- if ( unmasked )
+ rc = hvm_pi_update_irte(vcpu, info, pirq_dpci->gmsi.gvec);
+ if ( rc )
{
- struct xen_domctl_bind_pt_irq pt_irq_bind = {
- .machine_irq = machine_irq,
- .irq_type = PT_IRQ_TYPE_MSI,
- };
- unsigned long flags;
- struct irq_desc *desc = pirq_spin_lock_irq_desc(info, &flags);
+ pt_irq_destroy_bind(d, &pt_irq_bind);
+ return rc;
+ }
+ }
- if ( !desc )
- {
- pt_irq_destroy_bind(d, &pt_irq_bind);
- return -EINVAL;
- }
+ if ( unmasked )
+ {
+ struct xen_domctl_bind_pt_irq pt_irq_bind = {
+ .machine_irq = machine_irq,
+ .irq_type = PT_IRQ_TYPE_MSI,
+ };
+ unsigned long flags;
+ struct irq_desc *desc = pirq_spin_lock_irq_desc(info, &flags);
- guest_mask_msi_irq(desc, false);
- spin_unlock_irqrestore(&desc->lock, flags);
+ if ( !desc )
+ {
+ pt_irq_destroy_bind(d, &pt_irq_bind);
+ return -EINVAL;
}
- return 0;
+ guest_mask_msi_irq(desc, false);
+ spin_unlock_irqrestore(&desc->lock, flags);
}
+
+ return 0;
}
int pt_irq_create_bind(
--
2.53.0
--
Julian Vetter | Vates Hypervisor & Kernel Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |