DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bing Zhao <bingz@nvidia.com>
To: <parav@nvidia.com>, <xuemingl@nvidia.com>,
	<andrew.rybchenko@oktetlabs.ru>, <thomas@monjalon.net>
Cc: <dev@dpdk.org>, <matan@nvidia.com>, <rasland@nvidia.com>,
	<stable@dpdk.org>, Gregory Etelson <getelson@nvidia.com>
Subject: [PATCH] bus/auxiliary: prevent device from being probed again
Date: Wed, 9 Nov 2022 16:43:33 +0200	[thread overview]
Message-ID: <20221109144333.779058-1-bingz@nvidia.com> (raw)

The device on auxiliary bus doesn't support being probed again
without being removed firstly. The PMD will detect and return error
for this unsupported operation. Some of the resources would be
cleared wrongly. When quiting, there will be unexpected error like
crash.

To prevent this, the device driver will be checked before probing a
device.

Fixes: 1afce3086cf4 ("bus/auxiliary: introduce auxiliary bus")
Cc: xuemingl@nvidia.com
CC: stable@dpdk.org

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Reviewed-by: Gregory Etelson <getelson@nvidia.com>
Reviewed-by: Matan Azrad <matan@nvidia.com>
---
 drivers/bus/auxiliary/auxiliary_common.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c
index 6bb1fe7c96..8bc9f20f1b 100644
--- a/drivers/bus/auxiliary/auxiliary_common.c
+++ b/drivers/bus/auxiliary/auxiliary_common.c
@@ -89,6 +89,7 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv,
 {
 	enum rte_iova_mode iova_mode;
 	int ret;
+	bool already_probed;
 
 	if (drv == NULL || dev == NULL)
 		return -EINVAL;
@@ -116,6 +117,13 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv,
 		return -EINVAL;
 	}
 
+	already_probed = rte_dev_is_probed(&dev->device);
+	if (already_probed) {
+		RTE_LOG(DEBUG, EAL, "Device %s is already probed on auxiliary bus\n",
+			dev->device.name);
+		return -EEXIST;
+	}
+
 	/* Allocate interrupt instance */
 	dev->intr_handle =
 		rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
-- 
2.21.0


                 reply	other threads:[~2022-11-09 14:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221109144333.779058-1-bingz@nvidia.com \
    --to=bingz@nvidia.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=getelson@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=parav@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=xuemingl@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).