net: phy: call phy_disable_interrupts() in phy_init_hw()
Subsystems (3)
v3 cover net: phy: call phy_disable_interrupts() in phy_init_hw()
We face an issue with rtl8211f, a pin is shared between INTB and PMEB, and the PHY Register Accessible Interrupt is enabled by default, so the INTB/PMEB pin is always active in polling mode case.
As Heiner pointed out "I was thinking about calling phy_disable_interrupts() in phy_init_hw(), to have a defined init state as we don't know in which state the PHY is if the PHY driver is loaded. We shouldn't assume that it's the chip power-on defaults, BIOS or boot loader could have changed this. Or in case of dual-boot systems the other OS could leave the PHY in whatever state."
patch1 makes phy_disable_interrupts() non-static so that it could be used in phy_init_hw() to have a defined init state.
patch2 calls phy_disable_interrupts() in phy_init_hw() to have a defined init state.
Since v2:
- Don't export phy_disable_interrupts() but just make it non-static
Since v1:
- EXPORT the correct symbol
Jisheng Zhang (2):
net: phy: make phy_disable_interrupts() non-static
net: phy: call phy_disable_interrupts() in phy_init_hw()
drivers/net/phy/phy.c | 2 +- drivers/net/phy/phy_device.c | 7 +++++-- include/linux/phy.h | 1 + 3 files changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
2.27.0
PATCH v3 1/2 net: phy: make phy_disable_interrupts() non-static
We face an issue with rtl8211f, a pin is shared between INTB and PMEB, and the PHY Register Accessible Interrupt is enabled by default, so the INTB/PMEB pin is always active in polling mode case.
As Heiner pointed out "I was thinking about calling phy_disable_interrupts() in phy_init_hw(), to have a defined init state as we don't know in which state the PHY is if the PHY driver is loaded. We shouldn't assume that it's the chip power-on defaults, BIOS or boot loader could have changed this. Or in case of dual-boot systems the other OS could leave the PHY in whatever state."
Make phy_disable_interrupts() non-static so that it could be used in phy_init_hw() to have a defined init state.
--- drivers/net/phy/phy.c | 2 +- include/linux/phy.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
@@ -840,7 +840,7 @@ static void phy_error(struct phy_device *phydev)* phy_disable_interrupts - Disable the PHY interrupts from the PHY side * @phydev: target phy_device struct */ -static int phy_disable_interrupts (struct phy_device *phydev) +int phy_disable_interrupts (struct phy_device *phydev) {int err;
include/linux/phy.h +1 -0
@@ -1416,6 +1416,7 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,int phy_mii_ioctl (struct phy_device *phydev,struct ifreq *ifr,int cmd);int phy_do_ioctl (struct net_device *dev,struct ifreq *ifr,int cmd);int phy_do_ioctl_running (struct net_device *dev,struct ifreq *ifr,int cmd); +int phy_disable_interrupts (struct phy_device *phydev);void phy_request_interrupt (struct phy_device *phydev);void phy_free_interrupt (struct phy_device *phydev);void phy_print_status (struct phy_device *phydev);
Signature · 1 line
2.27.0
PATCH v3 2/2 net: phy: call phy_disable_interrupts() in phy_init_hw()
In reply to Jisheng ZhangCall phy_disable_interrupts() in phy_init_hw() to "have a defined init state as we don't know in which state the PHY is if the PHY driver is loaded. We shouldn't assume that it's the chip power-on defaults, BIOS or boot loader could have changed this. Or in case of dual-boot systems the other OS could leave the PHY in whatever state." as pointed out by Heiner.
--- drivers/net/phy/phy_device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/phy/phy_device.c +5 -2
@@ -1090,10 +1090,13 @@ int phy_init_hw(struct phy_device *phydev)if (ret <0 )return ret; -if (phydev->drv->config_init) +if (phydev->drv->config_init) { ret = phydev->drv->config_init (phydev); +if (ret <0 ) +return ret; + } -return ret; +return phy_disable_interrupts (phydev); }EXPORT_SYMBOL (phy_init_hw);
Signature · 1 line
2.27.0
Le 2020-06-23 à 20:26, Jisheng Zhang a écrit :
Quoted 20 lines
Call
phy_disable_interrupts()inphy_init_hw()to "have a defined init state as we don't know in which state the PHY is if the PHY driver is loaded. We shouldn't assume that it's the chip power-on defaults, BIOS or boot loader could have changed this. Or in case of dual-boot systems the other OS could leave the PHY in whatever state." as pointed out by Heiner.Suggested-by Heiner Kallweit <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/phy_device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/phy/phy_device.c +0
-0@@ -1090,10 +1090,13 @@ int phy_init_hw(struct phy_device *phydev)if (ret <0 )return ret;
drivers/net/phy/phy_device.c int phy_init_hw(struct phy_device *phydev) · line 1099
Quoted 10 lines
drivers/net/phy/phy_device.c +5
-2-if (phydev->drv->config_init) +if (phydev->drv->config_init) { ret = phydev->drv->config_init (phydev); +if (ret <0 ) +return ret; + } -return ret; +return phy_disable_interrupts (phydev);
Not sure if the order makes sense here, it may seem more natural for a driver writer to have interrupts disabled first and then config_init called (which could enable interrupts not related to link management like thermal events etc.)
Signature · 1 line
Florian
Russell King - ARM Linux admin
reviewerQuoted 29 lines · Florian Fainelli
Le 2020-06-23 à 20:26, Jisheng Zhang a écrit :
Quoted 28 lines
Call
phy_disable_interrupts()inphy_init_hw()to "have a defined init state as we don't know in which state the PHY is if the PHY driver is loaded. We shouldn't assume that it's the chip power-on defaults, BIOS or boot loader could have changed this. Or in case of dual-boot systems the other OS could leave the PHY in whatever state." as pointed out by Heiner.Suggested-by Heiner Kallweit <[email protected]>Signed-off-by Jisheng Zhang <[email protected]>--- drivers/net/phy/phy_device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/phy/phy_device.c +4
-1@@ -1090,10 +1090,13 @@ int phy_init_hw(struct phy_device *phydev)if (ret <0 )return ret; -if (phydev->drv->config_init) +if (phydev->drv->config_init) { ret = phydev->drv->config_init (phydev); +if (ret <0 ) +return ret; + }
Quoted 7 lines
drivers/net/phy/phy_device.c int phy_init_hw(struct phy_device *phydev) · line 1099
Quoted 2 lines
drivers/net/phy/phy_device.c +1
-1-return ret; +return phy_disable_interrupts (phydev);Not sure if the order makes sense here, it may seem more natural for a driver writer to have interrupts disabled first and then
config_initcalled (which could enable interrupts not related to link management like thermal events etc.)
If this is a shared interrupt, and the PHY interrupt has been left enabled, wouldn't we want to ensure that the PHY interrupt is disabled as early as possible - in other words, when the device is probed, rather than when the PHY is eventually bound to the network device.
However, I must point out that even disabling the PHY interrupt at probe time is only reducing the window for problems - if that shared interrupt has already been claimed by other users, and if the PHY interrupt is unmasked in the PHY, then the PHY can do whatever it likes with the shared interrupt before we even get to probe the PHY. So the only real solution to this is to fix the environment that is passing control to the kernel.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
David Miller
maintainerFrom: Jisheng Zhang <[email protected]>
Date: Wed, 24 Jun 2020 11:25:16 +0800
Quoted 14 lines
We face an issue with rtl8211f, a pin is shared between INTB and PMEB, and the PHY Register Accessible Interrupt is enabled by default, so the INTB/PMEB pin is always active in polling mode case.
As Heiner pointed out "I was thinking about calling
phy_disable_interrupts()inphy_init_hw(), to have a defined init state as we don't know in which state the PHY is if the PHY driver is loaded. We shouldn't assume that it's the chip power-on defaults, BIOS or boot loader could have changed this. Or in case of dual-boot systems the other OS could leave the PHY in whatever state."patch1 makes
phy_disable_interrupts()non-static so that it could be used inphy_init_hw()to have a defined init state.
Quoted 8 lines
patch2 calls
phy_disable_interrupts()inphy_init_hw()to have a defined init state.Since v2:
- Don't exportphy_disable_interrupts()but just make it non-staticSince v1:
- EXPORT the correct symbol
Series applied, thank you.
Quoted 20 lines · David Miller
From: Jisheng Zhang <[email protected]>
Date: Wed, 24 Jun 2020 11:25:16 +0800Quoted 17 lines
We face an issue with rtl8211f, a pin is shared between INTB and PMEB, and the PHY Register Accessible Interrupt is enabled by default, so the INTB/PMEB pin is always active in polling mode case.
As Heiner pointed out "I was thinking about calling
phy_disable_interrupts()inphy_init_hw(), to have a defined init state as we don't know in which state the PHY is if the PHY driver is loaded. We shouldn't assume that it's the chip power-on defaults, BIOS or boot loader could have changed this. Or in case of dual-boot systems the other OS could leave the PHY in whatever state."patch1 makes
phy_disable_interrupts()non-static so that it could be used inphy_init_hw()to have a defined init state.patch2 calls
phy_disable_interrupts()inphy_init_hw()to have a defined init state.
Quoted 7 lines
Quoted 5 lines
Since v2:
- Don't exportphy_disable_interrupts()but just make it non-staticSince v1:
- EXPORT the correct symbolSeries applied, thank you.
Did you mean that you applied v4? It does not look like you pushed your local changes to net-next yet, so I cannot tell for sure.
Signature · 1 line
Florian
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Wed, 24 Jun 2020 15:10:51 -0700
Quoted 2 lines
Did you mean that you applied v4? It does not look like you pushed your local changes to net-next yet, so I cannot tell for sure.
I ended up applying v4, yes.
Quoted 8 lines · David Miller
From: Florian Fainelli <[email protected]>
Date: Wed, 24 Jun 2020 15:10:51 -0700Quoted 2 lines
Did you mean that you applied v4? It does not look like you pushed your local changes to net-next yet, so I cannot tell for sure.
I ended up applying v4, yes.
OK, just making sure :) thanks!
Signature · 1 line
Florian