[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <521fd5184ef052ff768a90bbe670cfc4e375eff9.1682615447.git.reinette.chatre@intel.com>
Date: Thu, 27 Apr 2023 10:36:01 -0700
From: Reinette Chatre <reinette.chatre@...el.com>
To: jgg@...dia.com, yishaih@...dia.com,
shameerali.kolothum.thodi@...wei.com, kevin.tian@...el.com,
alex.williamson@...hat.com
Cc: tglx@...utronix.de, darwi@...utronix.de, kvm@...r.kernel.org,
dave.jiang@...el.com, jing2.liu@...el.com, ashok.raj@...el.com,
fenghua.yu@...el.com, tom.zanussi@...ux.intel.com,
reinette.chatre@...el.com, linux-kernel@...r.kernel.org
Subject: [PATCH V4 04/11] vfio/pci: Move to single error path
Enabling and disabling of an interrupt involves several steps
that can fail. Cleanup after failure is done when the error
is encountered, resulting in some repetitive code.
Support for dynamic contexts will introduce more steps during
interrupt enabling and disabling.
Transition to centralized exit path in preparation for dynamic
contexts to eliminate duplicate error handling code.
Signed-off-by: Reinette Chatre <reinette.chatre@...el.com>
---
No changes since V3.
Changes since V2:
- Move patch to earlier in series in support of the change to
dynamic context management.
- Do not add the "ctx->name = NULL" in error path. It is not done
in baseline and will not be needed when transitioning to
dynamic context management.
- Update changelog to not make this change specific to dynamic
MSI-X.
Changes since RFC V1:
- Improve changelog.
drivers/vfio/pci/vfio_pci_intrs.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index b664fbb6d2f2..9e17e59a4d60 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -418,8 +418,8 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
trigger = eventfd_ctx_fdget(fd);
if (IS_ERR(trigger)) {
- kfree(ctx->name);
- return PTR_ERR(trigger);
+ ret = PTR_ERR(trigger);
+ goto out_free_name;
}
/*
@@ -439,11 +439,8 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
ret = request_irq(irq, vfio_msihandler, 0, ctx->name, trigger);
vfio_pci_memory_unlock_and_restore(vdev, cmd);
- if (ret) {
- kfree(ctx->name);
- eventfd_ctx_put(trigger);
- return ret;
- }
+ if (ret)
+ goto out_put_eventfd_ctx;
ctx->producer.token = trigger;
ctx->producer.irq = irq;
@@ -458,6 +455,12 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
ctx->trigger = trigger;
return 0;
+
+out_put_eventfd_ctx:
+ eventfd_ctx_put(trigger);
+out_free_name:
+ kfree(ctx->name);
+ return ret;
}
static int vfio_msi_set_block(struct vfio_pci_core_device *vdev, unsigned start,
--
2.34.1
Powered by blists - more mailing lists