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

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

Checks

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

Commit Message

Jan Blunck Feb. 25, 2017, 10:28 a.m. UTC
  Also see commit f4ce209a ("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

Shreyansh Jain Feb. 27, 2017, 8:59 a.m. UTC | #1
On Saturday 25 February 2017 03:58 PM, Jan Blunck wrote:
> Also see commit f4ce209a ("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(-)
>
> 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;
> +		}
> +	}
> +

This has probably changed to do away with priority of RTE_REGISTER_*
macro.

This is based on an assumption that there is only a single 'virtual'
bus and no driver ever registers another bus with the same name.

The problem originates from the fact that rte_bus_register is
_not_ checking for duplicate entries while registering.
(Apparently, it would be a problem in case of RTE_* macros as well).

I think that should be fixed.

If we are in sync, I will push a patch.

>  	return 0;
>  }
>
>
  
Jan Blunck Feb. 27, 2017, 9:09 a.m. UTC | #2
On Mon, Feb 27, 2017 at 9:59 AM, Shreyansh Jain <shreyansh.jain@nxp.com> wrote:
> On Saturday 25 February 2017 03:58 PM, Jan Blunck wrote:
>>
>> Also see commit f4ce209a ("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(-)
>>
>> 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;
>> +               }
>> +       }
>> +
>
>
> This has probably changed to do away with priority of RTE_REGISTER_*
> macro.
>
> This is based on an assumption that there is only a single 'virtual'
> bus and no driver ever registers another bus with the same name.
>
> The problem originates from the fact that rte_bus_register is
> _not_ checking for duplicate entries while registering.
> (Apparently, it would be a problem in case of RTE_* macros as well).
>
> I think that should be fixed.
>
> If we are in sync, I will push a patch.
>

Indeed. The buses should have a unique name.
  

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;
 }