From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 368D6606A322 for ; Thu, 3 Dec 2026 20:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=LiodomVO; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IciKw0CI DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=Q8CKPbM6H8vUQALJ7g3B42d6bWX2NR47EN6j8UXWM9E=; b=LiodomVO6jmW/+ru42R6bAi8nk Vs8p3L1oNFl5Wv/cnK5PXaTb0icxgPk0viuxhW59rre2lccTRChnahrlpXfYKgFsySscgnptqJfpP FNI5VaYdjwUR3ZxA2RsEywxn+mMLEMEgFXctBkj4UVVU2OFGA/U1E9a9b3PTWh7YcT70hAhwHDOZ4 wK2iX4FFk32HahssTwi5w6TW57tPaZrAgrq9GYAiJ7cP8+0STW4hY/8dRIGFvbYw4VGTcC/j4ubCY aespo7AN39hR3hUwOlfwCIR8G1ei24vYrPaROCGvGQGcDCWDndcXudE4Q1IKbbHJCWWDwlFHsh+YV fbstOpog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZD4g-0000000FuTx-2zEi; Thu, 03 Dec 2026 20:06:38 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZD4d-0000000FuTM-25iR for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 20:06:37 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 2174B43E1E; Thu, 3 Dec 2026 20:06:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A51851F000CE; Thu, 3 Dec 2026 20:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796328395; bh=Q8CKPbM6H8vUQALJ7g3B42d6bWX2NR47EN6j8UXWM9E=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=IciKw0CIJW/mGVJM1og49akxnvfHE8+5VEpDGOFASMSzqHKcxhfWJl5fpbrm36KBb rxbI1AQC/RJolk0Vkrl13AWyXqQR2kWmakqm/yR8vquEYpsMJKZEDScyBOOLeHuoSE 1jm4YUQU/qifJJVR8YzYUhq84sVbZAonc3YCeFY20NEGU368USgCIEWPr1/r0f5DjT 2utKDzRIsQjj665Rm9MAzjOpz4PDqMRokCg/VqsVCPhV9stTEWqXpvC7euz1dvgdzv EveQXurCKfbum0FKAo+A05g+4FxpoSlqWe4hDF1OYld3VPfvbq4pgtnuykRe2n4NRV Qrpq7SAFvY8Ug== Subject: Re: [PATCH net-next v10 1/2] net: ti: icssg-prueth: Add Frame Preemption MAC Merge support 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 Date: Thu, 03 Dec 2026 20:06:33 +0000 Message-ID: <179632839318.3146.10515780344366015302@kernel.org> In-Reply-To: <20261202191238.2221903-2-m-malladi@ti.com> References: <20261202191238.2221903-2-m-malladi@ti.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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