Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libethdrivers: Nitrogen6_SoloX imx6 driver seems to have mdio register access issue #115

Open
kent-mcleod opened this issue Dec 2, 2021 · 12 comments

Comments

@kent-mcleod
Copy link
Member

I've found when trying to test imx6 ethernet driver on the Nitrogen6_SoloX platform that quite often, the mdio_read implementation (https://github.com/seL4/util_libs/blob/master/libethdrivers/src/plat/imx6/enet.c#L397) will start returning all ones (0xffff) until the hardware is reset. Has anyone else experienced this or know what could cause this?

@axel-h
Copy link
Member

axel-h commented Dec 7, 2021

This might be what is sampled on the MDIO bus due to the way it works. So the PHY you are trying top talk is mute. Can you narrow down when this happens? There are two ethernet ports on this board, but both PHYs are on the MDIO bus of ETH0 and thus the accesses need to be sync'ed properly and the PHYs must never end up using the same IDs.

@kent-mcleod
Copy link
Member Author

It usually happens when trying to autonegotiate the link. Usually with the second phy. The issue happens regardless if the two ethernet driver instances are in the same component or a separate component. In both cases there is synchronization between them so the second one isn't started until the first one successfully starts. The second device does need to use the MDIO interface from the first. Both successfully initialize about 1 in 3 or 4 attempts. I've added a log of all of the mdio_read results for when it fails on the second device.

I modified the auto negotiation code to declare a failure once it sees more than 5 0xffff results in a row otherwise it interprets 0xffff as an actual value and declares successful negotiation at which point no packets will be received or transmitted. It's also possible to observe that several of the mdio_read results while waiting for autonegotiation contain errors.

:

----  ethernet server ----

mdio_read: 4d
mdio_read: d072
mdio_read: 3100
mdio_read: 3100
mdio_read: 1100
mdio_read: b282
mdio_read: 2c47
mdio_read: 1de1
mdio_read: 300
mdio_read: 3100
mdio_read: 3100
mdio_read: 7949
genphy_update_link@phy.c:255 waiting for auto negotiation to complete on phy 4, 'DUMMY-EDEV'
.mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
.mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
.mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 796d
mdio_read: 796d
mdio_read: 796d
mdio_read: 796d
mdio_read: 796d
mdio_read: 796d
mdio_read: 796d
mdio_read: 796d
mdio_read: 796d
mdio_read: 796d
genphy_update_link@phy.c:293 auto negotiation complete on phy 4, 'DUMMY-EDEV'
mdio_read: 796d
mdio_read: 3800
mdio_read: 300

----  ethernet.2 server ----

mdio_read: 4d
mdio_read: d072
mdio_read: 3100
mdio_read: 3100
mdio_read: 1100
mdio_read: b282
mdio_read: 2c47
mdio_read: 1de1
mdio_read: 300
mdio_read: 3100
mdio_read: 1000
mdio_read: 7949
genphy_update_link@phy.c:255 waiting for auto negotiation to complete on phy 5, 'DUMMY-EDEV'
.mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 1041
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 1041
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: ffff
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7912
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: 7949
mdio_read: ffff
mdio_read: ffff
mdio_read: ffff
mdio_read: ffff
mdio_read: ffff
mdio_read: ffff
genphy_update_link@phy.c:281 auto negotiation failed

@kent-mcleod
Copy link
Member Author

Changing the udelay inside genphy_update_link() from 1ms to 15ms and replacing the implementation of udelay with one that uses a timesource instead of approximating the delay by looping on a volatile variable for a specified loop count does seem to resolve the issue. But I was still curious whether @axel-h you had experienced similar behavior?

@axel-h
Copy link
Member

axel-h commented Dec 7, 2021

Fixing the delays and make them use a timer seem a good improvement. We have some issues with these boards also, where some board appeared much more stable than others. A colleague of mine is doing some testing currently, I'll make him get in touch with you.

@FelixSchladt
Copy link

FelixSchladt commented Dec 7, 2021

Hi @kent-mcleod, I would appreciate it, if you could send me your fix as an patch.
I would like to test it on our boards.

@FelixSchladt
Copy link

I was able to reproduce the error on multiple of our units.
The chances for a successful connection differ widely between different units. some units have a about 4/5 chance of successful connection, one other a ca. 1/ chance.
A higher udelay(15000) helps a lot (7/10 chance on our worst board), but does not solve the problem.
Possibly a better timer implementation than the udelay one could fix the issue.

@kent-mcleod
Copy link
Member Author

Hi @FelixSchladt,

This was my patch:

--- a/libethdrivers/src/plat/imx6/uboot/phy.c
+++ b/libethdrivers/src/plat/imx6/uboot/phy.c
@@ -228,6 +228,7 @@ int genphy_config_aneg(struct phy_device *phydev)
  *   current link value.  In order to do this, we need to read
  *   the status register twice, keeping the second value.
  */
 int genphy_update_link(struct phy_device *phydev)
 {
     unsigned int mii_reg;
@@ -246,15 +247,17 @@ int genphy_update_link(struct phy_device *phydev)
         ZF_LOGI("link already established");
         return 0;
     }
+    int success_count = 0;
+    int fail_count = 0;
 
     if ((mii_reg & BMSR_ANEGCAPABLE) && !(mii_reg & BMSR_ANEGCOMPLETE)) {
         int i = 0;
 
-        ZF_LOGI(
+        ZF_LOGE(
             "waiting for auto negotiation to complete on phy %d, '%s'",
             phydev->addr, phydev->dev->name);
         fflush(stdout);
-        while (!(mii_reg & BMSR_ANEGCOMPLETE)) {
+        while (!((mii_reg & BMSR_ANEGCOMPLETE) && success_count >= 10 )) {
             /*
              * Timeout reached ?
              */
@@ -269,10 +272,26 @@ int genphy_update_link(struct phy_device *phydev)
                 fflush(stdout);
             }
 
-            udelay(1000);   /* 1 ms */
+            udelay(15000);   /* 15 ms */
             mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
+            if (mii_reg & BMSR_ANEGCOMPLETE && mii_reg != 0xffff) {
+                success_count++;
+            } else if (mii_reg == 0xffff) {
+                fail_count++;
+                if (fail_count > 5) {
+                    ZF_LOGE("auto negotiation failed");
+                    abort();
+                    phydev->link = 0;
+                    return 0;
+
+                }
+
+            } else {
+                success_count = 0;
+                fail_count = 0;
+            }
         }
-        ZF_LOGI("auto negotiation complete on phy %d, '%s'",
+        ZF_LOGE("auto negotiation complete on phy %d, '%s'",
                 phydev->addr, phydev->dev->name);
         phydev->link = 1;
     } else {


It was first to detect the failure, and then to increase the udelay. The implementation of udelay that I changed to uses a custom timer interface that returns a monotonic timestamp in ns. And spins until the delay period has passed.

@FelixSchladt
Copy link

FelixSchladt commented Dec 9, 2021

Hi @kent-mcleod,

thanks for providing the patch. I tested it on our boards and its definitely an improvement but sadly its only a ~80% success rate.
The introduced error handling is handy and if the auto-negotiation of Eth1 fails, it reliable throws an Error.
But I also experienced cases where Eth1 works fine and is able to be connect, but Eth0 does not work. Quite strange...

Further I did some benchmarking on the default udelay implementation and it seems to be surprisingly accurate:

[udelay_bench INFO: /host/src/udelay_bench.c:301: time used for 1000: 1142 us
[udelay_bench INFO: /host/src/udelay_bench.c:302: time used for 2000: 2266 us
[udelay_bench INFO: /host/src/udelay_bench.c:303: time used for 5000: 5654 us
[udelay_bench INFO: /host/src/udelay_bench.c:304: time used for 10000: 11298 us
[udelay_bench INFO: /host/src/udelay_bench.c:305: time used for 15000: 16944 us
[udelay_bench INFO: /host/src/udelay_bench.c:306: time used for 20000: 22588 us

I did this on a couple of our boards, and the times stay consistent. Considering that the timeserver likely introduced some overhead too, i would say, that a different udelay implementation is not necessarily required.

@kent-mcleod
Copy link
Member Author

If you keep increasing the udelay does your success rate go up?

@FelixSchladt
Copy link

FelixSchladt commented Dec 9, 2021

Yes this helps, I tried 20ms, 50ms and 100ms.
With the 50ms I get to around ~90% and with 100ms it worked almost completly except I still experienced the error where Eth0 fails but Eth1 works. So far with 100ms I only yet experienced once the autonegotiation failure.

@kent-mcleod
Copy link
Member Author

It's helpful to know that you are experiencing the issue too. Do you have a way to run Linux on the board and check whether both cards work there? I'll try and do the same with my board too.

@FelixSchladt
Copy link

Yes I did that already and both ethernet ports work flawlessly with linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants