linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: fec: Keep device numbering consistent with datasheet
@ 2020-09-23 14:25 Stefan Riedmueller
  2020-09-23 19:17 ` Andrew Lunn
  2020-09-23 20:31 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Riedmueller @ 2020-09-23 14:25 UTC (permalink / raw)
  To: Fugang Duan
  Cc: Stefan Riedmueller, netdev, linux-kernel, Christian Hemp,
	Jakub Kicinski, David S . Miller, linux-arm-kernel

From: Christian Hemp <c.hemp@phytec.de>

Make use of device tree alias for device enumeration to keep the device
order consistent with the naming in the datasheet.

Otherwise for the i.MX 6UL/ULL the ENET1 interface is enumerated as eth1
and ENET2 as eth0.

Signed-off-by: Christian Hemp <c.hemp@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
---
 drivers/net/ethernet/freescale/fec_main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index fb37816a74db..97dd41bed70a 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3504,6 +3504,7 @@ fec_probe(struct platform_device *pdev)
 	char irq_name[8];
 	int irq_cnt;
 	struct fec_devinfo *dev_info;
+	int eth_id;
 
 	fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
 
@@ -3691,6 +3692,10 @@ fec_probe(struct platform_device *pdev)
 
 	ndev->max_mtu = PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN;
 
+	eth_id = of_alias_get_id(pdev->dev.of_node, "ethernet");
+	if (eth_id >= 0)
+		sprintf(ndev->name, "eth%d", eth_id);
+
 	ret = register_netdev(ndev);
 	if (ret)
 		goto failed_register;
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] net: fec: Keep device numbering consistent with datasheet
  2020-09-23 14:25 [PATCH] net: fec: Keep device numbering consistent with datasheet Stefan Riedmueller
@ 2020-09-23 19:17 ` Andrew Lunn
  2020-09-23 20:31 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2020-09-23 19:17 UTC (permalink / raw)
  To: Stefan Riedmueller
  Cc: Fugang Duan, netdev, linux-kernel, Christian Hemp,
	Jakub Kicinski, David S . Miller, linux-arm-kernel

On Wed, Sep 23, 2020 at 04:25:28PM +0200, Stefan Riedmueller wrote:
> From: Christian Hemp <c.hemp@phytec.de>
> 
> Make use of device tree alias for device enumeration to keep the device
> order consistent with the naming in the datasheet.
> 
> Otherwise for the i.MX 6UL/ULL the ENET1 interface is enumerated as eth1
> and ENET2 as eth0.

What is wrong with that?  Ethernet interface names have never been
guaranteed to be stable.

You have to be careful here. Have you reviewed all the DTS files to
make sure none already have aliases? You could be breaking boards
which currently 'work' because the alias is ignored.

udev is actually a better solution for giving the interfaces
dependable names.

      Andrew

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] net: fec: Keep device numbering consistent with datasheet
  2020-09-23 14:25 [PATCH] net: fec: Keep device numbering consistent with datasheet Stefan Riedmueller
  2020-09-23 19:17 ` Andrew Lunn
@ 2020-09-23 20:31 ` David Miller
  2020-09-24  6:36   ` [EXT] " Andy Duan
  1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2020-09-23 20:31 UTC (permalink / raw)
  To: s.riedmueller
  Cc: fugang.duan, netdev, linux-kernel, c.hemp, kuba, linux-arm-kernel

From: Stefan Riedmueller <s.riedmueller@phytec.de>
Date: Wed, 23 Sep 2020 16:25:28 +0200

> From: Christian Hemp <c.hemp@phytec.de>
> 
> Make use of device tree alias for device enumeration to keep the device
> order consistent with the naming in the datasheet.
> 
> Otherwise for the i.MX 6UL/ULL the ENET1 interface is enumerated as eth1
> and ENET2 as eth0.
> 
> Signed-off-by: Christian Hemp <c.hemp@phytec.de>
> Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>

Device naming and ordering for networking devices was never, ever,
guaranteed.

Use udev or similar.

> @@ -3691,6 +3692,10 @@ fec_probe(struct platform_device *pdev)
>  
>  	ndev->max_mtu = PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN;
>  
> +	eth_id = of_alias_get_id(pdev->dev.of_node, "ethernet");
> +	if (eth_id >= 0)
> +		sprintf(ndev->name, "eth%d", eth_id);

You can't ever just write into ndev->name, what if another networking
device is already using that name?

This change is incorrect on many levels.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* RE: [EXT] Re: [PATCH] net: fec: Keep device numbering consistent with datasheet
  2020-09-23 20:31 ` David Miller
@ 2020-09-24  6:36   ` Andy Duan
  2020-09-24  7:11     ` Stefan Riedmüller
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Duan @ 2020-09-24  6:36 UTC (permalink / raw)
  To: David Miller, s.riedmueller
  Cc: kuba, c.hemp@phytec.de, linux-kernel, linux-arm-kernel, netdev

From: David Miller <davem@davemloft.net> Sent: Thursday, September 24, 2020 4:32 AM
> From: Stefan Riedmueller <s.riedmueller@phytec.de>
> Date: Wed, 23 Sep 2020 16:25:28 +0200
> 
> > From: Christian Hemp <c.hemp@phytec.de>
> >
> > Make use of device tree alias for device enumeration to keep the
> > device order consistent with the naming in the datasheet.
> >
> > Otherwise for the i.MX 6UL/ULL the ENET1 interface is enumerated as
> > eth1 and ENET2 as eth0.
> >
> > Signed-off-by: Christian Hemp <c.hemp@phytec.de>
> > Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
> 
> Device naming and ordering for networking devices was never, ever,
> guaranteed.
> 
> Use udev or similar.
> 
> > @@ -3691,6 +3692,10 @@ fec_probe(struct platform_device *pdev)
> >
> >       ndev->max_mtu = PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN;
> >
> > +     eth_id = of_alias_get_id(pdev->dev.of_node, "ethernet");
> > +     if (eth_id >= 0)
> > +             sprintf(ndev->name, "eth%d", eth_id);
> 
> You can't ever just write into ndev->name, what if another networking device is
> already using that name?
> 
> This change is incorrect on many levels.

David is correct.

For example, imx8DXL has ethernet0 is EQOS TSN, ethernet1 is FEC.
EQOS TSN is andother driver and is registered early, the dev->name is eth0.
So the patch will bring conflict in such case.

Andy

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [EXT] Re: [PATCH] net: fec: Keep device numbering consistent with datasheet
  2020-09-24  6:36   ` [EXT] " Andy Duan
@ 2020-09-24  7:11     ` Stefan Riedmüller
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Riedmüller @ 2020-09-24  7:11 UTC (permalink / raw)
  To: Andy Duan, David Miller, Andrew Lunn
  Cc: kuba, c.hemp@phytec.de, linux-kernel, linux-arm-kernel, netdev

Hi Andy, David and Andrew,

first of all, thanks for your review. I really appreciate it!

On 24.09.20 08:36, Andy Duan wrote:
> From: David Miller <davem@davemloft.net> Sent: Thursday, September 24, 2020 4:32 AM
>> From: Stefan Riedmueller <s.riedmueller@phytec.de>
>> Date: Wed, 23 Sep 2020 16:25:28 +0200
>>
>>> From: Christian Hemp <c.hemp@phytec.de>
>>>
>>> Make use of device tree alias for device enumeration to keep the
>>> device order consistent with the naming in the datasheet.
>>>
>>> Otherwise for the i.MX 6UL/ULL the ENET1 interface is enumerated as
>>> eth1 and ENET2 as eth0.
>>>
>>> Signed-off-by: Christian Hemp <c.hemp@phytec.de>
>>> Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
>>
>> Device naming and ordering for networking devices was never, ever,
>> guaranteed.
>>
>> Use udev or similar.
>>
>>> @@ -3691,6 +3692,10 @@ fec_probe(struct platform_device *pdev)
>>>
>>>        ndev->max_mtu = PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN;
>>>
>>> +     eth_id = of_alias_get_id(pdev->dev.of_node, "ethernet");
>>> +     if (eth_id >= 0)
>>> +             sprintf(ndev->name, "eth%d", eth_id);
>>
>> You can't ever just write into ndev->name, what if another networking device is
>> already using that name?
>>
>> This change is incorrect on many levels.
> 
> David is correct.
> 
> For example, imx8DXL has ethernet0 is EQOS TSN, ethernet1 is FEC.
> EQOS TSN is andother driver and is registered early, the dev->name is eth0.
> So the patch will bring conflict in such case.

I was not aware of that conflict, but now that you mention it it makes total 
sense.

I wanted to make life a little easier for myself but underestimated the 
global context. I will try to find a solution with udev or something similar.

So please drop this patch and sorry for the noise.

Stefan

> 
> Andy
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2020-09-24  7:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-23 14:25 [PATCH] net: fec: Keep device numbering consistent with datasheet Stefan Riedmueller
2020-09-23 19:17 ` Andrew Lunn
2020-09-23 20:31 ` David Miller
2020-09-24  6:36   ` [EXT] " Andy Duan
2020-09-24  7:11     ` Stefan Riedmüller

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