patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH v2] bus/auxiliary: prevent device from being probed again
@ 2022-11-09 14:53 Bing Zhao
  2022-11-14 10:20 ` David Marchand
  0 siblings, 1 reply; 2+ messages in thread
From: Bing Zhao @ 2022-11-09 14:53 UTC (permalink / raw)
  To: parav, xuemingl, andrew.rybchenko, thomas
  Cc: dev, matan, rasland, stable, Gregory Etelson

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 quitting, 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>
---
v2: fix typo
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] bus/auxiliary: prevent device from being probed again
  2022-11-09 14:53 [PATCH v2] bus/auxiliary: prevent device from being probed again Bing Zhao
@ 2022-11-14 10:20 ` David Marchand
  0 siblings, 0 replies; 2+ messages in thread
From: David Marchand @ 2022-11-14 10:20 UTC (permalink / raw)
  To: Bing Zhao
  Cc: parav, xuemingl, andrew.rybchenko, thomas, dev, matan, rasland,
	stable, Gregory Etelson

On Wed, Nov 9, 2022 at 3:54 PM Bing Zhao <bingz@nvidia.com> wrote:
>
> 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 quitting, 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: 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>
> ---
> v2: fix typo
> ---
>  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) {

No need for this variable, I removed it when applying.

For consistency with other bus code, I also moved this check before
the IOVA validation.

> +               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
>

Applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-14 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 14:53 [PATCH v2] bus/auxiliary: prevent device from being probed again Bing Zhao
2022-11-14 10:20 ` David Marchand

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).