Skip to contentSkip to conversation

bus/auxiliary: support cleanup callback

PATCH Superseded Xueming Li 2 participants 3 messages Mar 17, 2023 – Jun 6, 2023

lore
Share & tools
lore

Xueming Li

author
#0 lore raw

PATCH 1/1 bus/auxiliary: support cleanup callback

The bus cleanup callback is used to sunset all devices on bus gracefully. This patch supports the callback by unplug all devices on auxiliary bus.

---
 drivers/bus/auxiliary/auxiliary_common.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/bus/auxiliary/auxiliary_common.c +22 -0
index ff1369353a..19bf523660 100644
@@ -236,6 +236,7 @@ auxiliary_probe(void)
 	return (probed && probed == failed) ? -1 : 0;
 }
 
+
 static int
 auxiliary_parse(const char *name, void *addr)
 {
@@ -337,6 +338,26 @@ auxiliary_unplug(struct rte_device *dev)
 	return ret;
 }
 
+static int
+auxiliary_cleanup(void)
+{
+	struct rte_auxiliary_device *dev, *tmp_dev;
+	int error = 0;
+
+	RTE_TAILQ_FOREACH_SAFE(dev, &auxiliary_bus.device_list, next, tmp_dev) {
+		struct rte_auxiliary_driver *drv = dev->driver;
+		int ret = 0;
+
+		ret = auxiliary_unplug(&dev->device);
+		if (ret < 0) {
+			rte_errno = errno;
+			error = -1;
+		}
+	}
+
+	return error;
+}
+
 static int
 auxiliary_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
 {
@@ -406,6 +427,7 @@ struct rte_auxiliary_bus auxiliary_bus = {
 	.bus = {
 		.scan = auxiliary_scan,
 		.probe = auxiliary_probe,
+		.cleanup = auxiliary_cleanup,
 		.find_device = auxiliary_find_device,
 		.plug = auxiliary_plug,
 		.unplug = auxiliary_unplug,
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 1/1 bus/auxiliary: support cleanup callback

The bus cleanup callback is used to sunset all devices on bus gracefully. This patch supports the callback by unplug all devices on auxiliary bus.

---
 drivers/bus/auxiliary/auxiliary_common.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/bus/auxiliary/auxiliary_common.c +21 -0
index ff1369353a..a66cc85d86 100644
@@ -236,6 +236,7 @@ auxiliary_probe(void)
 	return (probed && probed == failed) ? -1 : 0;
 }
 
+
 static int
 auxiliary_parse(const char *name, void *addr)
 {
@@ -337,6 +338,25 @@ auxiliary_unplug(struct rte_device *dev)
 	return ret;
 }
 
+static int
+auxiliary_cleanup(void)
+{
+	struct rte_auxiliary_device *dev, *tmp_dev;
+	int error = 0;
+
+	RTE_TAILQ_FOREACH_SAFE(dev, &auxiliary_bus.device_list, next, tmp_dev) {
+		int ret;
+
+		ret = auxiliary_unplug(&dev->device);
+		if (ret < 0) {
+			rte_errno = errno;
+			error = -1;
+		}
+	}
+
+	return error;
+}
+
 static int
 auxiliary_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
 {
@@ -406,6 +426,7 @@ struct rte_auxiliary_bus auxiliary_bus = {
 	.bus = {
 		.scan = auxiliary_scan,
 		.probe = auxiliary_probe,
+		.cleanup = auxiliary_cleanup,
 		.find_device = auxiliary_find_device,
 		.plug = auxiliary_plug,
 		.unplug = auxiliary_unplug,
Signature · 1 line
2.25.1
#2 lore raw

17/03/2023 16:24, Xueming Li:

Quoted 5 lines

The bus cleanup callback is used to sunset all devices on bus gracefully. This patch supports the callback by unplug all devices on auxiliary bus.

Applied, thanks.