Devicetree
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v7 08/10] net: airoha: Do not stop GDM port if it is shared
Date: Tue, 19 May 2026 00:12:36 +0200	[thread overview]
Message-ID: <aguO1JODHEKFnsyk@lore-desk> (raw)
In-Reply-To: <20260517055814.DB1F8C2BCB0@smtp.kernel.org>

[-- Attachment #1: Type: text/plain, Size: 3014 bytes --]

On May 17, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Flawed hardware MTU recalculation logic in airoha_dev_change_mtu() for shared GDM ports
> --
> 
> commit 28e02ac4611575e19c4f6eef3fa74c11d4debb6e
> Author: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> net: airoha: Do not stop GDM port if it is shared
> 
> This commit updates the driver to allow multiple devices to share the same
> GDM port. It stops the port only when no other devices are using it and
> adjusts the hardware MTU to accommodate all active devices.
> 
> > diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> > index 8558790eca644..c70e3ace38e25 100644
> > --- a/drivers/net/ethernet/airoha/airoha_eth.c
> > +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> 
> [ ... ]
> 
> > @@ -1917,13 +1945,18 @@ static void airoha_dev_get_stats64(struct net_device *netdev,
> >  static int airoha_dev_change_mtu(struct net_device *netdev, int mtu)
> >  {
> >  	struct airoha_gdm_dev *dev = netdev_priv(netdev);
> > +	u32 cur_len, len = ETH_HLEN + mtu + ETH_FCS_LEN;
> >  	struct airoha_gdm_port *port = dev->port;
> > -	u32 len = ETH_HLEN + mtu + ETH_FCS_LEN;
> >  	struct airoha_eth *eth = dev->eth;
> >  
> > -	airoha_fe_rmw(eth, REG_GDM_LEN_CFG(port->id),
> > -		      GDM_LONG_LEN_MASK,
> > -		      FIELD_PREP(GDM_LONG_LEN_MASK, len));
> > +	cur_len = airoha_fe_get(eth, REG_GDM_LEN_CFG(port->id),
> > +				GDM_LONG_LEN_MASK);
> > +	if (len > cur_len || !port->users ||
> > +	    (port->users == 1 && netif_running(netdev)))
> > +		airoha_fe_rmw(eth, REG_GDM_LEN_CFG(port->id),
> > +			      GDM_LONG_LEN_MASK,
> > +			      FIELD_PREP(GDM_LONG_LEN_MASK, len));
> > +
> 
> The commit message states that the driver must "always set in GDM_LONG_LEN_MASK
> field of REG_GDM_LEN_CFG register the maximum MTU of all running net_devices
> connected to the same GDM port."
> 
> Does this logic successfully recalculate the MTU when the MTU of a running
> device is decreased while sibling devices are also running? In that scenario,
> len > cur_len evaluates to false, which appears to skip the update and leave
> the hardware MTU stuck at the previous larger value.
> 
> Additionally, if an administratively down device has its MTU increased,
> len > cur_len can evaluate to true. Does this prematurely increase the
> hardware MTU, exposing the running sibling devices to larger frames based
> on a stopped device's configuration?
> 
> Would it be more accurate to iterate over the devices to compute the
> actual maximum MTU of all active devices here, similar to the approach taken
> in airoha_dev_stop()?

ack, I will fix it in v8.

Regards,
Lorenzo

> 
> >  	WRITE_ONCE(netdev->mtu, mtu);
> >  
> >  	return 0;
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260516-airoha-eth-multi-serdes-v7-0-99e0093303e2@kernel.org?part=8

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-05-18 22:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-16  5:57 [PATCH net-next v7 00/10] net: airoha: Support multiple net_devices connected to the same GDM port Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 01/10] dt-bindings: net: airoha: Add EN7581 ethernet-ports properties Lorenzo Bianconi
2026-05-17  5:58   ` sashiko-bot
2026-05-18 20:39     ` Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 02/10] net: airoha: Introduce airoha_gdm_dev struct Lorenzo Bianconi
2026-05-17  5:58   ` sashiko-bot
2026-05-18 20:59     ` Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 03/10] net: airoha: Move airoha_qdma pointer in " Lorenzo Bianconi
2026-05-17  5:58   ` sashiko-bot
2026-05-19  8:21     ` Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 04/10] net: airoha: Rely on airoha_gdm_dev pointer in airoha_is_lan_gdm_port() Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 05/10] net: airoha: Move qos_sq_bmap in airoha_gdm_dev struct Lorenzo Bianconi
2026-05-17  5:58   ` sashiko-bot
2026-05-19  8:23     ` Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 06/10] net: airoha: Move {cpu,fwd}_tx_packets " Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 07/10] net: airoha: Support multiple net_devices for a single FE GDM port Lorenzo Bianconi
2026-05-17  5:58   ` sashiko-bot
2026-05-18 21:28     ` Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 08/10] net: airoha: Do not stop GDM port if it is shared Lorenzo Bianconi
2026-05-17  5:58   ` sashiko-bot
2026-05-18 22:12     ` Lorenzo Bianconi [this message]
2026-05-16  5:57 ` [PATCH net-next v7 09/10] net: airoha: Introduce WAN device flag Lorenzo Bianconi
2026-05-16  5:57 ` [PATCH net-next v7 10/10] net: airoha: Support multiple LAN/WAN interfaces for hw MAC address configuration Lorenzo Bianconi
2026-05-17  5:58   ` sashiko-bot
2026-05-19  8:37     ` Lorenzo Bianconi

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=aguO1JODHEKFnsyk@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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