From: Gerhard Engleder <hidden> Date: 2021-08-18 12:29:41
The Xilinx GMII2RGMII driver overrides PHY driver functions in order to
configure the device according to the link speed of the PHY attached to it.
This is implemented for a normal link but not for loopback.
Andrew told me to use phy_loopback and this changes make phy_loopback work
in combination with Xilinx GMII2RGMII.
Gerhard Engleder (2):
net: phy: Support set_loopback override
net: phy: gmii2rgmii: Support PHY loopback
drivers/net/phy/phy_device.c | 9 +++---
drivers/net/phy/xilinx_gmii2rgmii.c | 46 ++++++++++++++++++++++-------
2 files changed, 39 insertions(+), 16 deletions(-)
--
2.20.1
From: Gerhard Engleder <hidden> Date: 2021-08-18 12:29:53
phy_read_status and various other PHY functions support PHY specific
overriding of driver functions by using a PHY specific pointer to the
PHY driver. Add support of PHY specific override to phy_loopback too.
Signed-off-by: Gerhard Engleder <redacted>
---
drivers/net/phy/phy_device.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
From: Gerhard Engleder <hidden> Date: 2021-08-18 12:29:55
Configure speed if loopback is used. read_status is not called for
loopback.
Signed-off-by: Gerhard Engleder <redacted>
---
drivers/net/phy/xilinx_gmii2rgmii.c | 46 ++++++++++++++++++++++-------
1 file changed, 35 insertions(+), 11 deletions(-)
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-08-18 15:03:42
On Wed, Aug 18, 2021 at 02:27:35PM +0200, Gerhard Engleder wrote:
quoted hunk
phy_read_status and various other PHY functions support PHY specific
overriding of driver functions by using a PHY specific pointer to the
PHY driver. Add support of PHY specific override to phy_loopback too.
Signed-off-by: Gerhard Engleder <redacted>
---
drivers/net/phy/phy_device.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Humm, we need to take a closer look at what uses to_phy_driver() and
what uses phydev->drv. Do they need to be different? Can we make it
uniform?
Andrew
From: Gerhard Engleder <hidden> Date: 2021-08-18 20:11:52
On Wed, Aug 18, 2021 at 5:03 PM Andrew Lunn [off-list ref] wrote:
On Wed, Aug 18, 2021 at 02:27:35PM +0200, Gerhard Engleder wrote:
quoted
phy_read_status and various other PHY functions support PHY specific
overriding of driver functions by using a PHY specific pointer to the
PHY driver. Add support of PHY specific override to phy_loopback too.
Signed-off-by: Gerhard Engleder <redacted>
---
drivers/net/phy/phy_device.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Humm, we need to take a closer look at what uses to_phy_driver() and
what uses phydev->drv. Do they need to be different? Can we make it
uniform?
Andrew
I saw only 4 references for to_phy_driver():
- phy_loopback() of course
- phy_probe() which uses it to initialize phydev->drv 3 lines later
- mdio_bus_phy_may_suspend() which checks only for valid suspend function
pointer, but later phy_suspend() uses phydev->drv, so this is at
least inconsistent
- phy_bus_match() which casts from struct device_driver to struct phy_driver
phydev->drv is used much more often and seems to be the right way. I suggest to
also fix mdio_bus_phy_may_suspend(). phy_probe() and phy_bus_match() are
valid uses, because phydev->drv is not available for them.
Do you agree?
Gerhard
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-08-18 21:20:29
I saw only 4 references for to_phy_driver():
- phy_loopback() of course
- phy_probe() which uses it to initialize phydev->drv 3 lines later
This is correct. The driver core will set dev.driver to what it thinks
is the correct driver to use, before calling probe.
- mdio_bus_phy_may_suspend() which checks only for valid suspend function
pointer, but later phy_suspend() uses phydev->drv, so this is at
least inconsistent
I guess the real question here is, can a device be suspended before it
is probed? It would seem rather odd. So i expect phydev->drv is safe
to use.
- phy_bus_match() which casts from struct device_driver to struct phy_driver
This is used by the driver core when trying to find a matching
driver. So it is used before phy_probe(). So this is correct.
phydev->drv is used much more often and seems to be the right way. I suggest to
also fix mdio_bus_phy_may_suspend(). phy_probe() and phy_bus_match() are
valid uses, because phydev->drv is not available for them.
Do you agree?
Agreed. Thanks for spending the time to look at this. I was expecting
there to be more problems than just loopback.
Andrew