From patchwork Wed Oct 18 12:35:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13426991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20A46CDB482 for ; Wed, 18 Oct 2023 12:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=b6XnwXeoTLZWVvCcIjxaZT8w94MQyzbG9OFJKf+wRfw=; b=xluckLXvLgzAzx mR3Wxz0dEhIqtzcccQ5BDsIrU2VRlovTLFCPRxyaT6CuQq1Axsgc1Nx3F7w/nGtuXVy8fK3bB8rB0 7k7sB81k8/qEHKVuWDlqX3pli0PVya6sqcgTo32HZjyqoy6LlR+NzwFOjDiOUbSFVsALGWYo/K6/a 9+SifH/a/ZV2mvWDOlOGQ9wu5uo8M/VxV8JJw9ThuUTi415m8FMm9O/x/82Ja8qa+M4I9+GHSrBSg iEhlzFyk6dAeg23ogw2uWOe3laYxhVD2vFfHKmTMW6ifKplmejBTYkrHSdY07q+uMo9b1Y0QMgTxe GEveRH7vQ3AsS3okZsfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qt5mU-00Efia-2t; Wed, 18 Oct 2023 12:36:10 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qt5mO-00Efdk-2e for linux-arm-kernel@lists.infradead.org; Wed, 18 Oct 2023 12:36:06 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4084095722aso1857635e9.1 for ; Wed, 18 Oct 2023 05:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697632561; x=1698237361; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fQganKp8aZF21H/zUPTyA0gQtuZNoVrMeBEcku+H04Y=; b=arHeVvlXNTuUio4+lVOEnVw80ZOwQDvzHjtGgenOljrAW0lURnCyRTrF0pQi7x/N9/ eGXj49R2yOXvGMeREfbAemfxDHKmLdWUOaDy4C3qYzJFVt0LSCEXtx5kj8dITgWcYvBU WDEjSYXnlc1+N5fm9I72GN+LGbsBi1x9ft7M8RumgyCtVBPlxjBb5spouFTMUO6LfkH3 bi3bLJ71PFa09yr4oN+QoEYVezaqQVWdBDbu0Ed/IK0kpQnJBxQSCPPx/jcGzVQUWQTc RnEMM4cjMYBAXFYWM8pYJtji/mczelcKj3P9JfONugvvj5ZaLUP5u0MJKhfcXN2xjOQN FE7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697632561; x=1698237361; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fQganKp8aZF21H/zUPTyA0gQtuZNoVrMeBEcku+H04Y=; b=vcJtPU2ayx9lFHDK1coBo0MR6es1cC+EGatJFgu3rFZ8R+glKXvcoIPyuWVIUZV0ak WuZAF52veFb46iYsLp/TfrUfazCy31MOF2n2Bd2F//EyXeabRjn7ao11rbRmgj4zSwdc +t5HRj+4kk4x7z6Q05OUrDz6U9gCcCEooulu6euRWWCcJu9P/dryizaKVE9p0AUEKHAe 17kA9gkvKYO/CXWno//IfJXqzR9qtHUD9LSpAwM3W7dpzkw02CMAY9tMhXMxrO5afpGf RK9CcmCNYu8USOfQuJV41+3IAblMlI6MKbDaaFeMtR4mL0/6lIgsU4ttLVVxh5EO1Zqb InwA== X-Gm-Message-State: AOJu0YweuOAOF3jJyo08JE6sLsDb6eIeiSD9slNXnVtX7rxkcV6pi4Kc +gk1bKViouZXgQM2K7ZMJ7o= X-Google-Smtp-Source: AGHT+IGWvw4ZG3SuGsV3ihR3L7f4r/gBqme7cwP3cF/b5NR29eZ1jaXh9BTqQTHxCvA+LdtfhtVbtA== X-Received: by 2002:adf:cf0e:0:b0:32d:a43c:a23d with SMTP id o14-20020adfcf0e000000b0032da43ca23dmr4654866wrj.3.1697632560973; Wed, 18 Oct 2023 05:36:00 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id q28-20020adfab1c000000b003248a490e3asm2048211wrc.39.2023.10.18.05.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 05:36:00 -0700 (PDT) From: Christian Marangi To: Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Ping-Ke Shih , Kalle Valo , Simon Horman , Daniel Borkmann , Jiri Pirko , Hangbin Liu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v4 3/4] net: stmmac: move TX timer arm after DMA enable Date: Wed, 18 Oct 2023 14:35:49 +0200 Message-Id: <20231018123550.27110-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018123550.27110-1-ansuelsmth@gmail.com> References: <20231018123550.27110-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_053604_861491_FDFA1283 X-CRM114-Status: GOOD ( 17.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move TX timer arm call after DMA interrupt is enabled again. The TX timer arm function changed logic and now is skipped if a napi is already scheduled. By moving the TX timer arm call after DMA is enabled, we permit to correctly skip if a DMA interrupt has been fired and a napi has been scheduled again. Signed-off-by: Christian Marangi --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 5124ee87286c..11055e98efcc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2543,9 +2543,13 @@ static void stmmac_bump_dma_threshold(struct stmmac_priv *priv, u32 chan) * @priv: driver private structure * @budget: napi budget limiting this functions packet handling * @queue: TX queue index + * @pending_packets: signal to arm the TX coal timer * Description: it reclaims the transmit resources after transmission completes. + * If some packets still needs to be handled, due to TX coalesce, set + * pending_packets to true to make NAPI arm the TX coal timer. */ -static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue) +static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue, + bool *pending_packets) { struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue]; struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue]; @@ -2706,7 +2710,7 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue) /* We still have pending packets, let's call for a new scheduling */ if (tx_q->dirty_tx != tx_q->cur_tx) - stmmac_tx_timer_arm(priv, queue); + *pending_packets = true; flags = u64_stats_update_begin_irqsave(&txq_stats->syncp); txq_stats->tx_packets += tx_packets; @@ -5572,6 +5576,7 @@ static int stmmac_napi_poll_tx(struct napi_struct *napi, int budget) container_of(napi, struct stmmac_channel, tx_napi); struct stmmac_priv *priv = ch->priv_data; struct stmmac_txq_stats *txq_stats; + bool pending_packets = false; u32 chan = ch->index; unsigned long flags; int work_done; @@ -5581,7 +5586,7 @@ static int stmmac_napi_poll_tx(struct napi_struct *napi, int budget) txq_stats->napi_poll++; u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); - work_done = stmmac_tx_clean(priv, budget, chan); + work_done = stmmac_tx_clean(priv, budget, chan, &pending_packets); work_done = min(work_done, budget); if (work_done < budget && napi_complete_done(napi, work_done)) { @@ -5592,6 +5597,10 @@ static int stmmac_napi_poll_tx(struct napi_struct *napi, int budget) spin_unlock_irqrestore(&ch->lock, flags); } + /* TX still have packet to handle, check if we need to arm tx timer */ + if (pending_packets) + stmmac_tx_timer_arm(priv, chan); + return work_done; } @@ -5600,6 +5609,7 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget) struct stmmac_channel *ch = container_of(napi, struct stmmac_channel, rxtx_napi); struct stmmac_priv *priv = ch->priv_data; + bool tx_pending_packets = false; int rx_done, tx_done, rxtx_done; struct stmmac_rxq_stats *rxq_stats; struct stmmac_txq_stats *txq_stats; @@ -5616,7 +5626,7 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget) txq_stats->napi_poll++; u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); - tx_done = stmmac_tx_clean(priv, budget, chan); + tx_done = stmmac_tx_clean(priv, budget, chan, &tx_pending_packets); tx_done = min(tx_done, budget); rx_done = stmmac_rx_zc(priv, budget, chan); @@ -5641,6 +5651,10 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget) spin_unlock_irqrestore(&ch->lock, flags); } + /* TX still have packet to handle, check if we need to arm tx timer */ + if (tx_pending_packets) + stmmac_tx_timer_arm(priv, chan); + return min(rxtx_done, budget - 1); }