Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Muhammad Nazim Amirul Nazle Asmade <muhammad.nazim.amirul.nazle.asmade@altera.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"maxime.chevallier@bootlin.com" <maxime.chevallier@bootlin.com>,
	"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"robh@kernel.org" <robh@kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"dinguyen@kernel.org" <dinguyen@kernel.org>,
	"mcoquelin.stm32@gmail.com" <mcoquelin.stm32@gmail.com>,
	"alexandre.torgue@foss.st.com" <alexandre.torgue@foss.st.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-stm32@st-md-mailman.stormreply.com"
	<linux-stm32@st-md-mailman.stormreply.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v2 2/2] net: stmmac: dwmac-socfpga: Add support for Agilex5 TSN GMAC with FPGA converter
Date: Wed, 2 Dec 2026 01:28:14 +0000	[thread overview]
Message-ID: <1dd8730b-edb6-4c54-87e6-f39bfdbcb4e2@altera.com> (raw)
In-Reply-To: <20261110200844.2190972-1-kuba@kernel.org>

On 11/11/2026 4:08 am, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
> net: stmmac: dwmac-socfpga: Add support for Agilex5 TSN GMAC with FPGA converter
> 
> This adds the "altr,socfpga-stmmac-agilex5-tsn" compatible for Agilex5
> boards where an FPGA GMII-to-RGMII converter between the MAC and the PHY
> supplies the RGMII delays. socfpga_get_plat_phymode() now returns a new
> mac_interface field. The new setup_plat_dat callback forces that field
> to GMII and rewrites any RGMII phy_interface to plain RGMII.
> 
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
>> index 6d4bc1fe8f751..131d2a98c863f 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
> 
> [ ... ]
> 
>>   static phy_interface_t socfpga_get_plat_phymode(struct socfpga_dwmac *dwmac)
>>   {
>> -	return dwmac->plat_dat->phy_interface;
>> +	return dwmac->mac_interface;
>>   }
> 
> [Severity: Low]
> This isn't a bug, but socfpga_gen5_set_phy_mode() and
> socfpga_gen10_set_phy_mode() both still have this comment:
> 
> 	/* Overwrite val to GMII if splitter core is enabled. The phymode here
> 	 * is the actual phy mode on phy hardware, but phy interface from
> 	 * EMAC core is GMII.
> 	 */
> 
> After this change, phymode comes from dwmac->mac_interface, which is the
> MAC-side mode. For the agilex5-tsn compatible it is GMII while the PHY
> runs RGMII, so the comment now says the opposite of what phymode holds.
> 
> Should the comment be updated to match the new meaning? The same applies
> to the name socfpga_get_plat_phymode().
Agreed. For the splitter case mac_interface is still the DT phy-mode, so
the code is fine, but the name and comment are misleading now. In v3 I
will rename it to socfpga_get_mac_interface() and update both comments.
> 
> [ ... ]
> 
>> @@ -673,10 +676,28 @@ static const struct socfpga_dwmac_ops socfpga_agilex5_ops = {
>>   	.setup_plat_dat = socfpga_agilex5_setup_plat_dat,
>>   };
>>   
>> +static void socfpga_agilex5_tsn_gmac_setup_plat_dat(struct socfpga_dwmac *dwmac)
>> +{
>> +	struct plat_stmmacenet_data *plat_dat = dwmac->plat_dat;
>> +
>> +	socfpga_agilex5_setup_plat_dat(dwmac);
>> +
>> +	/* FPGA converter supplies RGMII delays; MAC uses GMII, PHY gets plain RGMII */
>> +	dwmac->mac_interface = PHY_INTERFACE_MODE_GMII;
> 
> [Severity: Medium]
> mac_interface is forced to GMII for every phy-mode. phy_interface is only
> rewritten for RGMII variants. What happens with phy-mode "sgmii" or
> "1000base-x"? The altr,socfpga-stmmac.yaml phy-mode enum allows both for
> this compatible.
> 
> In that case socfpga_get_plat_phymode() returns GMII.
> socfpga_dwmac_fix_mac_speed() then disables the SGMII adapter on every
> link-up and never turns it back on:
> 
> 	if (sgmii_adapter_base)
> 		socfpga_sgmii_config(dwmac, false);
> 	...
> 	if ((phymode == PHY_INTERFACE_MODE_SGMII ||
> 	     phymode == PHY_INTERFACE_MODE_1000BASEX) && sgmii_adapter_base)
> 		socfpga_sgmii_config(dwmac, true);
> 
> socfpga_gen10_set_phy_mode() also skips its final enable:
> 
> 	if (phymode == PHY_INTERFACE_MODE_SGMII)
> 		socfpga_sgmii_config(dwmac, true);
> 
> Meanwhile phylink and the Lynx PCS keep using the DT mode. The
> GMII-to-SGMII adapter would stay disabled while an SGMII or 1000base-x
> link comes up, and nothing reports the problem.
> 
> Should the GMII override also be guarded by phy_interface_mode_is_rgmii()?
Hm yes this should be a valid point as well, will update in v3 so the 
TSN setup will only apply to RGMII phy-modes. SGMII and 1000base-x will 
keep the standard Agilex5 behaviour.
> The other option would be to reject non-RGMII modes for this compatible.
> 
>> +	if (phy_interface_mode_is_rgmii(plat_dat->phy_interface))
>> +		plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII;
> 
> [Severity: Medium]
> If the converter always adds both the TX and RX delays, rgmii-id seems to
> be the only phy-mode that describes the board consistently. Is that
> right?
> 
> "rgmii", "rgmii-txid" and "rgmii-rxid" each describe the PCB as providing
> the delay in at least one direction. The converter would then add its
> delay on top of that. This code rewrites all of them to plain RGMII
> without a warning, so the link could fail with no diagnostic.
> 
> The stmmac core already handles MACs with fixed internal delays. With
> plat_dat->has_internal_tx_delay and has_internal_rx_delay set (as
> dwmac-ultrarisc.c does), stmmac_pltfr_probe() runs:
> 
> 	if (plat->has_internal_tx_delay || plat->has_internal_rx_delay) {
> 		plat->phy_interface =
> 			phy_fix_phy_mode_for_mac_delays(plat->phy_interface,
> 							plat->has_internal_tx_delay,
> 							plat->has_internal_rx_delay);
> 		if (plat->phy_interface == PHY_INTERFACE_MODE_NA)
> 			return dev_err_probe(&pdev->dev, -EINVAL,
> 					     "unsupported phy interface mode\n");
> 	}
> 
> When both delays are set, phy_fix_phy_mode_for_mac_delays() maps rgmii-id
> to rgmii and returns PHY_INTERFACE_MODE_NA for the other three modes:
> 
> 	if (mac_txid && mac_rxid) {
> 		if (interface == PHY_INTERFACE_MODE_RGMII_ID)
> 			return PHY_INTERFACE_MODE_RGMII;
> 		return PHY_INTERFACE_MODE_NA;
> 	}
> 
> Documentation/devicetree/bindings/net/ethernet-controller.yaml says this
> about MACs with hard coded delays:
> 
>    It does however mean that a 'phy-mode' of 'rgmii' is now invalid, it
>    cannot be supported, [...] Thus the MAC should report a fatal error for
>    any modes which cannot be supported.
> 
> Could has_internal_tx_delay and has_internal_rx_delay replace the
> open-coded rewrite here? Then inconsistent phy-modes would be rejected at
> probe time.
  In v3 I will set has_internal_tx_delay and has_internal_rx_delay 
instead of rewriting phy_interface, so the stmmac core maps "rgmii-id" 
to "rgmii" for the PHY and rejects "rgmii",
"rgmii-txid" and "rgmii-rxid" at probe time.
> 
>> +}
>> +
>> +static const struct socfpga_dwmac_ops socfpga_agilex5_tsn_gmac_ops = {
>> +	.set_phy_mode = socfpga_gen10_set_phy_mode,
>> +	.setup_plat_dat = socfpga_agilex5_tsn_gmac_setup_plat_dat,
>> +};
> 
> [ ... ]

Hi Jakub,

Really sorry for the late reply, will re-base and address all above in v3.

Thanks,
Nazim


      reply	other threads:[~2026-12-02  1:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  4:03 [PATCH net-next v2 0/2] net: stmmac: dwmac-socfpga: Add Agilex5 TSN GMAC support muhammad.nazim.amirul.nazle.asmade
2026-11-04  4:03 ` [PATCH net-next v2 1/2] dt-bindings: net: altr,socfpga-stmmac: Add altr,socfpga-stmmac-agilex5-tsn compatible muhammad.nazim.amirul.nazle.asmade
2026-11-19 21:03   ` Rob Herring (Arm)
2026-11-04  4:03 ` [PATCH net-next v2 2/2] net: stmmac: dwmac-socfpga: Add support for Agilex5 TSN GMAC with FPGA converter muhammad.nazim.amirul.nazle.asmade
2026-11-10 20:08   ` Jakub Kicinski
2026-12-02  1:28     ` Muhammad Nazim Amirul Nazle Asmade [this message]

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=1dd8730b-edb6-4c54-87e6-f39bfdbcb4e2@altera.com \
    --to=muhammad.nazim.amirul.nazle.asmade@altera.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dinguyen@kernel.org \
    --cc=edumazet@google.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@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