mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: theo.lebrun@bootlin.com
Cc: conor.dooley@microchip.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, linux@armlinux.org.uk, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, nb@tipi-net.de,
	pvalerio@redhat.com, vladimir.kondratiev@mobileye.com,
	gregory.clement@bootlin.com, benoit.monin@bootlin.com,
	tawfik.bayouk@mobileye.com, thomas.petazzoni@bootlin.com
Subject: Re: [PATCH net-next v7 1/3] net: macb: cache ENST config across link down/up
Date: Sun, 22 Nov 2026 20:01:31 +0000	[thread overview]
Message-ID: <179537769127.3135.3406600332849226108@kernel.org> (raw)
In-Reply-To: <20261118-macb-set-channels-v7-1-2dbc00f686af@bootlin.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In macb_mac_link_up()
  (drivers/net/ethernet/cadence/macb_main.c:1051), if the link comes…
- [Low] The commit message describes a user-visible defect in the
  existing TAPRIO offload, but the patch has no Fixes: tag.

--

net: macb: cache ENST config across link down/up

This patch caches the TAPRIO/ENST schedule in bp->enst and writes it
again from macb_mac_link_up(). If the link speed has changed, the cached
schedule is dropped instead. It also caches the link speed in
bp->speed_mbps, serialises taprio replace/destroy with bp->mac_cfg_lock,
moves the per-queue config from kmalloc to the stack, and removes the
pm_runtime_suspended() check.

> This causes trouble if the config is not compatible with the new open
> and link-up. The two issues that can occur are a link speed change (as
> all timings are configured in a unit relative to the link speed) or a
> change in the # of queues.

[Severity: Low]
Should this patch have a Fixes: tag?

The behaviour described here goes back to commit 89934dbf169e ("net:
macb: Add TAPRIO traffic scheduling support"). In that code, the ENST
registers are written only from macb_taprio_setup_replace(), using the
link speed at the time of the tc command. Nothing rewrites them on
link-up.

So after the link renegotiates to a different speed, the byte-unit
ON/OFF timings stay in hardware unchanged. The gate windows are then
off by the speed ratio, for example 10x for 1000 -> 100. If register
state is lost across close/open, the schedule silently stops being
enforced.

This patch depends on newer infrastructure (bp->mac_cfg_lock,
bp->link_up), so it may not backport as-is. Even so, would a Fixes: tag,
or a note on why this is net-next only, help record that released
kernels have this problem?

> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 9f6111661b40d..1e06666921160 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c

[ ... ]

> @@ -1009,6 +1048,15 @@ static void macb_mac_link_up(struct phylink_config *config,
>  
>  	spin_unlock_irqrestore(&bp->lock, flags);
>  
> +	if (bp->enst.speed_mbps && speed != bp->enst.speed_mbps) {
> +		netdev_warn(bp->netdev,
> +			    "TAPRIO dropped because link speed changed\n");
> +
> +		memset(&bp->enst, 0, sizeof(bp->enst));
> +	}
> +
> +	macb_apply_enst_config(bp);
> +

[Severity: Medium]
What happens to the installed taprio qdisc when this branch is taken?

If the link comes back up at a speed other than bp->enst.speed_mbps,
the cache is zeroed. macb_apply_enst_config() then writes the disable
bits for every queue into ENST_CONTROL and zeroes each queue's
ENST_START_TIME, ENST_ON_TIME and ENST_OFF_TIME.

The taprio layer is not told about this. The qdisc stays installed in
full offload mode, so tc keeps reporting a hardware-enforced gate
schedule that the MAC no longer applies.

The schedule also does not come back if the link returns to its
original speed. Take 1000 -> 100 -> 1000: after the first change,
bp->enst.speed_mbps is 0, so this check is skipped and the zeroed cache
is applied again. Gating stays off until the user reinstalls the qdisc.

Nothing can recompute the schedule later, because struct macb_enst only
stores byte units. macb_taprio_setup_replace() converts the nanosecond
values and then throws them away:

    config.queues[queue_id].on_time_bytes =
        enst_ns_to_hw_units(entry->interval, bp->speed_mbps);
    config.queues[queue_id].off_time_bytes =
        enst_ns_to_hw_units(off, bp->speed_mbps);

Could entry->interval and off be cached in nanoseconds instead? Link-up
could then recompute the byte values for the new speed with
enst_ns_to_hw_units() and check them again against
enst_max_hw_interval(). A lower speed only raises the hardware limit,
so the schedule would only have to be dropped when it really no longer
fits.

The later patches in this series that add set_channels and the Tx SRAM
segment distribution do not change this path.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-macb-set-channels-v7-0-2dbc00f686af%40bootlin.com

  parent reply	other threads:[~2026-11-22 20:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 20:53 [PATCH net-next v7 0/3] net: macb: implement ethtool set channels count operation Théo Lebrun
2026-11-18 20:53 ` [PATCH net-next v7 1/3] net: macb: cache ENST config across link down/up Théo Lebrun
2026-11-19 11:49   ` Nicolai Buchwitz
2026-11-19 12:36   ` Vineeth Karumanchi
2026-11-19 15:40     ` Théo Lebrun
2026-11-19 16:10       ` Théo Lebrun
2026-11-20  6:44       ` Vineeth Karumanchi
2026-11-22 20:01   ` netdev-bot+sashiko [this message]
2026-11-18 20:53 ` [PATCH net-next v7 2/3] net: macb: implement ethtool_ops.get|set_channels() Théo Lebrun
2026-11-19 11:54   ` Nicolai Buchwitz
2026-11-19 16:19     ` Théo Lebrun
2026-11-22 20:01   ` netdev-bot+sashiko
2026-11-18 20:53 ` [PATCH net-next v7 3/3] net: macb: distribute evenly Tx SRAM segments Théo Lebrun
2026-11-19 11:45   ` Nicolai Buchwitz
2026-11-22 20:01   ` netdev-bot+sashiko

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=179537769127.3135.3406600332849226108@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=benoit.monin@bootlin.com \
    --cc=conor.dooley@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pvalerio@redhat.com \
    --cc=tawfik.bayouk@mobileye.com \
    --cc=theo.lebrun@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vladimir.kondratiev@mobileye.com \
    /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

all inboxes | Powered by JetHome®