Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp789400pxb; Thu, 17 Feb 2022 15:01:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHtfwqegq7h5JpR1l+KUYemvxL9w6Ey45fvLXY02GxKxdfG5og+JxnYV7cJH4r+OqFh/Z4 X-Received: by 2002:a17:902:dac5:b0:14d:6f8d:f9af with SMTP id q5-20020a170902dac500b0014d6f8df9afmr4752003plx.82.1645138875446; Thu, 17 Feb 2022 15:01:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645138875; cv=none; d=google.com; s=arc-20160816; b=TvGT1Mqvdi95x7A5oCyI3nrA0UteNpnsF8vatU+BkRuaghwGj0ptEGn6Cb5vViuQYn UyyOnlbaD9yNJLQNT6uivO9eIi9zfGI1LzhQZeAVTyffmN0JLXM0FGPPplWqutfn2dBh NM/zvWi/jGUZdAWPLPpxX4dRDAKRTy7JKg4NthPMK/HmHo3ydvN8gj+LxSikdjdnT6Du nOaMiIhQHkbsQR+XFyfHTkDezcvm9NXbS1yj3M4LF+2+iYymewXou2FTH3QoAFLSwYOh mCM0WRbfuXNwetU/+LdFpsw3BUNhNSxaVK3QJWXPtatfVS+Vy9mWuntYbazQb1fV4bBk Z8gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QxcUKmOttRZJLYW7ut8tqGGUV1itp+JVUMIR7K85mzc=; b=0hYQvnyspj9N1OuITy2mNvFrUQ3OBjqhXvmrq3ghuxGPxaK9mhaG/N6XK3GTf5dGAm 0od2hU0V8fEACLRejuDR5yfMpQAF7fYjabxTpxJpQ9mMCmhxMq7xK/Qt8O5W95t9qEbt jaQRbc3CsRF6+SaAqaonbSLCVnWAUS0yB8rf8FLK/0w5HmjAjW88XER7MsF+zGS0kgWm 5lUj4nRzOzaXjatOYDxiZ32Bf2nDd1QBl16TYq/v1XuQceN40hzOuiCfFLIvLAL3iE4p l86FlI4A4KIXrDlYOhJn807TqFwqSk+QPkQcV/GfbzYHl/jXNsm8TsWmAyDoZKxkTwMp gxhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=jvv+jTDV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g17si993327pfv.115.2022.02.17.15.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:01:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=jvv+jTDV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B6A501111BB; Thu, 17 Feb 2022 14:57:07 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242268AbiBQO4F (ORCPT + 99 others); Thu, 17 Feb 2022 09:56:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:38138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242358AbiBQO4A (ORCPT ); Thu, 17 Feb 2022 09:56:00 -0500 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC0A1F5C85 for ; Thu, 17 Feb 2022 06:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1645109745; x=1676645745; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QxcUKmOttRZJLYW7ut8tqGGUV1itp+JVUMIR7K85mzc=; b=jvv+jTDVF9h6DWdFXBmrX1q6HMAK1xT36jfBm3N2qS7NYhdrAxq6SRGJ A6d80jwHcTrxYT/zGLAVAL1sP5mSRd6v64B8NZvV2HZdUvg4VeaNojGN0 pYRBen1uVHuxpQf+7dIaEleVwBpgzZso5cdODiutm9iWwnRG7zyLv2gx+ UAQfSaua91MyG82mxMtCT1LDSYLl8iShtlzs3uHFXb/IXDcsTCf1zbM+r xIEJQ9oVrv9NjRbbVlbLWRzRIncKTIBsSqsGM5jPz5s17IapMABjbB9Dr LTY9rg1MfPalKf5tAFc1MTg90OgJ7Nbs12tNa2fGAgIZwd0kjPC85tAGE w==; From: Vincent Whitchurch To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Maxime Coquelin CC: , Lars Persson , Vincent Whitchurch , Srinivas Kandagatla , , , , Subject: [PATCH] net: stmmac: Enable NAPI before interrupts go live Date: Thu, 17 Feb 2022 15:55:26 +0100 Message-ID: <20220217145527.2696444-1-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lars Persson The stmmac_open function has a race window between enabling the RX path and its interrupt to the point where napi_enabled is called. A chatty network with plenty of broadcast/multicast traffic has the potential to completely fill the RX ring before the interrupt handler is installed. In this scenario the single interrupt taken will find napi disabled and the RX ring will not be processed. No further RX interrupt will be delivered because the ring is full. The RX stall could eventually clear because the TX path will trigger a DMA interrupt once the tx_coal_frames threshold is reached and then NAPI becomes scheduled. Fixes: 523f11b5d4fd72efb ("net: stmmac: move hardware setup for stmmac_open to new function") Signed-off-by: Lars Persson [vincent.whitchurch@axis.com: Forward-port to mainline, change xdp_open too] Signed-off-by: Vincent Whitchurch --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 6708ca2aa4f7..8bd4123515b0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3753,11 +3753,12 @@ static int stmmac_open(struct net_device *dev) /* We may have called phylink_speed_down before */ phylink_speed_up(priv->phylink); + stmmac_enable_all_queues(priv); + ret = stmmac_request_irq(dev); if (ret) goto irq_error; - stmmac_enable_all_queues(priv); netif_tx_start_all_queues(priv->dev); return 0; @@ -3768,6 +3769,7 @@ static int stmmac_open(struct net_device *dev) for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) hrtimer_cancel(&priv->tx_queue[chan].txtimer); + stmmac_disable_all_queues(priv); stmmac_hw_teardown(dev); init_error: free_dma_desc_resources(priv); @@ -6562,12 +6564,13 @@ int stmmac_xdp_open(struct net_device *dev) /* Start Rx & Tx DMA Channels */ stmmac_start_all_dma(priv); + /* Enable NAPI process*/ + stmmac_enable_all_queues(priv); + ret = stmmac_request_irq(dev); if (ret) goto irq_error; - /* Enable NAPI process*/ - stmmac_enable_all_queues(priv); netif_carrier_on(dev); netif_tx_start_all_queues(dev); @@ -6577,6 +6580,7 @@ int stmmac_xdp_open(struct net_device *dev) for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) hrtimer_cancel(&priv->tx_queue[chan].txtimer); + stmmac_disable_all_queues(priv); stmmac_hw_teardown(dev); init_error: free_dma_desc_resources(priv); -- 2.34.1