netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock
@ 2024-01-30  9:28 Romain Gantois
  2024-01-30  9:28 ` [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags Romain Gantois
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Romain Gantois @ 2024-01-30  9:28 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger
  Cc: Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc, Romain Gantois,
	Clark Wang

Hello everyone,

This is version two of my series that addresses the issue with some MAC/PHY
combinations. Version one was sent on net, not net-next.

Notable changes in v2:
  - Introduced a pcs op for initializing hardware required for MAC
    initialization, instead of using phylink_validate() for this purpose.
  - Refactored stmmac to use a generic PCS reference in mac_device_info
    instead of a model-specific field.

There is an issue with some stmmac/PHY combinations that has been reported
some time ago in a couple of different series:

Clark Wang's report:
https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/
Clément Léger's report:
https://lore.kernel.org/linux-arm-kernel/20230116103926.276869-4-clement.leger@bootlin.com/

Stmmac controllers require an RX clock signal from the MII bus to perform
their hardware initialization successfully. This causes issues with some
PHY/PCS devices. If these devices do not bring the clock signal up before
the MAC driver initializes its hardware, then said initialization will
fail. This can happen at probe time or when the system wakes up from a
suspended state.

This series introduces new flags for phy_device and phylink_pcs. These
flags allow MAC drivers to signal to PHY/PCS drivers that the RX clock
signal should be enabled as soon as possible, and that it should always
stay enabled.

I have included specific uses of these flags that fix the RZN1 GMAC1 stmmac
driver that I am currently working on and that is not yet upstream. I have
also included changes to the at803x PHY driver that should fix the issue
that Clark Wang was having.

Clark, could you please confirm that this series fixes your issue with the
at803x PHY?

Best Regards,

Romain

Romain Gantois (2):
  net: phy: add rxc_always_on flag to phylink_pcs
  net: pcs: rzn1-miic: Init RX clock early if MAC requires it

Russell King (3):
  net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags
  net: stmmac: Signal to PHY/PCS drivers to keep RX clock on
  net: phy: at803x: Avoid hibernating if MAC requires RX clock

 .../net/ethernet/stmicro/stmmac/stmmac_main.c  |  5 +++++
 drivers/net/pcs/pcs-rzn1-miic.c                | 18 +++++++++++++-----
 drivers/net/phy/at803x.c                       |  3 ++-
 drivers/net/phy/phylink.c                      | 13 ++++++++++++-
 include/linux/phy.h                            |  1 +
 include/linux/phylink.h                        |  9 +++++++++
 6 files changed, 42 insertions(+), 7 deletions(-)

--
2.43.0

---
Maxime Chevallier (1):
      net: stmmac: don't rely on lynx_pcs presence to check for a PHY

Romain Gantois (4):
      net: phy: add rxc_always_on flag to phylink_pcs
      net: stmmac: Support a generic PCS field in mac_device_info
      net: stmmac: Signal to PHY/PCS drivers to keep RX clock on
      net: pcs: rzn1-miic: Init RX clock early if MAC requires it

Russell King (2):
      net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags
      net: phy: at803x: Avoid hibernating if MAC requires RX clock

 drivers/net/ethernet/stmicro/stmmac/common.h       |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    |  8 ++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 15 ++++++++------
 drivers/net/pcs/pcs-rzn1-miic.c                    | 16 +++++++++++++++
 drivers/net/phy/at803x.c                           |  3 ++-
 drivers/net/phy/phylink.c                          | 24 +++++++++++++++++++++-
 include/linux/phy.h                                |  1 +
 include/linux/phylink.h                            | 15 ++++++++++++++
 8 files changed, 71 insertions(+), 13 deletions(-)
---
base-commit: 795a7dfbc3d95e4c7c09569f319f026f8c7f5a9c
change-id: 20240126-rxc_bugfix-d47b3b1a374f

Best regards,
-- 
Romain Gantois <romain.gantois@bootlin.com>


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

* [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags
  2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
@ 2024-01-30  9:28 ` Romain Gantois
  2024-01-30  9:57   ` Russell King (Oracle)
  2024-01-30 13:55   ` Andrew Lunn
  2024-01-30  9:28 ` [PATCH net-next v2 2/7] net: phy: add rxc_always_on flag to phylink_pcs Romain Gantois
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 15+ messages in thread
From: Romain Gantois @ 2024-01-30  9:28 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger
  Cc: Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc, Romain Gantois

From: Russell King <linux@armlinux.org.uk>

Some MAC controllers (e.g. stmmac) require their connected PHY to
continuously provide a receive clock signal. This can cause issues in two
cases:

  1. The clock signal hasn't been started yet by the time the MAC driver
     initializes its hardware. This can make the initialization fail, as in
      the case of the rzn1 GMAC1 driver.
  2. The clock signal is cut during a power saving event. By the time the
     MAC is brought back up, the clock signal is still not active since
     phylink_start hasn't been called yet. This brings us back to case 1.

If a PHY driver reads this flag, it should ensure that the receive clock
signal is started as soon as possible, and that it isn't brought down when
the PHY goes into suspend.

Signed-off-by: Russell King <linux@armlinux.org.uk>
[rgantois: commit log]
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
 drivers/net/phy/phylink.c | 10 +++++++++-
 include/linux/phy.h       |  1 +
 include/linux/phylink.h   |  4 ++++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index ed0b4ccaa6a6..851049096488 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1923,6 +1923,8 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
 static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy,
 			      phy_interface_t interface)
 {
+	u32 flags = 0;
+
 	if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED ||
 		    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
 		     phy_interface_mode_is_8023z(interface) && !pl->sfp_bus)))
@@ -1931,7 +1933,10 @@ static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy,
 	if (pl->phydev)
 		return -EBUSY;
 
-	return phy_attach_direct(pl->netdev, phy, 0, interface);
+	if (pl->config->mac_requires_rxc)
+		flags |= PHY_F_RXC_ALWAYS_ON;
+
+	return phy_attach_direct(pl->netdev, phy, flags, interface);
 }
 
 /**
@@ -2034,6 +2039,9 @@ int phylink_fwnode_phy_connect(struct phylink *pl,
 		pl->link_config.interface = pl->link_interface;
 	}
 
+	if (pl->config->mac_requires_rxc)
+		flags |= PHY_F_RXC_ALWAYS_ON;
+
 	ret = phy_attach_direct(pl->netdev, phy_dev, flags,
 				pl->link_interface);
 	phy_device_free(phy_dev);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index c9994a59ca2e..3ef30f035bc0 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -768,6 +768,7 @@ struct phy_device {
 
 /* Generic phy_device::dev_flags */
 #define PHY_F_NO_IRQ		0x80000000
+#define PHY_F_RXC_ALWAYS_ON	BIT(30)
 
 static inline struct phy_device *to_phy_device(const struct device *dev)
 {
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index d589f89c612c..fcee99632964 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -138,6 +138,9 @@ enum phylink_op_type {
  * @poll_fixed_state: if true, starts link_poll,
  *		      if MAC link is at %MLO_AN_FIXED mode.
  * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM.
+ * @mac_requires_rxc: if true, the MAC always requires a receive clock from PHY.
+ *                    The PHY driver should start the clock signal as soon as
+ *                    possible and avoid stopping it during suspend events.
  * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND
  * @get_fixed_state: callback to execute to determine the fixed link state,
  *		     if MAC link is at %MLO_AN_FIXED mode.
@@ -150,6 +153,7 @@ struct phylink_config {
 	enum phylink_op_type type;
 	bool poll_fixed_state;
 	bool mac_managed_pm;
+	bool mac_requires_rxc;
 	bool ovr_an_inband;
 	void (*get_fixed_state)(struct phylink_config *config,
 				struct phylink_link_state *state);

-- 
2.43.0


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

* [PATCH net-next v2 2/7] net: phy: add rxc_always_on flag to phylink_pcs
  2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
  2024-01-30  9:28 ` [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags Romain Gantois
@ 2024-01-30  9:28 ` Romain Gantois
  2024-01-30 10:11   ` Russell King (Oracle)
  2024-01-30  9:28 ` [PATCH net-next v2 3/7] net: stmmac: don't rely on lynx_pcs presence to check for a PHY Romain Gantois
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Romain Gantois @ 2024-01-30  9:28 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger
  Cc: Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc, Romain Gantois

Some MAC drivers (e.g. stmmac) require a continuous receive clock signal to
be generated by a PCS that is handled by a standalone PCS driver.

Such a PCS driver does not have access to a PHY device, thus cannot check
the PHY_F_RXC_ALWAYS_ON flag. They cannot check max_requires_rxc in the
phylink config either, since it is a private member. Therefore, a new flag
is needed to signal to the PCS that it should keep the RX clock signal up
at all times.

Suggested-by: Russell King <linux@armlinux.org.uk>
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
 drivers/net/phy/phylink.c | 14 ++++++++++++++
 include/linux/phylink.h   | 11 +++++++++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 851049096488..6fcc0a8ba122 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1042,6 +1042,20 @@ static void phylink_pcs_poll_start(struct phylink *pl)
 		mod_timer(&pl->link_poll, jiffies + HZ);
 }
 
+int phylink_pcs_pre_init(struct phylink *pl, struct phylink_pcs *pcs)
+{
+	int ret = 0;
+
+	/* Signal to PCS driver that MAC requires RX clock for init */
+	if (pl->config->mac_requires_rxc)
+		pcs->rxc_always_on = true;
+
+	if (pcs->ops->pcs_pre_init)
+		ret = pcs->ops->pcs_pre_init(pcs, pl->link_config.interface);
+
+	return ret;
+}
+
 static void phylink_mac_config(struct phylink *pl,
 			       const struct phylink_link_state *state)
 {
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index fcee99632964..71e970271fd3 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -396,6 +396,10 @@ struct phylink_pcs_ops;
  * @phylink: pointer to &struct phylink_config
  * @neg_mode: provide PCS neg mode via "mode" argument
  * @poll: poll the PCS for link changes
+ * @rxc_always_on: The MAC driver requires the reference clock
+ *                 to always be on. Standalone PCS drivers which
+ *                 do not have access to a PHY device can check
+ *                 this instead of PHY_F_RXC_ALWAYS_ON.
  *
  * This structure is designed to be embedded within the PCS private data,
  * and will be passed between phylink and the PCS.
@@ -408,6 +412,7 @@ struct phylink_pcs {
 	struct phylink *phylink;
 	bool neg_mode;
 	bool poll;
+	bool rxc_always_on;
 };
 
 /**
@@ -422,6 +427,8 @@ struct phylink_pcs {
  * @pcs_an_restart: restart 802.3z BaseX autonegotiation.
  * @pcs_link_up: program the PCS for the resolved link configuration
  *               (where necessary).
+ * @pcs_pre_init: configure PCS components necessary for MAC hardware
+ *                initialization e.g. RX clock for stmmac.
  */
 struct phylink_pcs_ops {
 	int (*pcs_validate)(struct phylink_pcs *pcs, unsigned long *supported,
@@ -441,6 +448,8 @@ struct phylink_pcs_ops {
 	void (*pcs_an_restart)(struct phylink_pcs *pcs);
 	void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int neg_mode,
 			    phy_interface_t interface, int speed, int duplex);
+	int (*pcs_pre_init)(struct phylink_pcs *pcs,
+			    phy_interface_t interface);
 };
 
 #if 0 /* For kernel-doc purposes only. */
@@ -568,6 +577,8 @@ void phylink_disconnect_phy(struct phylink *);
 void phylink_mac_change(struct phylink *, bool up);
 void phylink_pcs_change(struct phylink_pcs *, bool up);
 
+int phylink_pcs_pre_init(struct phylink *pl, struct phylink_pcs *pcs);
+
 void phylink_start(struct phylink *);
 void phylink_stop(struct phylink *);
 

-- 
2.43.0


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

* [PATCH net-next v2 3/7] net: stmmac: don't rely on lynx_pcs presence to check for a PHY
  2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
  2024-01-30  9:28 ` [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags Romain Gantois
  2024-01-30  9:28 ` [PATCH net-next v2 2/7] net: phy: add rxc_always_on flag to phylink_pcs Romain Gantois
@ 2024-01-30  9:28 ` Romain Gantois
  2024-01-30  9:28 ` [PATCH net-next v2 4/7] net: stmmac: Support a generic PCS field in mac_device_info Romain Gantois
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Romain Gantois @ 2024-01-30  9:28 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger
  Cc: Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc, Romain Gantois

From: Maxime Chevallier <maxime.chevallier@bootlin.com>

When initializing attached PHYs, there are some cases where we don't expect
any PHY to be connected. The logic uses conditions based on various local
PCS configuration, but also calls-in phylink_expects_phy() via
stmmac_init_phy(), which is enough to ensure we don't try to initialize a
PHY when using a Lynx PCS, as long as we have the phy_interface set to a
802.3z mode and are using inband negociation.

Drop the lynx check, making the stmmac generic code more pcs_lynx-agnostic.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
[rgantois: commit log]
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b334eb16da23..7f0900f53248 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3918,8 +3918,7 @@ static int __stmmac_open(struct net_device *dev,
 	if (priv->hw->pcs != STMMAC_PCS_TBI &&
 	    priv->hw->pcs != STMMAC_PCS_RTBI &&
 	    (!priv->hw->xpcs ||
-	     xpcs_get_an_mode(priv->hw->xpcs, mode) != DW_AN_C73) &&
-	    !priv->hw->lynx_pcs) {
+	     xpcs_get_an_mode(priv->hw->xpcs, mode) != DW_AN_C73)) {
 		ret = stmmac_init_phy(dev);
 		if (ret) {
 			netdev_err(priv->dev,

-- 
2.43.0


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

* [PATCH net-next v2 4/7] net: stmmac: Support a generic PCS field in mac_device_info
  2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
                   ` (2 preceding siblings ...)
  2024-01-30  9:28 ` [PATCH net-next v2 3/7] net: stmmac: don't rely on lynx_pcs presence to check for a PHY Romain Gantois
@ 2024-01-30  9:28 ` Romain Gantois
  2024-01-30  9:28 ` [PATCH net-next v2 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on Romain Gantois
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Romain Gantois @ 2024-01-30  9:28 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger
  Cc: Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc, Romain Gantois

Global stmmac support for early initialization of PCS devices requires a
generic PCS reference that can be passed to phylink_pcs_pre_init().
Currently, the mac_device_info struct contains only one PCS field, which is
specific to the Lynx model.

As PCS models are hardware-specific, it is more appropriate to have a
generic PCS field in the mac_device_info struct.

Refactor the lynx_pcs field into a generic phylink_pcs field.

Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/common.h        | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   | 5 +----
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 721c1f8e892f..318a70d6b330 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -565,7 +565,7 @@ struct mac_device_info {
 	const struct stmmac_mmc_ops *mmc;
 	const struct stmmac_est_ops *est;
 	struct dw_xpcs *xpcs;
-	struct phylink_pcs *lynx_pcs; /* Lynx external PCS */
+	struct phylink_pcs *phylink_pcs;
 	struct mii_regs mii;	/* MII register Addresses */
 	struct mac_link link;
 	void __iomem *pcsr;     /* vpointer to device CSRs */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 68f85e4605cb..12b4a80ea3aa 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -479,9 +479,9 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
 			goto err_dvr_remove;
 		}
 
-		stpriv->hw->lynx_pcs = lynx_pcs_create_mdiodev(pcs_bus, 0);
-		if (IS_ERR(stpriv->hw->lynx_pcs)) {
-			ret = PTR_ERR(stpriv->hw->lynx_pcs);
+		stpriv->hw->phylink_pcs = lynx_pcs_create_mdiodev(pcs_bus, 0);
+		if (IS_ERR(stpriv->hw->phylink_pcs)) {
+			ret = PTR_ERR(stpriv->hw->phylink_pcs);
 			goto err_dvr_remove;
 		}
 	}
@@ -498,7 +498,7 @@ static void socfpga_dwmac_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct stmmac_priv *priv = netdev_priv(ndev);
-	struct phylink_pcs *pcs = priv->hw->lynx_pcs;
+	struct phylink_pcs *pcs = priv->hw->phylink_pcs;
 
 	stmmac_pltfr_remove(pdev);
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7f0900f53248..72e02ef0ee6b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -944,10 +944,7 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
 	if (priv->hw->xpcs)
 		return &priv->hw->xpcs->pcs;
 
-	if (priv->hw->lynx_pcs)
-		return priv->hw->lynx_pcs;
-
-	return NULL;
+	return priv->hw->phylink_pcs;
 }
 
 static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,

-- 
2.43.0


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

* [PATCH net-next v2 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on
  2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
                   ` (3 preceding siblings ...)
  2024-01-30  9:28 ` [PATCH net-next v2 4/7] net: stmmac: Support a generic PCS field in mac_device_info Romain Gantois
@ 2024-01-30  9:28 ` Romain Gantois
  2024-01-30  9:28 ` [PATCH net-next v2 6/7] net: phy: at803x: Avoid hibernating if MAC requires RX clock Romain Gantois
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Romain Gantois @ 2024-01-30  9:28 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger
  Cc: Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc, Clark Wang,
	Romain Gantois

There is a reocurring issue with stmmac controllers where the MAC fails to
initialize its hardware if an RX clock signal isn't provided on the MAC/PHY
link.

This causes issues when PHY or PCS devices either go into suspend while
cutting the RX clock or do not bring the clock signal up early enough for
the MAC to initialize successfully.

Set the mac_requires_rxc flag in the stmmac phylink config so that PHY/PCS
drivers know to keep the RX clock up at all times.

Reported-by: Clark Wang <xiaoning.wang@nxp.com>
Link: https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/
Reported-by: Clément Léger <clement.leger@bootlin.com>
Link: https://lore.kernel.org/linux-arm-kernel/20230116103926.276869-4-clement.leger@bootlin.com/
Suggested-by: Russell King <linux@armlinux.org.uk>
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 72e02ef0ee6b..7345e3fa07c4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1218,6 +1218,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 	priv->phylink_config.type = PHYLINK_NETDEV;
 	priv->phylink_config.mac_managed_pm = true;
 
+	/* Stmmac always requires an RX clock for hardware initialization */
+	priv->phylink_config.mac_requires_rxc = true;
+
 	mdio_bus_data = priv->plat->mdio_bus_data;
 	if (mdio_bus_data)
 		priv->phylink_config.ovr_an_inband =
@@ -3402,6 +3405,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
 	u32 chan;
 	int ret;
 
+	/* Make sure RX clock is enabled */
+	if (priv->hw->phylink_pcs)
+		phylink_pcs_pre_init(priv->phylink, priv->hw->phylink_pcs);
+
 	/* DMA initialization and SW reset */
 	ret = stmmac_init_dma_engine(priv);
 	if (ret < 0) {

-- 
2.43.0


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

* [PATCH net-next v2 6/7] net: phy: at803x: Avoid hibernating if MAC requires RX clock
  2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
                   ` (4 preceding siblings ...)
  2024-01-30  9:28 ` [PATCH net-next v2 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on Romain Gantois
@ 2024-01-30  9:28 ` Romain Gantois
  2024-01-30  9:28 ` [PATCH net-next v2 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it Romain Gantois
  2024-01-30  9:58 ` [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Maxime Chevallier
  7 siblings, 0 replies; 15+ messages in thread
From: Romain Gantois @ 2024-01-30  9:28 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger
  Cc: Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc, Clark Wang,
	Romain Gantois

From: Russell King <linux@armlinux.org.uk>

Stmmac controllers connected to an at803x PHY cannot resume properly after
suspend when WoL is enabled. This happens because the MAC requires an RX
clock generated by the PHY to initialize its hardware properly. But the RX
clock is cut when the PHY suspends and isn't brought up until the MAC
driver resumes the phylink.

Prevent the at803x PHY driver from going into suspend if the attached MAC
driver always requires an RX clock signal.

Reported-by: Clark Wang <xiaoning.wang@nxp.com>
Link: https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/
Signed-off-by: Russell King <linux@armlinux.org.uk>
[rgantois: commit log]
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
 drivers/net/phy/at803x.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 9c07a6cc6e67..5d8d6b89a162 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -895,7 +895,8 @@ static int at803x_hibernation_mode_config(struct phy_device *phydev)
 	/* The default after hardware reset is hibernation mode enabled. After
 	 * software reset, the value is retained.
 	 */
-	if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE))
+	if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE) &&
+	    !(phydev->dev_flags & PHY_F_RXC_ALWAYS_ON))
 		return 0;
 
 	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL,

-- 
2.43.0


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

* [PATCH net-next v2 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it
  2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
                   ` (5 preceding siblings ...)
  2024-01-30  9:28 ` [PATCH net-next v2 6/7] net: phy: at803x: Avoid hibernating if MAC requires RX clock Romain Gantois
@ 2024-01-30  9:28 ` Romain Gantois
  2024-01-30  9:58 ` [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Maxime Chevallier
  7 siblings, 0 replies; 15+ messages in thread
From: Romain Gantois @ 2024-01-30  9:28 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger
  Cc: Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc, Romain Gantois

The GMAC1 controller in the RZN1 IP requires the RX MII clock signal to be
started before it initializes its own hardware, thus before it calls
phylink_start.

Check the rxc_always_on pcs flag and enable the clock signal during the
link validation phase.

Reported-by: Clément Léger <clement.leger@bootlin.com>
Link: https://lore.kernel.org/linux-arm-kernel/20230116103926.276869-4-clement.leger@bootlin.com/
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
 drivers/net/pcs/pcs-rzn1-miic.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
index d93f84fbb1fd..7ca10b7330ef 100644
--- a/drivers/net/pcs/pcs-rzn1-miic.c
+++ b/drivers/net/pcs/pcs-rzn1-miic.c
@@ -279,10 +279,26 @@ static int miic_validate(struct phylink_pcs *pcs, unsigned long *supported,
 	return -EINVAL;
 }
 
+static int miic_pre_init(struct phylink_pcs *pcs,
+			 phy_interface_t interface)
+{
+	int ret = 0;
+
+	/* Start RX clock if required */
+	if (pcs->rxc_always_on) {
+		ret = miic_config(pcs, 0, interface, NULL, false);
+		if (ret)
+			pr_err("Error: Failed to init RX clock in RZN1 MIIC PCS!");
+	}
+
+	return ret;
+}
+
 static const struct phylink_pcs_ops miic_phylink_ops = {
 	.pcs_validate = miic_validate,
 	.pcs_config = miic_config,
 	.pcs_link_up = miic_link_up,
+	.pcs_pre_init = miic_pre_init,
 };
 
 struct phylink_pcs *miic_create(struct device *dev, struct device_node *np)

-- 
2.43.0


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

* Re: [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags
  2024-01-30  9:28 ` [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags Romain Gantois
@ 2024-01-30  9:57   ` Russell King (Oracle)
  2024-01-30 13:55   ` Andrew Lunn
  1 sibling, 0 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2024-01-30  9:57 UTC (permalink / raw)
  To: Romain Gantois
  Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Clément Léger, Maxime Chevallier,
	Miquel Raynal, Thomas Petazzoni, netdev, linux-stm32,
	linux-arm-kernel, linux-renesas-soc

On Tue, Jan 30, 2024 at 10:28:36AM +0100, Romain Gantois wrote:
> From: Russell King <linux@armlinux.org.uk>
> 
> Some MAC controllers (e.g. stmmac) require their connected PHY to
> continuously provide a receive clock signal. This can cause issues in two
> cases:
> 
>   1. The clock signal hasn't been started yet by the time the MAC driver
>      initializes its hardware. This can make the initialization fail, as in
>       the case of the rzn1 GMAC1 driver.
>   2. The clock signal is cut during a power saving event. By the time the
>      MAC is brought back up, the clock signal is still not active since
>      phylink_start hasn't been called yet. This brings us back to case 1.
> 
> If a PHY driver reads this flag, it should ensure that the receive clock
> signal is started as soon as possible, and that it isn't brought down when
> the PHY goes into suspend.
> 
> Signed-off-by: Russell King <linux@armlinux.org.uk>
> [rgantois: commit log]
> Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>

You seem to have combined two of my patches into this one, which touch
two different bits of code. I'm fine with that, but please adjust the
subject line to match the _majority_ of the code that is being touched,
which is phylink (having the prefix net: phylink:), rather than phylib
(having the prefix net: phy:).

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock
  2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
                   ` (6 preceding siblings ...)
  2024-01-30  9:28 ` [PATCH net-next v2 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it Romain Gantois
@ 2024-01-30  9:58 ` Maxime Chevallier
  7 siblings, 0 replies; 15+ messages in thread
From: Maxime Chevallier @ 2024-01-30  9:58 UTC (permalink / raw)
  To: Romain Gantois
  Cc: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger,
	Miquel Raynal, Thomas Petazzoni, netdev, linux-stm32,
	linux-arm-kernel, linux-renesas-soc, Clark Wang

Hello Romain,

On Tue, 30 Jan 2024 10:28:35 +0100
Romain Gantois <romain.gantois@bootlin.com> wrote:

> Hello everyone,
> 
> This is version two of my series that addresses the issue with some MAC/PHY
> combinations. Version one was sent on net, not net-next.
> 
> Notable changes in v2:
>   - Introduced a pcs op for initializing hardware required for MAC
>     initialization, instead of using phylink_validate() for this purpose.
>   - Refactored stmmac to use a generic PCS reference in mac_device_info
>     instead of a model-specific field.

As this impacts the dwmac-socfpga lynx integration, I'd like to give it
a try, I'll be able to give some feedback on that part probably
tomorrow.

Thanks,

Maxime

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

* Re: [PATCH net-next v2 2/7] net: phy: add rxc_always_on flag to phylink_pcs
  2024-01-30  9:28 ` [PATCH net-next v2 2/7] net: phy: add rxc_always_on flag to phylink_pcs Romain Gantois
@ 2024-01-30 10:11   ` Russell King (Oracle)
  2024-01-30 13:40     ` Romain Gantois
  0 siblings, 1 reply; 15+ messages in thread
From: Russell King (Oracle) @ 2024-01-30 10:11 UTC (permalink / raw)
  To: Romain Gantois
  Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Clément Léger, Maxime Chevallier,
	Miquel Raynal, Thomas Petazzoni, netdev, linux-stm32,
	linux-arm-kernel, linux-renesas-soc

On Tue, Jan 30, 2024 at 10:28:37AM +0100, Romain Gantois wrote:
> Some MAC drivers (e.g. stmmac) require a continuous receive clock signal to
> be generated by a PCS that is handled by a standalone PCS driver.
> 
> Such a PCS driver does not have access to a PHY device, thus cannot check
> the PHY_F_RXC_ALWAYS_ON flag. They cannot check max_requires_rxc in the
> phylink config either, since it is a private member. Therefore, a new flag
> is needed to signal to the PCS that it should keep the RX clock signal up
> at all times.
> 
> Suggested-by: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
> ---
>  drivers/net/phy/phylink.c | 14 ++++++++++++++
>  include/linux/phylink.h   | 11 +++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 851049096488..6fcc0a8ba122 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -1042,6 +1042,20 @@ static void phylink_pcs_poll_start(struct phylink *pl)
>  		mod_timer(&pl->link_poll, jiffies + HZ);
>  }
>  
> +int phylink_pcs_pre_init(struct phylink *pl, struct phylink_pcs *pcs)
> +{
> +	int ret = 0;
> +
> +	/* Signal to PCS driver that MAC requires RX clock for init */
> +	if (pl->config->mac_requires_rxc)
> +		pcs->rxc_always_on = true;
> +
> +	if (pcs->ops->pcs_pre_init)
> +		ret = pcs->ops->pcs_pre_init(pcs, pl->link_config.interface);

Given that:
1) phylink supports switching between mutliple different interfaces,
2) from what I can see you are only calling this from stmmac's
   initialisation path,
3) you pass the interface mode to the PCS here

then we don't want the PCS to configure itself for the interface mode
passed in, because this function won't be called when the interface
mode changes - and PCS driver authors will have to bear that in mind.
So...

> diff --git a/include/linux/phylink.h b/include/linux/phylink.h
> index fcee99632964..71e970271fd3 100644
> --- a/include/linux/phylink.h
> +++ b/include/linux/phylink.h
> @@ -422,6 +427,8 @@ struct phylink_pcs {
>   * @pcs_an_restart: restart 802.3z BaseX autonegotiation.
>   * @pcs_link_up: program the PCS for the resolved link configuration
>   *               (where necessary).
> + * @pcs_pre_init: configure PCS components necessary for MAC hardware
> + *                initialization e.g. RX clock for stmmac.

This is fine as a short description.

>   */
>  struct phylink_pcs_ops {
>  	int (*pcs_validate)(struct phylink_pcs *pcs, unsigned long *supported,
> @@ -441,6 +448,8 @@ struct phylink_pcs_ops {
>  	void (*pcs_an_restart)(struct phylink_pcs *pcs);
>  	void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int neg_mode,
>  			    phy_interface_t interface, int speed, int duplex);
> +	int (*pcs_pre_init)(struct phylink_pcs *pcs,
> +			    phy_interface_t interface);

... I would prefer this to be called initial_interface to make it
clear that it's just the initial interface mode.

However, do we really need it - if the PCS is supplying the RXC to
the MAC, then is the interface mode between the PCS and PHY all that
relevant at this point?

Also, please note that this is poor documentation for this function
(encouraged by broken kernel doc not able to properly describe "ops"
structures). See further down in the #if 0..#endif block where each
and every function in this ops structure is fully documented. Please
do the same for any new functions added.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net-next v2 2/7] net: phy: add rxc_always_on flag to phylink_pcs
  2024-01-30 10:11   ` Russell King (Oracle)
@ 2024-01-30 13:40     ` Romain Gantois
  0 siblings, 0 replies; 15+ messages in thread
From: Romain Gantois @ 2024-01-30 13:40 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Romain Gantois, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Torgue,
	Jose Abreu, Maxime Coquelin, Clément Léger,
	Maxime Chevallier, Miquel Raynal, Thomas Petazzoni, netdev,
	linux-stm32, linux-arm-kernel, linux-renesas-soc

Hello Russell,

On Tue, 30 Jan 2024, Russell King (Oracle) wrote:
...
> > +int phylink_pcs_pre_init(struct phylink *pl, struct phylink_pcs *pcs)
> > +{
> > +	int ret = 0;
> > +
> > +	/* Signal to PCS driver that MAC requires RX clock for init */
> > +	if (pl->config->mac_requires_rxc)
> > +		pcs->rxc_always_on = true;
> > +
> > +	if (pcs->ops->pcs_pre_init)
> > +		ret = pcs->ops->pcs_pre_init(pcs, pl->link_config.interface);
> 
> Given that:
> 1) phylink supports switching between mutliple different interfaces,
> 2) from what I can see you are only calling this from stmmac's
>    initialisation path,
> 3) you pass the interface mode to the PCS here
> 
> then we don't want the PCS to configure itself for the interface mode
> passed in, because this function won't be called when the interface
> mode changes - and PCS driver authors will have to bear that in mind.
> So...
> 
...
> However, do we really need it - if the PCS is supplying the RXC to
> the MAC, then is the interface mode between the PCS and PHY all that
> relevant at this point?

If a PCS can set the needed clock signal without configuring the details 
of a particular link mode, then passing the interface mode to pcs_pre_init() 
would indeed not be relevant. Generally, I agree that setting the interface mode 
shouldn't be the concern of the pre-initialization function. I'll dig a bit 
more into the PCS datasheet and run more tests to see if I can get away with 
enabling the RX clock selectively for this particular PCS model. If not, then 
maybe I can hardcode a "default" interface mode for the pre-initialization that 
will not interfere with the rest of the link setup process.

Best Regards,

-- 
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags
  2024-01-30  9:28 ` [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags Romain Gantois
  2024-01-30  9:57   ` Russell King (Oracle)
@ 2024-01-30 13:55   ` Andrew Lunn
  2024-01-30 14:02     ` Russell King (Oracle)
  1 sibling, 1 reply; 15+ messages in thread
From: Andrew Lunn @ 2024-01-30 13:55 UTC (permalink / raw)
  To: Romain Gantois
  Cc: Russell King, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Clément Léger, Maxime Chevallier,
	Miquel Raynal, Thomas Petazzoni, netdev, linux-stm32,
	linux-arm-kernel, linux-renesas-soc

> @@ -768,6 +768,7 @@ struct phy_device {
>  
>  /* Generic phy_device::dev_flags */
>  #define PHY_F_NO_IRQ		0x80000000
> +#define PHY_F_RXC_ALWAYS_ON	BIT(30)

It is a bit odd mixing 0x numbers and BIT() macros for the same class
of thing. I would use 0x40000000, or convert PHY_F_NO_IRQ to BIT(31)
  
	Andrew

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

* Re: [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags
  2024-01-30 13:55   ` Andrew Lunn
@ 2024-01-30 14:02     ` Russell King (Oracle)
  2024-01-31 13:53       ` Andrew Lunn
  0 siblings, 1 reply; 15+ messages in thread
From: Russell King (Oracle) @ 2024-01-30 14:02 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Romain Gantois, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Clément Léger, Maxime Chevallier,
	Miquel Raynal, Thomas Petazzoni, netdev, linux-stm32,
	linux-arm-kernel, linux-renesas-soc

On Tue, Jan 30, 2024 at 02:55:50PM +0100, Andrew Lunn wrote:
> > @@ -768,6 +768,7 @@ struct phy_device {
> >  
> >  /* Generic phy_device::dev_flags */
> >  #define PHY_F_NO_IRQ		0x80000000
> > +#define PHY_F_RXC_ALWAYS_ON	BIT(30)
> 
> It is a bit odd mixing 0x numbers and BIT() macros for the same class
> of thing. I would use 0x40000000, or convert PHY_F_NO_IRQ to BIT(31)

If I used 0x40000000, there would be review comments suggesting the use
of BIT(). Can't win!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags
  2024-01-30 14:02     ` Russell King (Oracle)
@ 2024-01-31 13:53       ` Andrew Lunn
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew Lunn @ 2024-01-31 13:53 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Romain Gantois, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Clément Léger, Maxime Chevallier,
	Miquel Raynal, Thomas Petazzoni, netdev, linux-stm32,
	linux-arm-kernel, linux-renesas-soc

On Tue, Jan 30, 2024 at 02:02:12PM +0000, Russell King (Oracle) wrote:
> On Tue, Jan 30, 2024 at 02:55:50PM +0100, Andrew Lunn wrote:
> > > @@ -768,6 +768,7 @@ struct phy_device {
> > >  
> > >  /* Generic phy_device::dev_flags */
> > >  #define PHY_F_NO_IRQ		0x80000000
> > > +#define PHY_F_RXC_ALWAYS_ON	BIT(30)
> > 
> > It is a bit odd mixing 0x numbers and BIT() macros for the same class
> > of thing. I would use 0x40000000, or convert PHY_F_NO_IRQ to BIT(31)
> 
> If I used 0x40000000, there would be review comments suggesting the use
> of BIT(). Can't win!

No, you cannot win, but at least it would be consistent :-)

    Andrew

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

end of thread, other threads:[~2024-01-31 13:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-30  9:28 [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois
2024-01-30  9:28 ` [PATCH net-next v2 1/7] net: phy: add PHY_F_RXC_ALWAYS_ON to PHY dev flags Romain Gantois
2024-01-30  9:57   ` Russell King (Oracle)
2024-01-30 13:55   ` Andrew Lunn
2024-01-30 14:02     ` Russell King (Oracle)
2024-01-31 13:53       ` Andrew Lunn
2024-01-30  9:28 ` [PATCH net-next v2 2/7] net: phy: add rxc_always_on flag to phylink_pcs Romain Gantois
2024-01-30 10:11   ` Russell King (Oracle)
2024-01-30 13:40     ` Romain Gantois
2024-01-30  9:28 ` [PATCH net-next v2 3/7] net: stmmac: don't rely on lynx_pcs presence to check for a PHY Romain Gantois
2024-01-30  9:28 ` [PATCH net-next v2 4/7] net: stmmac: Support a generic PCS field in mac_device_info Romain Gantois
2024-01-30  9:28 ` [PATCH net-next v2 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on Romain Gantois
2024-01-30  9:28 ` [PATCH net-next v2 6/7] net: phy: at803x: Avoid hibernating if MAC requires RX clock Romain Gantois
2024-01-30  9:28 ` [PATCH net-next v2 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it Romain Gantois
2024-01-30  9:58 ` [PATCH net-next v2 0/7] Fix missing PHY-to-MAC RX clock Maxime Chevallier

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).