Skip to contentSkip to conversation

bus/auxiliary: prevent device from being probed again

PATCH Applied Bing Zhao 2 participants 2 messages Nov 9, 2022 – Nov 14, 2022

lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH v2 1/1 bus/auxiliary: prevent device from being probed again

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

---
v2: fix typo

---
 drivers/bus/auxiliary/auxiliary_common.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/bus/auxiliary/auxiliary_common.c +8 -0
index 6bb1fe7c96..8bc9f20f1b 100644
@@ -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);
Signature · 1 line
2.21.0
#1 lore raw
Quoted 35 lines · Bing Zhao

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

---
v2: fix typo

---
 drivers/bus/auxiliary/auxiliary_common.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/bus/auxiliary/auxiliary_common.c +1 -0
index 6bb1fe7c96..8bc9f20f1b 100644
@@ -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;

drivers/bus/auxiliary/auxiliary_common.c rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv, · line 121

Quoted 5 lines
drivers/bus/auxiliary/auxiliary_common.c +2 -0
@@ -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.

Quoted 11 lines
drivers/bus/auxiliary/auxiliary_common.c +5 -1
+               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.

Signature · 1 line
David Marchand