From patchwork Wed Nov 16 16:49:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 21180 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp248080wru; Wed, 16 Nov 2022 08:59:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf5pwbgQD1TlEwqAYZ1ejGXEat9G6Q7HkK1zGtGaQpybm5ktPRu69FGUNpFddx+KelSmPIdy X-Received: by 2002:a17:902:d54d:b0:186:886f:e1e0 with SMTP id z13-20020a170902d54d00b00186886fe1e0mr9781856plf.162.1668617962824; Wed, 16 Nov 2022 08:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668617962; cv=none; d=google.com; s=arc-20160816; b=cWJp7VJWfM3Euz8LBrmLAY//06Q5Etr3iP5CqGKngdNrOwAuyasABBCxccd/uZoZ5E aSBZVc5EEFMv1jOkSmFwcH8FwWK3uwgf3k8YG/AHf6xUFpy0GNATMbToVGQRXfvG4H6M zA+956vW++6ruWm3myvhH4fZUs26PEsdBvC6DJHvTvGKb2+/s1kNsG251FHzjGqa1/AZ uzLY9IrA5BGtqQ/GyeTxN6ToRZB7UxKkVvhsiQJppMJXATEV7S4WtZV89DtoEv3RECzn H9+pTv8YtdHyZJHTn1VG1iKJWBfKwnSApJ2pDFCqS/Zg8seP7f6qZIHO/hmdjrBMKZZz gcCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=te4hB+FAMcvIfsa9MBMIw3NQZWr7BPrC3P77sMSU2l4=; b=PzxQFPFTy65R0NYAuSsE6nVGd4cJO6Gb6dWKkYE19lTrLo0Qmc1G9XXSwQ7HwTLPQ5 w/ULw0pV0+pjGQf4cwdPqhR1rtK6WRKVbj199C/vS3QVitz/a21EsKOqP2qHnb1V0LI2 5Kok4+pQhT+YT2g85MM+v3UUwWsH/UPau8jqQ+6bh/TzDnmfGRrOYlhYHespWgv+TAKd 8i9QVS1dQtQqL+O09UKRe9UN/Dqt/BtrIpnZqm690hxJFHW5LqBvwSya4+Lrwlr/FngJ RuVLJA/1kSJNhZ0EBJ1ABA0Ky4ybgYUoUSro1k4bzcIP0TlDZpUks+qry0QNv8h4j9GV vEhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="EnG/VCOB"; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z13-20020a170902d54d00b001782bd6c443si15586110plf.621.2022.11.16.08.59.10; Wed, 16 Nov 2022 08:59:22 -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=@kernel.org header.s=k20201202 header.b="EnG/VCOB"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbiKPQv0 (ORCPT + 99 others); Wed, 16 Nov 2022 11:51:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239058AbiKPQur (ORCPT ); Wed, 16 Nov 2022 11:50:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09F3030E; Wed, 16 Nov 2022 08:49:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 98A08B81DB4; Wed, 16 Nov 2022 16:49:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23DC8C433D6; Wed, 16 Nov 2022 16:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668617364; bh=E6yZWb4Zgw7rrjeckDWIQDswo1fWS678H2ta34vLVeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EnG/VCOBKFFnDY0bj7dOu9i1eGZ/wMIkTyHAjXKBJeijtkZ25bkh8qZ7Ro8Nt9ets darTkPByZzoBHA0QdYc20TxKbYQE/+s3WWQE6NwsKU4oPQjH+Cywyw1scyQcUz83cf 4hBybG0L/nKEtlvjAiY5ENe5x4Z0XfOGGd3bogXgS5GqOLZL0MlYcBcKwTDJLMBK+v W+Hwb5yH+tvDQKWo9PDGDhJeaOyREfytjYkn4j8rx4AW74Z/6hPb4ngHa1N44wJlwZ 9MEv26Mu6VCwUbXy6TDmJ2423NhXO5u12Y+18bpU3SbmpzYRuIefMrfksiEx44nWNj olKV1LlIa5s4Q== From: Roger Quadros To: davem@davemloft.net, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH 1/4] net: ethernet: ti: am65-cpsw: Fix set channel operation Date: Wed, 16 Nov 2022 18:49:12 +0200 Message-Id: <20221116164915.13236-2-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221116164915.13236-1-rogerq@kernel.org> References: <20221116164915.13236-1-rogerq@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749672636971697281?= X-GMAIL-MSGID: =?utf-8?q?1749672749066929793?= The set channel operation "ethtool -L tx " broke with the recent suspend/resume changes. Revert back to original driver behaviour of not freeing the TX/RX IRQs at am65_cpsw_nuss_common_stop(). We will now free them only on .suspend() as we need to release the DMA channels (as DMA looses context) and re-acquiring them on .resume() may not necessarily give us the same IRQs. Introduce am65_cpsw_nuss_remove_rx_chns() which is similar to am65_cpsw_nuss_remove_tx_chns() and invoke them both in .suspend(). At .resume() call am65_cpsw_nuss_init_rx/tx_chns() to acquire the DMA channels. To as IRQs need to be requested after knowing the IRQ numbers, move am65_cpsw_nuss_ndev_add_tx_napi() call to am65_cpsw_nuss_init_tx_chns(). Also fixes the below warning during suspend/resume on multi CPU system. [ 67.347684] ------------[ cut here ]------------ [ 67.347700] Unbalanced enable for IRQ 119 [ 67.347726] WARNING: CPU: 0 PID: 1080 at kernel/irq/manage.c:781 __enable_irq+0x4c/0x80 [ 67.347754] Modules linked in: wlcore_sdio wl18xx wlcore mac80211 libarc4 cfg80211 rfkill crct10dif_ce sch_fq_codel ipv6 [ 67.347803] CPU: 0 PID: 1080 Comm: rtcwake Not tainted 6.1.0-rc4-00023-gc826e5480732-dirty #203 [ 67.347812] Hardware name: Texas Instruments AM625 (DT) [ 67.347818] pstate: 400000c5 (nZcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 67.347829] pc : __enable_irq+0x4c/0x80 [ 67.347838] lr : __enable_irq+0x4c/0x80 [ 67.347846] sp : ffff80000999ba00 [ 67.347850] x29: ffff80000999ba00 x28: ffff0000011c1c80 x27: 0000000000000000 [ 67.347863] x26: 00000000000001f4 x25: ffff000001058358 x24: ffff000001059080 [ 67.347876] x23: ffff000001058080 x22: ffff000001060000 x21: 0000000000000077 [ 67.347888] x20: ffff0000011c1c80 x19: ffff000001429600 x18: 0000000000000001 [ 67.347900] x17: 0000000000000080 x16: fffffc000176e008 x15: ffff0000011c21b0 [ 67.347913] x14: 0000000000000000 x13: 3931312051524920 x12: 726f6620656c6261 [ 67.347925] x11: 656820747563205b x10: 000000000000000a x9 : ffff80000999ba00 [ 67.347938] x8 : ffff800009121068 x7 : ffff80000999b810 x6 : 00000000fffff17f [ 67.347950] x5 : ffff00007fb99b18 x4 : 0000000000000000 x3 : 0000000000000027 [ 67.347962] x2 : ffff00007fb99b20 x1 : 50dd48f7f19deb00 x0 : 0000000000000000 [ 67.347975] Call trace: [ 67.347980] __enable_irq+0x4c/0x80 [ 67.347989] enable_irq+0x4c/0xa0 [ 67.347999] am65_cpsw_nuss_ndo_slave_open+0x4b0/0x568 [ 67.348015] am65_cpsw_nuss_resume+0x68/0x160 [ 67.348025] dpm_run_callback.isra.0+0x28/0x88 [ 67.348040] device_resume+0x78/0x160 [ 67.348050] dpm_resume+0xc0/0x1f8 [ 67.348057] dpm_resume_end+0x18/0x30 [ 67.348063] suspend_devices_and_enter+0x1cc/0x4e0 [ 67.348075] pm_suspend+0x1f8/0x268 [ 67.348084] state_store+0x8c/0x118 [ 67.348092] kobj_attr_store+0x18/0x30 [ 67.348104] sysfs_kf_write+0x44/0x58 [ 67.348117] kernfs_fop_write_iter+0x118/0x1a8 [ 67.348127] vfs_write+0x31c/0x418 [ 67.348140] ksys_write+0x6c/0xf8 [ 67.348150] __arm64_sys_write+0x1c/0x28 [ 67.348160] invoke_syscall+0x44/0x108 [ 67.348172] el0_svc_common.constprop.0+0x44/0xf0 [ 67.348182] do_el0_svc+0x2c/0xc8 [ 67.348191] el0_svc+0x2c/0x88 [ 67.348201] el0t_64_sync_handler+0xb8/0xc0 [ 67.348209] el0t_64_sync+0x18c/0x190 [ 67.348218] ---[ end trace 0000000000000000 ]--- Fixes: fd23df72f2be ("net: ethernet: ti: am65-cpsw: Add suspend/resume support") Signed-off-by: Roger Quadros --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 160 +++++++++++++---------- 1 file changed, 88 insertions(+), 72 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index f2e377524088..f8899ac5e249 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -133,10 +133,7 @@ NETIF_MSG_IFUP | NETIF_MSG_PROBE | NETIF_MSG_IFDOWN | \ NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) -static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common); -static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common); -static void am65_cpsw_nuss_free_tx_chns(struct am65_cpsw_common *common); -static void am65_cpsw_nuss_free_rx_chns(struct am65_cpsw_common *common); +static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common); static void am65_cpsw_port_set_sl_mac(struct am65_cpsw_port *slave, const u8 *dev_addr) @@ -379,20 +376,6 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) if (common->usage_count) return 0; - /* init tx/rx channels */ - ret = am65_cpsw_nuss_init_tx_chns(common); - if (ret) { - dev_err(common->dev, "init_tx_chns failed\n"); - return ret; - } - - ret = am65_cpsw_nuss_init_rx_chns(common); - if (ret) { - dev_err(common->dev, "init_rx_chns failed\n"); - am65_cpsw_nuss_free_tx_chns(common); - return ret; - } - /* Control register */ writel(AM65_CPSW_CTL_P0_ENABLE | AM65_CPSW_CTL_P0_TX_CRC_REMOVE | AM65_CPSW_CTL_VLAN_AWARE | AM65_CPSW_CTL_P0_RX_PAD, @@ -453,8 +436,7 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) GFP_KERNEL); if (!skb) { dev_err(common->dev, "cannot allocate skb\n"); - ret = -ENOMEM; - goto err; + return -ENOMEM; } ret = am65_cpsw_nuss_rx_push(common, skb); @@ -463,7 +445,7 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) "cannot submit skb to channel rx, error %d\n", ret); kfree_skb(skb); - goto err; + return ret; } kmemleak_not_leak(skb); } @@ -472,7 +454,7 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) for (i = 0; i < common->tx_ch_num; i++) { ret = k3_udma_glue_enable_tx_chn(common->tx_chns[i].tx_chn); if (ret) - goto err; + return ret; napi_enable(&common->tx_chns[i].napi_tx); } @@ -484,12 +466,6 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) dev_dbg(common->dev, "cpsw_nuss started\n"); return 0; - -err: - am65_cpsw_nuss_free_tx_chns(common); - am65_cpsw_nuss_free_rx_chns(common); - - return ret; } static void am65_cpsw_nuss_tx_cleanup(void *data, dma_addr_t desc_dma); @@ -543,9 +519,6 @@ static int am65_cpsw_nuss_common_stop(struct am65_cpsw_common *common) writel(0, common->cpsw_base + AM65_CPSW_REG_CTL); writel(0, common->cpsw_base + AM65_CPSW_REG_STAT_PORT_EN); - am65_cpsw_nuss_free_tx_chns(common); - am65_cpsw_nuss_free_rx_chns(common); - dev_dbg(common->dev, "cpsw_nuss stopped\n"); return 0; } @@ -597,9 +570,6 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) cpsw_sl_ctl_set(port->slave.mac_sl, CPSW_SL_CTL_CMD_IDLE); tmo = cpsw_sl_wait_for_idle(port->slave.mac_sl, 100); - dev_info(common->dev, "down msc_sl %08x tmo %d\n", - cpsw_sl_reg_read(port->slave.mac_sl, CPSW_SL_MACSTATUS), tmo); - cpsw_sl_ctl_reset(port->slave.mac_sl); /* soft reset MAC */ @@ -1548,9 +1518,9 @@ static void am65_cpsw_nuss_slave_disable_unused(struct am65_cpsw_port *port) cpsw_sl_ctl_reset(port->slave.mac_sl); } -static void am65_cpsw_nuss_free_tx_chns(struct am65_cpsw_common *common) +static void am65_cpsw_nuss_free_tx_chns(void *data) { - struct device *dev = common->dev; + struct am65_cpsw_common *common = data; int i; for (i = 0; i < common->tx_ch_num; i++) { @@ -1562,11 +1532,7 @@ static void am65_cpsw_nuss_free_tx_chns(struct am65_cpsw_common *common) if (!IS_ERR_OR_NULL(tx_chn->tx_chn)) k3_udma_glue_release_tx_chn(tx_chn->tx_chn); - /* Don't clear tx_chn memory as we need to preserve - * data between suspend/resume - */ - if (!(tx_chn->irq < 0)) - devm_free_irq(dev, tx_chn->irq, tx_chn); + memset(tx_chn, 0, sizeof(*tx_chn)); } } @@ -1575,10 +1541,12 @@ void am65_cpsw_nuss_remove_tx_chns(struct am65_cpsw_common *common) struct device *dev = common->dev; int i; + devm_remove_action(dev, am65_cpsw_nuss_free_tx_chns, common); + for (i = 0; i < common->tx_ch_num; i++) { struct am65_cpsw_tx_chn *tx_chn = &common->tx_chns[i]; - if (!(tx_chn->irq < 0)) + if (tx_chn->irq) devm_free_irq(dev, tx_chn->irq, tx_chn); netif_napi_del(&tx_chn->napi_tx); @@ -1648,7 +1616,7 @@ static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common) } tx_chn->irq = k3_udma_glue_tx_get_irq(tx_chn->tx_chn); - if (tx_chn->irq < 0) { + if (tx_chn->irq <= 0) { dev_err(dev, "Failed to get tx dma irq %d\n", tx_chn->irq); goto err; @@ -1657,41 +1625,59 @@ static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common) snprintf(tx_chn->tx_chn_name, sizeof(tx_chn->tx_chn_name), "%s-tx%d", dev_name(dev), tx_chn->id); - - ret = devm_request_irq(dev, tx_chn->irq, - am65_cpsw_nuss_tx_irq, - IRQF_TRIGGER_HIGH, - tx_chn->tx_chn_name, tx_chn); - if (ret) { - dev_err(dev, "failure requesting tx%u irq %u, %d\n", - tx_chn->id, tx_chn->irq, ret); - tx_chn->irq = -EINVAL; - goto err; - } } - return 0; + ret = am65_cpsw_nuss_ndev_add_tx_napi(common); + if (ret) { + dev_err(dev, "Failed to add tx NAPI %d\n", ret); + goto err; + } err: - am65_cpsw_nuss_free_tx_chns(common); + i = devm_add_action(dev, am65_cpsw_nuss_free_tx_chns, common); + if (i) { + dev_err(dev, "Failed to add free_tx_chns action %d\n", i); + return i; + } return ret; } -static void am65_cpsw_nuss_free_rx_chns(struct am65_cpsw_common *common) +static void am65_cpsw_nuss_free_rx_chns(void *data) { + struct am65_cpsw_common *common = data; struct am65_cpsw_rx_chn *rx_chn; rx_chn = &common->rx_chns; + if (!IS_ERR_OR_NULL(rx_chn->desc_pool)) + k3_cppi_desc_pool_destroy(rx_chn->desc_pool); + + if (!IS_ERR_OR_NULL(rx_chn->rx_chn)) + k3_udma_glue_release_rx_chn(rx_chn->rx_chn); +} + +static void am65_cpsw_nuss_remove_rx_chns(void *data) +{ + struct am65_cpsw_common *common = data; + struct am65_cpsw_rx_chn *rx_chn; + struct device *dev = common->dev; + + rx_chn = &common->rx_chns; + devm_remove_action(dev, am65_cpsw_nuss_free_rx_chns, common); + if (!(rx_chn->irq < 0)) - devm_free_irq(common->dev, rx_chn->irq, common); + devm_free_irq(dev, rx_chn->irq, common); + + netif_napi_del(&common->napi_rx); if (!IS_ERR_OR_NULL(rx_chn->desc_pool)) k3_cppi_desc_pool_destroy(rx_chn->desc_pool); if (!IS_ERR_OR_NULL(rx_chn->rx_chn)) k3_udma_glue_release_rx_chn(rx_chn->rx_chn); + + common->rx_flow_id_base = -1; } static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common) @@ -1709,7 +1695,7 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common) rx_cfg.swdata_size = AM65_CPSW_NAV_SW_DATA_SIZE; rx_cfg.flow_id_num = AM65_CPSW_MAX_RX_FLOWS; - rx_cfg.flow_id_base = -1; + rx_cfg.flow_id_base = common->rx_flow_id_base; /* init all flows */ rx_chn->dev = dev; @@ -1781,20 +1767,24 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common) } } + netif_napi_add(common->dma_ndev, &common->napi_rx, + am65_cpsw_nuss_rx_poll); + ret = devm_request_irq(dev, rx_chn->irq, am65_cpsw_nuss_rx_irq, IRQF_TRIGGER_HIGH, dev_name(dev), common); if (ret) { dev_err(dev, "failure requesting rx irq %u, %d\n", rx_chn->irq, ret); - rx_chn->irq = -EINVAL; goto err; } - return 0; - err: - am65_cpsw_nuss_free_rx_chns(common); + i = devm_add_action(dev, am65_cpsw_nuss_free_rx_chns, common); + if (i) { + dev_err(dev, "Failed to add free_rx_chns action %d\n", i); + return i; + } return ret; } @@ -2114,24 +2104,33 @@ static int am65_cpsw_nuss_init_ndevs(struct am65_cpsw_common *common) return ret; } - netif_napi_add(common->dma_ndev, &common->napi_rx, - am65_cpsw_nuss_rx_poll); - return ret; } static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common) { - int i; + struct device *dev = common->dev; + int i, ret = 0; for (i = 0; i < common->tx_ch_num; i++) { struct am65_cpsw_tx_chn *tx_chn = &common->tx_chns[i]; netif_napi_add_tx(common->dma_ndev, &tx_chn->napi_tx, am65_cpsw_nuss_tx_poll); + + ret = devm_request_irq(dev, tx_chn->irq, + am65_cpsw_nuss_tx_irq, + IRQF_TRIGGER_HIGH, + tx_chn->tx_chn_name, tx_chn); + if (ret) { + dev_err(dev, "failure requesting tx%u irq %u, %d\n", + tx_chn->id, tx_chn->irq, ret); + goto err; + } } - return 0; +err: + return ret; } static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common) @@ -2597,7 +2596,11 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common) struct am65_cpsw_port *port; int ret = 0, i; - ret = am65_cpsw_nuss_ndev_add_tx_napi(common); + /* init tx channels */ + ret = am65_cpsw_nuss_init_tx_chns(common); + if (ret) + return ret; + ret = am65_cpsw_nuss_init_rx_chns(common); if (ret) return ret; @@ -2645,10 +2648,8 @@ int am65_cpsw_nuss_update_tx_chns(struct am65_cpsw_common *common, int num_tx) common->tx_ch_num = num_tx; ret = am65_cpsw_nuss_init_tx_chns(common); - if (ret) - return ret; - return am65_cpsw_nuss_ndev_add_tx_napi(common); + return ret; } struct am65_cpsw_soc_pdata { @@ -2756,6 +2757,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) if (common->port_num < 1 || common->port_num > AM65_CPSW_MAX_PORTS) return -ENOENT; + common->rx_flow_id_base = -1; init_completion(&common->tdown_complete); common->tx_ch_num = 1; common->pf_p0_rx_ptype_rrobin = false; @@ -2918,6 +2920,9 @@ static int am65_cpsw_nuss_suspend(struct device *dev) am65_cpts_suspend(common->cpts); + am65_cpsw_nuss_remove_rx_chns(common); + am65_cpsw_nuss_remove_tx_chns(common); + return 0; } @@ -2929,6 +2934,17 @@ static int am65_cpsw_nuss_resume(struct device *dev) int i, ret; struct am65_cpsw_host *host_p = am65_common_get_host(common); + ret = am65_cpsw_nuss_init_tx_chns(common); + if (ret) + return ret; + ret = am65_cpsw_nuss_init_rx_chns(common); + if (ret) + return ret; + + /* If RX IRQ was disabled before suspend, keep it disabled */ + if (common->rx_irq_disabled) + disable_irq(common->rx_chns.irq); + am65_cpts_resume(common->cpts); for (i = 0; i < common->port_num; i++) { From patchwork Wed Nov 16 16:49:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 21181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp248119wru; Wed, 16 Nov 2022 08:59:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf7agKJigDDLMh9DEDBikNYcj5+BO0rSZ44qWYq6AiP3lMo+EVggd78awhGyHnO2ZdWZLqVZ X-Received: by 2002:a17:902:a402:b0:186:994b:5b55 with SMTP id p2-20020a170902a40200b00186994b5b55mr10033017plq.100.1668617968971; Wed, 16 Nov 2022 08:59:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668617968; cv=none; d=google.com; s=arc-20160816; b=sBNEmRiXcCl5E8M+A3l0Bx2bC09DMrhJht/ZOW77NBXNPOtO+Qg1NKBVVABL4rSPNr 1kNu6ihTBtdRovjrZK2ojsEJ5hlJolxIJVFsXYcSrfdzwf7wjBbfUR40+Zu6EeJXDTsX hOBTAs/RJPKpCc7Xv3ybWJWhMktxSOtmBXNtN0sLpjaTXR5mlpKGKSrtwwGZABDtEEvN Hhmk9dDc7STBitqAyf15rsA2y1+trY7FfaB7BdzZ4Vlti2cKohKOAsR97FHTZCX+yaCL S9lvbTrrvGdLq6qUlNnhzd6qpaO1FcqU1rJ1vJXlpCLpKqo9Wf5LIJQ5bNT65BPvpoZi sT5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ByuitP/gl1A6jrn6Sjyz8Qzq9Z6CHdwwioyVapJn0xk=; b=vz8sUg1xdXwnCOrOBIVx7SidVbGff1vOHClDOc1aSuAzo7YuA9eCcVL2RRPCTt9MbL 3hUoGN++NMpGZZGuJx8Zu5IyHR7H0/tjWC4BbbVoSiKo3F5rsRG0Ir0iSRnICe2Z1Xfr WPDk8GQtBYbwErnwXgqjRKQKCYQnLS3JBZ4E+b3UmKaVter9ERyD7v8/o2t/bXkrBYIA yJgrxzShiHnQZOYKV8jTUAQY0IXu//u7hz6c69bmLfZ2RcMUIff0LMxz4W4A3nm6Dujf lclv3H4Jhi0UlOZw/lFtzsWaYB/lT7wNrvIXCL3futMWOQEDMQlFQODfHCdqMf3iDZBU OL0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cRlE3TGR; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k36-20020a635624000000b00476cd353915si4061254pgb.63.2022.11.16.08.59.16; Wed, 16 Nov 2022 08:59:28 -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=@kernel.org header.s=k20201202 header.b=cRlE3TGR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbiKPQva (ORCPT + 99 others); Wed, 16 Nov 2022 11:51:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239079AbiKPQur (ORCPT ); Wed, 16 Nov 2022 11:50:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F223EBFD; Wed, 16 Nov 2022 08:49:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8F47C61EEE; Wed, 16 Nov 2022 16:49:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8684C433C1; Wed, 16 Nov 2022 16:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668617367; bh=16nnj3/xX+6iwyOgTVs9QzovzYa3SNqQYQfd1VXyLeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRlE3TGR1U6cSXl9fCHIs/XV+TdWdcs1TMYAMDX5IWHXUGnSlu2GVTDFRuKhE4VOl +abfIUsa9kbUOuYcqWi7o4oDK+DCRpCYUNAC0nXEAqzWT5dGEgam3hyrxSPVyCdl7j oU2woeD6kE4BKXBAw98UQ5WEAXiNatFhBmHIqd5brvAI3eS9nhYBuoApAp+fYZ4p3d F0091tTLQTi7S4kWOZv9wBUX3PYpw1HBskoCE1MstIiJ5eWwR4mIcFp7XGOYFCqytb 7rfAdNldYJd88eUIHV+EOgK1PQ3rqyrsnPbcQaibnCEKtCWWEWohoH6EiMXkTnBzL4 eYweCjtYAAKLA== From: Roger Quadros To: davem@davemloft.net, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH 2/4] net: ethernet: ti: am65-cpsw-nuss: Remove redundant ALE_CLEAR Date: Wed, 16 Nov 2022 18:49:13 +0200 Message-Id: <20221116164915.13236-3-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221116164915.13236-1-rogerq@kernel.org> References: <20221116164915.13236-1-rogerq@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749672755306032389?= X-GMAIL-MSGID: =?utf-8?q?1749672755306032389?= ALE_CLEAR command is issued in cpsw_ale_start() so no need to issue it before the call to cpsw_ale_start(). Fixes: fd23df72f2be ("net: ethernet: ti: am65-cpsw: Add suspend/resume support") Signed-off-by: Roger Quadros --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index f8899ac5e249..4107e9df65cd 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -404,7 +404,6 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) /* disable priority elevation */ writel(0, common->cpsw_base + AM65_CPSW_REG_PTYPE); - cpsw_ale_control_set(common->ale, 0, ALE_CLEAR, 1); cpsw_ale_start(common->ale); /* limit to one RX flow only */ From patchwork Wed Nov 16 16:49:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 21178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp247409wru; Wed, 16 Nov 2022 08:57:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf6cXHkdZBgB2yV2VEOx9YXsLd/nmd/3bVZubRgdu7tSU6sLdMooSPwxqSLKI84U35LlRnY9 X-Received: by 2002:a17:902:76ca:b0:188:4ba9:79ee with SMTP id j10-20020a17090276ca00b001884ba979eemr9865276plt.83.1668617874052; Wed, 16 Nov 2022 08:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668617874; cv=none; d=google.com; s=arc-20160816; b=dzdCVqaJyRUbKLuLxCVvBzRKnDRviHvAyJA5cfbkqSi4bFcNojpjGuzyHlmS2/hqFZ FDbC9N1bGWt7MfGKB7dGtrwtBTqcHR7dik0MqTnlXuF1hw6dfQ7tTaaonJia6zwBT5NL rwRAs64aUMxD0igHLrtdHgx2SEtx62iqsZXOU5g/43Yfq47yH8CjomHk/Aqc8kyl9035 FbfS/0Adm4RVWv+bpPo2MKTaMqPe46NDGpzqCId0DEH9rNVj429Dqe4HXijeD6z+6M68 nYRnm/HIhACH204pwy+G8wDB43SpPOzQ0G129lWtpawP4p56eXPxPbhY4T0Sgr8Xw9M4 rg1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=PQFNmsQA2shYgRBUJtaFfVqsS/IN8otDuRu/VsyQ+Xs=; b=sxFHZ7NEnFtptKdQPazXhpREIk0PQ70KQhW4evtRDfepHMbSSnpP7k0qXhjjsX+6n+ go1LaQUPof/z/uDEgx8INXqk6JYfM/QT6n1r3vSyJmnzolhUuCoUf/qJIAYVrmoy+yhN drqMs4+M1177fJ9/sOtXxiFEpVFiL5GQB5inqnZVabJ7zmy4BM6M86k1Rb6/0rBIqa0P QXNekOJn74XaF/k6Lh301rU/Cvqc/tFKSOCFbd0SMUGpaIO2NBOMNkUgjtakmqZJF9jA epxVnYVMxs1Z99hpZMQ49clJncFwhqoegPc4EsdiKm6aUkVZbgJuKWiAxHZm7ttAEHMC TttQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bRc42h0h; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f14-20020a170902ce8e00b00186b1459953si16949968plg.382.2022.11.16.08.57.41; Wed, 16 Nov 2022 08:57:54 -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=@kernel.org header.s=k20201202 header.b=bRc42h0h; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233378AbiKPQvO (ORCPT + 99 others); Wed, 16 Nov 2022 11:51:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239087AbiKPQus (ORCPT ); Wed, 16 Nov 2022 11:50:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B306127B; Wed, 16 Nov 2022 08:49:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 423ED61EEF; Wed, 16 Nov 2022 16:49:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77E5DC433D7; Wed, 16 Nov 2022 16:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668617369; bh=+Yl4jjx33Nm+4lEyKhK/gA6nkezg3rtXvgUlWPsJ0wM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bRc42h0h2SVfBHFiiWOdAzQgZ9ojwrl0PCcB8tMt4/0OM5qTBCUOQd7vuSsMQg7rF /fttjPYOBp1zsMHTohX2Rq3TtgkTP4PVRdWhbQVOd+fXrXRywxaWBXdzigRfzs/Ekq EQiNvTK3lpQupWmbc1uOK3c9lNftGce3/KPwsNC+gQuCpwZMXisQF2SCRsSpZuOb4C Vtg6Sf8OjrrOijqf1UGBKa7L/vu26bFaUSk8QLN33fflTPUCpFas1seSpO15/Sis40 IWsHpyCCdJ1zPR5X3fw8lpTnKMP1ZFXoEXFaAaPOQp11tOAqk5P+BkRGUpKRsJf7aw rQJHZDTPX6StQ== From: Roger Quadros To: davem@davemloft.net, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH 3/4] net: ethernet: ti: am65-cpsw: Restore ALE only if any interface was up Date: Wed, 16 Nov 2022 18:49:14 +0200 Message-Id: <20221116164915.13236-4-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221116164915.13236-1-rogerq@kernel.org> References: <20221116164915.13236-1-rogerq@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749672655786333755?= X-GMAIL-MSGID: =?utf-8?q?1749672655786333755?= There is no point in restoring ALE if all interfaces were down prior to suspend as ALE will be cleared when any interface is brought up. So restore ALE only if any interface was up before system suspended. Fixes: 1af3cb3702d0 ("net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume") Signed-off-by: Roger Quadros --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 4107e9df65cd..9f3871373ebd 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2932,6 +2932,7 @@ static int am65_cpsw_nuss_resume(struct device *dev) struct net_device *ndev; int i, ret; struct am65_cpsw_host *host_p = am65_common_get_host(common); + bool need_ale_restore = false; ret = am65_cpsw_nuss_init_tx_chns(common); if (ret) @@ -2954,6 +2955,7 @@ static int am65_cpsw_nuss_resume(struct device *dev) continue; if (netif_running(ndev)) { + need_ale_restore = true; rtnl_lock(); ret = am65_cpsw_nuss_ndo_slave_open(ndev); rtnl_unlock(); @@ -2968,7 +2970,8 @@ static int am65_cpsw_nuss_resume(struct device *dev) } writel(host_p->vid_context, host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); - cpsw_ale_restore(common->ale, common->ale_context); + if (need_ale_restore) + cpsw_ale_restore(common->ale, common->ale_context); return 0; } From patchwork Wed Nov 16 16:49:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 21179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp247578wru; Wed, 16 Nov 2022 08:58:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf7mvDyjFC6677e2E25Agnfja/Y8/474t+be6PE24+Kmpd1K1dQ5SYM9VCUAi/DfhYu//a3M X-Received: by 2002:a17:903:32c7:b0:187:403c:7a15 with SMTP id i7-20020a17090332c700b00187403c7a15mr10014783plr.28.1668617898687; Wed, 16 Nov 2022 08:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668617898; cv=none; d=google.com; s=arc-20160816; b=NelVRjvyBreN1k4mve3dy8vMAw9LnuCdTxlPjaSSp3yGaWkYWYNB3JEQcbcmyp7n4W gA1ohC329AQbw7CI3sU6kYpWfuA3pk26osf7B9JA3yCvAXV9orw8CtKg4Bc3yJS6ezgU pS+fr+Vcrzzr0iJdiA70L0jKJKpHDCfUwZb60HKNfI8jW3uaP/ytK+NFwJmwJdzhVvTq x05wGLQMYUAVaDtl5COEtldyhcjWqZDVOgtSY9l+XXwTHZGuOBGdxfrcjOnBaNIwKq8k TWoi+jgbQ6Ro7wgUoFQ1ZQSO8o9sDvbsMH66MWfG9oCfMnhwj3O3rWlBrwBLeulMLVkI U0uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=NgJNf0hJAGvV104ZzCyAi2fWI9UoRFdPBJS6aRl1IS4=; b=eNY0547Xo18CptLF7nWMV2ifku64JKEy9HsK5FFP5I9HfWkfCJnXgyFZDYpzndFy60 DJzEvoIv6lvKsoEf5gQgcGVbDBVf8hZ5nWzMaOkp3f5WOS4R37OtaKdRVGBxU14bdPvn VncFlZ7mpA5i7nC7l5yHXnbfLz4hUf519htJKJFXv5CnzyAZaKX9ZCKGDttNkjldmlBT J77KkjJIEJYXPDBaYrqrgtw/oW84xRdOzYJ73jAokVsphj0BSLzyPK74Aizdb5s0AbsX eDjllZY7iZk1zzpGDgGJdrjTLpGFhUqZa4KNNRvMfN3j2fXWUquIKCmSMMmig9A8adw9 8fhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ANYxNHBC; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020a17090a9f0400b00213d28acc5esi2154261pjp.73.2022.11.16.08.58.06; Wed, 16 Nov 2022 08:58:18 -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=@kernel.org header.s=k20201202 header.b=ANYxNHBC; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239022AbiKPQvS (ORCPT + 99 others); Wed, 16 Nov 2022 11:51:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239097AbiKPQus (ORCPT ); Wed, 16 Nov 2022 11:50:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504821112; Wed, 16 Nov 2022 08:49:33 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E13D861EEE; Wed, 16 Nov 2022 16:49:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27E8AC43470; Wed, 16 Nov 2022 16:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668617372; bh=qvQKpvLNHVXrB7+8IiQETTMMyyG0jxiPHRO3yv3NGeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ANYxNHBCK+3ptBc0Q7XznL1jDwyzPsSoTxs+evIacNUxebzuC/LZTteEaU9DEWbit GIYnMdJCpq6n6QPwuplWul7GiAKSkSQAGskQLG7mPqUfzMAOo9xRZl7Nr1oVE7g7SZ aWCGtwi36aK+2QfOmvWflT4ft81C0z732rEqRCbta9gUrFRIUU4Lvcl5xSRGiWOviS iMkUOSgrwwuC2ktvIsRTq1G0CIRNm7P4B2BQTb2hqNelq8bxqhxs6zWwkPpo7eD2FQ 7qyWD+oBngSS2a/93aQLLg5oca8BiEyhOEEbqzevf86/mteZgbyB1ogBT+7W6rCYlK 2NoCFlOBOzgYA== From: Roger Quadros To: davem@davemloft.net, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH 4/4] net: ethernet: ti: cpsw_ale: optimize cpsw_ale_restore() Date: Wed, 16 Nov 2022 18:49:15 +0200 Message-Id: <20221116164915.13236-5-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221116164915.13236-1-rogerq@kernel.org> References: <20221116164915.13236-1-rogerq@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749672681793112083?= X-GMAIL-MSGID: =?utf-8?q?1749672681793112083?= If an entry was FREE then we don't have to restore it. This will make the restore faster in most cases. Signed-off-by: Roger Quadros --- drivers/net/ethernet/ti/cpsw_ale.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c index 0c5e783e574c..41bcf34a22f8 100644 --- a/drivers/net/ethernet/ti/cpsw_ale.c +++ b/drivers/net/ethernet/ti/cpsw_ale.c @@ -1452,12 +1452,15 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) } } +/* ALE table should be cleared (ALE_CLEAR) before cpsw_ale_restore() */ void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data) { - int i; + int i, type; for (i = 0; i < ale->params.ale_entries; i++) { - cpsw_ale_write(ale, i, data); + type = cpsw_ale_get_entry_type(data); + if (type != ALE_TYPE_FREE) + cpsw_ale_write(ale, i, data); data += ALE_ENTRY_WORDS; } }