Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1831120imw; Sat, 16 Jul 2022 16:18:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tM+JdoHLyC1V0xPcIJdoUhqP/sqDbfCJyZU7LyfaJXRWTV3DVZihafZY8ldHC9yf39wTml X-Received: by 2002:a17:907:271a:b0:72b:4ef4:2d8e with SMTP id w26-20020a170907271a00b0072b4ef42d8emr20130674ejk.634.1658013493833; Sat, 16 Jul 2022 16:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658013493; cv=none; d=google.com; s=arc-20160816; b=YOBXeXBTAxIYjgoxD/DaRdkxumUX5z2i41dE0CvfnwiSR32VxevorA+Y8iJNljWwIE LL+uxS8b69431b9MUCTFiVsHyTpfrS5HTkwsmUoLIgpvvV6sKtIfpBWkn1/CP+tWasoJ FpJKchVte9hV64GFhS6fYw5WYrDYCGpwRy+SPqA86Z0KTtQKOWr4EP6h5H+vPGO+f3vH LKMdsLUYfvwjzXV6XOl8v6PbuBMRC9sCYfQDHaWdhj/W5WzqrwPgBrOHgU4D+gg+NIMq n/eO2cENAkyprwVTR6z5Yl+wXVNLnHTI8IL7dmCOJgX6Ve74VNEal7zblXSMZEoNXYte RR1w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dtK+f+e69ktRtm1DfmKkH7OgqSKD4ay2ViO2yXXI+mw=; b=e1G52rVAmIqfYB0irrKTGPv6/oI5PQGjNKHTrUPGvDBfyZoVCUj7t7N3g+Anlgj3Xl s9CP5dXX+J0Yn58VRDcyCVmJB0sbLys05WSAYsoOnunnpRN3y+pYf7uRlhruINICTckT c1ueD0MSxaIN8e3/lccCFwXK1C6sbCGNXJUvnDLjzGL/SoDX778r+DPQxJrV7htN6CfC aDxRacZFmtUYaFNwWEW1c7x/q0ijOPgyzcZ7+3GgZ3guXvIxQ8AxkpEvhyrEaMTeJNhb n+utxivsDm6SuEVr9djkKqnOBpmE6iLW3Epo3VrT3laMx0KDBpUNkl5KQjRwKtxGtKET M9YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gBa6l3Fj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw11-20020a170906478b00b0072f17b3722csi4815514ejc.933.2022.07.16.16.17.49; Sat, 16 Jul 2022 16:18:13 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=gBa6l3Fj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232855AbiGPXIP (ORCPT + 99 others); Sat, 16 Jul 2022 19:08:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232839AbiGPXIM (ORCPT ); Sat, 16 Jul 2022 19:08:12 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF71B1A80A; Sat, 16 Jul 2022 16:08:11 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bu1so11820031wrb.9; Sat, 16 Jul 2022 16:08:11 -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=gBa6l3FjD2NBiKRdUrA+vSEfdVG/DuS1OVdJmo3gChyBx3IQNigjo951LIhpxNX52F u4B9wvUcH7dU2Y3jLtI3O5//+lw4ZHW+UMTOiuzUBg7JFE8A3fQfO3O3FLsI4gOEcy+M rKLVOPRt3sVedBuuxrPYiu3M+gMIesl580xcPJKASaQHowGtvat+G8dIAhLJkYDUl/9i F+apPfzh/vZU7e59DjvwC9tlQ38mDTw/Ha0L0SpW53qTsLjablVhsSsM9Fdx98QH9Pxu wdIVelNlEtlAdWOC2hfq0R/NA5+PndcESNcECKVpWaJ87AVYcbWH52ZLbRRvi/oT5fgx Aapw== 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=bEsht295dAMFPWuz6zFDwL1tIXApoTT9b3b7RtY2xIliBI8sLSUfLwx5QYaVNyAmep EwQkVT07rbtWiq9AXcasQToCdiinOptQugMjdQ8ydYgWZUInYtUICMckpC4jg32mIA0I sPVSpB6M2drYr1E4xLD+mQ7K/WTZ0R7phOQFOkKwZR5SGZg/DmaxxBda3FX2V6gIhf+P Fz2LAqcFALpYmdZsSaDOi0mKk9b8kEFKyauBYAggYq7AKNLJs20wXqSr4Agfsr2RcDkN nG8MC3rUuWWwPRFTvVT/xPViu0CwVGa6jfxXbNqL+t2lQxAAFAycgapZ/d7LoIHyELbN 2cwQ== X-Gm-Message-State: AJIora9Agbe3Zz7yd84RMG+gkPv2DA9zbtC6ehCkuRvNboZlO8A78l/4 4xATBWQLJUOWGsIuimhYgx8= X-Received: by 2002:adf:f211:0:b0:21d:6f1a:b857 with SMTP id p17-20020adff211000000b0021d6f1ab857mr18311465wro.614.1658012890128; Sat, 16 Jul 2022 16:08:10 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id l13-20020a05600c2ccd00b003a2f2bb72d5sm15150755wmc.45.2022.07.16.16.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jul 2022 16:08:09 -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 v3 1/5] net: ethernet: stmicro: stmmac: move queue reset to dedicated functions Date: Sun, 17 Jul 2022 01:07:58 +0200 Message-Id: <20220716230802.20788-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220716230802.20788-1-ansuelsmth@gmail.com> References: <20220716230802.20788-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 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); } /** -- 2.36.1