was: FEC on MPC860T & race condition
Hi there,
in October 2001 (!) there were two threads, one was "FEC on MPC860T & race condition" and the other was "Problem using FEC on a860T"
You, Laurent, told us about a race condition.
You, Dan, first claimed, it was already fix but mentioned later that the patch was somehow lost.
Now I have this problem as well and realised that in 2.4.20 the "mii_link_interrupt interrupt handler is still registered before the PHY chip is initialized".
Are there any plans to fix that?
Laurent, did you fix taht for your board properly or just as a work around?
Thanks a million,
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 4 lines · Steven Scholz
You, Laurent, told us about a race condition.
You, Dan, first claimed, it was already fix but mentioned later that the patch
was somehow lost.
IIRC, it was the usual problem of having it fixed in only one of the two 2.4 trees. I ensured both trees were made up to date.
Quoted 3 lines
Now I have this problem as well and realised that in 2.4.20 the "
mii_link_interruptinterrupt handler is still registered before the PHY chip is initialized".
The link interrupt is board design and PHY dependent. I don't think there is any one "right" way to initialize this interrupt handler. If you have something that isn't working to your liking, we may have to extend the MII logic in some way to accomodate this. Keep in mind that the existing driver is likely working with other boards, and you don't want to break those configurations.
Thanks.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 11 lines · Dan Malek
Quoted 4 lines · Steven Scholz
You, Laurent, told us about a race condition.
You, Dan, first claimed, it was already fix but mentioned later that the patch
was somehow lost.IIRC, it was the usual problem of having it fixed in only one of the two 2.4 trees. I ensured both trees were made up to date.
There is still no fix in linuxppc_2_4_devel!
Quoted 10 lines
Quoted 3 lines
Now I have this problem as well and realised that in 2.4.20 the "
mii_link_interruptinterrupt handler is still registered before the PHY chip is initialized".The link interrupt is board design and PHY dependent. I don't think there is any one "right" way to initialize this interrupt handler. If you have something that isn't working to your liking, we may have to extend the MII logic in some way to accomodate this. Keep in mind that the existing driver is likely working with other boards, and you don't want to break those configurations.
There is a race condition!
Lucky you if you never see it! :o)
But fair enough. If more people had this problem, the fix would be in the trees by now.
How about adding something like CONFIG_FEC_LATE_ENABLE_PHY or so. Of course with a help text in Documentation/Configure.help so that people having that problem could easily enable that. And for the rest (although this might be the majority) everythings stays as it it.
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 10 lines · Steven Scholz
Quoted 8 lines · Dan Malek
Quoted 4 lines · Steven Scholz
You, Laurent, told us about a race condition.
You, Dan, first claimed, it was already fix but mentioned later that the patch
was somehow lost.
Quoted 4 lines
Quoted 2 lines
IIRC, it was the usual problem of having it fixed in only one of the two 2.4 trees. I ensured both trees were made up to date.
There is still no fix in
linuxppc_2_4_devel!
Um, but there is in linuxppc_2_4 ?
--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 13 lines · Tom Rini
Quoted 11 lines · Steven Scholz
Quoted 9 lines · Dan Malek
Quoted 4 lines · Steven Scholz
You, Laurent, told us about a race condition.
You, Dan, first claimed, it was already fix but mentioned later that the patch
was somehow lost.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
IIRC, it was the usual problem of having it fixed in only one of the two 2.4 trees. I ensured both trees were made up to date.
There is still no fix in
linuxppc_2_4_devel!Um, but there is in
linuxppc_2_4?
Is that a question or a statement?
I just hab a look at arch/ppc/8xx_io/fec.c in the recent linuxppc_2_4 and could find this problem fixed! The MII irq is still requested very early without waiting for the PHY to discovered!
Cheers,
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 14 lines · Steven Scholz
Quoted 13 lines · Tom Rini
Quoted 11 lines · Steven Scholz
Quoted 9 lines · Dan Malek
Quoted 4 lines · Steven Scholz
You, Laurent, told us about a race condition.
You, Dan, first claimed, it was already fix but mentioned later that the patch
was somehow lost.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
IIRC, it was the usual problem of having it fixed in only one of the two 2.4 trees. I ensured both trees were made up to date.
There is still no fix in
linuxppc_2_4_devel!Um, but there is in
linuxppc_2_4?Is that a question or a statement?
A question.
Quoted 3 lines
I just hab a look at
arch/ppc/8xx_io/fec.cin the recentlinuxppc_2_4and could find this problem fixed! The MII irq is still requested very early without waiting for the PHY to discovered!
So linuxppc_2_4 has a partial fix then is what you're saying? Around what lines? I'm interested to see why _devel doesn't have this.
--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 3 lines · I wrote:
Quoted 3 lines
I just hab a look at
arch/ppc/8xx_io/fec.cin the recentlinuxppc_2_4and could find this problem fixed! The MII irq is still requested very early without waiting for the PHY to discovered!
Damn it!!! Stupid fingers.
I meant to write "could NOT find this problem fixed" !
Quoted 2 lines
So
linuxppc_2_4has a partial fix then is what you're saying? Around what lines? I'm interested to see why_develdoesn't have this.
So IHMO there is neither in recent linuxppc_2_4_devel nor in linuxppc_2_4 a fix for the mentioned problem.
I'll attach my patch. It is not configurable since I think it won't break anything.
If you need or wish something like CONFIG_FEC_FIX_RACE or CONFIG_FEC_LATE_ENABLE_PHY I could do that!
Regards,
Steven
Index: arch/ppc/8xx_io/fec.c
===================================================================
RCS file: /home/cvsroot/linuxppc_2_4_denx/arch/ppc/8xx_io/fec.c,v retrieving revision 1.1.1.1
ppc/8xx_io/fec.c +38 -12
@@ -33,6 +33,10 @@* * Added code for Multicast support, Frederic Goddeeris, Paul Geerinckx * Copyright (c) 2002 Siemens Atea +* +* Fix compiler warning: changed type of mem_addr +* Fix to avoid race condition: wait until PHY is discovered +* before requesting the MII irq */ #include <linux/config.h>
@@ -2032,7 +2036,7 @@struct fec_enet_private *fep;int i, j, k;unsigned char *eap, *iap, *ba; -unsigned long mem_addr; +dma_addr_t mem_addr;volatile cbd_t *bdp;cbd_t *cbd_base;volatile immap_t *immap;
@@ -2172,17 +2176,6 @@ *((uint *)RPX_CSR_ADDR ) &= ~BCSR2_FETHLEDMODE ;#endif /* CONFIG_RPXCLASSIC */ -#ifdef CONFIG_USE_MDIO -# ifndef PHY_INTERRUPT -# error Want to use MII, but PHY_INTERRUPT not defined! -# endif - ((immap_t *)IMAP_ADDR )->im_siu_conf.sc_siel |= - (0x80000000 >>PHY_INTERRUPT ); - -if (request_8xxirq (PHY_INTERRUPT , mii_link_interrupt,0 ,"mii" , dev) !=0 ) -panic ("Could not allocate MII IRQ!" ); -#endif /* CONFIG_USE_MDIO */ - dev->base_addr = (unsigned long )fecp; dev->priv = fep;
@@ -2285,6 +2278,39 @@ fep->old_status =0 ;#endif /* CONFIG_USE_MDIO */ +#ifdef CONFIG_USE_MDIO +# ifndef PHY_INTERRUPT +# error Want to use MII, but PHY_INTERRUPT not defined! +# endif +/* before requesting the irq, we should wait until PHY is discovered +* to avoid race conditions +*/ +while (!fep->phy_id_done) { +udelay (5 ); + } + +/* I found the following lines in a post from [email protected]> +* (http://lists.linuxppc.org/linuxppc-embedded/200110/msg00206.html) +* But I am not sure if and why this is necessary. +* Enable it just to be sure, be sure ... ? +* It works for me without it. +*/ +#if 0 +mii_do_cmd (dev, fep->phy->ack_int); +mii_do_cmd (dev, fep->phy->startup); + + { +int tmp; +for (tmp =0 ; tmp <50 ; tmp++) +udelay (5 ); + } +#endif +if (request_8xxirq (PHY_INTERRUPT , mii_link_interrupt,0 ,"mii" , dev) !=0 ) +panic ("Could not allocate MII IRQ!" ); + + ((immap_t *)IMAP_ADDR )->im_siu_conf.sc_siel |= + (0x80000000 >>PHY_INTERRUPT ); +#endif /* CONFIG_USE_MDIO */ return 0 ; }
Quoted 2 lines · Steven Scholz
I'll attach my patch. It is not configurable since I think it won't break anything.
Okay. Moving along the process, I have a comment:
Quoted 4 lines
ppc/8xx_io/fec.c +0
-0@@ -2285,6 +2278,39 @@ fep->old_status =0 ;#endif /* CONFIG_USE_MDIO */
ppc/8xx_io/fec.c line 2290
Quoted 10 lines
ppc/8xx_io/fec.c +10
-0+#ifdef CONFIG_USE_MDIO +# ifndef PHY_INTERRUPT +# error Want to use MII, but PHY_INTERRUPT not defined! +# endif +/* before requesting the irq, we should wait until PHY is discovered +* to avoid race conditions +*/ +while (!fep->phy_id_done) { +udelay (5 ); + }
I believe this is wrong, in that trying to udelay() here is a bad idea. I don't have the time right now, but I suspect google, or #kernelnewbies might be able to suggest a more appropriate way of waiting here.
Or perhaps classes have fried my mind, and this is correct.
Quoted 6 lines
ppc/8xx_io/fec.c +6
-0+/* I found the following lines in a post from [email protected]> +* (http://lists.linuxppc.org/linuxppc-embedded/200110/msg00206.html) +* But I am not sure if and why this is necessary. +* Enable it just to be sure, be sure ... ? +* It works for me without it. +*/
ppc/8xx_io/fec.c line 2307
Quoted 10 lines
ppc/8xx_io/fec.c +10
-0+#if 0 +mii_do_cmd (dev, fep->phy->ack_int); +mii_do_cmd (dev, fep->phy->startup); + + { +int tmp; +for (tmp =0 ; tmp <50 ; tmp++) +udelay (5 ); + } +#endif
I believe this is an attempt at waiting as well. Kick the PHY and do nothing until it's hopefully discovered.
--
Tom Rini
http://gate.crashing.org/~trini/
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 1 line · Tom Rini
I believe this is wrong, in that trying to
udelay()here is a bad idea.
I agree. All of the MII communcation is interrupt driven. This is easy and the way everything should work on the 8xx. The link interrupt is more challenging because the interrupt from that depends upon the phy type and the board design. The link interrupts are either real interrupts or managed with a timed thread.
If you need to wait before installing the link interrupt (which I still don't understand why), this should be done as part of the phy discovery interrupt. For example, add an indirect function pointer and if it isn't NULL, call it at that time to do anything that must wait until the phy is discovered and initialized.
Thanks.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 11 lines · Dan Malek
Quoted 1 line · Tom Rini
I believe this is wrong, in that trying to
udelay()here is a bad idea.I agree. All of the MII communcation is interrupt driven. This is easy and the way everything should work on the 8xx. The link interrupt is more challenging because the interrupt from that depends upon the phy type and the board design. The link interrupts are either real interrupts or managed with a timed thread.
Quoted 5 lines
If you need to wait before installing the link interrupt (which I still don't understand why), this should be done as part of the phy discovery interrupt. For example, add an indirect function pointer and if it isn't NULL, call it at that time to do anything that must wait until the phy is discovered and initialized.
I understand what you mean. And certanly you're right.
I moved the request_irq into 3 but my board still hanges from time to time. At a different place in a different way though.
I have to admit that I don't understand this mii_queue stuff. Please, Dan, would you please give me a small hint!
I assume by "add an indirect function pointer" you mean "add something to mii_queue"... Is that right?
Thanks!
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 24 lines · Tom Rini
...
Okay. Moving along the process, I have a comment:Quoted 4 lines
ppc/8xx_io/fec.c +0
-0@@ -2285,6 +2278,39 @@ fep->old_status =0 ;#endif /* CONFIG_USE_MDIO */ ppc/8xx_io/fec.c line 2290
Quoted 10 lines
ppc/8xx_io/fec.c +10
-0+#ifdef CONFIG_USE_MDIO +# ifndef PHY_INTERRUPT +# error Want to use MII, but PHY_INTERRUPT not defined! +# endif +/* before requesting the irq, we should wait until PHY is discovered +* to avoid race conditions +*/ +while (!fep->phy_id_done) { +udelay (5 ); + }I believe this is wrong, in that trying to
udelay()here is a bad idea. I don't have the time right now, but I suspect google, or #kernelnewbies might be able to suggest a more appropriate way of waiting here.
Quoted 1 line
Or perhaps classes have fried my mind, and this is correct.
No. I bet you're right.
But can you make any suggestion on how to wait for some I/O to become ready?
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 25 lines · Steven Scholz
Quoted 24 lines · Tom Rini
...
Okay. Moving along the process, I have a comment:Quoted 4 lines
ppc/8xx_io/fec.c +0
-0@@ -2285,6 +2278,39 @@ fep->old_status =0 ;#endif /* CONFIG_USE_MDIO */ ppc/8xx_io/fec.c line 2290
Quoted 10 lines
ppc/8xx_io/fec.c +10
-0+#ifdef CONFIG_USE_MDIO +# ifndef PHY_INTERRUPT +# error Want to use MII, but PHY_INTERRUPT not defined! +# endif +/* before requesting the irq, we should wait until PHY is discovered +* to avoid race conditions +*/ +while (!fep->phy_id_done) { +udelay (5 ); + }I believe this is wrong, in that trying to
udelay()here is a bad idea. I don't have the time right now, but I suspect google, or #kernelnewbies might be able to suggest a more appropriate way of waiting here.
Quoted 3 lines
Quoted 1 line
Or perhaps classes have fried my mind, and this is correct.
No. I bet you're right.
But can you make any suggestion on how to wait for some I/O to become ready?
How about what Dan mentioned, with a function pointer and whatnot?
--
Tom Rini
http://gate.crashing.org/~trini/
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 29 lines · Tom Rini
Quoted 27 lines · Steven Scholz
Quoted 25 lines · Tom Rini
...
Okay. Moving along the process, I have a comment:Quoted 4 lines
ppc/8xx_io/fec.c +0
-0@@ -2285,6 +2278,39 @@ fep->old_status =0 ;#endif /* CONFIG_USE_MDIO */ ppc/8xx_io/fec.c line 2290
Quoted 10 lines
ppc/8xx_io/fec.c +10
-0+#ifdef CONFIG_USE_MDIO +# ifndef PHY_INTERRUPT +# error Want to use MII, but PHY_INTERRUPT not defined! +# endif +/* before requesting the irq, we should wait until PHY is discovered +* to avoid race conditions +*/ +while (!fep->phy_id_done) { +udelay (5 ); + }I believe this is wrong, in that trying to
udelay()here is a bad idea. I don't have the time right now, but I suspect google, or #kernelnewbies might be able to suggest a more appropriate way of waiting here.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Or perhaps classes have fried my mind, and this is correct.
No. I bet you're right.
But can you make any suggestion on how to wait for some I/O to become ready?How about what Dan mentioned, with a function pointer and whatnot?
As I admitted in my mail to Dan, I am not sure if I understand excactly what mean...
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/