* [PATCH net v3 1/2] net: phy: move DECLARE_PHY_INTERFACE_MASK_ZERO to core
2026-11-02 21:25 [PATCH net v3 0/2] net: phy: fix PHY interface mask initialization and XPCS usage Coia Prant
@ 2026-11-02 21:25 ` Coia Prant
2026-11-02 21:25 ` [PATCH net v3 2/2] net: pcs: xpcs: make supported_interfaces authoritative Coia Prant
2026-11-02 21:28 ` [PATCH net v3 0/2] net: phy: fix PHY interface mask initialization and XPCS usage netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: Coia Prant @ 2026-11-02 21:25 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Jiawen Wu, Mengyuan Lou, Andrew Lunn, David S . Miller,
Eric Dumazet, Paolo Abeni, Heiner Kallweit, Russell King,
Heiko Stuebner, Aleksandr Loktionov, Fabio Baltieri, netdev,
linux-rockchip, linux-arm-kernel, linux-kernel, Coia Prant
The txgbe driver currently defines DECLARE_PHY_INTERFACE_MASK_ZERO()
locally, but incorrectly uses PHY_INTERFACE_MODE_MAX as the array
length instead of BITS_TO_LONGS().
Move the macro to include/linux/phy.h and use
DECLARE_PHY_INTERFACE_MASK() to properly size the bitmap, while still
zeroing the stack variable.
Fixes: 47f848aac4e7 ("net: txgbe: initialize PHY interface to 0")
Signed-off-by: Coia Prant <coiaprant@gmail.com>
---
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h | 3 ---
include/linux/phy.h | 3 +++
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
index 757d1ce8d3ad..8071464c7b90 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
@@ -315,9 +315,6 @@ void txgbe_up(struct wx *wx);
int txgbe_setup_tc(struct net_device *dev, u8 tc);
void txgbe_do_reset(struct net_device *netdev, bool reinit);
-#define DECLARE_PHY_INTERFACE_MASK_ZERO(name) \
- unsigned long name[PHY_INTERFACE_MODE_MAX] = { 0, }
-
#define TXGBE_LINK_SPEED_UNKNOWN 0
#define TXGBE_LINK_SPEED_10GB_FULL 4
#define TXGBE_LINK_SPEED_25GB_FULL 0x10
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 21afc2082b17..43aba23109fa 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -159,6 +159,9 @@ typedef enum {
#define DECLARE_PHY_INTERFACE_MASK(name) \
DECLARE_BITMAP(name, PHY_INTERFACE_MODE_MAX)
+#define DECLARE_PHY_INTERFACE_MASK_ZERO(name) \
+ DECLARE_PHY_INTERFACE_MASK(name) = { 0, }
+
static inline void phy_interface_zero(unsigned long *intf)
{
bitmap_zero(intf, PHY_INTERFACE_MODE_MAX);
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net v3 2/2] net: pcs: xpcs: make supported_interfaces authoritative
2026-11-02 21:25 [PATCH net v3 0/2] net: phy: fix PHY interface mask initialization and XPCS usage Coia Prant
2026-11-02 21:25 ` [PATCH net v3 1/2] net: phy: move DECLARE_PHY_INTERFACE_MASK_ZERO to core Coia Prant
@ 2026-11-02 21:25 ` Coia Prant
2026-11-02 21:28 ` [PATCH net v3 0/2] net: phy: fix PHY interface mask initialization and XPCS usage netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: Coia Prant @ 2026-11-02 21:25 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Jiawen Wu, Mengyuan Lou, Andrew Lunn, David S . Miller,
Eric Dumazet, Paolo Abeni, Heiner Kallweit, Russell King,
Heiko Stuebner, Aleksandr Loktionov, Fabio Baltieri, netdev,
linux-rockchip, linux-arm-kernel, linux-kernel, Coia Prant
pcs.supported_interfaces is the mask of interfaces a given xpcs
instance actually supports. The compat table describes what the
Synopsys IP can do in general, but a specific integration may support
a different subset: the RK3568 XPCS supports 1000BASE-X, SGMII and
QSGMII in hardware, but does not implement the C73, 10GBASE-R or 2500BASE-X
modes that the Synopsys compat table advertises.
However, xpcs_find_compat() only walks desc->compat[] and does not look
at pcs.supported_interfaces. If a caller ever passes an interface
outside the mask, the core would still find and configure a compat
entry for it, contradicting the mask the glue already set. This was a
known gap: the mask was written but never consulted by the core.
Fix both sides:
- In xpcs_find_compat(), return NULL when the interface is not in
pcs.supported_interfaces, so the mask is authoritative for what the
core will configure.
- In the Rockchip glue, build a platform mask with the three modes
supported by RK3568 (1000BASE-X, SGMII, QSGMII) and intersect it
with the core's supported_interfaces using phy_interface_and().
This narrows the mask inherited from the generic compat table so it
reflects the actual SoC capabilities.
This is a logical inconsistency rather than a user-visible bug in a
released kernel: the affected Rockchip platform is not present in any
released version, and the MAC side forces the phy mode, so phylink does
not normally pass an interface outside the mask. The patch makes the
mask the single source of truth for both the core and the glue.
Fixes: b9e7cb89aac8 ("net: pcs: xpcs: add Rockchip RK3568 platform glue driver")
Signed-off-by: Coia Prant <coiaprant@gmail.com>
---
drivers/net/pcs/pcs-xpcs-rk.c | 10 ++++++++++
drivers/net/pcs/pcs-xpcs.c | 3 +++
2 files changed, 13 insertions(+)
diff --git a/drivers/net/pcs/pcs-xpcs-rk.c b/drivers/net/pcs/pcs-xpcs-rk.c
index 6f0a110e32d2..25fdc9c6b72c 100644
--- a/drivers/net/pcs/pcs-xpcs-rk.c
+++ b/drivers/net/pcs/pcs-xpcs-rk.c
@@ -483,6 +483,7 @@ struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int
struct platform_device *pdev;
struct dw_xpcs_rk *pxpcs;
struct dw_xpcs *xpcs;
+ DECLARE_PHY_INTERFACE_MASK_ZERO(supported_interfaces);
if (!of_device_is_available(pcs))
return ERR_PTR(-ENODEV);
@@ -536,6 +537,15 @@ struct dw_xpcs *xpcs_rk_create(struct device *dev, struct device_node *pcs, int
return xpcs;
}
+ /*
+ * The RK3568 XPCS supports 1000BASE-X, SGMII and QSGMII.
+ */
+ __set_bit(PHY_INTERFACE_MODE_1000BASEX, supported_interfaces);
+ __set_bit(PHY_INTERFACE_MODE_SGMII, supported_interfaces);
+ __set_bit(PHY_INTERFACE_MODE_QSGMII, supported_interfaces);
+ phy_interface_and(xpcs->pcs.supported_interfaces, xpcs->pcs.supported_interfaces,
+ supported_interfaces);
+
xpcs_config_eee_mult_fact(xpcs, pxpcs->eee_mult_fact);
put_device(&pdev->dev);
return xpcs;
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 6466e0ff2a98..46878a66064e 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -169,6 +169,9 @@ xpcs_find_compat(struct dw_xpcs *xpcs, phy_interface_t interface)
{
const struct dw_xpcs_compat *compat;
+ if (!test_bit(interface, xpcs->pcs.supported_interfaces))
+ return NULL;
+
for (compat = xpcs->desc->compat; compat->supported; compat++)
if (compat->interface == interface)
return compat;
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net v3 0/2] net: phy: fix PHY interface mask initialization and XPCS usage
2026-11-02 21:25 [PATCH net v3 0/2] net: phy: fix PHY interface mask initialization and XPCS usage Coia Prant
2026-11-02 21:25 ` [PATCH net v3 1/2] net: phy: move DECLARE_PHY_INTERFACE_MASK_ZERO to core Coia Prant
2026-11-02 21:25 ` [PATCH net v3 2/2] net: pcs: xpcs: make supported_interfaces authoritative Coia Prant
@ 2026-11-02 21:28 ` netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-02 21:28 UTC (permalink / raw)
To: Coia Prant
Cc: Jakub Kicinski, Jiawen Wu, Mengyuan Lou, Andrew Lunn,
David S . Miller, Eric Dumazet, Paolo Abeni, Heiner Kallweit,
Russell King, Heiko Stuebner, Aleksandr Loktionov, Fabio Baltieri,
netdev, linux-rockchip, linux-arm-kernel, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by code inspection). If it was triggered please include
the symptoms, like the stack trace or error messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread