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: 626765 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A7BEC4332F for ; Wed, 16 Nov 2022 16:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238991AbiKPQvK (ORCPT ); Wed, 16 Nov 2022 11:51:10 -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> Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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; }