> 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 at the time probe_device is called. > > Signed-off-by: David Marchand <[email protected]>
Reviewed-by: Long Li <[email protected]> > --- > Changes since v1: > - fixed/reordered interrupt handle allocation, > > --- > drivers/bus/vmbus/linux/vmbus_bus.c | 6 ------ > drivers/bus/vmbus/vmbus_common.c | 18 ++++++++++++++++-- > 2 files changed, 16 insertions(+), 8 deletions(-) > > diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c > b/drivers/bus/vmbus/linux/vmbus_bus.c > index 0af10f6a69..77d904ad6d 100644 > --- a/drivers/bus/vmbus/linux/vmbus_bus.c > +++ b/drivers/bus/vmbus/linux/vmbus_bus.c > @@ -345,12 +345,6 @@ vmbus_scan_one(const char *name) > } > } > > - /* Allocate interrupt handle instance */ > - dev->intr_handle = > - rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); > - if (dev->intr_handle == NULL) > - goto error; > - > /* device is valid, add in list (sorted) */ > VMBUS_LOG(DEBUG, "Adding vmbus device %s", name); > > diff --git a/drivers/bus/vmbus/vmbus_common.c > b/drivers/bus/vmbus/vmbus_common.c > index 74c1ddff69..bfb45e963c 100644 > --- a/drivers/bus/vmbus/vmbus_common.c > +++ b/drivers/bus/vmbus/vmbus_common.c > @@ -100,10 +100,16 @@ vmbus_probe_device(struct rte_driver *drv, struct > rte_device *dev) > return 1; > } > > + /* allocate interrupt handle instance */ > + vmbus_dev->intr_handle = > + rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); > + if (vmbus_dev->intr_handle == NULL) > + return -ENOMEM; > + > /* map resources for device */ > ret = rte_vmbus_map_device(vmbus_dev); > if (ret != 0) > - return ret; > + goto free_intr; > > if (vmbus_dev->device.numa_node < 0 && rte_socket_count() > 1) > VMBUS_LOG(INFO, "Device %s is not NUMA-aware", guid); @@ > -112,7 +118,15 @@ vmbus_probe_device(struct rte_driver *drv, struct > rte_device *dev) > VMBUS_LOG(INFO, " probe driver: %s", vmbus_drv->driver.name); > ret = vmbus_drv->probe(vmbus_drv, vmbus_dev); > if (ret != 0) > - rte_vmbus_unmap_device(vmbus_dev); > + goto unmap; > + > + return 0; > + > +unmap: > + rte_vmbus_unmap_device(vmbus_dev); > +free_intr: > + rte_intr_instance_free(vmbus_dev->intr_handle); > + vmbus_dev->intr_handle = NULL; > > return ret; > } > -- > 2.53.0

