diff mbox series

[U-Boot,01/14] net: eth-uclass: eth_get_dev based on SEQ_ALIAS instead of probe order

Message ID 20190806103844.25277-2-j-keerthy@ti.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series net: ti: icssg: Add prueth support | expand

Commit Message

J, KEERTHY Aug. 6, 2019, 10:38 a.m. UTC
In case of multiple eth interfaces currently eth_get_dev
fetches the device based on the probe order which can be
random hence try with the alias.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 net/eth-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Oct. 25, 2019, 12:05 p.m. UTC | #1
On Tue, Aug 06, 2019 at 04:08:31PM +0530, Keerthy wrote:

> In case of multiple eth interfaces currently eth_get_dev
> fetches the device based on the probe order which can be
> random hence try with the alias.
> 
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> ---
>  net/eth-uclass.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
> index 031d558625..f11c307b8c 100644
> --- a/net/eth-uclass.c
> +++ b/net/eth-uclass.c
> @@ -68,8 +68,8 @@ struct udevice *eth_get_dev(void)
>  
>  	uc_priv = eth_get_uclass_priv();
>  	if (!uc_priv->current)
> -		eth_errno = uclass_first_device(UCLASS_ETH,
> -				    &uc_priv->current);
> +		eth_errno = uclass_get_device_by_seq(UCLASS_ETH,
> +						     0, &uc_priv->current);
>  	return uc_priv->current;
>  }

This breaks networking on qemu_arm / qemu_arm64 and no networking device
is found.
J, KEERTHY Oct. 25, 2019, 4:53 p.m. UTC | #2
On 10/25/2019 5:35 PM, Tom Rini wrote:
> On Tue, Aug 06, 2019 at 04:08:31PM +0530, Keerthy wrote:
> 
>> In case of multiple eth interfaces currently eth_get_dev
>> fetches the device based on the probe order which can be
>> random hence try with the alias.
>>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>> ---
>>   net/eth-uclass.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
>> index 031d558625..f11c307b8c 100644
>> --- a/net/eth-uclass.c
>> +++ b/net/eth-uclass.c
>> @@ -68,8 +68,8 @@ struct udevice *eth_get_dev(void)
>>   
>>   	uc_priv = eth_get_uclass_priv();
>>   	if (!uc_priv->current)
>> -		eth_errno = uclass_first_device(UCLASS_ETH,
>> -				    &uc_priv->current);
>> +		eth_errno = uclass_get_device_by_seq(UCLASS_ETH,
>> +						     0, &uc_priv->current);
>>   	return uc_priv->current;
>>   }
> 
> This breaks networking on qemu_arm / qemu_arm64 and no networking device
> is found.

Okay. That is pretty strange. So seems like uclass_get_device_by_seq is 
failing for some reason.

>
Lokesh Vutla Oct. 29, 2019, 9:03 a.m. UTC | #3
On 25/10/19 10:23 PM, keerthy wrote:
> 
> 
> On 10/25/2019 5:35 PM, Tom Rini wrote:
>> On Tue, Aug 06, 2019 at 04:08:31PM +0530, Keerthy wrote:
>>
>>> In case of multiple eth interfaces currently eth_get_dev
>>> fetches the device based on the probe order which can be
>>> random hence try with the alias.
>>>
>>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>>> ---
>>>   net/eth-uclass.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
>>> index 031d558625..f11c307b8c 100644
>>> --- a/net/eth-uclass.c
>>> +++ b/net/eth-uclass.c
>>> @@ -68,8 +68,8 @@ struct udevice *eth_get_dev(void)
>>>         uc_priv = eth_get_uclass_priv();
>>>       if (!uc_priv->current)
>>> -        eth_errno = uclass_first_device(UCLASS_ETH,
>>> -                    &uc_priv->current);
>>> +        eth_errno = uclass_get_device_by_seq(UCLASS_ETH,
>>> +                             0, &uc_priv->current);
>>>       return uc_priv->current;
>>>   }
>>
>> This breaks networking on qemu_arm / qemu_arm64 and no networking device
>> is found.
> 
> Okay. That is pretty strange. So seems like uclass_get_device_by_seq is failing
> for some reason.

because not everyone populates aliases. You can do something like below:

	eth_errno = uclass_get_device_by_seq(UCLASS_ETH, 0, &uc_priv->current);
	if (eth_errno || !uc_priv->current)
		 eth_errno = uclass_first_device(UCLASS_ETH, &uc_priv->current);


Thanks and regards,
Lokesh

> 
>>
J, KEERTHY Oct. 29, 2019, 9:56 a.m. UTC | #4
On 10/29/2019 2:33 PM, Lokesh Vutla wrote:
> 
> 
> On 25/10/19 10:23 PM, keerthy wrote:
>>
>>
>> On 10/25/2019 5:35 PM, Tom Rini wrote:
>>> On Tue, Aug 06, 2019 at 04:08:31PM +0530, Keerthy wrote:
>>>
>>>> In case of multiple eth interfaces currently eth_get_dev
>>>> fetches the device based on the probe order which can be
>>>> random hence try with the alias.
>>>>
>>>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>>>> ---
>>>>    net/eth-uclass.c | 4 ++--
>>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
>>>> index 031d558625..f11c307b8c 100644
>>>> --- a/net/eth-uclass.c
>>>> +++ b/net/eth-uclass.c
>>>> @@ -68,8 +68,8 @@ struct udevice *eth_get_dev(void)
>>>>          uc_priv = eth_get_uclass_priv();
>>>>        if (!uc_priv->current)
>>>> -        eth_errno = uclass_first_device(UCLASS_ETH,
>>>> -                    &uc_priv->current);
>>>> +        eth_errno = uclass_get_device_by_seq(UCLASS_ETH,
>>>> +                             0, &uc_priv->current);
>>>>        return uc_priv->current;
>>>>    }
>>>
>>> This breaks networking on qemu_arm / qemu_arm64 and no networking device
>>> is found.
>>
>> Okay. That is pretty strange. So seems like uclass_get_device_by_seq is failing
>> for some reason.
> 
> because not everyone populates aliases. You can do something like below:
> 
> 	eth_errno = uclass_get_device_by_seq(UCLASS_ETH, 0, &uc_priv->current);
> 	if (eth_errno || !uc_priv->current)
> 		 eth_errno = uclass_first_device(UCLASS_ETH, &uc_priv->current);

Thanks Lokesh. I will add that check.

> 
> 
> Thanks and regards,
> Lokesh
> 
>>
>>>
diff mbox series

Patch

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 031d558625..f11c307b8c 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -68,8 +68,8 @@  struct udevice *eth_get_dev(void)
 
 	uc_priv = eth_get_uclass_priv();
 	if (!uc_priv->current)
-		eth_errno = uclass_first_device(UCLASS_ETH,
-				    &uc_priv->current);
+		eth_errno = uclass_get_device_by_seq(UCLASS_ETH,
+						     0, &uc_priv->current);
 	return uc_priv->current;
 }