DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xueming Li <xuemingl@nvidia.com>
To: Parav Pandit <parav@nvidia.com>,
	David Marchand <david.marchand@redhat.com>,
	Kevin Laatz <kevin.laatz@intel.com>,
	"Bruce Richardson" <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>
Subject: [PATCH] bus/auxiliary: support cleanup callback
Date: Fri, 17 Mar 2023 22:55:21 +0800	[thread overview]
Message-ID: <20230317145521.3742-1-xuemingl@nvidia.com> (raw)

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


             reply	other threads:[~2023-03-17 14:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 14:55 Xueming Li [this message]
2023-03-17 15:24 ` [PATCH v2] " Xueming Li
2023-06-06 14:33   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230317145521.3742-1-xuemingl@nvidia.com \
    --to=xuemingl@nvidia.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=kevin.laatz@intel.com \
    --cc=parav@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).