The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: <netdev-bot+sashiko@kernel.org>
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: Mon, 23 Nov 2026 16:37:56 +0100	[thread overview]
Message-ID: <DN2PANJIGO0C.14LOQ76W0VAJS@bootlin.com> (raw)
In-Reply-To: <179537769127.3135.3406600332849226108@kernel.org>

Hello netdev-bot+sashiko,

On Sun Nov 22, 2026 at 9:01 PM CET,  wrote:
> 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.

[...]

Yes, I'll add a 'Fixes' trailer to reference the old commit but I'll
mark it as 'Cc: stable+noautosel'; this feels more like a feature
(capability to keep TAPRIO across close/open) and I don't think it is
useful to backport.

>> 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.

So this whole paragraph is correct, see discussion thread with
Vineeth. [0] When sending the series, I wasn't sure about my approach.
More and more, I think it is the correct one.

 - We have no API to drop a qdisc from driver code.

 - An EnST schedule is, by definition, link speed sensitive. Userspace
   must have looked at the link speed to compute the first schedule. If
   link speed changes, userspace most probably wants another schedule.

 - EnST is one part of TSN; the whole point is stable links and
   deterministic usage of that link. If you get a link speed change,
   the ENST schedule being wrong is the last of your worries.

So I will *keep my approach*: on TAPRIO_CMD_REPLACE command, we compute
our schedule and attach it to a link speed. If we go down and back up
at the same link speed, we restore the cached schedule. If the link
speed changes, we warn and let userspace deal with it. Sadly we cannot
properly drop the qdisc; we can only log a warning.

This is any way much better than the current approach. Currently the
EnST registers are only written to on TAPRIO_CMD_{REPLACE,DESTROY}.
 - the EnST schedule can be lost if HW resets with close+open
 - the EnST schedule can be stale+invalid if the link speed changes
 - DESTROY cannot land while link down

[0]: https://lore.kernel.org/all/20261118-macb-set-channels-v7-1-2dbc00f686af@bootlin.com/

Thanks,

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


  reply	other threads:[~2026-11-23 15:38 UTC|newest]

Thread overview: 18+ 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
2026-11-23 15:37     ` Théo Lebrun [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-23 16:04     ` Théo Lebrun
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
2026-11-23 16:16     ` Théo Lebrun

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=DN2PANJIGO0C.14LOQ76W0VAJS@bootlin.com \
    --to=theo.lebrun@bootlin.com \
    --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-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pvalerio@redhat.com \
    --cc=tawfik.bayouk@mobileye.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