[v2] bus/auxiliary: support cleanup callback
Checks
Commit Message
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.
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
drivers/bus/auxiliary/auxiliary_common.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
Comments
17/03/2023 16:24, Xueming Li:
> 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.
>
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Applied, thanks.
@@ -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,