From: Jakub Kicinski <kuba@kernel.org>
To: rmk+kernel@armlinux.org.uk
Cc: Jakub Kicinski <kuba@kernel.org>,
linux-phy@lists.infradead.org, davem@davemloft.net,
maxime.chevallier@bootlin.com, alexandre.torgue@foss.st.com,
mohd.anwar@oss.qualcomm.com, neil.armstrong@linaro.org,
hkallweit1@gmail.com, mcoquelin.stm32@gmail.com,
netdev@vger.kernel.org, edumazet@google.com,
linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, vkoul@kernel.org,
andrew@lunn.ch, pabeni@redhat.com, andrew+netdev@lunn.ch,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [net-next,12/14] net: stmmac: add support for reading inband SGMII status
Date: Mon, 19 Jan 2026 11:21:35 -0800 [thread overview]
Message-ID: <20260119192135.1245138-1-kuba@kernel.org> (raw)
In-Reply-To: <E1vhoSr-00000005H2N-2H2L@rmk-PC.armlinux.org.uk>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: stmmac: add support for reading inband SGMII status
This patch adds support for reading link status, speed, and duplex for
SGMII links from the RGSMII status register. New fields are added to
stmmac_pcs_info and stmmac_pcs structures for the register offset and mask.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
> index 73fc56ce5e55..9dd7e78cfbc4 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
[ ... ]
> @@ -111,7 +121,37 @@ static void dwmac_integrated_pcs_get_state(struct phylink_pcs *pcs,
>
> phylink_mii_c22_pcs_decode_state(state, neg_mode, status, lpa);
> } else {
> - state->link = false;
> + rgsmii = field_get(spcs->rgsmii_status_mask,
> + readl(spcs->rgsmii));
^^^^
When dwmac1000_pcs_init() or dwmac4_pcs_init() is used, the pcs_info
structures do not initialize the new rgsmii_offset and rgsmii_status_mask
fields. For example, dwmac4_pcs_info in dwmac4_core.c only sets:
static const struct stmmac_pcs_info dwmac4_pcs_info = {
.pcs_offset = GMAC_PCS_BASE,
.int_mask = GMAC_INT_PCS_LINK | GMAC_INT_PCS_ANE,
};
This leaves rgsmii_status_mask implicitly zero. Calling field_get() with a
mask of zero violates its API contract (mask must be non-zero) and results
in undefined behavior from __ffs(0).
Should the existing dwmac1000_pcs_info and dwmac4_pcs_info structures be
updated to provide proper values for the new fields? Or should there be a
guard check before calling field_get() when rgsmii_status_mask is zero?
> +
> + state->link = status & BMSR_LSTATUS &&
> + rgsmii & GMAC_RGSMIII_LNKSTS;
[ ... ]
> @@ -205,6 +245,8 @@ int stmmac_integrated_pcs_init(struct stmmac_priv *priv,
>
> spcs->priv = priv;
> spcs->base = priv->ioaddr + pcs_info->pcs_offset;
> + spcs->rgsmii = priv->ioaddr + pcs_info->rgsmii_offset;
> + spcs->rgsmii_status_mask = pcs_info->rgsmii_status_mask;
The values are copied from pcs_info here, but dwmac1000_pcs_info and
dwmac4_pcs_info do not initialize these fields.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
> index a7c71f40f952..f9e7a7ed840b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
> @@ -29,12 +29,16 @@ struct stmmac_priv;
>
> struct stmmac_pcs_info {
> unsigned int pcs_offset;
> + unsigned int rgsmii_offset;
> + u32 rgsmii_status_mask;
> u32 int_mask;
> };
These new fields need to be initialized by all users of stmmac_pcs_info.
next prev parent reply other threads:[~2026-01-19 19:23 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-19 12:32 [PATCH net-next 00/14] net: stmmac: SerDes, PCS, BASE-X, and inband goodies Russell King (Oracle)
2026-01-19 12:33 ` [PATCH net-next 01/14] net: stmmac: qcom-ethqos: remove mac_base Russell King (Oracle)
2026-01-19 13:59 ` Bartosz Golaszewski
2026-01-19 12:33 ` [PATCH net-next 02/14] net: stmmac: qcom-ethqos: convert to set_clk_tx_rate() method Russell King (Oracle)
2026-01-19 14:00 ` Bartosz Golaszewski
2026-01-19 12:33 ` [PATCH net-next 03/14] phy: qcom-sgmii-eth: add .set_mode() and .validate() methods Russell King (Oracle)
2026-01-19 14:00 ` Bartosz Golaszewski
2026-01-21 7:10 ` Vinod Koul
2026-01-19 12:33 ` [PATCH net-next 04/14] net: stmmac: wrap phylink's rx_clk_stop functions Russell King (Oracle)
2026-01-19 12:34 ` [PATCH net-next 05/14] net: stmmac: add stmmac core serdes support Russell King (Oracle)
2026-01-19 19:21 ` [net-next,05/14] " Jakub Kicinski
2026-01-20 5:04 ` Russell King (Oracle)
2026-01-20 8:18 ` Vladimir Oltean
2026-01-20 10:12 ` Russell King (Oracle)
2026-01-20 12:11 ` Vladimir Oltean
2026-01-21 14:46 ` Russell King (Oracle)
2026-01-21 16:23 ` Vladimir Oltean
2026-01-21 17:33 ` Russell King (Oracle)
2026-01-22 11:29 ` Vladimir Oltean
2026-01-20 8:42 ` Vladimir Oltean
2026-01-20 10:14 ` Russell King (Oracle)
2026-01-20 23:32 ` Jakub Kicinski
2026-01-19 12:34 ` [PATCH net-next 06/14] net: stmmac: qcom-ethqos: convert to dwmac generic SerDes support Russell King (Oracle)
2026-01-19 12:34 ` [PATCH net-next 07/14] net: stmmac: move most PCS register definitions to stmmac_pcs.c Russell King (Oracle)
2026-01-19 12:34 ` [PATCH net-next 08/14] net: stmmac: handle integrated PCS phy_intf_sel separately Russell King (Oracle)
2026-01-19 12:34 ` [PATCH net-next 09/14] net: stmmac: add BASE-X support to integrated PCS Russell King (Oracle)
2026-01-19 12:34 ` [PATCH net-next 10/14] net: stmmac: use integrated PCS for BASE-X modes Russell King (Oracle)
2026-01-19 13:20 ` Maxime Chevallier
2026-01-19 12:34 ` [PATCH net-next 11/14] net: stmmac: add struct stmmac_pcs_info Russell King (Oracle)
2026-01-19 13:23 ` Maxime Chevallier
2026-01-19 12:34 ` [PATCH net-next 12/14] net: stmmac: add support for reading inband SGMII status Russell King (Oracle)
2026-01-19 19:21 ` Jakub Kicinski [this message]
2026-01-19 12:34 ` [PATCH net-next 13/14] net: stmmac: configure SGMII AN control according to phylink Russell King (Oracle)
2026-01-19 12:34 ` [PATCH net-next 14/14] net: stmmac: report PCS configuration changes Russell King (Oracle)
2026-01-19 14:27 ` Russell King (Oracle)
-- strict thread matches above, loose matches on Subject: below --
2026-01-14 17:46 [PATCH net-next 12/14] net: stmmac: add support for reading inband SGMII status Russell King (Oracle)
2026-01-16 2:58 ` [net-next,12/14] " Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260119192135.1245138-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mohd.anwar@oss.qualcomm.com \
--cc=neil.armstrong@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox