netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3 net 0/2] Add DT property to disable hibernation mode
@ 2022-08-18  3:00 wei.fang
  2022-08-18  3:00 ` [PATCH V3 net 1/2] dt-bindings: net: ar803x: add disable-hibernation-mode propetry wei.fang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: wei.fang @ 2022-08-18  3:00 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	robh+dt, krzysztof.kozlowski+dt, f.fainelli, netdev, devicetree,
	linux-kernel

From: Wei Fang <wei.fang@nxp.com>

The patches add the ability to disable the hibernation mode of AR803x
PHYs. Hibernation mode defaults to enabled after hardware reset on
these PHYs. If the AR803x PHYs enter hibernation mode, they will not
provide any clock. For some MACs, they might need the clocks which
provided by the PHYs to support their own hardware logic.
So, the patches add the support to disable hibernation mode by adding
a boolean:
        qca,disable-hibernation-mode
If one wished to disable hibernation mode to better match with the
specifical MAC, just add this property in the phy node of DT.

Wei Fang (2):
  dt-bindings: net: ar803x: add disable-hibernation-mode propetry
  net: phy: at803x: add disable hibernation mode support

 .../devicetree/bindings/net/qca,ar803x.yaml   |  8 ++++++
 drivers/net/phy/at803x.c                      | 25 +++++++++++++++++++
 2 files changed, 33 insertions(+)

-- 
2.25.1


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

* [PATCH V3 net 1/2] dt-bindings: net: ar803x: add disable-hibernation-mode propetry
  2022-08-18  3:00 [PATCH V3 net 0/2] Add DT property to disable hibernation mode wei.fang
@ 2022-08-18  3:00 ` wei.fang
  2022-08-18 16:35   ` Rob Herring
  2022-08-18  3:00 ` [PATCH V3 net 2/2] net: phy: at803x: add disable hibernation mode support wei.fang
  2022-08-18 23:40 ` [PATCH V3 net 0/2] Add DT property to disable hibernation mode patchwork-bot+netdevbpf
  2 siblings, 1 reply; 8+ messages in thread
From: wei.fang @ 2022-08-18  3:00 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	robh+dt, krzysztof.kozlowski+dt, f.fainelli, netdev, devicetree,
	linux-kernel

From: Wei Fang <wei.fang@nxp.com>

The hibernation mode of Atheros AR803x PHYs defaults to be
enabled after hardware reset. When the cable is unplugged,
the PHY will enter hibernation mode after about 10 seconds
and the PHY clocks will be stopped to save power.
However, some MACs need the phy output clock for proper
functioning of their logic. For instance, stmmac needs the
RX_CLK of PHY for software reset to complete.
Therefore, add a DT property to configure the PHY to disable
this hardware hibernation mode.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
V2 change:
1. Add subject prefix.
2. Modify the property name and description to make them clear.
V3 change:
According to Andrew's suggestion, remodify the description to
make it clear.
---
 Documentation/devicetree/bindings/net/qca,ar803x.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/qca,ar803x.yaml b/Documentation/devicetree/bindings/net/qca,ar803x.yaml
index b3d4013b7ca6..161d28919316 100644
--- a/Documentation/devicetree/bindings/net/qca,ar803x.yaml
+++ b/Documentation/devicetree/bindings/net/qca,ar803x.yaml
@@ -40,6 +40,14 @@ properties:
       Only supported on the AR8031.
     type: boolean
 
+  qca,disable-hibernation-mode:
+    description: |
+      Disable Atheros AR803X PHYs hibernation mode. If present, indicates
+      that the hardware of PHY will not enter power saving mode when the
+      cable is disconnected. And the RX_CLK always keeps outputting a
+      valid clock.
+    type: boolean
+
   qca,smarteee-tw-us-100m:
     description: EEE Tw parameter for 100M links.
     $ref: /schemas/types.yaml#/definitions/uint32
-- 
2.25.1


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

* [PATCH V3 net 2/2] net: phy: at803x: add disable hibernation mode support
  2022-08-18  3:00 [PATCH V3 net 0/2] Add DT property to disable hibernation mode wei.fang
  2022-08-18  3:00 ` [PATCH V3 net 1/2] dt-bindings: net: ar803x: add disable-hibernation-mode propetry wei.fang
@ 2022-08-18  3:00 ` wei.fang
  2022-08-18 19:29   ` Andrew Lunn
  2022-08-18 23:40 ` [PATCH V3 net 0/2] Add DT property to disable hibernation mode patchwork-bot+netdevbpf
  2 siblings, 1 reply; 8+ messages in thread
From: wei.fang @ 2022-08-18  3:00 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	robh+dt, krzysztof.kozlowski+dt, f.fainelli, netdev, devicetree,
	linux-kernel

From: Wei Fang <wei.fang@nxp.com>

When the cable is unplugged, the Atheros AR803x PHYs will enter
hibernation mode after about 10 seconds if the hibernation mode
is enabled and will not provide any clock to the MAC. But for
some MACs, this feature might cause unexpected issues due to the
logic of MACs.
Taking SYNP MAC (stmmac) as an example, if the cable is unplugged
and the "eth0" interface is down, the AR803x PHY will enter
hibernation mode. Then perform the "ifconfig eth0 up" operation,
the stmmac can't be able to complete the software reset operation
and fail to init it's own DMA. Therefore, the "eth0" interface is
failed to ifconfig up. Why does it cause this issue? The truth is
that the software reset operation of the stmmac is designed to
depend on the RX_CLK of PHY.
So, this patch offers an option for the user to determine whether
to disable the hibernation mode of AR803x PHYs.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
V2 change:
Modify the property name and the function name to make them
more clear.
V3 change:
No change.
---
 drivers/net/phy/at803x.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 59fe356942b5..11ebd59bf2eb 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -115,6 +115,7 @@
 #define AT803X_DEBUG_REG_HIB_CTRL		0x0b
 #define   AT803X_DEBUG_HIB_CTRL_SEL_RST_80U	BIT(10)
 #define   AT803X_DEBUG_HIB_CTRL_EN_ANY_CHANGE	BIT(13)
+#define   AT803X_DEBUG_HIB_CTRL_PS_HIB_EN	BIT(15)
 
 #define AT803X_DEBUG_REG_3C			0x3C
 
@@ -192,6 +193,9 @@
 #define AT803X_KEEP_PLL_ENABLED			BIT(0)
 #define AT803X_DISABLE_SMARTEEE			BIT(1)
 
+/* disable hibernation mode */
+#define AT803X_DISABLE_HIBERNATION_MODE		BIT(2)
+
 /* ADC threshold */
 #define QCA808X_PHY_DEBUG_ADC_THRESHOLD		0x2c80
 #define QCA808X_ADC_THRESHOLD_MASK		GENMASK(7, 0)
@@ -730,6 +734,9 @@ static int at803x_parse_dt(struct phy_device *phydev)
 	if (of_property_read_bool(node, "qca,disable-smarteee"))
 		priv->flags |= AT803X_DISABLE_SMARTEEE;
 
+	if (of_property_read_bool(node, "qca,disable-hibernation-mode"))
+		priv->flags |= AT803X_DISABLE_HIBERNATION_MODE;
+
 	if (!of_property_read_u32(node, "qca,smarteee-tw-us-1g", &tw)) {
 		if (!tw || tw > 255) {
 			phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n");
@@ -999,6 +1006,20 @@ static int at8031_pll_config(struct phy_device *phydev)
 					     AT803X_DEBUG_PLL_ON, 0);
 }
 
+static int at803x_hibernation_mode_config(struct phy_device *phydev)
+{
+	struct at803x_priv *priv = phydev->priv;
+
+	/* The default after hardware reset is hibernation mode enabled. After
+	 * software reset, the value is retained.
+	 */
+	if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE))
+		return 0;
+
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL,
+					 AT803X_DEBUG_HIB_CTRL_PS_HIB_EN, 0);
+}
+
 static int at803x_config_init(struct phy_device *phydev)
 {
 	struct at803x_priv *priv = phydev->priv;
@@ -1051,6 +1072,10 @@ static int at803x_config_init(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
+	ret = at803x_hibernation_mode_config(phydev);
+	if (ret < 0)
+		return ret;
+
 	/* Ar803x extended next page bit is enabled by default. Cisco
 	 * multigig switches read this bit and attempt to negotiate 10Gbps
 	 * rates even if the next page bit is disabled. This is incorrect
-- 
2.25.1


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

* Re: [PATCH V3 net 1/2] dt-bindings: net: ar803x: add disable-hibernation-mode propetry
  2022-08-18  3:00 ` [PATCH V3 net 1/2] dt-bindings: net: ar803x: add disable-hibernation-mode propetry wei.fang
@ 2022-08-18 16:35   ` Rob Herring
  0 siblings, 0 replies; 8+ messages in thread
From: Rob Herring @ 2022-08-18 16:35 UTC (permalink / raw)
  To: wei.fang
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	krzysztof.kozlowski+dt, f.fainelli, netdev, devicetree,
	linux-kernel

On Thu, Aug 18, 2022 at 11:00:53AM +0800, wei.fang@nxp.com wrote:
> From: Wei Fang <wei.fang@nxp.com>
> 
> The hibernation mode of Atheros AR803x PHYs defaults to be
> enabled after hardware reset. When the cable is unplugged,
> the PHY will enter hibernation mode after about 10 seconds
> and the PHY clocks will be stopped to save power.
> However, some MACs need the phy output clock for proper
> functioning of their logic. For instance, stmmac needs the
> RX_CLK of PHY for software reset to complete.
> Therefore, add a DT property to configure the PHY to disable
> this hardware hibernation mode.
> 
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
> V2 change:
> 1. Add subject prefix.
> 2. Modify the property name and description to make them clear.
> V3 change:
> According to Andrew's suggestion, remodify the description to
> make it clear.
> ---
>  Documentation/devicetree/bindings/net/qca,ar803x.yaml | 8 ++++++++
>  1 file changed, 8 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH V3 net 2/2] net: phy: at803x: add disable hibernation mode support
  2022-08-18  3:00 ` [PATCH V3 net 2/2] net: phy: at803x: add disable hibernation mode support wei.fang
@ 2022-08-18 19:29   ` Andrew Lunn
  2022-08-18 19:58     ` Jakub Kicinski
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2022-08-18 19:29 UTC (permalink / raw)
  To: wei.fang
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, f.fainelli, netdev, devicetree,
	linux-kernel

On Thu, Aug 18, 2022 at 11:00:54AM +0800, wei.fang@nxp.com wrote:
> From: Wei Fang <wei.fang@nxp.com>
> 
> When the cable is unplugged, the Atheros AR803x PHYs will enter
> hibernation mode after about 10 seconds if the hibernation mode
> is enabled and will not provide any clock to the MAC. But for
> some MACs, this feature might cause unexpected issues due to the
> logic of MACs.
> Taking SYNP MAC (stmmac) as an example, if the cable is unplugged
> and the "eth0" interface is down, the AR803x PHY will enter
> hibernation mode. Then perform the "ifconfig eth0 up" operation,
> the stmmac can't be able to complete the software reset operation
> and fail to init it's own DMA. Therefore, the "eth0" interface is
> failed to ifconfig up. Why does it cause this issue? The truth is
> that the software reset operation of the stmmac is designed to
> depend on the RX_CLK of PHY.
> So, this patch offers an option for the user to determine whether
> to disable the hibernation mode of AR803x PHYs.
> 
> Signed-off-by: Wei Fang <wei.fang@nxp.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH V3 net 2/2] net: phy: at803x: add disable hibernation mode support
  2022-08-18 19:29   ` Andrew Lunn
@ 2022-08-18 19:58     ` Jakub Kicinski
  2022-08-18 20:28       ` Andrew Lunn
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2022-08-18 19:58 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: wei.fang, hkallweit1, linux, davem, edumazet, pabeni, robh+dt,
	krzysztof.kozlowski+dt, f.fainelli, netdev, devicetree,
	linux-kernel

On Thu, 18 Aug 2022 21:29:07 +0200 Andrew Lunn wrote:
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Any guidance on net / net-next and Fixes, Andrew?

Seems like a "this never worked" / "we haven't supported such platforms"
case, perhaps?

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

* Re: [PATCH V3 net 2/2] net: phy: at803x: add disable hibernation mode support
  2022-08-18 19:58     ` Jakub Kicinski
@ 2022-08-18 20:28       ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2022-08-18 20:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: wei.fang, hkallweit1, linux, davem, edumazet, pabeni, robh+dt,
	krzysztof.kozlowski+dt, f.fainelli, netdev, devicetree,
	linux-kernel

On Thu, Aug 18, 2022 at 12:58:01PM -0700, Jakub Kicinski wrote:
> On Thu, 18 Aug 2022 21:29:07 +0200 Andrew Lunn wrote:
> > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> 
> Any guidance on net / net-next and Fixes, Andrew?
> 
> Seems like a "this never worked" / "we haven't supported such platforms"
> case, perhaps?

That was what i was thinking, which is why i did not question a
missing Fixes tag. So net-next.

	Andrew

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

* Re: [PATCH V3 net 0/2] Add DT property to disable hibernation mode
  2022-08-18  3:00 [PATCH V3 net 0/2] Add DT property to disable hibernation mode wei.fang
  2022-08-18  3:00 ` [PATCH V3 net 1/2] dt-bindings: net: ar803x: add disable-hibernation-mode propetry wei.fang
  2022-08-18  3:00 ` [PATCH V3 net 2/2] net: phy: at803x: add disable hibernation mode support wei.fang
@ 2022-08-18 23:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-18 23:40 UTC (permalink / raw)
  To: Wei Fang
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	robh+dt, krzysztof.kozlowski+dt, f.fainelli, netdev, devicetree,
	linux-kernel

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 18 Aug 2022 11:00:52 +0800 you wrote:
> From: Wei Fang <wei.fang@nxp.com>
> 
> The patches add the ability to disable the hibernation mode of AR803x
> PHYs. Hibernation mode defaults to enabled after hardware reset on
> these PHYs. If the AR803x PHYs enter hibernation mode, they will not
> provide any clock. For some MACs, they might need the clocks which
> provided by the PHYs to support their own hardware logic.
> So, the patches add the support to disable hibernation mode by adding
> a boolean:
>         qca,disable-hibernation-mode
> If one wished to disable hibernation mode to better match with the
> specifical MAC, just add this property in the phy node of DT.
> 
> [...]

Here is the summary with links:
  - [V3,net,1/2] dt-bindings: net: ar803x: add disable-hibernation-mode propetry
    https://git.kernel.org/netdev/net-next/c/2e7f089914b9
  - [V3,net,2/2] net: phy: at803x: add disable hibernation mode support
    https://git.kernel.org/netdev/net-next/c/9ecf04016c87

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-08-18 23:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18  3:00 [PATCH V3 net 0/2] Add DT property to disable hibernation mode wei.fang
2022-08-18  3:00 ` [PATCH V3 net 1/2] dt-bindings: net: ar803x: add disable-hibernation-mode propetry wei.fang
2022-08-18 16:35   ` Rob Herring
2022-08-18  3:00 ` [PATCH V3 net 2/2] net: phy: at803x: add disable hibernation mode support wei.fang
2022-08-18 19:29   ` Andrew Lunn
2022-08-18 19:58     ` Jakub Kicinski
2022-08-18 20:28       ` Andrew Lunn
2022-08-18 23:40 ` [PATCH V3 net 0/2] Add DT property to disable hibernation mode patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).