net: macb: Add small delay after link establishment
PATCH 1/1 net: macb: Add small delay after link establishment
I've noticed that the first ethernet packet after PHY link establishment is not tranferred correctly most of the time on my AT91SAM9G25 board. Here I usually see a timeout of a few seconds, which is quite annoying.
Adding a small delay (10ms in this case) after the link establishment helps to solve this problem. With this patch applied, this timeout on the first packet is not seen any more.
--- drivers/net/macb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/macb.c +7 -1
@@ -550,8 +550,14 @@ static int macb_phy_init(struct macb_device *macb, const char *name)for (i =0 ; i <MACB_AUTONEG_TIMEOUT /100 ; i++) { status =macb_mdio_read (macb,MII_BMSR ); -if (status &BMSR_LSTATUS ) +if (status &BMSR_LSTATUS ) { +/* +* Delay a bit after the link is established, +* so that the next xfer does not fail +*/ +mdelay (10 );break ; + }udelay (100 ); } }
Signature · 1 line
2.21.0
PATCH 1/1 net: macb: Add small delay after link establishment
Quoted 8 lines · Stefan Roese
I've noticed that the first ethernet packet after PHY link establishment is not tranferred correctly most of the time on my AT91SAM9G25 board. Here I usually see a timeout of a few seconds, which is quite annoying.
Adding a small delay (10ms in this case) after the link establishment helps to solve this problem. With this patch applied, this timeout on the first packet is not seen any more.
Hi Stefan,
I find this a bit odd... maybe someone with a different board having this Ethernet controller can confirm or infirm this ?
Linux driver for macb has a similar issue ?
Adding a delay just for the sake of it might hide another issue that we are missing at this point: why exactly transfer fails right away... it is likely that we want to send packets but link in fact is not ready ? Or any reason why the packet is not correctly transferred? Do you see errors on the line or the packet vanishes completely ?
What kind of packet is this first one ? Does it depend on the packet type ?
Sorry for maybe asking too many questions.
I have added Nicolas and Claudiu who have more experience with macb on at91 boards
Thanks,
Eugen
Quoted 30 lines
Signed-off-by Stefan Roese <[email protected]>Cc Wenyou Yang <[email protected]>Cc Eugen Hristev <[email protected]>Cc Joe Hershberger <[email protected]>--- drivers/net/macb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/net/macb.c +7
-1@@ -550,8 +550,14 @@ static int macb_phy_init(struct macb_device *macb, const char *name)for (i =0 ; i <MACB_AUTONEG_TIMEOUT /100 ; i++) { status =macb_mdio_read (macb,MII_BMSR ); -if (status &BMSR_LSTATUS ) +if (status &BMSR_LSTATUS ) { +/* +* Delay a bit after the link is established, +* so that the next xfer does not fail +*/ +mdelay (10 );break ; + }udelay (100 ); } }
PATCH 1/1 net: macb: Add small delay after link establishment
Hi Eugen,
Quoted 5 lines · Eugen.Hristev at microchip.com
Quoted 5 lines
I've noticed that the first ethernet packet after PHY link establishment is not tranferred correctly most of the time on my AT91SAM9G25 board. Here I usually see a timeout of a few seconds, which is quite annoying.
Quoted 8 lines
Quoted 3 lines
Adding a small delay (10ms in this case) after the link establishment helps to solve this problem. With this patch applied, this timeout on the first packet is not seen any more.
Hi Stefan,
I find this a bit odd... maybe someone with a different board having this Ethernet controller can confirm or infirm this ?
I've seen such issues of timeouts with the first ethernet packet after link negotiation on other platforms / controllers a few times before in U-Boot. Using a short delay after link-up always did help here.
I'm not saying that this is the perfect solution, but its one that works and removes these timeouts, which really annoy me.
Quoted 1 line
Linux driver for macb has a similar issue ?
Not that I am aware of. There might be some delay in the link establishment hidden as well. I did not check yet.
Quoted 3 lines
Adding a delay just for the sake of it might hide another issue that we are missing at this point: why exactly transfer fails right away... it is likely that we want to send packets but link in fact is not ready ?
Yes, something like this.
Quoted 3 lines
Or any reason why the packet is not correctly transferred? Do you see errors on the line or the packet vanishes completely ?
What kind of packet is this first one ? Does it depend on the packet type ?
I did not check too closely, as this issue was so similar to the ones I've seen before in U-Boot (see above). It happens upon "ping" and "tftp" - that's what I did test with.
Quoted 1 line
Sorry for maybe asking too many questions.
No need to be sorry. If this can be solved in another perhaps cleaner way, I'll gladly use another solution.
Quoted 2 lines
I have added Nicolas and Claudiu who have more experience with macb on at91 boards
Sure, let's see what others have to say on this. Did someone else notice these timeouts resulting in quite big delays?
Thanks,
Stefan
PATCH 1/1 net: macb: Add small delay after link establishment
Quoted 27 lines · Stefan Roese
Hi Eugen,
Quoted 5 lines · Eugen.Hristev at microchip.com
Quoted 5 lines
I've noticed that the first ethernet packet after PHY link establishment is not tranferred correctly most of the time on my AT91SAM9G25 board. Here I usually see a timeout of a few seconds, which is quite annoying.
Quoted 8 lines
Quoted 3 lines
Adding a small delay (10ms in this case) after the link establishment helps to solve this problem. With this patch applied, this timeout on the first packet is not seen any more.
Hi Stefan,
I find this a bit odd... maybe someone with a different board having this Ethernet controller can confirm or infirm this ?
I've seen such issues of timeouts with the first ethernet packet after link negotiation on other platforms / controllers a few times before in U-Boot. Using a short delay after link-up always did help here.
I'm not saying that this is the perfect solution, but its one that works and removes these timeouts, which really annoy me.
Quoted 1 line
Linux driver for macb has a similar issue ?
Quoted 8 lines
Not that I am aware of. There might be some delay in the link establishment hidden as well. I did not check yet.
Quoted 3 lines
Adding a delay just for the sake of it might hide another issue that we are missing at this point: why exactly transfer fails right away... it is likely that we want to send packets but link in fact is not ready ?
Yes, something like this.
I see there is a small udelay below your code, you add a delay 100 times bigger... maybe that small delay is related ?
Quoted 23 lines
Quoted 5 lines
Or any reason why the packet is not correctly transferred? Do you see errors on the line or the packet vanishes completely ? What kind of packet is this first one ? Does it depend on the packet type ?
I did not check too closely, as this issue was so similar to the ones I've seen before in U-Boot (see above). It happens upon "ping" and "tftp" - that's what I did test with.
Quoted 1 line
Sorry for maybe asking too many questions.
No need to be sorry. If this can be solved in another perhaps cleaner way, I'll gladly use another solution.
Quoted 2 lines
I have added Nicolas and Claudiu who have more experience with macb on at91 boards
Sure, let's see what others have to say on this. Did someone else notice these timeouts resulting in quite big delays?
Thanks,
Stefan
PATCH 1/1 net: macb: Add small delay after link establishment
Quoted 34 lines · Eugen.Hristev at microchip.com
Quoted 30 lines · Stefan Roese
Hi Eugen,
Quoted 5 lines · Eugen.Hristev at microchip.com
Quoted 5 lines
I've noticed that the first ethernet packet after PHY link establishment is not tranferred correctly most of the time on my AT91SAM9G25 board. Here I usually see a timeout of a few seconds, which is quite annoying.
Quoted 8 lines
Quoted 3 lines
Adding a small delay (10ms in this case) after the link establishment helps to solve this problem. With this patch applied, this timeout on the first packet is not seen any more.
Hi Stefan,
I find this a bit odd... maybe someone with a different board having this Ethernet controller can confirm or infirm this ?
I've seen such issues of timeouts with the first ethernet packet after link negotiation on other platforms / controllers a few times before in U-Boot. Using a short delay after link-up always did help here.
I'm not saying that this is the perfect solution, but its one that works and removes these timeouts, which really annoy me.
Quoted 1 line
Linux driver for macb has a similar issue ?
Not that I am aware of. There might be some delay in the link establishment hidden as well. I did not check yet.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Adding a delay just for the sake of it might hide another issue that we are missing at this point: why exactly transfer fails right away... it is likely that we want to send packets but link in fact is not ready ?
Yes, something like this.
I see there is a small udelay below your code, you add a delay 100 times bigger... maybe that small delay is related ?
The udelay(100) below is for the timeout handling of the link autoneg loop. This should be probably moved to some loop using get_timer() so that this udelay can be removed completely.
Coming back to your question, if these delays are related. No, they are not. The one that I insert is explicitly added *after* the link was established. I could experiment if a smaller value also works, but I found that 100ms was working in all my test cases. Possibly 10ms or even 1ms also works. Not sure.
Thanks,
Stefan
PATCH 1/1 net: macb: Add small delay after link establishment
Quoted 50 lines · Stefan Roese
Quoted 35 lines · Eugen.Hristev at microchip.com
Quoted 31 lines · Stefan Roese
Hi Eugen,
Quoted 6 lines · Eugen.Hristev at microchip.com
Quoted 6 lines
I've noticed that the first ethernet packet after PHY link establishment
is not tranferred correctly most of the time on my AT91SAM9G25 board. Here I usually see a timeout of a few seconds, which is quite annoying.Quoted 8 lines
Quoted 3 lines
Adding a small delay (10ms in this case) after the link establishment helps to solve this problem. With this patch applied, this timeout on the first packet is not seen any more.
Hi Stefan,
I find this a bit odd... maybe someone with a different board having this Ethernet controller can confirm or infirm this ?
I've seen such issues of timeouts with the first ethernet packet after link negotiation on other platforms / controllers a few times before in U-Boot. Using a short delay after link-up always did help here.
I'm not saying that this is the perfect solution, but its one that works and removes these timeouts, which really annoy me.
Quoted 1 line
Linux driver for macb has a similar issue ?
Not that I am aware of. There might be some delay in the link establishment hidden as well. I did not check yet.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Adding a delay just for the sake of it might hide another issue that we are missing at this point: why exactly transfer fails right away... it is likely that we want to send packets but link in fact is not ready ?
Yes, something like this.
I see there is a small udelay below your code, you add a delay 100 times bigger... maybe that small delay is related ?
The udelay(100) below is for the timeout handling of the link autoneg loop. This should be probably moved to some loop using
get_timer()so that this udelay can be removed completely.
Quoted 5 lines
Coming back to your question, if these delays are related. No, they are not. The one that I insert is explicitly added *after* the link was established. I could experiment if a smaller value also works, but I found that 100ms was working in all my test cases. Possibly 10ms or even 1ms also works. Not sure.
Hi Joe,
If you agree with this change I will take it through my tree. Or any feedback appreciated from you or someone familiar with the macb / network devices.
Thanks !
Eugen
Quoted 3 lines
Thanks,
Stefan
PATCH 1/1 net: macb: Add small delay after link establishment
In reply to Stefan RoeseQuoted 6 lines · Stefan Roese
I've noticed that the first ethernet packet after PHY link establishment is not tranferred correctly most of the time on my AT91SAM9G25 board. Here I usually see a timeout of a few seconds, which is quite annoying.
Quoted 8 lines
Adding a small delay (10ms in this case) after the link establishment helps to solve this problem. With this patch applied, this timeout on the first packet is not seen any more.
Signed-off-by Stefan Roese <[email protected]>Cc Wenyou Yang <[email protected]>Cc Eugen Hristev <[email protected]>Cc Joe Hershberger <[email protected]>
PATCH 1/1 net: macb: Add small delay after link establishment
Quoted 12 lines · Joe Hershberger
Quoted 10 lines · Stefan Roese
I've noticed that the first ethernet packet after PHY link establishment is not tranferred correctly most of the time on my AT91SAM9G25 board. Here I usually see a timeout of a few seconds, which is quite annoying.
Adding a small delay (10ms in this case) after the link establishment helps to solve this problem. With this patch applied, this timeout on the first packet is not seen any more.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Stefan Roese <[email protected]>Cc Wenyou Yang <[email protected]>Cc Eugen Hristev <[email protected]>Cc Joe Hershberger <[email protected]>Acked-by Joe Hershberger <[email protected]>_______________________________________________
Applied to u-boot-atmel/next
Thanks !