From patchwork Sat Jul 23 14:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 12927211 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 B2EE9C43334 for ; Sat, 23 Jul 2022 14:31:21 +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=pXlvxzts0DQ2OLWL1GVaSBYCpMLt2whBy0KqwA5POFU=; b=r3o1ut4JXBag4K 3rKodZBRd/l+21tdB6erRecFBfVdiZDRdWAE54hE24/RGES4jX9cWliELuPEXX2SOwlPIbJLtcMuA zauGgpFLxp29JG6CbH5liJaasvNlX/GCUQWweewJdgetW+yuQll8nCavFQv3UpcvjFLHquIp4KSbP 41tHnzZcboM5UcIGk9rcyIdiueFoF7mfvygiD/wFV4WMQ6VNzPZaImWLrz8rEiQ7z96hl66X/sTF/ QsoW3Zipkd5CH7EmEjwpE2O7mjzuLjzrh3BYuv36PsKitK0qz4JBmBsZSW1uDwAMgkJ+npLwqZ6Gm LRTydYabFaN+trOgn0Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFG8q-00466j-Sw; Sat, 23 Jul 2022 14:30:05 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFG8d-0045tA-Ad for linux-arm-kernel@lists.infradead.org; Sat, 23 Jul 2022 14:29:52 +0000 Received: by mail-wr1-x430.google.com with SMTP id d8so9998003wrp.6 for ; Sat, 23 Jul 2022 07:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dtK+f+e69ktRtm1DfmKkH7OgqSKD4ay2ViO2yXXI+mw=; b=BRKTixbhnurH9pcfogJZP+9+9XbOYRMbxDufycEZFZc8tpLD+IfE7sDdgURmuvojSb mx6bjoYVKP5r8Y/ktV+gn4iSMhObNTo6afdTGZNOQgaKQi4DaXEonBi/YQf6qTyeHyCS c4gm8WFbaUMcHH5XF5X1rjnhpMynADfN1xdfxtCuBqLbyXEmojT7QQt6xz9i1dENaeut wqtCHIW/32q30tWK2DyAYSr+1VDV25kwnGHSmIdEwcpXHqMo1l5BEtpOJjrU/Qv9XTgY T42zHG0pqL6dT/GJa012PbeuB/yx+X685jDREvV2rslvY3b4bjKX9MnKiWcBwmzzHveU BUvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dtK+f+e69ktRtm1DfmKkH7OgqSKD4ay2ViO2yXXI+mw=; b=KzYXMch/UBHrx5QMnXELjwO7g3AaOVbwt8ceRlbns3nuCL2RknoEn0736LyKJsxpz8 yB3Lhx9V9QMORSxKw15gIQDy3x1YZB+X08UqoV8ewI3Ob7Q6CxEze63vPHayye/mvHhi aTHWy/J9/VjeA07WI6ksJ5HiCdQ2xo2TaxCT0eUcZTZTCOTWuaAEljfL/wR07lgYMmCl KaRU7zAPt9w2Nx0Rju9C/4iaj5R5iMz7PAURpBCKoGGj1nTkgMACN1cV0AXjHAbJtANM XwV/Okiyu6iPQsItZljhJMeSw+Qn4d7sd5LEWHlMx/8Vm/+Lr9JlvmTKZ5XjgeuCnJUZ 8o0A== X-Gm-Message-State: AJIora/XhBTQATwMB5CZiASsmEQgCBDHU45eCLgq0A0NWkPwBgqwbEsI 4iUM/nwShdKvEbhUtEdB5cM= X-Google-Smtp-Source: AGRyM1vLn8trzceLunwqhaXT5AIv6dL8/i2Cw1MFuKkaH+23TDjqBDi7C+PEM5t9iwwpDbzI1v8hQQ== X-Received: by 2002:a05:6000:186:b0:21e:5874:2bfb with SMTP id p6-20020a056000018600b0021e58742bfbmr3016866wrx.510.1658586587614; Sat, 23 Jul 2022 07:29:47 -0700 (PDT) Received: from localhost.localdomain (host-87-7-207-127.retail.telecomitalia.it. [87.7.207.127]) by smtp.googlemail.com with ESMTPSA id q6-20020a1cf306000000b0039c5ab7167dsm11689717wmq.48.2022.07.23.07.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jul 2022 07:29:47 -0700 (PDT) From: Christian Marangi To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v5 1/5] net: ethernet: stmicro: stmmac: move queue reset to dedicated functions Date: Sat, 23 Jul 2022 16:29:29 +0200 Message-Id: <20220723142933.16030-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220723142933.16030-1-ansuelsmth@gmail.com> References: <20220723142933.16030-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220723_072951_389222_9A1ABE8F X-CRM114-Status: GOOD ( 17.20 ) 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 queue reset to dedicated functions. This aside from a simple cleanup is also required to allocate a dma conf without resetting the tx queue while the device is temporarily detached as now the reset is not part of the dma init function and can be done later in the code flow. Signed-off-by: Christian Marangi --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 59 ++++++++++--------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 6f14b00c0b14..5578abb14949 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -130,6 +130,9 @@ static irqreturn_t stmmac_mac_interrupt(int irq, void *dev_id); static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id); static irqreturn_t stmmac_msi_intr_tx(int irq, void *data); static irqreturn_t stmmac_msi_intr_rx(int irq, void *data); +static void stmmac_reset_rx_queue(struct stmmac_priv *priv, u32 queue); +static void stmmac_reset_tx_queue(struct stmmac_priv *priv, u32 queue); +static void stmmac_reset_queues_param(struct stmmac_priv *priv); static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue); static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue); static void stmmac_set_dma_operation_mode(struct stmmac_priv *priv, u32 txmode, @@ -1648,9 +1651,6 @@ static int __init_dma_rx_desc_rings(struct stmmac_priv *priv, u32 queue, gfp_t f return -ENOMEM; } - rx_q->cur_rx = 0; - rx_q->dirty_rx = 0; - /* Setup the chained descriptor addresses */ if (priv->mode == STMMAC_CHAIN_MODE) { if (priv->extend_desc) @@ -1753,12 +1753,6 @@ static int __init_dma_tx_desc_rings(struct stmmac_priv *priv, u32 queue) tx_q->tx_skbuff[i] = NULL; } - tx_q->dirty_tx = 0; - tx_q->cur_tx = 0; - tx_q->mss = 0; - - netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); - return 0; } @@ -2644,10 +2638,7 @@ static void stmmac_tx_err(struct stmmac_priv *priv, u32 chan) stmmac_stop_tx_dma(priv, chan); dma_free_tx_skbufs(priv, chan); stmmac_clear_tx_descriptors(priv, chan); - tx_q->dirty_tx = 0; - tx_q->cur_tx = 0; - tx_q->mss = 0; - netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, chan)); + stmmac_reset_tx_queue(priv, chan); stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, tx_q->dma_tx_phy, chan); stmmac_start_tx_dma(priv, chan); @@ -3706,6 +3697,8 @@ static int stmmac_open(struct net_device *dev) goto init_error; } + stmmac_reset_queues_param(priv); + ret = stmmac_hw_setup(dev, true); if (ret < 0) { netdev_err(priv->dev, "%s: Hw setup failed\n", __func__); @@ -6332,6 +6325,7 @@ void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue) return; } + stmmac_reset_rx_queue(priv, queue); stmmac_clear_rx_descriptors(priv, queue); stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, @@ -6393,6 +6387,7 @@ void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue) return; } + stmmac_reset_tx_queue(priv, queue); stmmac_clear_tx_descriptors(priv, queue); stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, @@ -7319,6 +7314,25 @@ int stmmac_suspend(struct device *dev) } EXPORT_SYMBOL_GPL(stmmac_suspend); +static void stmmac_reset_rx_queue(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + + rx_q->cur_rx = 0; + rx_q->dirty_rx = 0; +} + +static void stmmac_reset_tx_queue(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + + tx_q->cur_tx = 0; + tx_q->dirty_tx = 0; + tx_q->mss = 0; + + netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); +} + /** * stmmac_reset_queues_param - reset queue parameters * @priv: device pointer @@ -7329,22 +7343,11 @@ static void stmmac_reset_queues_param(struct stmmac_priv *priv) u32 tx_cnt = priv->plat->tx_queues_to_use; u32 queue; - for (queue = 0; queue < rx_cnt; queue++) { - struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; - - rx_q->cur_rx = 0; - rx_q->dirty_rx = 0; - } - - for (queue = 0; queue < tx_cnt; queue++) { - struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + for (queue = 0; queue < rx_cnt; queue++) + stmmac_reset_rx_queue(priv, queue); - tx_q->cur_tx = 0; - tx_q->dirty_tx = 0; - tx_q->mss = 0; - - netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); - } + for (queue = 0; queue < tx_cnt; queue++) + stmmac_reset_tx_queue(priv, queue); } /**