net: fec: fix probing of fec1 when fec0 is not probed yet
Subsystems (3)
PATCH 1/1 net: fec: fix probing of fec1 when fec0 is not probed yet
it is possible that fec1 is probed before fec0. On SoCs with FEC_QUIRK_SINGLE_MDIO set (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this case fec_enet_mii_init for fec1 returns with -ENODEV, and so fec1 never comes up.
Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_main.c +1 -1
@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ; } bus_freq =2500000 ;/* 2.5MHz by default */
Signature · 1 line
2.20.1
Hello Heiko,
Am Donnerstag, 23. November 2023, 14:27:43 CET schrieb Heiko Schocher:
Quoted 11 lines
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
But FEC_QUIRK_SINGLE_MDIO is only set for imx28. How is this related to imx8qxp?
Will this also help for imx6ul when fec1 is almost always probed before fec0 due to order of DT nodes?
Best regards,
Alexander
Quoted 20 lines
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/net/ethernet/freescale/fec_main.cindexc3b7694a7485..d956f95e7a65100644drivers/net/ethernet/freescale/fec_main.c +1
-1@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ; } bus_freq =2500000 ;/* 2.5MHz by default */
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
Hello Alexander,
Quoted 9 lines · Alexander Stein
Hello Heiko,
Am Donnerstag, 23. November 2023, 14:27:43 CET schrieb Heiko Schocher:
Quoted 6 lines
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.
Quoted 8 lines
Quoted 5 lines
Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
But
FEC_QUIRK_SINGLE_MDIOis only set for imx28. How is this related to imx8qxp?
Ah, yes ... customer uses NXP based kernel there is:
/* board only enable one mii bus in default */
if (!of_get_property(np, "fsl,mii-exclusive", NULL))
fep->quirks |= FEC_QUIRK_SINGLE_MDIO;which is missing in mainline... nevertheless patch fixes a problem with boards having quirk FEC_QUIRK_SINGLE_MDIO set.
Quoted 2 lines
Will this also help for imx6ul when fec1 is almost always probed before fec0 due to order of DT nodes?
Yep, I think so... do you have the chance to test such a setup?
bye,
Heiko
Quoted 26 lines
Best regards,
AlexanderQuoted 20 lines
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/net/ethernet/freescale/fec_main.cindexc3b7694a7485..d956f95e7a65100644drivers/net/ethernet/freescale/fec_main.c +1
-1@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ; } bus_freq =2500000 ;/* 2.5MHz by default */
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Hello Heiko,
Am Donnerstag, 23. November 2023, 16:26:18 CET schrieb Heiko Schocher:
Quoted 21 lines
Hello Alexander,
Quoted 9 lines · Alexander Stein
Hello Heiko,
Am Donnerstag, 23. November 2023, 14:27:43 CET schrieb Heiko Schocher:
Quoted 6 lines
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.Quoted 8 lines
Quoted 5 lines
Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
But
FEC_QUIRK_SINGLE_MDIOis only set for imx28. How is this related to imx8qxp?
Quoted 8 lines
Ah, yes ... customer uses NXP based kernel there is:
/* board only enable one mii bus in default */ if (!of_get_property(np, "fsl,mii-exclusive", NULL)) fep->quirks |= FEC_QUIRK_SINGLE_MDIO;which is missing in mainline... nevertheless patch fixes a problem with boards having quirk
FEC_QUIRK_SINGLE_MDIOset.
But this seems wrong. Apparently fec driver fails if MDIO bus is not (yet) available. But 'fsl,mii-exclusive' + FEC_QUIRK_SINGLE_MDIO assumes both interfaces use fec, no? Will this work e.g. on imx8mp if the FEC PHY is attached to STMMAC (EQOS) PHY?
Quoted 4 lines
Quoted 2 lines
Will this also help for imx6ul when fec1 is almost always probed before fec0 due to order of DT nodes?
Yep, I think so... do you have the chance to test such a setup?
I have a board for that. But I'm not able to test at the moment.
Best regards,
Alexander
Quoted 30 lines
bye,
HeikoQuoted 27 lines
Best regards,
AlexanderQuoted 24 lines
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/net/ethernet/freescale/fec_main.cindexc3b7694a7485..d956f95e7a65100644drivers/net/ethernet/freescale/fec_main.c +1
-1@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ;drivers/net/ethernet/freescale/fec_main.c +0
-0} bus_freq =2500000 ;/* 2.5MHz by default */
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
Quoted 23 lines · Heiko Schocher
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_main.c +0
-0
drivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct platform_device *pdev) · line 2448
Quoted 5 lines
drivers/net/ethernet/freescale/fec_main.c +1
-1@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ;
I think this has been tried before.
Are there any issues with the mii_cnt++; I thought the previous attempt as this had problems with the wrong mdio bus being assigned to fep->mii_bus ? But i could be remembering wrongly.
Andrew
Wei Fang
maintainerQuoted 37 lines
-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: 2023年11月24日 4:09
To: Heiko Schocher <[email protected]>
Cc: [email protected]; Heiko Schocher <[email protected]>; Clark Wang <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; dl-linux-imx <[email protected]>; Paolo Abeni <[email protected]>; Shenwei Wang <[email protected]>; Wei Fang <[email protected]>; [email protected]
Subject: Re: [PATCH] net: fec: fix probing of fec1 when fec0 is not probed yetdrivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct
Quoted 23 lines · Heiko Schocher
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_main.c +0
-0@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct
platform_device*pdev)
Quoted 8 lines
drivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct platform_device *pdev) · line 2448
Quoted 5 lines
drivers/net/ethernet/freescale/fec_main.c +1
-1mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ;I think this has been tried before.
Yes, there was indeed a similar patch [1] before. but this issue seems to only exist in downstream tree, because there is a local patch which is not in the upstream.
/* board only enable one mii bus in default */
if (!of_get_property(np, "fsl,mii-exclusive", NULL))
fep->quirks |= FEC_QUIRK_SINGLE_MDIO;I will think about how to solve this issue in downstream if I'm free later.
[1] https://lore.kernel.org/lkml/[email protected]/T/#r6313852054bf12baabe21418584fbb6d58343197
Quoted 4 lines
Are there any issues with the mii_cnt++; I thought the previous attempt as this had problems with the wrong mdio bus being assigned to
fep->mii_bus? But i could be remembering wrongly.
Hello Wei,
Quoted 45 lines · Wei Fang
Quoted 37 lines
-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: 2023年11月24日 4:09
To: Heiko Schocher <[email protected]>
Cc: [email protected]; Heiko Schocher <[email protected]>; Clark Wang <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; dl-linux-imx <[email protected]>; Paolo Abeni <[email protected]>; Shenwei Wang <[email protected]>; Wei Fang <[email protected]>; [email protected]
Subject: Re: [PATCH] net: fec: fix probing of fec1 when fec0 is not probed yetdrivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct
Quoted 23 lines · Heiko Schocher
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_main.c +0
-0@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct
platform_device*pdev)Quoted 8 lines
drivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct platform_device *pdev) · line 2448
Quoted 5 lines
drivers/net/ethernet/freescale/fec_main.c +1
-1mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ;I think this has been tried before.
Quoted 6 lines
Yes, there was indeed a similar patch [1] before. but this issue seems to only exist in downstream tree, because there is a local patch which is not in the upstream.
/* board only enable one mii bus in default */ if (!of_get_property(np, "fsl,mii-exclusive", NULL)) fep->quirks |= FEC_QUIRK_SINGLE_MDIO;
Yes, sorry for overseeing this ... but there are SoCs in upstream which set FEC_QUIRK_SINGLE_MDIO and so mii bus from for example fec0 is used on other fecX devices, correct?
And for them probing currently fail, when probed before fec0.
Quoted 3 lines
I will think about how to solve this issue in downstream if I'm free later.
[1] https://lore.kernel.org/lkml/[email protected]/T/#r6313852054bf12baabe21418584fbb6d58343197
Hmm.. simply deferring the probe to later point solves the problem here.
I added Alexander may he can comment...
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Wei Fang
maintainerQuoted 67 lines
-----Original Message-----
From: Heiko Schocher <[email protected]>
Sent: 2023年11月24日 13:19
To: Wei Fang <[email protected]>; Andrew Lunn <[email protected]>; Heiko Schocher <[email protected]>
Cc: [email protected]; Clark Wang <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; dl-linux-imx <[email protected]>; Paolo Abeni <[email protected]>; Shenwei Wang <[email protected]>; [email protected]; Alexander Sverdlin <[email protected]>
Subject: Re: [PATCH] net: fec: fix probing of fec1 when fec0 is not probed yetHello Wei,
Quoted 9 lines · Wei Fang
Quoted 9 lines
-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: 2023年11月24日 4:09
To: Heiko Schocher <[email protected]>
Cc: [email protected]; Heiko Schocher <[email protected]>; Clark Wang <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; dl-linux-imx <[email protected]>; Paolo Abeni <[email protected]>; Shenwei Wang <[email protected]>; Wei FangQuoted 37 lines
Quoted 29 lines
[email protected]
Subject: Re: [PATCH] net: fec: fix probing of fec1 when fec0 is not probed yetdrivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct
Quoted 23 lines · Heiko Schocher
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_main.c +0
-0@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct
platform_device*pdev)Quoted 8 lines
drivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct platform_device *pdev) · line 2448
Quoted 5 lines
drivers/net/ethernet/freescale/fec_main.c +1
-1mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ;I think this has been tried before.
Quoted 2 lines
Yes, there was indeed a similar patch [1] before. but this issue seems to only exist in downstream tree, because there is a local patch which is not
in the upstream.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
/* board only enable one mii bus in default */ if (!of_get_property(np, "fsl,mii-exclusive", NULL)) fep->quirks |= FEC_QUIRK_SINGLE_MDIO;Yes, sorry for overseeing this ... but there are SoCs in upstream which set
FEC_QUIRK_SINGLE_MDIOand so mii bus from for example fec0 is used on other fecX devices, correct?
Yes, i.MX28 still uses FEC_QUIRK_SINGLE_MDIO flag in the upstream, But the current patch doesn't seem to completely solve this issue.
If fec1 is probed before fec0, I think its fep->dev_id should be equal to 0, so it will not go to the following statement.
if ((fep->quirks & FEC_QUIRK_SINGLE_MDIO) && fep->dev_id > 0) {
/* fec1 uses fec0 mii_bus */
if (mii_cnt && fec0_mii_bus) {
fep->mii_bus = fec0_mii_bus;
mii_cnt++;
return 0;
}
return -ENOENT;
}I'm considering removing the FEC_QUIRK_SINGLE_MDIO flag from upstream in the future as it's not necessary. But not now as I am busy with other projects.
Hello Wei,
Quoted 75 lines · Wei Fang
Quoted 67 lines
-----Original Message-----
From: Heiko Schocher <[email protected]>
Sent: 2023年11月24日 13:19
To: Wei Fang <[email protected]>; Andrew Lunn <[email protected]>; Heiko Schocher <[email protected]>
Cc: [email protected]; Clark Wang <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; dl-linux-imx <[email protected]>; Paolo Abeni <[email protected]>; Shenwei Wang <[email protected]>; [email protected]; Alexander Sverdlin <[email protected]>
Subject: Re: [PATCH] net: fec: fix probing of fec1 when fec0 is not probed yetHello Wei,
Quoted 9 lines · Wei Fang
Quoted 9 lines
-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: 2023年11月24日 4:09
To: Heiko Schocher <[email protected]>
Cc: [email protected]; Heiko Schocher <[email protected]>; Clark Wang <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; dl-linux-imx <[email protected]>; Paolo Abeni <[email protected]>; Shenwei Wang <[email protected]>; Wei FangQuoted 37 lines
Quoted 29 lines
[email protected]
Subject: Re: [PATCH] net: fec: fix probing of fec1 when fec0 is not probed yetdrivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct
Quoted 23 lines · Heiko Schocher
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_main.c +0
-0@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct
platform_device*pdev)Quoted 8 lines
drivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct platform_device *pdev) · line 2448
Quoted 5 lines
drivers/net/ethernet/freescale/fec_main.c +1
-1mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ;I think this has been tried before.
Quoted 2 lines
Yes, there was indeed a similar patch [1] before. but this issue seems to only exist in downstream tree, because there is a local patch which is not
in the upstream.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
/* board only enable one mii bus in default */ if (!of_get_property(np, "fsl,mii-exclusive", NULL)) fep->quirks |= FEC_QUIRK_SINGLE_MDIO;Yes, sorry for overseeing this ... but there are SoCs in upstream which set
FEC_QUIRK_SINGLE_MDIOand so mii bus from for example fec0 is used on other fecX devices, correct?
Quoted 5 lines
Yes, i.MX28 still uses
FEC_QUIRK_SINGLE_MDIOflag in the upstream, But the current patch doesn't seem to completely solve this issue.If fec1 is probed before fec0, I think its
fep->dev_idshould be equal to 0, so it will not go to the following statement.
Indeed... and than fep->dev_id is interchanged too... I wonder why not using:
fep->dev_id = of_alias_get_id(np, "ethernet");
in fec_probe function for getting the dev_id. With that no problems with "wrong" dev_id and also my change makes sense...
But you are correct, currently patch is useless.
Quoted 10 lines
if ((fep->quirks & FEC_QUIRK_SINGLE_MDIO) && fep->dev_id > 0) {
/* fec1 uses fec0 mii_bus */
if (mii_cnt && fec0_mii_bus) {
fep->mii_bus = fec0_mii_bus;
mii_cnt++;
return 0;
}
return -ENOENT;
}Quoted 2 lines
I'm considering removing the
FEC_QUIRK_SINGLE_MDIOflag from upstream in the future as it's not necessary. But not now as I am busy with other projects.
Hmm.. and what is on platforms which have this usecase?
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Wei Fang
maintainerQuoted 48 lines
-----Original Message-----
From: Heiko Schocher <[email protected]>
Sent: 2023年11月28日 12:42
To: Wei Fang <[email protected]>; Andrew Lunn <[email protected]>; Heiko Schocher <[email protected]>
Cc: [email protected]; Clark Wang <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; dl-linux-imx <[email protected]>; Paolo Abeni <[email protected]>; Shenwei Wang <[email protected]>; [email protected]; Alexander Sverdlin <[email protected]>
Subject: Re: [PATCH] net: fec: fix probing of fec1 when fec0 is not probed yetQuoted 35 lines
Quoted 24 lines
Quoted 19 lines
Quoted 11 lines
drivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct
Quoted 10 lines
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_main.c +0
-0@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct
platform_device*pdev)Quoted 8 lines
drivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct platform_device *pdev) · line 2448
Quoted 5 lines
drivers/net/ethernet/freescale/fec_main.c +1
-1mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ;I think this has been tried before.
Quoted 3 lines
Yes, there was indeed a similar patch [1] before. but this issue seems to only exist in downstream tree, because there is a local patch which is not
in the upstream.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
/* board only enable one mii bus in default */ if (!of_get_property(np, "fsl,mii-exclusive", NULL)) fep->quirks |= FEC_QUIRK_SINGLE_MDIO;Yes, sorry for overseeing this ... but there are SoCs in upstream which set
FEC_QUIRK_SINGLE_MDIOand so mii bus from for example fec0 is used on other fecX devices, correct?Yes, i.MX28 still uses
FEC_QUIRK_SINGLE_MDIOflag in the upstream, But the current patch doesn't seem to completely solve this issue.
Quoted 7 lines
Quoted 2 lines
If fec1 is probed before fec0, I think its
fep->dev_idshould be equal to 0, so it will not go to the following statement.Indeed... and than
fep->dev_idis interchanged too... I wonder why not using:fep->dev_id = of_alias_get_id(np, "ethernet");
Maybe not all dts have ethernet aliases in them. And there are some platforms that may not use DT.
Quoted 29 lines
in
fec_probefunction for getting thedev_id. With that no problems with "wrong"dev_idand also my change makes sense...But you are correct, currently patch is useless.
Quoted 11 lines
if ((fep->quirks & FEC_QUIRK_SINGLE_MDIO) && fep->dev_id > 0) { /* fec1 uses fec0 mii_bus */ if (mii_cnt && fec0_mii_bus) { fep->mii_bus = fec0_mii_bus; mii_cnt++; return 0; } return -ENOENT; }I'm considering removing the
FEC_QUIRK_SINGLE_MDIOflag fromupstream
Quoted 1 line
in the future as it's not necessary. But not now as I am busy with other
projects.
Hmm.. and what is on platforms which have this usecase?
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email:
[email protected]
Hello Andrew,
Quoted 19 lines · Andrew Lunn
Quoted 18 lines · Heiko Schocher
it is possible that fec1 is probed before fec0. On SoCs with
FEC_QUIRK_SINGLE_MDIOset (which means fec1 uses mii from fec0) init of mii fails for fec1 when fec0 is not yet probed, as fec0 setups mii bus. In this casefec_enet_mii_initfor fec1 returns with-ENODEV, and so fec1 never comes up.Return here with -EPROBE_DEFER so interface gets later probed again.
Found this on imx8qxp based board, using 2 ethernet interfaces, and from time to time, fec1 interface came not up.
Signed-off-by Heiko Schocher <[email protected]>---
drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
drivers/net/ethernet/freescale/fec_main.c static int fec_enet_mii_init(struct platform_device *pdev) · line 2448
Quoted 10 lines
drivers/net/ethernet/freescale/fec_main.c +1
-1@@ -2445,7 +2445,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) mii_cnt++;return 0 ; } -return -ENOENT ; +return -EPROBE_DEFER ;I think this has been tried before.
Oh, wasn;t aware of it...
Quoted 3 lines
Are there any issues with the mii_cnt++; I thought the previous attempt as this had problems with the wrong mdio bus being assigned to
fep->mii_bus? But i could be remembering wrongly.
The problem with returning -ENOENT is, that the probe never called again ... with returning -EPROBE_DEFER, the device gets probed later again.
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]