From: David Marchand <david.marchand@redhat.com>
To: hemant.agrawal@nxp.com, dev@dpdk.org
Cc: Sachin Saxena <sachin.saxena@nxp.com>
Subject: [RFC v2 03/16] bus/dpaa: allocate interrupt during probing
Date: Thu, 17 Sep 2026 09:49:03 +0200 [thread overview]
Message-ID: <20260917074917.595603-4-david.marchand@redhat.com> (raw)
In-Reply-To: <20260917074917.595603-1-david.marchand@redhat.com>
Allocating the interrupt handle is a waste of memory if no device is
probed later (like for example, if a allowlist is passed).
Instead, allocate this handle, set eventfds and vfio at the time
probe_device is called.
Adjust the unplug_device path accordingly.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since RFC v1:
- restored return code on error in cleanup,
---
drivers/bus/dpaa/dpaa_bus.c | 82 ++++++++++++++++++++-----------------
1 file changed, 44 insertions(+), 38 deletions(-)
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 5df2dff8f2..ef904a7192 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -215,16 +215,6 @@ dpaa_create_device_list(void)
dev->device.numa_node = SOCKET_ID_ANY;
- /* Allocate interrupt handle instance */
- dev->intr_handle =
- rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
- if (dev->intr_handle == NULL) {
- DPAA_BUS_LOG(ERR, "Failed to allocate intr handle");
- ret = -ENOMEM;
- free(dev);
- goto cleanup;
- }
-
cfg = &dpaa_netcfg->port_cfg[i];
fman_intf = cfg->fman_if;
@@ -276,16 +266,6 @@ dpaa_create_device_list(void)
goto cleanup;
}
- /* Allocate interrupt handle instance */
- dev->intr_handle =
- rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
- if (dev->intr_handle == NULL) {
- DPAA_BUS_LOG(ERR, "Failed to allocate intr handle");
- ret = -ENOMEM;
- free(dev);
- goto cleanup;
- }
-
dev->device_type = FSL_DPAA_CRYPTO;
dev->id.dev_id = dpaa_bus.device_count + i;
@@ -336,7 +316,6 @@ dpaa_create_device_list(void)
cleanup:
RTE_BUS_FOREACH_DEV(dev, &rte_dpaa_bus) {
rte_bus_remove_device(&rte_dpaa_bus, &dev->device);
- rte_intr_instance_free(dev->intr_handle);
free(dev);
}
@@ -637,7 +616,8 @@ rte_dpaa_bus_dev_build(void)
return 0;
}
-static int rte_dpaa_setup_intr(struct rte_intr_handle *intr_handle)
+static int
+dpaa_setup_intr(struct rte_intr_handle *intr_handle)
{
int fd;
@@ -660,13 +640,21 @@ static int rte_dpaa_setup_intr(struct rte_intr_handle *intr_handle)
return 0;
}
+static void
+dpaa_close_intr(struct rte_intr_handle *intr_handle)
+{
+ if (rte_intr_fd_get(intr_handle) >= 0) {
+ close(rte_intr_fd_get(intr_handle));
+ rte_intr_fd_set(intr_handle, -1);
+ }
+}
+
#define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa"
#define DPAA_DEV_PATH2 "/sys/devices/platform/fsl,dpaa"
static int
rte_dpaa_bus_scan(void)
{
- struct rte_dpaa_device *dev;
FILE *svr_file = NULL;
uint32_t svr_ver;
static int process_once;
@@ -755,14 +743,6 @@ rte_dpaa_bus_scan(void)
*/
rte_mbuf_set_platform_mempool_ops(DPAA_MEMPOOL_OPS_NAME);
- RTE_BUS_FOREACH_DEV(dev, &rte_dpaa_bus) {
- if (dev->device_type == FSL_DPAA_ETH) {
- ret = rte_dpaa_setup_intr(dev->intr_handle);
- if (ret)
- DPAA_BUS_ERR("Error setting up interrupt.");
- }
- }
-
/* And initialize the PA->VA translation table */
dpaax_iova_table_populate();
@@ -790,10 +770,30 @@ dpaa_bus_probe_device(struct rte_driver *drv, struct rte_device *dev)
struct rte_dpaa_driver *dpaa_drv = RTE_BUS_DRIVER(drv, *dpaa_drv);
int ret;
+ /* Allocate interrupt handle instance */
+ dpaa_dev->intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
+ if (dpaa_dev->intr_handle == NULL) {
+ DPAA_BUS_LOG(ERR, "Failed to allocate intr handle");
+ return -ENOMEM;
+ }
+
+ if (dpaa_dev->device_type == FSL_DPAA_ETH) {
+ ret = dpaa_setup_intr(dpaa_dev->intr_handle);
+ if (ret != 0) {
+ DPAA_BUS_ERR("error setting up interrupt: %s", dpaa_dev->name);
+ ret = -ret;
+ goto release_intr;
+ }
+ }
+
ret = dpaa_drv->probe(dpaa_drv, dpaa_dev);
- if (ret != 0)
+ if (ret != 0) {
DPAA_BUS_ERR("unable to probe: %s", dpaa_dev->name);
-
+ dpaa_close_intr(dpaa_dev->intr_handle);
+release_intr:
+ rte_intr_instance_free(dpaa_dev->intr_handle);
+ dpaa_dev->intr_handle = NULL;
+ }
return ret;
}
@@ -801,29 +801,35 @@ static int
dpaa_bus_cleanup(struct rte_bus *bus)
{
struct rte_dpaa_device *dev;
+ int error = 0;
BUS_INIT_FUNC_TRACE();
RTE_BUS_FOREACH_DEV(dev, bus) {
const struct rte_dpaa_driver *drv;
- int ret = 0;
+ int ret;
if (!rte_dev_is_probed(&dev->device))
- continue;
+ goto next;
drv = RTE_BUS_DRIVER(dev->device.driver, *drv);
if (drv->remove == NULL)
- continue;
+ goto next;
ret = drv->remove(dev);
if (ret < 0) {
rte_errno = errno;
- return -1;
+ error = -1;
+ goto next;
}
dev->device.driver = NULL;
+next:
+ dpaa_close_intr(dev->intr_handle);
+ rte_intr_instance_free(dev->intr_handle);
+ dev->intr_handle = NULL;
}
dpaa_portal_finish((void *)DPAA_PER_LCORE_PORTAL);
dpaa_bus_global_init = 0;
DPAA_BUS_DEBUG("Bus cleanup done");
- return 0;
+ return error;
}
/* Adding destructor for double check in case non-gracefully
--
2.54.0
next prev parent reply other threads:[~2026-09-17 7:49 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 13:53 [RFC 00/11] Device unplug and bus cleanup refactoring for NXP David Marchand
2026-07-23 13:53 ` [RFC 01/11] drivers/bus: cleanup device freeing in NXP bus scan David Marchand
2026-07-23 13:53 ` [RFC 02/11] bus/dpaa: allocate interrupt during probing David Marchand
2026-07-23 13:53 ` [RFC 03/11] bus/dpaa: support unplug and use generic cleanup David Marchand
2026-07-23 13:53 ` [RFC 04/11] bus/fslmc: fix memory leaks in scan David Marchand
2026-07-23 13:53 ` [RFC 05/11] bus/fslmc: fix per type device count David Marchand
2026-07-23 13:53 ` [RFC 06/11] bus/fslmc: simplify device parsing in scan David Marchand
2026-07-23 13:53 ` [RFC 07/11] bus/fslmc: refactor device filtering for multiprocess David Marchand
2026-07-23 13:53 ` [RFC 08/11] bus/fslmc: move unplug for some device out of VFIO David Marchand
2026-07-23 13:53 ` [RFC 09/11] bus/fslmc: call VFIO setup for some device from bus layer David Marchand
2026-07-23 13:53 ` [RFC 10/11] bus/fslmc: allocate interrupt during probing David Marchand
2026-07-23 13:53 ` [RFC 11/11] bus/fslmc: use generic cleanup David Marchand
2026-07-23 14:11 ` [RFC 00/11] Device unplug and bus cleanup refactoring for NXP Hemant Agrawal
2026-09-03 13:30 ` David Marchand
2026-09-08 14:20 ` Hemant Agrawal
2026-09-10 11:54 ` David Marchand
2026-08-11 20:09 ` Stephen Hemminger
2026-09-17 7:49 ` [RFC v2 00/16] " David Marchand
2026-09-17 7:49 ` [RFC v2 01/16] drivers/bus: cleanup device freeing in NXP bus scan David Marchand
2026-09-17 7:49 ` [RFC v2 02/16] drivers/bus: fix FD leak during scan in NXP drivers David Marchand
2026-09-17 7:49 ` David Marchand [this message]
2026-09-17 7:49 ` [RFC v2 04/16] bus/dpaa: support unplug and use generic cleanup David Marchand
2026-09-17 7:49 ` [RFC v2 05/16] bus/fslmc: fix device name leak David Marchand
2026-09-17 7:49 ` [RFC v2 06/16] bus/fslmc: fix memory leaks in scan David Marchand
2026-09-17 7:49 ` [RFC v2 07/16] bus/fslmc: fix per type device count David Marchand
2026-09-17 7:49 ` [RFC v2 08/16] bus/fslmc: fix some VFIO device FD and memory leaks David Marchand
2026-09-17 7:49 ` [RFC v2 09/16] bus/fslmc: fix interrupt leak in DPIO cleanup David Marchand
2026-09-17 7:49 ` [RFC v2 10/16] bus/fslmc: simplify device parsing in scan David Marchand
2026-09-17 7:49 ` [RFC v2 11/16] bus/fslmc: release resources on scan failure David Marchand
2026-09-17 7:49 ` [RFC v2 12/16] bus/fslmc: refactor device filtering for multiprocess David Marchand
2026-09-17 7:49 ` [RFC v2 13/16] bus/fslmc: move unplug for some device out of VFIO David Marchand
2026-09-17 7:49 ` [RFC v2 14/16] bus/fslmc: call VFIO setup for some device from bus layer David Marchand
2026-09-17 7:49 ` [RFC v2 15/16] bus/fslmc: allocate interrupt during probing David Marchand
2026-09-17 7:49 ` [RFC v2 16/16] bus/fslmc: use generic cleanup David Marchand
2026-09-24 6:46 ` [RFC v2 00/16] Device unplug and bus cleanup refactoring for NXP David Marchand
2026-09-24 6:53 ` Hemant Agrawal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917074917.595603-4-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
--cc=sachin.saxena@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox