Skip to contentSkip to conversation

net: phy: call phy_disable_interrupts() in phy_init_hw()

PATCH New Jisheng Zhang 1 participant 3 messages Jun 24, 2020

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

v4 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 v3:
- call phy_disable_interrupts() have interrupts disabled first then config_init, thank Florian

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 | 4 ++++
 include/linux/phy.h          | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH v4 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
index 1de3938628f4..56cfae950472 100644
@@ -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
index 8c05d0fb5c00..b693b609b2f5 100644
@@ -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
#2 lore raw

PATCH v4 2/2 net: phy: call phy_disable_interrupts() in phy_init_hw()

In reply to Jisheng Zhang

Call 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 | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/phy/phy_device.c +4 -0
index 04946de74fa0..6a5886202619 100644
@@ -1090,6 +1090,10 @@ int phy_init_hw(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
+	ret = phy_disable_interrupts(phydev);
+	if (ret)
+		return ret;
+
 	if (phydev->drv->config_init)
 		ret = phydev->drv->config_init(phydev);
 
Signature · 1 line
2.27.0