Skip to contentSkip to conversation

net/phy: Fix phy_connect() for phy addr 0

PATCH New Priyanka Jain 5 participants 18 messages Nov 5, 2019 – Dec 19, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index ae37dd6c1e..419e6869c0 100644
@@ -952,7 +952,7 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
 #endif
 {
 	struct phy_device *phydev = NULL;
-	uint mask = (addr > 0) ? (1 << addr) : 0xffffffff;
+	uint mask = (addr >= 0) ? (1 << addr) : 0xffffffff;
 
 #ifdef CONFIG_PHY_FIXED
 	phydev = phy_connect_fixed(bus, dev, interface);
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 6 lines · Priyanka Jain

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Reported-by tetsu-aoki via github
Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191107/d1300644/attachment.sig>
#3 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 9 lines · Joe Hershberger
Quoted 8 lines · Tom Rini
Quoted 5 lines · Priyanka Jain

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 12 lines · Marek Vasut
Quoted 11 lines · Joe Hershberger
Quoted 10 lines · Tom Rini
Quoted 6 lines · Priyanka Jain

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Well, a simple revert breaks the other boards that this fixes. So we need to think about how to fix all of the cases involved here, thanks!

Signature · 1 line
Tom
#5 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 15 lines · Tom Rini
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Joe Hershberger
Quoted 11 lines · Tom Rini
Quoted 6 lines · Priyanka Jain

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Reported-by tetsu-aoki via github
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Well, a simple revert breaks the other boards that this fixes. So we need to think about how to fix all of the cases involved here, thanks!

That's probably task for the author of the patch.

btw -rc4 worked fine, -rc5 does not work.

#6 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

In reply to Marek Vasut

Hi Marek,

Quoted 13 lines · Marek Vasut
Quoted 11 lines · Joe Hershberger
Quoted 10 lines · Tom Rini
Quoted 6 lines · Priyanka Jain

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

It seems like a case that shouldn't have worked before. What about this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Cheers,
-Joe

#7 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 16 lines · Marek Vasut
Quoted 15 lines · Joe Hershberger
Quoted 13 lines · Tom Rini
Quoted 11 lines · Priyanka Jain
Quoted 7 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Reported-by tetsu-aoki via github
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Nope, the address is actually configured to 0 in hardware.

#8 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 24 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 18 lines · Marek Vasut
Quoted 17 lines · Joe Hershberger
Quoted 14 lines · Tom Rini
Quoted 11 lines · Priyanka Jain
Quoted 7 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Reported-by tetsu-aoki via github
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

Quoted 8 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Nope, the address is actually configured to 0 in hardware.

Can you double check that? The code as is should compute a mask of "0x01" which should match the offset for address 0. If it really is at 0 in hardware, maybe there is a different bug. Otherwise I don't see how this patch would work for the author.

Thanks,
-Joe

#9 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 29 lines · Joe Hershberger
Quoted 28 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 22 lines · Marek Vasut
Quoted 20 lines · Joe Hershberger
Quoted 9 lines · Tom Rini
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

Quoted 4 lines

The code as is should compute a mask of
"0x01" which should match the offset for address 0. If it really is at 0 in hardware, maybe there is a different bug. Otherwise I don't see how this patch would work for the author.

Reverting this patch makes things work again for me.

#10 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 62 lines · Marek Vasut
Quoted 19 lines · Joe Hershberger
Quoted 18 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 12 lines · Marek Vasut
Quoted 11 lines · Joe Hershberger
Quoted 9 lines · Tom Rini
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch,

I

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

cannot use ethernet. Please revert.

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

Quoted 7 lines
Quoted 4 lines

The code as is should compute a mask of
"0x01" which should match the offset for address 0. If it really is at 0 in hardware, maybe there is a different bug. Otherwise I don't see how this patch would work for the author.

Reverting this patch makes things work again for me.

Ok but breaking other boards again to fix your board is also unacceptable. It's not a theoretical case that something else failed previously.

Quoted 1 line
#11 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 69 lines · Tom Rini
Quoted 67 lines · Marek Vasut
Quoted 19 lines · Joe Hershberger
Quoted 18 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 12 lines · Marek Vasut
Quoted 11 lines · Joe Hershberger
Quoted 9 lines · Tom Rini
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch,

I

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

cannot use ethernet. Please revert.

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

Quoted 4 lines

The code as is should compute a mask of
"0x01" which should match the offset for address 0. If it really is at 0 in hardware, maybe there is a different bug. Otherwise I don't see how this patch would work for the author.

Quoted 5 lines
Quoted 2 lines

Reverting this patch makes things work again for me.

Ok but breaking other boards again to fix your board is also unacceptable. It's not a theoretical case that something else failed previously.

At least it restores the behavior in -rc4 , so that is the last option if there is no better patch.

#12 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

In reply to Marek Vasut
Quoted 40 lines · Marek Vasut
Quoted 29 lines · Joe Hershberger
Quoted 28 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 22 lines · Marek Vasut
Quoted 20 lines · Joe Hershberger
Quoted 9 lines · Tom Rini
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

Quoted 7 lines

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

The only thing this patch should change is to not access addresses other than 0. I read the data sheet for the LAN8720 and it doesn't mention anything about any broadcast behavior, so I'm not sure what you're trying to state here.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

It seems there is no phy driver for this in U-Boot so the generic behavior is being used. I'm at a disadvantage of not having this board to try. Can you revert this patch and run with debug enabled for drivers/net/phy/phy.c to determine what is happening for this board? I would appreciate you helping with this.

Quoted 6 lines
Quoted 4 lines

The code as is should compute a mask of
"0x01" which should match the offset for address 0. If it really is at 0 in hardware, maybe there is a different bug. Otherwise I don't see how this patch would work for the author.

Reverting this patch makes things work again for me.

#13 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 45 lines · Joe Hershberger
Quoted 44 lines · Marek Vasut
Quoted 29 lines · Joe Hershberger
Quoted 28 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 22 lines · Marek Vasut
Quoted 20 lines · Joe Hershberger
Quoted 9 lines · Tom Rini
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

Quoted 8 lines
Quoted 3 lines

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

The only thing this patch should change is to not access addresses other than 0. I read the data sheet for the LAN8720 and it doesn't mention anything about any broadcast behavior, so I'm not sure what you're trying to state here.

Read [1] section 3.7.1 PHYAD[2:0]: PHY ADDRESS CONFIGURATION

What I am saying is that there are two types of PHYs, ones which treat PHY address 0 as broadcast and ones which treat it as regular address. This one is the later and is configured as such in my case.

http://ww1.microchip.com/downloads/en/DeviceDoc/00002164B.pdf

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

Quoted 8 lines
Quoted 2 lines

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

It seems there is no phy driver for this in U-Boot so the generic behavior is being used. I'm at a disadvantage of not having this board to try. Can you revert this patch and run with debug enabled for drivers/net/phy/phy.c to determine what is happening for this board? I would appreciate you helping with this.

It only says "connected to Generic PHY" .

So looking at the commit message, I am not really sure which board or issue does this patch fix. But if I understand the commit message right, then the aim is to set mask to 0 instead of 0xffffffff for address 0. But that's not right either, the mask should be BIT(0) = 1 for address 0, and that's what the patch actually does. I guess this then fails somewhere further down the road ...

#14 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 56 lines · Marek Vasut
Quoted 45 lines · Joe Hershberger
Quoted 44 lines · Marek Vasut
Quoted 29 lines · Joe Hershberger
Quoted 28 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 22 lines · Marek Vasut
Quoted 20 lines · Joe Hershberger
Quoted 9 lines · Tom Rini
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

Quoted 8 lines
Quoted 3 lines

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

The only thing this patch should change is to not access addresses other than 0. I read the data sheet for the LAN8720 and it doesn't mention anything about any broadcast behavior, so I'm not sure what you're trying to state here.

Quoted 7 lines

Read [1] section 3.7.1 PHYAD[2:0]: PHY ADDRESS CONFIGURATION

What I am saying is that there are two types of PHYs, ones which treat PHY address 0 as broadcast and ones which treat it as regular address. This one is the later and is configured as such in my case.

http://ww1.microchip.com/downloads/en/DeviceDoc/00002164B.pdf

I see. What's an example of a phy that treats 0 as broadcast?

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

Quoted 8 lines
Quoted 2 lines

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

It seems there is no phy driver for this in U-Boot so the generic behavior is being used. I'm at a disadvantage of not having this board to try. Can you revert this patch and run with debug enabled for drivers/net/phy/phy.c to determine what is happening for this board? I would appreciate you helping with this.

Quoted 8 lines

It only says "connected to Generic PHY" .

So looking at the commit message, I am not really sure which board or issue does this patch fix. But if I understand the commit message right, then the aim is to set mask to 0 instead of 0xffffffff for address 0. But that's not right either, the mask should be BIT(0) = 1 for address 0, and that's what the patch actually does. I guess this then fails somewhere further down the road ...

Yes, the commit message is wrong... the expected value is 1, not 0. I missed that in the review.

Is the patch you sent earlier a solution for your board or something unrelated you found as a result of this discussion?

#15 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 59 lines · Joe Hershberger
Quoted 58 lines · Marek Vasut
Quoted 45 lines · Joe Hershberger
Quoted 44 lines · Marek Vasut
Quoted 29 lines · Joe Hershberger
Quoted 28 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

Hi Marek,

Hi Joe,

Quoted 22 lines · Marek Vasut
Quoted 20 lines · Joe Hershberger
Quoted 9 lines · Tom Rini
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0.
I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

Quoted 8 lines
Quoted 3 lines

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

The only thing this patch should change is to not access addresses other than 0. I read the data sheet for the LAN8720 and it doesn't mention anything about any broadcast behavior, so I'm not sure what you're trying to state here.

Read [1] section 3.7.1 PHYAD[2:0]: PHY ADDRESS CONFIGURATION

Quoted 7 lines
Quoted 5 lines

What I am saying is that there are two types of PHYs, ones which treat PHY address 0 as broadcast and ones which treat it as regular address. This one is the later and is configured as such in my case.

http://ww1.microchip.com/downloads/en/DeviceDoc/00002164B.pdf

I see. What's an example of a phy that treats 0 as broadcast?

IIRC KSZ9031 does.

Quoted 29 lines
Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the issue is with these boards.

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

Quoted 8 lines
Quoted 2 lines

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

It seems there is no phy driver for this in U-Boot so the generic behavior is being used. I'm at a disadvantage of not having this board to try. Can you revert this patch and run with debug enabled for drivers/net/phy/phy.c to determine what is happening for this board? I would appreciate you helping with this.

Quoted 8 lines

It only says "connected to Generic PHY" .

So looking at the commit message, I am not really sure which board or issue does this patch fix. But if I understand the commit message right, then the aim is to set mask to 0 instead of 0xffffffff for address 0. But that's not right either, the mask should be BIT(0) = 1 for address 0, and that's what the patch actually does. I guess this then fails somewhere further down the road ...

Quoted 5 lines

Yes, the commit message is wrong... the expected value is 1, not 0. I missed that in the review.

Is the patch you sent earlier a solution for your board or something unrelated you found as a result of this discussion?

It works for my board, but I wonder how many other boards got broken here.

#16 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 123 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Marek Vasut
Sent: Wednesday, December 18, 2019 9:47 PM
To: joe.hershberger at ni.com
Cc: u-boot at lists.denx.de; Tom Rini <[email protected]>; Joseph Hershberger <[email protected]>
Subject: Re: [U-Boot] [PATCH] net/phy: Fix phy_connect() for phy addr 0

Quoted 7 lines · Joe Hershberger
Quoted 6 lines · Marek Vasut
Quoted 4 lines · Joe Hershberger
Quoted 3 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

On Tue, Dec 17, 2019 at 11:46 AM Marek Vasut <[email protected]>

Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Joe Hershberger
Quoted 1 line

Hi Marek,

Hi Joe,

Quoted 1 line

On Tue, Dec 17, 2019 at 1:39 AM Marek Vasut <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Joe Hershberger
Quoted 1 line

On Thu, Nov 7, 2019 at 1:16 PM Tom Rini <[email protected]>

Quoted 40 lines · wrote:
Quoted 40 lines
Quoted 39 lines
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'. 'mask' is getting set to '0xffffffff' for phy addr '0' in phy_connect() whereas expected value is '0'.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0. I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

Quoted 7 lines

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

The only thing this patch should change is to not access addresses other than 0. I read the data sheet for the LAN8720 and it doesn't mention anything about any broadcast behavior, so I'm not sure what you're trying to state here.

Quoted 4 lines
Quoted 4 lines

Read [1] section 3.7.1 PHYAD[2:0]: PHY ADDRESS CONFIGURATION

What I am saying is that there are two types of PHYs, ones which treat PHY address 0 as broadcast and ones which treat it as regular

address.

Quoted 4 lines
Quoted 4 lines

This one is the later and is configured as such in my case.

https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fww1.

microchip.com%2Fdownloads%2Fen%2FDeviceDoc%2F00002164B.pdf&amp;da ta=0

Quoted 1 line
Quoted 1 line

2%7C01%7Cpriyanka.jain%40nxp.com%7C5270d34d955647ee66ea08d783d5ab c8%7

Quoted 1 line
Quoted 1 line

C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7C637122826047859376&a mp;sd

Quoted 1 line
Quoted 1 line

ata=s22V5eU1kUe0030lbvWazQpooiM2OutlJbTxrPjbxs0%3D&amp;reserved=0

Quoted 2 lines

I see. What's an example of a phy that treats 0 as broadcast?

IIRC KSZ9031 does.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the

issue is with these boards.

Quoted 23 lines
Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

Quoted 8 lines
Quoted 2 lines

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

It seems there is no phy driver for this in U-Boot so the generic behavior is being used. I'm at a disadvantage of not having this board to try. Can you revert this patch and run with debug enabled for drivers/net/phy/phy.c to determine what is happening for this board? I would appreciate you helping with this.

It only says "connected to Generic PHY" .

So looking at the commit message, I am not really sure which board or issue does this patch fix. But if I understand the commit message right, then the aim is to set mask to 0 instead of 0xffffffff for address 0. But that's not right either, the mask should be BIT(0) = 1 for address 0, and that's what the patch actually does. I guess this then fails somewhere further down the road ...

Quoted 7 lines
Quoted 5 lines

Yes, the commit message is wrong... the expected value is 1, not 0. I missed that in the review.

Is the patch you sent earlier a solution for your board or something unrelated you found as a result of this discussion?

It works for my board, but I wonder how many other boards got broken here.

I also realized a mistake in commit message . The value of mask will be 1.

This current patch was basically a fix to an issue reported at https://github.com/u-boot/u-boot/commit/afbc31948a007e03d6a1282677aafc2208f45819#commitcomment-35747179
introduced by commit afbc31948a007e03d6a1282677aafc2208f45819 (net: phy: implement fallback mechanism for negative phy addresses)
Before this commit, the argument value passed to phy_find_by_mask() in phy_connect() for phy addr '0' was '1' , so this current patch tries to revert to same value '1'. So, not sure how has this current patch has introduced the issue . Via git log, I can see many other commits related to phy_id '0'. I don’t have the board which is broken because of this current patch. So, need help in analysis and proper fix.

Thanks
Priyanka

#17 lore raw

PATCH 1/1 net/phy: Fix phy_connect() for phy addr 0

Quoted 132 lines · Priyanka Jain
Quoted 123 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Marek Vasut
Sent: Wednesday, December 18, 2019 9:47 PM
To: joe.hershberger at ni.com
Cc: u-boot at lists.denx.de; Tom Rini <[email protected]>; Joseph Hershberger <[email protected]>
Subject: Re: [U-Boot] [PATCH] net/phy: Fix phy_connect() for phy addr 0

Quoted 7 lines · Joe Hershberger
Quoted 6 lines · Marek Vasut
Quoted 4 lines · Joe Hershberger
Quoted 3 lines · Marek Vasut
Quoted 1 line · Joe Hershberger

On Tue, Dec 17, 2019 at 11:46 AM Marek Vasut <[email protected]>

Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Joe Hershberger
Quoted 1 line

Hi Marek,

Hi Joe,

Quoted 1 line

On Tue, Dec 17, 2019 at 1:39 AM Marek Vasut <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Joe Hershberger
Quoted 1 line

On Thu, Nov 7, 2019 at 1:16 PM Tom Rini <[email protected]>

Quoted 40 lines · wrote:
Quoted 40 lines
Quoted 39 lines
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines · Priyanka Jain
Quoted 6 lines

Fix 'mask' calculation in phy_connect() for phy addr '0'.
'mask' is getting set to '0xffffffff' for phy addr '0'
in phy_connect() whereas expected value is '0'.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Signed-off-by: Priyanka Jain <[email protected]>

Reported-by tetsu-aoki via github

Sadly, this breaks systems where a PHY is at address 0. I have such an STM32MP1 system with LAN8720 PHY and since this patch, I cannot use ethernet. Please revert.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

It seems like a case that shouldn't have worked before.

Eh? PHY at address 0 definitely did work before and must work now.

Agreed that a phy at address 0 should work. Not agreed that because the value "0" used to work due to a bug that it must still. Which of these is the statement you are making? Do we already agree or disagree?

Quoted 7 lines

I am saying that because a board worked on rc4 and does not work on rc5, this is a bug introduced by this patch in rc5 and must be fixed before the release.

The address 0 is a PHY broadcast address for some PHYs, it's a fixed address for other PHYs. Thus, a PHY at address 0 must work. If this is broken now, it's a bug.

The only thing this patch should change is to not access addresses other than 0. I read the data sheet for the LAN8720 and it doesn't mention anything about any broadcast behavior, so I'm not sure what you're trying to state here.

Quoted 4 lines
Quoted 4 lines

Read [1] section 3.7.1 PHYAD[2:0]: PHY ADDRESS CONFIGURATION

What I am saying is that there are two types of PHYs, ones which treat PHY address 0 as broadcast and ones which treat it as regular

address.

Quoted 4 lines
Quoted 4 lines

This one is the later and is configured as such in my case.

https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fww1.

microchip.com%2Fdownloads%2Fen%2FDeviceDoc%2F00002164B.pdf&amp;da ta=0

Quoted 1 line
Quoted 1 line

2%7C01%7Cpriyanka.jain%40nxp.com%7C5270d34d955647ee66ea08d783d5ab c8%7

Quoted 1 line
Quoted 1 line

C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7C637122826047859376&a mp;sd

Quoted 1 line
Quoted 1 line

ata=s22V5eU1kUe0030lbvWazQpooiM2OutlJbTxrPjbxs0%3D&amp;reserved=0

Quoted 2 lines

I see. What's an example of a phy that treats 0 as broadcast?

IIRC KSZ9031 does.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

What about
this board requires the mask to be all 'f's, other than specifying the wrong phy address? It seems that in your case the phy address is not actually 0 (or the computed mask would find it), but your board dts may be setting it to 0 as an "unknown" value, but the correct unknown value should be "-1". It seems the

issue is with these boards.

Quoted 23 lines
Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

Nope, the address is actually configured to 0 in hardware.

Can you double check that?

Quoted 8 lines
Quoted 2 lines

No, sorry, I know the hardware is fixed to 0. Checking it again will not change this fact.

It seems there is no phy driver for this in U-Boot so the generic behavior is being used. I'm at a disadvantage of not having this board to try. Can you revert this patch and run with debug enabled for drivers/net/phy/phy.c to determine what is happening for this board? I would appreciate you helping with this.

It only says "connected to Generic PHY" .

So looking at the commit message, I am not really sure which board or issue does this patch fix. But if I understand the commit message right, then the aim is to set mask to 0 instead of 0xffffffff for address 0. But that's not right either, the mask should be BIT(0) = 1 for address 0, and that's what the patch actually does. I guess this then fails somewhere further down the road ...

Quoted 7 lines
Quoted 5 lines

Yes, the commit message is wrong... the expected value is 1, not 0. I missed that in the review.

Is the patch you sent earlier a solution for your board or something unrelated you found as a result of this discussion?

It works for my board, but I wonder how many other boards got broken here.

I also realized a mistake in commit message . The value of mask will be 1.

Quoted 8 lines

This current patch was basically a fix to an issue reported at https://github.com/u-boot/u-boot/commit/afbc31948a007e03d6a1282677aafc2208f45819#commitcomment-35747179
introduced by commit afbc31948a007e03d6a1282677aafc2208f45819 (net: phy: implement fallback mechanism for negative phy addresses)
Before this commit, the argument value passed to phy_find_by_mask() in phy_connect() for phy addr '0' was '1' , so this current patch tries to revert to same value '1'. So, not sure how has this current patch has introduced the issue . Via git log, I can see many other commits related to phy_id '0'. I don’t have the board which is broken because of this current patch. So, need help in analysis and proper fix.

Thanks
Priyanka

The fix is OK, the issue is that some of the drivers were using addr 0 in phy_connect() to trigger a MDIO bus scan, not to connect to PHY @ addr 0. I am using a board with a PHY @ addr 0 and it works fine.

Grepping though the code it seems a couple of drivers hardcode addr 0:
- dwc_eth_qos already solved by Marek in a separate patch,
- bcm-sf2-eth.

Other drivers may use 0 but passed though a variable, those are harder to spot.

Converting bcm-sf2-eth to phy_connect(-1) may be OK, it would work like it did before this patch.

Alex