All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] net: phy: realtek: Introduce quirk to mark RXC not stoppable
@ 2019-01-23 13:55 Carlo Caione
  2019-01-23 16:19 ` Joe Hershberger
  0 siblings, 1 reply; 4+ messages in thread
From: Carlo Caione @ 2019-01-23 13:55 UTC (permalink / raw)
  To: u-boot

When EEE is supported by the PHY and the driver allows it, libphy in the
kernel is configuring the PHY to stop receiving the xMII clock while it
is signaling LPI. While this (usually) works fine in the kernel this is
causing issues in U-Boot when rebooting from the linux kernel with this
bit set (without having the possibility to reset the PHY) where the PHY
suddenly stops working.

A new quirk is introduced to unconditionally reset this bit. If the
quirk is not enabled using the proper configuration symbol, the PHY state
is not changed.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---

Hi Joe,
just an heads up that this patch depends on the MMD helpers patch I 
submitted earlier.

---
 drivers/net/phy/Kconfig   | 19 +++++++++++++++++++
 drivers/net/phy/realtek.c | 19 +++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 3dc0822d9c..d0dab3014e 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -202,6 +202,25 @@ config RTL8211X_PHY_FORCE_MASTER
 
 	  If unsure, say N.
 
+config RTL8211F_PHY_FORCE_EEE_RXC_ON
+	bool "Ethernet PHY RTL8211F: do not stop receiving the xMII clock during LPI"
+	depends on PHY_REALTEK
+	default n
+	help
+	  The IEEE 802.3az-2010 (EEE) standar provides a protocol to coordinate
+	  transitions to/from a lower power consumption level (Low Power Idle
+	  mode) based on link utilization. When no packets are being
+	  transmitted, the system goes to Low Power Idle mode to save power.
+
+	  Under particular circumstances this setting can cause issues where
+	  the PHY is unable to transmit or receive any packet when in LPI mode.
+	  The problem is caused when the PHY is configured to stop receiving
+	  the xMII clock while it is signaling LPI. When not stated otherwise
+	  this bit is set by libphy in the linux kernel.
+
+	  Default n, which means that the PHY state is not changed. To work
+	  around the issues, change this setting to y.
+
 config PHY_SMSC
 	bool  "Microchip(SMSC) Ethernet PHYs support"
 
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index b3e6578df9..fa11696fe2 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -12,6 +12,7 @@
 
 #define PHY_RTL8211x_FORCE_MASTER BIT(1)
 #define PHY_RTL8211E_PINE64_GIGABIT_FIX BIT(2)
+#define PHY_RTL8211F_FORCE_EEE_RXC_ON BIT(3)
 
 #define PHY_AUTONEGOTIATE_TIMEOUT 5000
 
@@ -75,6 +76,15 @@ static int rtl8211e_probe(struct phy_device *phydev)
 	return 0;
 }
 
+static int rtl8211f_probe(struct phy_device *phydev)
+{
+#ifdef CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON
+	phydev->flags |= PHY_RTL8211F_FORCE_EEE_RXC_ON;
+#endif
+
+	return 0;
+}
+
 /* RealTek RTL8211x */
 static int rtl8211x_config(struct phy_device *phydev)
 {
@@ -124,6 +134,14 @@ static int rtl8211f_config(struct phy_device *phydev)
 {
 	u16 reg;
 
+	if (phydev->flags & PHY_RTL8211F_FORCE_EEE_RXC_ON) {
+		unsigned int reg;
+
+		reg = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1);
+		reg &= ~MDIO_PCS_CTRL1_CLKSTOP_EN;
+		phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, reg);
+	}
+
 	phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
 
 	phy_write(phydev, MDIO_DEVAD_NONE,
@@ -333,6 +351,7 @@ static struct phy_driver RTL8211F_driver = {
 	.uid = 0x1cc916,
 	.mask = 0xffffff,
 	.features = PHY_GBIT_FEATURES,
+	.probe = &rtl8211f_probe,
 	.config = &rtl8211f_config,
 	.startup = &rtl8211f_startup,
 	.shutdown = &genphy_shutdown,
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] net: phy: realtek: Introduce quirk to mark RXC not stoppable
  2019-01-23 13:55 [U-Boot] [PATCH] net: phy: realtek: Introduce quirk to mark RXC not stoppable Carlo Caione
@ 2019-01-23 16:19 ` Joe Hershberger
  2019-01-23 16:39   ` Carlo Caione
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Hershberger @ 2019-01-23 16:19 UTC (permalink / raw)
  To: u-boot

On Wed, Jan 23, 2019 at 7:57 AM Carlo Caione <ccaione@baylibre.com> wrote:
>
> When EEE is supported by the PHY and the driver allows it, libphy in the
> kernel is configuring the PHY to stop receiving the xMII clock while it
> is signaling LPI. While this (usually) works fine in the kernel this is
> causing issues in U-Boot when rebooting from the linux kernel with this
> bit set (without having the possibility to reset the PHY) where the PHY
> suddenly stops working.
>
> A new quirk is introduced to unconditionally reset this bit. If the
> quirk is not enabled using the proper configuration symbol, the PHY state
> is not changed.
>
> Signed-off-by: Carlo Caione <ccaione@baylibre.com>

Other than a few nits below,

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

> ---
>
> Hi Joe,
> just an heads up that this patch depends on the MMD helpers patch I
> submitted earlier.
>
> ---
>  drivers/net/phy/Kconfig   | 19 +++++++++++++++++++
>  drivers/net/phy/realtek.c | 19 +++++++++++++++++++
>  2 files changed, 38 insertions(+)
>
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index 3dc0822d9c..d0dab3014e 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -202,6 +202,25 @@ config RTL8211X_PHY_FORCE_MASTER
>
>           If unsure, say N.
>
> +config RTL8211F_PHY_FORCE_EEE_RXC_ON
> +       bool "Ethernet PHY RTL8211F: do not stop receiving the xMII clock during LPI"
> +       depends on PHY_REALTEK
> +       default n
> +       help
> +         The IEEE 802.3az-2010 (EEE) standar provides a protocol to coordinate

Typo: standard

> +         transitions to/from a lower power consumption level (Low Power Idle
> +         mode) based on link utilization. When no packets are being
> +         transmitted, the system goes to Low Power Idle mode to save power.
> +
> +         Under particular circumstances this setting can cause issues where
> +         the PHY is unable to transmit or receive any packet when in LPI mode.
> +         The problem is caused when the PHY is configured to stop receiving
> +         the xMII clock while it is signaling LPI. When not stated otherwise
> +         this bit is set by libphy in the linux kernel.

This seems to be copied from Linux, please update to describe what
happens in U-Boot.

> +
> +         Default n, which means that the PHY state is not changed. To work
> +         around the issues, change this setting to y.
> +
>  config PHY_SMSC
>         bool  "Microchip(SMSC) Ethernet PHYs support"
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index b3e6578df9..fa11696fe2 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -12,6 +12,7 @@
>
>  #define PHY_RTL8211x_FORCE_MASTER BIT(1)
>  #define PHY_RTL8211E_PINE64_GIGABIT_FIX BIT(2)
> +#define PHY_RTL8211F_FORCE_EEE_RXC_ON BIT(3)
>
>  #define PHY_AUTONEGOTIATE_TIMEOUT 5000
>
> @@ -75,6 +76,15 @@ static int rtl8211e_probe(struct phy_device *phydev)
>         return 0;
>  }
>
> +static int rtl8211f_probe(struct phy_device *phydev)
> +{
> +#ifdef CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON
> +       phydev->flags |= PHY_RTL8211F_FORCE_EEE_RXC_ON;
> +#endif
> +
> +       return 0;
> +}
> +
>  /* RealTek RTL8211x */
>  static int rtl8211x_config(struct phy_device *phydev)
>  {
> @@ -124,6 +134,14 @@ static int rtl8211f_config(struct phy_device *phydev)
>  {
>         u16 reg;
>
> +       if (phydev->flags & PHY_RTL8211F_FORCE_EEE_RXC_ON) {
> +               unsigned int reg;
> +
> +               reg = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1);
> +               reg &= ~MDIO_PCS_CTRL1_CLKSTOP_EN;
> +               phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, reg);
> +       }
> +
>         phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
>
>         phy_write(phydev, MDIO_DEVAD_NONE,
> @@ -333,6 +351,7 @@ static struct phy_driver RTL8211F_driver = {
>         .uid = 0x1cc916,
>         .mask = 0xffffff,
>         .features = PHY_GBIT_FEATURES,
> +       .probe = &rtl8211f_probe,
>         .config = &rtl8211f_config,
>         .startup = &rtl8211f_startup,
>         .shutdown = &genphy_shutdown,
> --
> 2.19.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] net: phy: realtek: Introduce quirk to mark RXC not stoppable
  2019-01-23 16:19 ` Joe Hershberger
@ 2019-01-23 16:39   ` Carlo Caione
  2019-01-23 17:04     ` Joe Hershberger
  0 siblings, 1 reply; 4+ messages in thread
From: Carlo Caione @ 2019-01-23 16:39 UTC (permalink / raw)
  To: u-boot

On 23/01/19 16:19, Joe Hershberger wrote:

/cut
>> +         transitions to/from a lower power consumption level (Low 
>> Power Idle
>> +         mode) based on link utilization. When no packets are being
>> +         transmitted, the system goes to Low Power Idle mode to save power.
>> +
>> +         Under particular circumstances this setting can cause issues where
>> +         the PHY is unable to transmit or receive any packet when in LPI mode.
>> +         The problem is caused when the PHY is configured to stop receiving
>> +         the xMII clock while it is signaling LPI. When not stated otherwise
>> +         this bit is set by libphy in the linux kernel.
>
>This seems to be copied from Linux, please update to describe what
>happens in U-Boot.

It is not copied from Linux. The problem is that the libphy in the 
kernel is flipping this bit and this is causing the issue in U-Boot on 
reboot. So I'm saying exactly that.

-- 
Carlo Caione

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] net: phy: realtek: Introduce quirk to mark RXC not stoppable
  2019-01-23 16:39   ` Carlo Caione
@ 2019-01-23 17:04     ` Joe Hershberger
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Hershberger @ 2019-01-23 17:04 UTC (permalink / raw)
  To: u-boot

On Wed, Jan 23, 2019 at 10:39 AM Carlo Caione <ccaione@baylibre.com> wrote:
>
> On 23/01/19 16:19, Joe Hershberger wrote:
>
> /cut
> >> +         transitions to/from a lower power consumption level (Low
> >> Power Idle
> >> +         mode) based on link utilization. When no packets are being
> >> +         transmitted, the system goes to Low Power Idle mode to save power.
> >> +
> >> +         Under particular circumstances this setting can cause issues where
> >> +         the PHY is unable to transmit or receive any packet when in LPI mode.
> >> +         The problem is caused when the PHY is configured to stop receiving
> >> +         the xMII clock while it is signaling LPI. When not stated otherwise
> >> +         this bit is set by libphy in the linux kernel.
> >
> >This seems to be copied from Linux, please update to describe what
> >happens in U-Boot.
>
> It is not copied from Linux. The problem is that the libphy in the
> kernel is flipping this bit and this is causing the issue in U-Boot on
> reboot. So I'm saying exactly that.

I see... you are saying it retains the value that may have be changed
by Linux. "When not stated otherwise" is to mean "If this config is
disabled" Should capitalize Linux.

>
> --
> Carlo Caione
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-23 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23 13:55 [U-Boot] [PATCH] net: phy: realtek: Introduce quirk to mark RXC not stoppable Carlo Caione
2019-01-23 16:19 ` Joe Hershberger
2019-01-23 16:39   ` Carlo Caione
2019-01-23 17:04     ` Joe Hershberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.