bus: invoke TAILQ_REMOVE when bus cleanup

Message ID 20250220080906.49705-1-fengchengwen@huawei.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series bus: invoke TAILQ_REMOVE when bus cleanup |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-marvell-Functional fail Functional Testing issues

Commit Message

fengchengwen Feb. 20, 2025, 8:09 a.m. UTC
Although eal_bus_cleanup() is not invoked for multiple times, this is a
good programming habit to remove the device object from list when
cleanup bus.

Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
Fixes: 62b906cf06ba ("bus/uacce: introduce UACCE bus")
Fixes: 65780eada9d9 ("bus/vmbus: support cleanup")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/bus/pci/pci_common.c     | 1 +
 drivers/bus/uacce/uacce.c        | 1 +
 drivers/bus/vdev/vdev.c          | 1 +
 drivers/bus/vmbus/vmbus_common.c | 1 +
 4 files changed, 4 insertions(+)
  

Comments

Morten Brørup Feb. 20, 2025, 10:31 a.m. UTC | #1
> From: Chengwen Feng [mailto:fengchengwen@huawei.com]
> Sent: Thursday, 20 February 2025 09.09
> 
> Although eal_bus_cleanup() is not invoked for multiple times, this is a
> good programming habit to remove the device object from list when
> cleanup bus.
> 
> Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
> Fixes: 62b906cf06ba ("bus/uacce: introduce UACCE bus")
> Fixes: 65780eada9d9 ("bus/vmbus: support cleanup")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---

Thank you for cleaning this up.

Acked-by: Morten Brørup <mb@smartsharesystems.com>
  

Patch

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 1173f0887c..2e6d7e43dc 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -459,6 +459,7 @@  pci_cleanup(void)
 		rte_intr_instance_free(dev->vfio_req_intr_handle);
 		dev->vfio_req_intr_handle = NULL;
 
+		TAILQ_REMOVE(&rte_pci_bus.device_list, dev, next);
 		pci_free(RTE_PCI_DEVICE_INTERNAL(dev));
 	}
 
diff --git a/drivers/bus/uacce/uacce.c b/drivers/bus/uacce/uacce.c
index 9ca048122d..75a07957bf 100644
--- a/drivers/bus/uacce/uacce.c
+++ b/drivers/bus/uacce/uacce.c
@@ -454,6 +454,7 @@  uacce_cleanup(void)
 		dev->device.driver = NULL;
 
 free:
+		TAILQ_REMOVE(&uacce_bus.device_list, dev, next);
 		memset(dev, 0, sizeof(*dev));
 		free(dev);
 	}
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index ec7abe7cda..ae79cfd049 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -596,6 +596,7 @@  vdev_cleanup(void)
 
 		dev->device.driver = NULL;
 free:
+		TAILQ_REMOVE(&vdev_device_list, dev, next);
 		free(dev);
 	}
 
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 8a965d10d9..4dac5a6298 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -238,6 +238,7 @@  rte_vmbus_cleanup(void)
 
 		dev->driver = NULL;
 		dev->device.driver = NULL;
+		TAILQ_REMOVE(&rte_vmbus_bus.device_list, dev, next);
 		free(dev);
 	}