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 C835B606A31F for ; Sun, 6 Dec 2026 05:57:05 +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=j43/5GRs; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=LwHdnpfp 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:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID: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=Vx5ToooHmdO4LjXdCndrCeuwFCPXViyno9W+D5Pa/Jc=; b=j43/5GRsNckVoI sUaj1K1G20ChAXkbJRFQ8Q+pDjXxyoWVuvsJ4jGbTWI2wG/UYGk4Juflgcdly5Zhvzprdnz6vIpUX lwTBhJd4CtKMINlHmpqF2e+HwSc0W1kIkiJrEhb8r7/VMzsCh7HpHQdjpeb0nrD4MwuXEnRWMhmP7 U6JF26h9EkES4EAo+W9Tqg61wxNLL1ryRGXRgx7EOyiWGKzhYsOA2Aa2EZ6XcgkmP3p1KGJDxtXdV 3sLvfllRguYCVbrz/METIHfzYImDBFhpojauiXlr1oiT6vKEU1yfU+SyvSjyPEy7/+AB3/5AyFxUS pbYV6KDAvr5SKC5g60Nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xa5F2-00000003Gh4-2pEY; Sun, 06 Dec 2026 05:56:56 +0000 Received: from smtpout-02.galae.net ([185.246.84.56]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xa5Ey-00000003Ggg-1Nwr for linux-arm-kernel@lists.infradead.org; Sun, 06 Dec 2026 05:56:54 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 59CE01A1999; Sun, 6 Dec 2026 05:56:49 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2499D604C0; Sun, 6 Dec 2026 05:56:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D2E4411EA179C; Sun, 06 Dec 2026 06:56:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796536608; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=Vx5ToooHmdO4LjXdCndrCeuwFCPXViyno9W+D5Pa/Jc=; b=LwHdnpfpQ0kqJN58N7PvRs3yDcmCD2jzGPWWV93CmH20g4XU8FLZa0gLHYu3Pb+/PqX3kK JsCLnQv8Gc8xKt0ytxIu4LsIvlv/Qxm6N527tzqGC/bSshzVndY9T6Thlr++LBCe0zSuE8 36ubyOURk/f22G5QL9BXz4ilH60HwitZfnBHrlIJaw7OdQKJDk3Iz6g0bq+NTaiNstEtW6 KMzn8dw0LvdJp8+v8NNoVgff58zx99e+nU6fHZjpn6KIIq4JOAWUjjtqH342ecJ29A3TcN dA29bqmKYYzcpLXYq3m48kB0tmzlevvyDqGCePeabbXdDCsQzl/SKjDjQtma1A== Message-ID: <5d6b1d95-d942-4cb8-b452-29f980223c27@bootlin.com> Date: Sun, 6 Dec 2026 06:56:41 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] net: stmmac: do not toggle RX VLAN offload while running To: Lorenzo Bianconi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Lai Peter Jun Ann Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20261205-stmmac-do-not-flip-vlan-offload-v1-1-5b3fa52c306b@oss.qualcomm.com> Content-Language: en-US From: Maxime Chevallier In-Reply-To: <20261205-stmmac-do-not-flip-vlan-offload-v1-1-5b3fa52c306b@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261205_215652_544773_D8C761AA X-CRM114-Status: GOOD ( 27.04 ) X-Spam-Score: -2.1 (--) 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 Hi Lorenzo, On 12/5/26 18:26, Lorenzo Bianconi wrote: > The RX VLAN offload mode is consumed by the receive path: stmmac_rx() > and stmmac_dispatch_skb_zc() use hw_vlan_en to decide whether to take > the VLAN tag from the RX descriptor, and the software stripping path > uses the advertised RX VLAN feature bits. > > stmmac_set_features() changes that state at runtime, while RX NAPI can > run concurrently. A frame received with one setting can therefore be > processed after the setting has changed, which may lose a tag that was > stripped or duplicate a tag that is still in the frame. The MAC register > update also cannot be made atomic with respect to frames already in > flight without stopping RX DMA and flushing the descriptor rings. > > Since this is an RX offload mode change and there is no cheap way to > synchronize it with the receive path, only allow it while the interface > is down. Mask the RX VLAN feature bits back to their currently advertised > state in stmmac_fix_features() when the device is running, so > ndo_set_features() never changes the mode under a live RX path. A request > made while the interface is running is ignored and is not deferred to the > next open; userspace must bring the interface down to change the RX VLAN > offload. > > Fixes: 750011e239a5 ("net: stmmac: Add support for HW-accelerated VLAN stripping") > Signed-off-by: Lorenzo Bianconi This triggered some new failures on the Netdev CI for 6 stmmac runners: - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-rk3568/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-imx8mp/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-jh7110/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-socfpga-agilex5/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-stm32mp1/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-stm32mp2/test-outputs/24-vlan-py/ The test fails precisely because we can't switch offload mode while interface is on. Besides the selftest, is it worth fixing ? We may have an error on one frame while it's being actively reconfigured, I guess a lot of other drivers are subject to the same class of problem... Is it a bit too defensive ? I may be wrong here, I don't know exactly what's the netdev policy regarding wether it's OK to have potentially one frame corrupt while the user is reconfiguring offloads... Maxime > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index d32d3e7b1b8c..b978e64399d4 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -6371,6 +6371,8 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, > netdev_features_t features) > { > struct stmmac_priv *priv = netdev_priv(dev); > + netdev_features_t vlan_rx = NETIF_F_HW_VLAN_CTAG_RX | > + NETIF_F_HW_VLAN_STAG_RX; > > if (priv->plat->rx_coe == STMMAC_RX_COE_NONE) > features &= ~NETIF_F_RXCSUM; > @@ -6393,6 +6395,15 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, > features &= ~NETIF_F_HW_VLAN_STAG_RX; > } > > + /* The RX VLAN mode cannot be changed while RX is running: frames > + * received under the old mode might otherwise be processed with the > + * new one. Keep the current mode and defer the change until the > + * interface is down. > + */ > + if (netif_running(dev) && > + (features & vlan_rx) != (dev->features & vlan_rx)) > + features = (features & ~vlan_rx) | (dev->features & vlan_rx); > + > return features; > } > > > --- > base-commit: e9d78fc6741ac06d438cf64e314c28e57014432a > change-id: 20261205-stmmac-do-not-flip-vlan-offload-613a9cad635b > > Best regards,