Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1564481pxm; Thu, 24 Feb 2022 05:38:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNx5B+GSZn+rNsgGxTJZ1g1z1u5hXGRIGkuADuaVdqECpj7RKtYYz2runNGmJadfr51VtZ X-Received: by 2002:a17:902:9a96:b0:14f:ecc0:c21a with SMTP id w22-20020a1709029a9600b0014fecc0c21amr2698292plp.78.1645709905505; Thu, 24 Feb 2022 05:38:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645709905; cv=none; d=google.com; s=arc-20160816; b=QlPuJ4q5/YGoAfcnERdP91Y59/PKXq2vOBzl0mzcaxrXIum+4qksuaOShXplqQlhAy 0J807uGj00Iw+wEhLqIQRj1cBp9IhqPCYJEgZttIKlmbybUGav1ghMNo0Wj/1YaHPSEp WevFq8QxIs5CadeKpNYEUzgKKOwf1F08MVRq2Sv93ltjEESQUAiMqiy6K1ke+0Y8URZh /zdpSfXpqb7abjIaj1lfHPeGFiYMIa7kGEVYBIZU9L+vhqqwxzz0v3viiW3rhpgMMbUl /Cs+vq3TIqnopuk/nwmqm0gDgr7pM+LEnSm1UjAV5XTcm6Zorq4aHfLzxV76VbW2Ey2I JMiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=2G7Q4/SbY0/u6FJFyQ5u7ok3xEUfxBWHs/wk8cUfVjo=; b=YjWbnvNm+ZgppyAqvgwS6YfQKe/G+Rp1QKnMAPKTGTM3nHiMr2u5CVDGh5b3CZ1i1D ORt0Y1AFbfhAh0exv7wjNJQ2730U7IPkBnb3tiL2htwVbuPy70Lk7buK3mu1xxsJJw7J MfJWiHwuY5FaUA/7/90920vsuRpg1OMSa3qoDVLAkoYQ2zOrsxX6tYQEozEJSh7gCCYi vwuStG2hqZ/POYaw/rrxBw1Z8J7f9F5gIYEwxJ+z64AQtx9v02iLWfTRHxq4/ex0XNbA 79Ch3BQCJjRy8GFJPJnCohDXDddebaUrTJHUQAp/IFUUMdcFoF4vf7nor3lWdT/f2Q50 3TDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=UPAiUuz+; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1si2448531pfj.152.2022.02.24.05.38.09; Thu, 24 Feb 2022 05:38:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=UPAiUuz+; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234600AbiBXMy1 (ORCPT + 99 others); Thu, 24 Feb 2022 07:54:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234594AbiBXMy1 (ORCPT ); Thu, 24 Feb 2022 07:54:27 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B6D20E796; Thu, 24 Feb 2022 04:53:56 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3504F1F44A; Thu, 24 Feb 2022 12:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1645707235; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2G7Q4/SbY0/u6FJFyQ5u7ok3xEUfxBWHs/wk8cUfVjo=; b=UPAiUuz+WH8h7pPxSNNG6Dpza+Qb+DM5ZsIxaWxc1kG25pDybpqYRQX9kVy96n/KQltFxM vCZj0mVEeW3p5oSQ+Rdkp5XuV/rGPiV4X0Q4CY3EpPGaEBOzTiQGkDt8cbMTH188U9lC2M 4/y8+BgA/LqcXC5UeGyUaGQEyyqilIo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1645707235; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2G7Q4/SbY0/u6FJFyQ5u7ok3xEUfxBWHs/wk8cUfVjo=; b=PIqZ3B1fxD+QIGOx68q/WUrx7rRxAgTPIf32nkK4Qbync3bJbDpyVAY9lHUo4LrfE3UD9a 22Slgo4cEHRrhsBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5311B13AD9; Thu, 24 Feb 2022 12:53:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id d5/wEOJ/F2IoEgAAMHmgww (envelope-from ); Thu, 24 Feb 2022 12:53:54 +0000 Message-ID: Date: Thu, 24 Feb 2022 15:53:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH v2] net: stmmac: only enable DMA interrupts when ready Content-Language: ru To: Vincent Whitchurch , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Maxime Coquelin Cc: kernel@axis.com, Lars Persson , Srinivas Kandagatla , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220224113829.1092859-1-vincent.whitchurch@axis.com> From: Denis Kirjanov In-Reply-To: <20220224113829.1092859-1-vincent.whitchurch@axis.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 2/24/22 14:38, Vincent Whitchurch пишет: > In this driver's ->ndo_open() callback, it enables DMA interrupts, > starts the DMA channels, then requests interrupts with request_irq(), > and then finally enables napi. > > If RX DMA interrupts are received before napi is enabled, no processing > is done because napi_schedule_prep() will return false. If the network > has a lot of broadcast/multicast traffic, then the RX ring could fill up > completely before napi is enabled. When this happens, no further RX > interrupts will be delivered, and the driver will fail to receive any > packets. > > Fix this by only enabling DMA interrupts after all other initialization > is complete. > > Fixes: 523f11b5d4fd72efb ("net: stmmac: move hardware setup for stmmac_open to new function") > Reported-by: Lars Persson > Signed-off-by: Vincent Whitchurch > --- > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++++-- > 1 file changed, 26 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 6708ca2aa4f7..43978558d6c0 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -2260,6 +2260,23 @@ static void stmmac_stop_tx_dma(struct stmmac_priv *priv, u32 chan) > stmmac_stop_tx(priv, priv->ioaddr, chan); > } > > +static void stmmac_enable_all_dma_irq(struct stmmac_priv *priv) > +{ > + u32 rx_channels_count = priv->plat->rx_queues_to_use; > + u32 tx_channels_count = priv->plat->tx_queues_to_use; > + u32 dma_csr_ch = max(rx_channels_count, tx_channels_count); > + u32 chan; > + > + for (chan = 0; chan < dma_csr_ch; chan++) { > + struct stmmac_channel *ch = &priv->channel[chan]; > + unsigned long flags; > + > + spin_lock_irqsave(&ch->lock, flags); > + stmmac_enable_dma_irq(priv, priv->ioaddr, chan, 1, 1); > + spin_unlock_irqrestore(&ch->lock, flags); > + } > +} > + > /** > * stmmac_start_all_dma - start all RX and TX DMA channels > * @priv: driver private structure > @@ -2902,8 +2919,10 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) > stmmac_axi(priv, priv->ioaddr, priv->plat->axi); > > /* DMA CSR Channel configuration */ > - for (chan = 0; chan < dma_csr_ch; chan++) > + for (chan = 0; chan < dma_csr_ch; chan++) { > stmmac_init_chan(priv, priv->ioaddr, priv->plat->dma_cfg, chan); Did you miss to take a channel lock? > + stmmac_disable_dma_irq(priv, priv->ioaddr, chan, 1, 1); > + } > > /* DMA RX Channel Configuration */ > for (chan = 0; chan < rx_channels_count; chan++) { > @@ -3759,6 +3778,7 @@ static int stmmac_open(struct net_device *dev) > > stmmac_enable_all_queues(priv); > netif_tx_start_all_queues(priv->dev); > + stmmac_enable_all_dma_irq(priv); > > return 0; > > @@ -6508,8 +6528,10 @@ int stmmac_xdp_open(struct net_device *dev) > } > > /* DMA CSR Channel configuration */ > - for (chan = 0; chan < dma_csr_ch; chan++) > + for (chan = 0; chan < dma_csr_ch; chan++) { > stmmac_init_chan(priv, priv->ioaddr, priv->plat->dma_cfg, chan); > + stmmac_disable_dma_irq(priv, priv->ioaddr, chan, 1, 1); > + } > > /* Adjust Split header */ > sph_en = (priv->hw->rx_csum > 0) && priv->sph; > @@ -6570,6 +6592,7 @@ int stmmac_xdp_open(struct net_device *dev) > stmmac_enable_all_queues(priv); > netif_carrier_on(dev); > netif_tx_start_all_queues(dev); > + stmmac_enable_all_dma_irq(priv); > > return 0; > > @@ -7447,6 +7470,7 @@ int stmmac_resume(struct device *dev) > stmmac_restore_hw_vlan_rx_fltr(priv, ndev, priv->hw); > > stmmac_enable_all_queues(priv); > + stmmac_enable_all_dma_irq(priv); > > mutex_unlock(&priv->lock); > rtnl_unlock();