* [PATCH] bus/auxiliary: support cleanup callback
@ 2023-03-17 14:55 Xueming Li
2023-03-17 15:24 ` [PATCH v2] " Xueming Li
0 siblings, 1 reply; 3+ messages in thread
From: Xueming Li @ 2023-03-17 14:55 UTC (permalink / raw)
To: Parav Pandit, David Marchand, Kevin Laatz, Bruce Richardson; +Cc: dev
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 | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c
index ff1369353a..19bf523660 100644
--- a/drivers/bus/auxiliary/auxiliary_common.c
+++ b/drivers/bus/auxiliary/auxiliary_common.c
@@ -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,
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] bus/auxiliary: support cleanup callback
2023-03-17 14:55 [PATCH] bus/auxiliary: support cleanup callback Xueming Li
@ 2023-03-17 15:24 ` Xueming Li
2023-06-06 14:33 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Xueming Li @ 2023-03-17 15:24 UTC (permalink / raw)
To: Parav Pandit, David Marchand, Kevin Laatz, Bruce Richardson; +Cc: dev, xuemingl
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(+)
diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c
index ff1369353a..a66cc85d86 100644
--- a/drivers/bus/auxiliary/auxiliary_common.c
+++ b/drivers/bus/auxiliary/auxiliary_common.c
@@ -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,
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] bus/auxiliary: support cleanup callback
2023-03-17 15:24 ` [PATCH v2] " Xueming Li
@ 2023-06-06 14:33 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2023-06-06 14:33 UTC (permalink / raw)
To: Xueming Li
Cc: Parav Pandit, David Marchand, Kevin Laatz, Bruce Richardson, dev
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-06 14:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 14:55 [PATCH] bus/auxiliary: support cleanup callback Xueming Li
2023-03-17 15:24 ` [PATCH v2] " Xueming Li
2023-06-06 14:33 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).