Move device unplug out of the code dealing with VFIO, interrupts and
IO devices.

Signed-off-by: David Marchand <[email protected]>
---
Changes since RFC v1:
- simplified the loop over devices since only devices for ethdev, dma or
  crypto are in the bus device list,

---
 drivers/bus/fslmc/fslmc_bus.c  | 11 ++++++++++-
 drivers/bus/fslmc/fslmc_vfio.c | 13 -------------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 4789ab0cf3..3b22d3367d 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -620,10 +620,19 @@ fslmc_bus_match(const struct rte_driver *drv, const 
struct rte_device *dev)
 }
 
 static int
-rte_fslmc_close(struct rte_bus *bus __rte_unused)
+fslmc_bus_unplug_device(struct rte_device *rte_dev);
+
+static int
+rte_fslmc_close(struct rte_bus *bus)
 {
+       struct rte_dpaa2_device *dev;
        int ret = 0;
 
+       RTE_BUS_FOREACH_DEV(dev, bus) {
+               if (rte_dev_is_probed(&dev->device) && 
fslmc_bus_unplug_device(&dev->device))
+                       DPAA2_BUS_ERR("Unable to remove %s", dev->device.name);
+       }
+
        ret = fslmc_vfio_close_group();
        if (ret)
                DPAA2_BUS_INFO("Unable to close devices %d", ret);
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 954167f452..857f22f204 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -1449,7 +1449,6 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,
        int vfio_fd)
 {
        struct rte_dpaa2_object *object = NULL;
-       const struct rte_dpaa2_driver *drv;
        int ret;
 
        switch (dev->dev_type) {
@@ -1465,15 +1464,6 @@ fslmc_close_iodevices(struct rte_dpaa2_device *dev,
                                continue;
                }
                break;
-       case DPAA2_ETH:
-       case DPAA2_CRYPTO:
-       case DPAA2_QDMA:
-               if (dev->device.driver != NULL) {
-                       drv = RTE_BUS_DRIVER(dev->device.driver, *drv);
-                       if (drv->remove && drv->remove(dev))
-                               DPAA2_BUS_ERR("Unable to remove");
-               }
-               break;
        default:
                break;
        }
@@ -1617,9 +1607,6 @@ fslmc_vfio_close_group(void)
                fslmc_close_iodevices(dev, vfio_group_fd);
        }
 
-       RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus)
-               fslmc_close_iodevices(dev, vfio_group_fd);
-
        fslmc_vfio_clear_group(vfio_group_fd);
 
        return 0;
-- 
2.54.0

Reply via email to