[dpdk-dev,v4,02/10] eal: probe new virtual bus after other bus devices

Message ID 1488797809-12917-3-git-send-email-jblunck@infradead.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jan Blunck March 6, 2017, 10:56 a.m. UTC
  Also see commit f4ce209a8ce5 ("eal: postpone vdev initialization").

Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
 lib/librte_eal/common/eal_common_bus.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon March 13, 2017, 5:42 p.m. UTC | #1
2017-03-06 11:56, Jan Blunck:
> @@ -86,9 +86,14 @@ int
>  rte_bus_probe(void)
>  {
>  	int ret;
> -	struct rte_bus *bus;
> +	struct rte_bus *bus, *vbus = NULL;
>  
>  	TAILQ_FOREACH(bus, &rte_bus_list, next) {
> +		if (!strcmp(bus->name, "virtual")) {
> +			vbus = bus;
> +			continue;
> +		}

Why this special handling?

[...]
> +	if (vbus) {
> +		ret = vbus->probe();
> +		if (ret) {
> +			RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n",
> +				vbus->name);
> +			return ret;
> +		}
> +	}

We should not have any special code in this function.
  

Patch

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 4638e78..8f9baf8 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -86,9 +86,14 @@  int
 rte_bus_probe(void)
 {
 	int ret;
-	struct rte_bus *bus;
+	struct rte_bus *bus, *vbus = NULL;
 
 	TAILQ_FOREACH(bus, &rte_bus_list, next) {
+		if (!strcmp(bus->name, "virtual")) {
+			vbus = bus;
+			continue;
+		}
+
 		ret = bus->probe();
 		if (ret) {
 			RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n",
@@ -97,6 +102,15 @@  rte_bus_probe(void)
 		}
 	}
 
+	if (vbus) {
+		ret = vbus->probe();
+		if (ret) {
+			RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n",
+				vbus->name);
+			return ret;
+		}
+	}
+
 	return 0;
 }