From: netdev-bot+sashiko@kernel.org
To: m-malladi@ti.com
Cc: icheng@nvidia.com, kees+treewide@kernel.org,
marco.crivellari@suse.com, haokexin@gmail.com,
laixiangwu@cmss.chinamobile.com, arnd@arndb.de, afd@ti.com,
basharath@couthit.com, parvathi@couthit.com, horms@kernel.org,
vladimir.oltean@nxp.com, rogerq@kernel.org, danishanwar@ti.com,
pabeni@redhat.com, kuba@kernel.org, edumazet@kernel.org,
davem@davemloft.net, andrew+netdev@lunn.ch,
linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, srk@ti.com, vigneshr@ti.com
Subject: Re: [PATCH net-next v10 1/2] net: ti: icssg-prueth: Add Frame Preemption MAC Merge support
Date: Thu, 03 Dec 2026 20:06:33 +0000 [thread overview]
Message-ID: <179632839318.3146.10515780344366015302@kernel.org> (raw)
In-Reply-To: <20261202191238.2221903-2-m-malladi@ti.com>
Thank you for your contribution! Sashiko AI review found 8 potential
issue(s) to consider.
Critical: 0 · High: 2 · Medium: 3 · Low: 3
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).
- [High] emac_tc_setup_mqprio()
(drivers/net/ethernet/ti/icssg/icssg_qos.c) calls…
- [High] If FPE was active before prueth_emac_restart(), it is not re-
armed in the rebooted firmware.
- [Medium] The commit message says that callers which do not already hold
phydev->lock take it before fpe_lock, to keep the phydev->lock ->…
- [Medium] emac_adjust_link() now calls icssg_qos_link_state_update() on
every link transition.
- [Medium] The FPE verify handshake sleeps while phydev->lock is held.
- [Low] Concern: icssg_prueth_sr1.c uses the same struct prueth_emac, now
with qos.iet.fpe_lock, and the shared icssg_ethtool_ops, but never…
- [Low] In icssg_config_ietfpe(), the verify branch clears
PRE_EMPTION_ACTIVE_TX (and VERIFY_STATUS) before arming, to avoid…
- [Low] Concern: three paths clear the software FPE state without
confirming the firmware disarmed: (a) the link-down branch of…
--
net: ti: icssg-prueth: Add Frame Preemption MAC Merge support
This adds QoS infrastructure for IET Frame Preemption to the ICSSG driver.
It covers firmware FPE configuration with a verify handshake, and MQPRIO
offload that maps preemptible traffic classes to queues. FPE is re-applied
on link changes and after a firmware restart, serialized by a new fpe_lock
taken after phydev->lock.
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> index 9bb67e185a3ea..7a18e3650399c 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
[ ... ]
> @@ -1867,6 +1873,16 @@ static int prueth_emac_restart(struct prueth *prueth)
> ret = icssg_set_port_state(emac0, ICSSG_EMAC_PORT_FORWARD);
> ret |= icssg_set_port_state(emac1, ICSSG_EMAC_PORT_FORWARD);
>
> + /* Re-apply FPE state after firmware restart. prueth_emac_common_start()
> + * fires emac_adjust_link() before the firmware is booted, so the R30
> + * command times out and fpe_active is cleared. The link state does not
> + * change again after boot, so re-apply here for any port that is up.
> + */
[Severity: High]
Does this comment still hold when FPE was already active before the
restart?
Nothing in the restart sequence clears iet->fpe_active.
prueth_emac_common_start() sets the link to 0 with WRITE_ONCE(), and
emac_adjust_link() then sees a 0->1 transition. The link-down branch of
icssg_qos_link_state_update(), which is what clears fpe_active, never runs.
So the pre-boot call and this post-boot re-apply both hit the new shortcut
in icssg_iet_change_preemptible_tcs():
if (iet->fpe_active) {
icssg_iet_set_preempt_mask(emac);
mutex_unlock(&iet->fpe_lock);
return 0;
}
No R30 command is sent. The rebooted firmware never gets
ICSSG_EMAC_PORT_PREMPT_TX_ENABLE or the verify setup, and
PRE_EMPTION_ACTIVE_TX is never checked.
Wouldn't the driver keep reporting tx_active through get_mm() and keep
marking queues preemptible in EXPRESS_PRE_EMPTIVE_Q_MASK/Q_MAP, while FPE
is not enabled in the firmware?
This becomes reachable once .set_mm is wired up in the next patch. For
example, ethtool --set-mm tx-enabled on followed by a bridge or HSR
join/leave goes through icssg_change_mode() -> prueth_emac_restart().
Should fpe_active be cleared when the firmware is restarted, so the
re-apply goes through icssg_config_ietfpe()?
> + if (READ_ONCE(emac0->link))
> + icssg_qos_link_state_update(emac0->ndev);
> + if (READ_ONCE(emac1->link))
> + icssg_qos_link_state_update(emac1->ndev);
[Severity: Medium]
The commit message says:
Callers that do not already hold phydev->lock take it before fpe_lock
to maintain the phydev->lock -> fpe_lock ordering established by
emac_adjust_link().
Should these calls take phydev->lock too?
prueth_emac_restart() runs under rtnl only, from icssg_change_mode(),
prueth_netdevice_port_unlink() and prueth_hsr_port_unlink(). The PHY state
machine is not stopped, so emac_adjust_link() can run at the same time
under phydev->lock.
emac_adjust_link() publishes the link before it configures the port:
if (!emac->link) {
new_state = true;
WRITE_ONCE(emac->link, 1);
}
...
icssg_update_rgmii_cfg(prueth->miig_rt, emac);
...
icssg_config_set_speed(emac);
icssg_set_port_state(emac, ICSSG_EMAC_PORT_FORWARD);
Can the restart path see link == 1 in that window? If so, it would send
PREMPT_TX_ENABLE and start verify before speed and FORWARD are set up.
icssg_qos_link_state_update() also reads emac->link outside fpe_lock and
picks its branch from that value. fpe_lock alone therefore doesn't
serialize FPE configuration against link processing here.
[ ... ]
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_qos.c b/drivers/net/ethernet/ti/icssg/icssg_qos.c
> new file mode 100644
> index 0000000000000..f20a03111a1cb
> --- /dev/null
> +++ b/drivers/net/ethernet/ti/icssg/icssg_qos.c
[ ... ]
> +static int icssg_iet_verify_wait(struct prueth_emac *emac)
> +{
> + void __iomem *config = emac->dram.va + ICSSG_CONFIG_OFFSET;
> + struct prueth_qos_iet *iet = &emac->qos.iet;
> + unsigned long delay_us, timeout_us;
> + u32 status;
> + int ret;
> +
> + delay_us = iet->verify_time_ms * 1000;
> + timeout_us = delay_us * ICSSG_IET_VERIFY_ATTEMPTS;
> +
> + ret = readb_poll_timeout(config + PRE_EMPTION_VERIFY_STATUS,
> + status,
> + status == ICSSG_IETFPE_STATE_SUCCEEDED ||
> + status == ICSSG_IETFPE_STATE_FAILED,
> + delay_us,
> + timeout_us);
[Severity: Medium]
The default verify_time_ms is ICSSG_IET_MAX_VERIFY_TIME (128). With that,
this poll can sleep for about 384 ms, plus up to 10 ms for the R30
command. Is it intended to sleep that long with phydev->lock held?
emac_adjust_link() now reaches this from phylib:
phy_state_machine() /* holds phydev->lock */
emac_adjust_link()
icssg_qos_link_state_update()
icssg_iet_change_preemptible_tcs()
icssg_config_ietfpe(ndev, true)
icssg_iet_verify_wait()
prueth_emac_common_start() and emac_tc_setup_mqprio() also hold
phydev->lock under rtnl for the same handshake, and so does emac_set_mm()
later in the series.
Each link-up with FPE and verify enabled could then stall the PHY state
machine for hundreds of milliseconds. Any rtnl holder that needs
phydev->lock, such as the ethtool link settings ops, would stall too.
This is worst with a link partner that never answers verify.
[ ... ]
> + if (enable && iet->mac_verify_configure) {
> + writeb(0, config + PRE_EMPTION_ACTIVE_TX);
> + writeb(ICSSG_IETFPE_STATE_UNKNOWN, config + PRE_EMPTION_VERIFY_STATUS);
> + writeb(1, config + PRE_EMPTION_ENABLE_VERIFY);
> + writel(iet->verify_time_ms, config + PRE_EMPTION_VERIFY_TIME);
> + } else {
> + writeb(0, config + PRE_EMPTION_ENABLE_VERIFY);
> + iet->verify_status = ICSSG_IETFPE_STATE_DISABLED;
> + }
[ ... ]
> + } else if (enable) {
> + /* Give firmware some time to update
> + * PRE_EMPTION_ACTIVE_TX state
> + */
> + usleep_range(100, 200);
> + }
> +
> + if (enable) {
> + val = readb(config + PRE_EMPTION_ACTIVE_TX);
> + if (val != 1) {
> + netdev_err(ndev,
> + "Firmware fails to activate IET/FPE\n");
> + ret = -EIO;
> + goto disable_tx;
> + }
> + iet->fpe_active = true;
[Severity: Low]
Can this read a stale PRE_EMPTION_ACTIVE_TX when verify is disabled?
Only the verify branch above clears PRE_EMPTION_ACTIVE_TX before sending
the command. With enable true and mac_verify_configure false, the register
is not reset. A value of 1 is then accepted after a 100-200 us sleep.
PRE_EMPTION_ACTIVE_TX (0x05A1) is outside the range that icssg_config()
clears with memset_io(config, 0, TAS_GATE_MASK_LIST0). The link-down path
only clears ENABLE_TX and ENABLE_VERIFY.
A 1 left over from an earlier FPE session could be taken as confirmation
even if the firmware did not activate preemption this time. It isn't clear
from the driver whether the firmware always rewrites this byte before it
completes the R30 command.
Would it be safer to clear PRE_EMPTION_ACTIVE_TX in both enable branches?
[ ... ]
> +disable_tx:
> + icssg_set_port_state(emac, ICSSG_EMAC_PORT_PREMPT_TX_DISABLE);
> +fallback:
> + writeb(0, config + PRE_EMPTION_ENABLE_TX);
> + writeb(0, config + PRE_EMPTION_ENABLE_VERIFY);
> + if (iet->verify_status != ICSSG_IETFPE_STATE_FAILED)
> + iet->verify_status = ICSSG_IETFPE_STATE_DISABLED;
> + iet->fpe_active = false;
> + icssg_iet_set_preempt_mask(emac);
> + return ret;
> +}
[Severity: Low]
This probably isn't a functional bug, but three paths clear the software
FPE state without confirming that the firmware has disarmed:
- the link-down branch of icssg_qos_link_state_update() only zeroes the
PRE_EMPTION_ENABLE_TX and PRE_EMPTION_ENABLE_VERIFY bytes
- disable_tx ignores the return value of PREMPT_TX_DISABLE
- fallback, reached after PREMPT_TX_ENABLE fails, never sends DISABLE
The next link-up always goes through icssg_config_ietfpe() and sends an
explicit enable or disable command. Fallback also ends with
icssg_iet_set_preempt_mask() with fpe_active false, which resets all
queues to express.
So there is no concrete impact visible from the driver side, but the
firmware behaviour can't be fully checked from here.
> +void icssg_qos_init(struct net_device *ndev)
> +{
> + struct prueth_emac *emac = netdev_priv(ndev);
> + struct prueth_qos_iet *iet = &emac->qos.iet;
> +
> + mutex_init(&iet->fpe_lock);
[Severity: Low]
This isn't a bug at the end of the series, but icssg_prueth_sr1.c uses the
same struct prueth_emac (now including qos.iet.fpe_lock) and the shared
icssg_ethtool_ops. It never calls icssg_qos_init().
SR1 is safe today for these reasons:
- emac_get_mm(), emac_set_mm() and emac_get_mm_stats() return early on
emac->is_sr1
- .ndo_setup_tc is only set in the SR2 emac_netdev_ops
- icssg_qos_link_state_update() is only called from the SR2 driver
That leaves an uninitialized fpe_lock in SR1 that any future shared path
could reach without the is_sr1 check. Would it make sense to initialize it
for SR1 as well?
[ ... ]
> +static int icssg_iet_change_preemptible_tcs(struct prueth_emac *emac)
> +{
> + struct prueth_qos_iet *iet = &emac->qos.iet;
> + int ret;
> +
> + mutex_lock(&iet->fpe_lock);
> + if (!iet->fpe_enabled && !iet->preemptible_tcs) {
> + ret = icssg_config_ietfpe(emac->ndev, false);
> + mutex_unlock(&iet->fpe_lock);
> + return ret;
> + }
[Severity: Medium]
When FPE was never configured, this still calls icssg_config_ietfpe(false).
That writes the PRE_EMPTION_* bytes and sends
ICSSG_EMAC_PORT_PREMPT_TX_DISABLE.
emac_adjust_link() now calls icssg_qos_link_state_update() on every link
transition. Does that mean an extra R30 command on each link-up, even for
users who never use FPE?
During a firmware restart this runs before the PRUs are booted:
prueth_emac_restart()
prueth_emac_common_start()
icssg_config()
WRITE_ONCE(emac->link, 0);
emac_adjust_link() /* link 0->1 */
icssg_qos_link_state_update()
icssg_iet_change_preemptible_tcs()
icssg_config_ietfpe(ndev, false)
icssg_set_port_state(PREMPT_TX_DISABLE) /* 10 ms timeout */
prueth_emac_start() /* firmware booted here */
If the PHY link is up, wouldn't each port wait out the timeout on every
switch or HSR mode change? It would also log "timeout waiting for command
done" and "TX preempt disable command failed", even if FPE was never
enabled.
The PREMPT_TX_DISABLE command words also stay in the R30 mailbox, in place
of the FORWARD command written just before.
Plain mqprio offload with no preemption now depends on this command too.
If it fails, emac_tc_setup_mqprio() rolls back and calls netdev_reset_tc().
Could this return early when there is nothing to disable?
[ ... ]
> +static int emac_tc_setup_mqprio(struct net_device *ndev, void *type_data)
> +{
[ ... ]
> + netdev_dbg(ndev, "dev->num_tc %u dev->real_num_tx_queues %u\n",
> + ndev->num_tc, ndev->real_num_tx_queues);
> +
> + mutex_lock(&ndev->phydev->lock);
[Severity: High]
Can ndev->phydev be NULL here?
prueth_remove() clears phydev before it unregisters the netdev.
unregister_netdev() then tears down an offloaded mqprio qdisc through
ndo_setup_tc():
prueth_remove()
phy_disconnect(prueth->emac[i]->ndev->phydev);
prueth->emac[i]->ndev->phydev = NULL;
unregister_netdev()
dev_shutdown()
qdisc_put()
mqprio_destroy()
mqprio_disable_offload()
ndo_setup_tc(dev, TC_SETUP_QDISC_MQPRIO, &mqprio)
emac_tc_setup_mqprio()
mutex_lock(&ndev->phydev->lock);
mqprio_disable_offload() passes a zeroed tc_mqprio_qopt_offload, so
num_tc is 0. Nothing returns early for num_tc == 0 before this lock.
Wouldn't unbinding the driver after "tc qdisc add ... mqprio ... hw 1"
then hit a NULL pointer dereference? The netdev_unregister unwind in
prueth_probe() clears phydev in the same order.
prueth_probe() also calls register_netdev() before emac_phy_connect(). A
tc request in that window would see phydev == NULL as well.
ndev->phydev is read again for the mutex_unlock() at the end of this
function. prueth_remove() clears it without rtnl, so could the lock and the
unlock see different pointers?
The same unchecked pattern is copied into emac_set_mm() in the later patch
"net: ti: icssg-prueth: Add ethtool ops for Frame Preemption MAC Merge".
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202191238.2221903-1-m-malladi%40ti.com
next prev parent reply other threads:[~2026-12-03 20:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 19:12 [PATCH net-next v10 0/2] Add Frame Preemption MAC Merge support for ICSSG Meghana Malladi
2026-12-02 19:12 ` [PATCH net-next v10 1/2] net: ti: icssg-prueth: Add Frame Preemption MAC Merge support Meghana Malladi
2026-12-03 20:06 ` netdev-bot+sashiko [this message]
2026-12-02 19:12 ` [PATCH net-next v10 2/2] net: ti: icssg-prueth: Add ethtool ops for Frame Preemption MAC Merge Meghana Malladi
2026-12-03 20:06 ` 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=179632839318.3146.10515780344366015302@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=afd@ti.com \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=basharath@couthit.com \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=haokexin@gmail.com \
--cc=horms@kernel.org \
--cc=icheng@nvidia.com \
--cc=kees+treewide@kernel.org \
--cc=kuba@kernel.org \
--cc=laixiangwu@cmss.chinamobile.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-malladi@ti.com \
--cc=marco.crivellari@suse.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parvathi@couthit.com \
--cc=rogerq@kernel.org \
--cc=srk@ti.com \
--cc=vigneshr@ti.com \
--cc=vladimir.oltean@nxp.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