From patchwork Tue Nov 29 13:34:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 27236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp340704wrr; Tue, 29 Nov 2022 05:38:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf6wcmd5pUY6l0rL50wXk6iO+Ol/kJX4YniYA07QEKQCIrjPCLw0eJkZ6uzXczXECIFgCbTm X-Received: by 2002:a17:907:9010:b0:7ad:ba48:7e7c with SMTP id ay16-20020a170907901000b007adba487e7cmr47725187ejc.443.1669729090050; Tue, 29 Nov 2022 05:38:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669729090; cv=none; d=google.com; s=arc-20160816; b=tfgM2vjpXYSwUpzbxh5eBWYm4uVwPPCqe7CJcFFgeVRzSMZZjFukHIo5FFk3HfaGMw j3CPxg+LLccauzpQC/ipjEVj5svNYgjn+R9f64cdyyMA7qqExFohI7gLCogC796456BW a4jjDMYi65Klvo3STfDVIKVWBmL0aEh7i6D2X/THTMVaQNPNeO42pt6HFHftODsriqDa GSJEqHn2qFaL18mzdCUYFrc6TfGNquEuS3XRcE9POsq+Hc3aU13HamYndd6/0an2+pX1 6lQ1iRMPDbeApjYhOr1KjKqm+GMjpf+vyMvV3C4LYBJznpOGLMzRrzBhhAYmV3M1QA2g P0XQ== 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=U0xWu72zRL3sYdfI/x6/kKjsn2kmtTey9+kq3p3nqOI=; b=mbD5XJ6Z7FWHGcQgYoQM1TVU7x45JM6FKDk0JUFMeM28lwrNDC0yo2u/S/V5BIn00K Rm5yTI8fbpuJE4m8YdWMxDSU8i0lO2p2wJ/A4bEYwVqL/26kuCT4wnq3p9brzTasHNgc 0tofBM0HRslseASNLrd5oAvgZnWtjXpgV83tdT/pN3PvmPl1gkEGoaP27DAOOlIU05Cq F6GhZ3+un2prNTKAk4SRkOKOG78DAg0xXxIreZ5yUTLKbxw1jBNMrsXWPorKmWdVkls+ 9zBRF4yvGDLLfyPZsMgapuexYjFtmK0bSgBgC9ajLRPsBNQtWcZoN8HMkBnjc3eQIZzd vCPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WsahoVjm; 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 dn21-20020a17090794d500b007bfdadb58d8si4851497ejc.544.2022.11.29.05.37.45; Tue, 29 Nov 2022 05:38:10 -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=WsahoVjm; 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 S232515AbiK2NfR (ORCPT + 99 others); Tue, 29 Nov 2022 08:35:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231853AbiK2NfP (ORCPT ); Tue, 29 Nov 2022 08:35:15 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 402491FF8F; Tue, 29 Nov 2022 05:35:14 -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 F1F37B811BC; Tue, 29 Nov 2022 13:35:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A01AC433D7; Tue, 29 Nov 2022 13:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669728911; bh=VSOHmo7sDplewfab+OwnRAyCOu/HX80NiUna1LwAweg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WsahoVjm0ty0uYcAGRz7J33BoIStIU5MqEJP9ul5OIWU5H1yW0dddUUQ/bMQmJK6T bii/PYHtN/8Whh3ya9MXoojAefWyFEAj6+tJbJcEKQbaxyqGDleVMezfUL3vxzybxo 6bdyaRQLyH7vZW4ww26KGZHrwDddugdsuSUxP4LrrccN4Y0X3YQoJMVA7BVbXxXgxd qH90M/VMaCuvmdztowAF6lJ7McOBRRt8fCXqCfLO+hsdwaNGL9LaDX8fiDUSTZHK/E 8Gzkm5KUSpSEsGip35Vq9OpV1skBFIhbSXB2q4pei4b/aQQ3Q7HSCwMODdXpPHcMcf WzrXqMPFMvcBA== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: andrew@lunn.ch, 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 v4 net-next 1/6] Revert "net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume" Date: Tue, 29 Nov 2022 15:34:56 +0200 Message-Id: <20221129133501.30659-2-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221129133501.30659-1-rogerq@kernel.org> References: <20221129133501.30659-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?1750837850141377965?= X-GMAIL-MSGID: =?utf-8?q?1750837850141377965?= This reverts commit 1af3cb3702d02167926a2bd18580cecb2d64fd94. This is to make it easier to revert the offending commit fd23df72f2be ("net: ethernet: ti: am65-cpsw: Add suspend/resume support") Signed-off-by: Roger Quadros --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 7 ------- drivers/net/ethernet/ti/am65-cpsw-nuss.h | 2 -- 2 files changed, 9 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 6b0458df613a..b43dc75c2202 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2714,7 +2714,6 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) struct clk *clk; u64 id_temp; int ret, i; - int ale_entries; common = devm_kzalloc(dev, sizeof(struct am65_cpsw_common), GFP_KERNEL); if (!common) @@ -2809,10 +2808,6 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) goto err_of_clear; } - ale_entries = common->ale->params.ale_entries; - common->ale_context = devm_kzalloc(dev, - ale_entries * ALE_ENTRY_WORDS * sizeof(u32), - GFP_KERNEL); ret = am65_cpsw_init_cpts(common); if (ret) goto err_of_clear; @@ -2883,7 +2878,6 @@ static int am65_cpsw_nuss_suspend(struct device *dev) int i, ret; struct am65_cpsw_host *host_p = am65_common_get_host(common); - cpsw_ale_dump(common->ale, common->ale_context); host_p->vid_context = readl(host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); for (i = 0; i < common->port_num; i++) { port = &common->ports[i]; @@ -2942,7 +2936,6 @@ 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); return 0; } diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h index 4b75620f8d28..e95cc37a7286 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h @@ -149,8 +149,6 @@ struct am65_cpsw_common { struct net_device *hw_bridge_dev; struct notifier_block am65_cpsw_netdevice_nb; unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN]; - /* only for suspend/resume context restore */ - u32 *ale_context; }; struct am65_cpsw_ndev_stats { From patchwork Tue Nov 29 13:34:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 27235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp339848wrr; Tue, 29 Nov 2022 05:36:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf5nvry6iQbp/MJnsIo1vSOuWxfD6iOtEE6/5uVrJcE/IDcSOTRXvlvb0LzKFpR8E3k1nCqb X-Received: by 2002:a05:6402:1f03:b0:468:7be6:55e7 with SMTP id b3-20020a0564021f0300b004687be655e7mr51798059edb.345.1669728983306; Tue, 29 Nov 2022 05:36:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669728983; cv=none; d=google.com; s=arc-20160816; b=GNDiyii9TAx0yvFeS2oqSybPUkgu5LCFRwGMbNEUkaXpMrWAfbSnipA0F3ncglzgi+ uokF/f/uHuzLtKT23rQWxDQiFUtRrZh4GYrCUSaLWvtjsLgP+NTdy8QGLFANfPPPnvEz dTfNrnSmUf0XagQ+d27i4Nm1lTwN9gsIL1aj+Eepwy+jxeaL1t/GsdhvU2qomvoKNOxj Wn54oh0bShlIhklILZMWCcz4zHUA3AiyUNEIN9hr8ROuQb0i7zs4h7kUqT4kzOp74DL7 Jwu+5bQoA5zVLWIT3GgLyawHDjG5XdoB05zJ/3Cgej49hH6bluFzen0smm3S28NZyHd/ jpQg== 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=fvZYG9l58GQ50YFwa6j6Em7vcI2L8gova/KckLIeymM=; b=yEl5bP79+4mLMxAfaleXe+syGSJEGrT2Pelp73zgjoDwWZRfU/Pk8QZu/A/iB/lwhi 8o/HfM5cH++DbozWs9noRyKzlL0r0xBkMMhe29xBR4D9Q5FAMpfSLjVxreBFhN0tF2Xg dzou6e2z/KSn1ndWiCiicGo5Q+mkSEeAUUysBvlFY4xteHz1ffJ8aPxv5L2kp6jMcTYT H1X1x6xis/HUhQunFhTkwU4rmwgz5xENbJJgfojQoCVPqiG4JpFizZAMe1iulQB2PI4D E1de3t6TKIniem0rLa5ny42+WF4226uanZCEm9biDsVw2y7tScH3iG7uFamZPjVUHTer RMOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JMCK03I4; 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 n19-20020a170906b31300b007ae7d12bef1si9849307ejz.909.2022.11.29.05.35.58; Tue, 29 Nov 2022 05:36:23 -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=JMCK03I4; 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 S232729AbiK2NfV (ORCPT + 99 others); Tue, 29 Nov 2022 08:35:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232442AbiK2NfQ (ORCPT ); Tue, 29 Nov 2022 08:35:16 -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 CD90C1FF8F; Tue, 29 Nov 2022 05:35:15 -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 64EF761734; Tue, 29 Nov 2022 13:35:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 381F8C433D6; Tue, 29 Nov 2022 13:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669728914; bh=qfseqzA5QeFGbDcdL8jAeZcM/YWcdxti75h4w7j1dOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JMCK03I4+nK/r1o4v/OB6a6fornBI7jfIZY0bkDR8eoD0vZtnsLe5ULGlVbd3Xelb di/k080iP3YbqPUlU9uoFKWjGSyMedGRLDYtMz8doxRRKrKkBHoCkU9WzDT9e3QgqW F/9sWOCr9gt8IytrsAsvFMFXI3Hs0DbU761Uyj7IG0eQCWCXU9RafQYELP+ZHkcDCV CwcLHbWEcprw1vDI/KPz/sJwUDvktivx+Vx6xgqXqMmBnqL3VCoCP41jWQkisSu5f3 PqwHx7cp75HWygz4zlfWEwj8x76bHPBa01k9EgzI/N8B/VB7Erc1K02aE2quybItIk 1FMgfU/fVJfhQ== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: andrew@lunn.ch, 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 v4 net-next 2/6] Revert "net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume" Date: Tue, 29 Nov 2022 15:34:57 +0200 Message-Id: <20221129133501.30659-3-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221129133501.30659-1-rogerq@kernel.org> References: <20221129133501.30659-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?1750837738491103289?= X-GMAIL-MSGID: =?utf-8?q?1750837738491103289?= This reverts commit 643cf0e3ab5ccee37b3c53c018bd476c45c4b70e. This is to make it easier to revert the offending commit fd23df72f2be ("net: ethernet: ti: am65-cpsw: Add suspend/resume support") Signed-off-by: Roger Quadros --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 7 ------- drivers/net/ethernet/ti/am65-cpsw-nuss.h | 4 ---- 2 files changed, 11 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index b43dc75c2202..04e673902d53 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2876,9 +2876,7 @@ static int am65_cpsw_nuss_suspend(struct device *dev) struct am65_cpsw_port *port; struct net_device *ndev; int i, ret; - struct am65_cpsw_host *host_p = am65_common_get_host(common); - host_p->vid_context = readl(host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); for (i = 0; i < common->port_num; i++) { port = &common->ports[i]; ndev = port->ndev; @@ -2886,7 +2884,6 @@ static int am65_cpsw_nuss_suspend(struct device *dev) if (!ndev) continue; - port->vid_context = readl(port->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); netif_device_detach(ndev); if (netif_running(ndev)) { rtnl_lock(); @@ -2910,7 +2907,6 @@ static int am65_cpsw_nuss_resume(struct device *dev) struct am65_cpsw_port *port; struct net_device *ndev; int i, ret; - struct am65_cpsw_host *host_p = am65_common_get_host(common); am65_cpts_resume(common->cpts); @@ -2932,11 +2928,8 @@ static int am65_cpsw_nuss_resume(struct device *dev) } netif_device_attach(ndev); - writel(port->vid_context, port->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); } - writel(host_p->vid_context, host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); - return 0; } #endif /* CONFIG_PM_SLEEP */ diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h index e95cc37a7286..2c9850fdfcb6 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h @@ -55,16 +55,12 @@ struct am65_cpsw_port { bool rx_ts_enabled; struct am65_cpsw_qos qos; struct devlink_port devlink_port; - /* Only for suspend resume context */ - u32 vid_context; }; struct am65_cpsw_host { struct am65_cpsw_common *common; void __iomem *port_base; void __iomem *stat_base; - /* Only for suspend resume context */ - u32 vid_context; }; struct am65_cpsw_tx_chn { From patchwork Tue Nov 29 13:34:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 27239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp341288wrr; Tue, 29 Nov 2022 05:39:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4MFP20ntDTomKRBL8ZQQkdZqDyv+wOkwr6QevNRx/GayBOQvEFwiG+kAS1qGbIVQNUAeXz X-Received: by 2002:a17:906:8e0a:b0:7b9:bef6:3eea with SMTP id rx10-20020a1709068e0a00b007b9bef63eeamr27182250ejc.487.1669729161581; Tue, 29 Nov 2022 05:39:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669729161; cv=none; d=google.com; s=arc-20160816; b=AcuUa+b11RZzKGEBw2yCUbVRrSM8kfHLik6Yi6wf0HLpbp7ctM3gRcQUZP7l7IqinD vf07KEo7gTH32/8xc2Lil4CbvaCRaW6m5FCK2jbQEzxTRyF0SdYRpt1akh44Grkdo4sg FK8iyEN3aO/Mk0nvaQJmOYRt0S+qzA/+XivbOFlO2BRohawG/gZyxkA6/GmLHGlo+IER K1rc5/afDX0H8/qBKhPYwONdVKmDwyUhXpfegiadsXTVyX9ects5fKGCQyCR7k2/QxfP BIOmcTvTB5MkupZ8GpYKCcoAnTyfA2R0MCD1MyoHbi5m8s5TGZMTJsr/j1DFtIp/J4SP tPtw== 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=q//aGdRdoDB13dRDUW+d/zPykPEVARhyEzZXqnPIAEo=; b=s5HJ93V9cMhFRKc5dJFpci61bxofj+qhQ+5A76npSC46P+q2nTKBeWReiPNJI10UIb 4WMATmGMuZZL2r+FeX+Kl65kShWAfp/cDSwspyWEjg29iEK1AsN85MYOCFUH03IVXp77 3aPwCjr2reeku/E+Alh2XCcU6qmrqZ15hCBzJa6xu+EffIxs9tgs4oBU96jGMkov2mcg Mhn5hME/0cRS3Z2Af1uPHTF2nGtlh78+y6NXKfqBJOPnmUY66hF7PipBt4ufrVI898vh SeHeQOdEJFbJFuFffzWi3ZOwPf+NMiGDjyQJNrgh9ljWqfz/Ebs/qFIkx+6c8S2cnlhr UtKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PxUW4rsm; 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-20020a05640206c400b0046b5dac0671si3154699edy.407.2022.11.29.05.38.57; Tue, 29 Nov 2022 05:39:21 -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=PxUW4rsm; 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 S233156AbiK2Nf3 (ORCPT + 99 others); Tue, 29 Nov 2022 08:35:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbiK2NfW (ORCPT ); Tue, 29 Nov 2022 08:35:22 -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 C2943205C4; Tue, 29 Nov 2022 05:35:20 -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 44647B811BB; Tue, 29 Nov 2022 13:35:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49C84C433D7; Tue, 29 Nov 2022 13:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669728918; bh=YUV//X6HxHjXUQ1u7/m0WgbXNCSgLyJRZ3XKO02tN/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxUW4rsmkIDvgYG2+GmvDBtpkiUlU25QzmkNDx1X9eC6uhZxASJvp52DFbRQHEYOx A8wduBo4yvz0x/85Xd/Frio+qg3iQp5t64V5YhIZLwfiMYyAvjlVTjcGPDHqrvZuZB LKu0vVdXVZYkiB4aJndtJ2xjcJJqVzGQ3g84H/AfqYihIGkRLMWNksOHPw1LbY8Nym DReho5cnexj2vWTjfT2z6qXfhQkBK2IsPG317gMeivA2882w6m5SgpARwidwtok89D IIqLQSaPuu6V5YRC+4uGRA3kZoItvBqUzUfnH6FtNxr136ECBhxfryTcSsbnR8xyyD vtw2o1n1b8RXw== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: andrew@lunn.ch, 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 v4 net-next 3/6] Revert "net: ethernet: ti: am65-cpsw: Add suspend/resume support" Date: Tue, 29 Nov 2022 15:34:58 +0200 Message-Id: <20221129133501.30659-4-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221129133501.30659-1-rogerq@kernel.org> References: <20221129133501.30659-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?1750837925341927787?= X-GMAIL-MSGID: =?utf-8?q?1750837925341927787?= This reverts commit fd23df72f2be317d38d9fde0a8996b8e7454fd2a. This commit broke set channel operation. Revert this and implement it with a different approach in a separate patch. Signed-off-by: Roger Quadros --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 221 ++++++----------------- 1 file changed, 55 insertions(+), 166 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 04e673902d53..4836960b0dd8 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -133,11 +132,6 @@ 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 void am65_cpsw_port_set_sl_mac(struct am65_cpsw_port *slave, const u8 *dev_addr) { @@ -379,20 +373,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, @@ -421,7 +401,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 */ @@ -453,8 +432,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 +441,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 +450,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 +462,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 +515,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; } @@ -586,29 +555,11 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) struct am65_cpsw_common *common = am65_ndev_to_common(ndev); struct am65_cpsw_port *port = am65_ndev_to_port(ndev); int ret, i; - u32 reg; - int tmo; ret = pm_runtime_resume_and_get(common->dev); if (ret < 0) return ret; - /* Idle MAC port */ - 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 */ - cpsw_sl_reg_write(port->slave.mac_sl, CPSW_SL_SOFT_RESET, 1); - mdelay(1); - reg = cpsw_sl_reg_read(port->slave.mac_sl, CPSW_SL_SOFT_RESET); - if (reg) - dev_info(common->dev, "mac reset not yet done\n"); - /* Notify the stack of the actual queue counts. */ ret = netif_set_real_num_tx_queues(ndev, common->tx_ch_num); if (ret) { @@ -1539,9 +1490,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++) { @@ -1553,11 +1504,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)); } } @@ -1566,10 +1513,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); @@ -1639,7 +1588,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; @@ -1648,36 +1597,25 @@ 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; - 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 (!(rx_chn->irq < 0)) - devm_free_irq(common->dev, rx_chn->irq, common); - if (!IS_ERR_OR_NULL(rx_chn->desc_pool)) k3_cppi_desc_pool_destroy(rx_chn->desc_pool); @@ -1700,7 +1638,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; @@ -1772,20 +1710,12 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common) } } - 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; } @@ -2051,7 +1981,6 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx) port->slave.phylink_config.dev = &port->ndev->dev; port->slave.phylink_config.type = PHYLINK_NETDEV; port->slave.phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; - port->slave.phylink_config.mac_managed_pm = true; /* MAC does PM */ if (phy_interface_mode_is_rgmii(port->slave.phy_if)) { phy_interface_set_rgmii(port->slave.phylink_config.supported_interfaces); @@ -2113,16 +2042,28 @@ static int am65_cpsw_nuss_init_ndevs(struct am65_cpsw_common *common) 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) @@ -2591,6 +2532,15 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common) if (ret) return ret; + ret = devm_request_irq(dev, common->rx_chns.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", + common->rx_chns.irq, ret); + return ret; + } + ret = am65_cpsw_nuss_register_devlink(common); if (ret) return ret; @@ -2744,6 +2694,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; @@ -2785,6 +2736,14 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) am65_cpsw_nuss_get_ver(common); + /* init tx channels */ + ret = am65_cpsw_nuss_init_tx_chns(common); + if (ret) + goto err_of_clear; + ret = am65_cpsw_nuss_init_rx_chns(common); + if (ret) + goto err_of_clear; + ret = am65_cpsw_nuss_init_host_p(common); if (ret) goto err_of_clear; @@ -2869,80 +2828,10 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int am65_cpsw_nuss_suspend(struct device *dev) -{ - struct am65_cpsw_common *common = dev_get_drvdata(dev); - struct am65_cpsw_port *port; - struct net_device *ndev; - int i, ret; - - for (i = 0; i < common->port_num; i++) { - port = &common->ports[i]; - ndev = port->ndev; - - if (!ndev) - continue; - - netif_device_detach(ndev); - if (netif_running(ndev)) { - rtnl_lock(); - ret = am65_cpsw_nuss_ndo_slave_stop(ndev); - rtnl_unlock(); - if (ret < 0) { - netdev_err(ndev, "failed to stop: %d", ret); - return ret; - } - } - } - - am65_cpts_suspend(common->cpts); - - return 0; -} - -static int am65_cpsw_nuss_resume(struct device *dev) -{ - struct am65_cpsw_common *common = dev_get_drvdata(dev); - struct am65_cpsw_port *port; - struct net_device *ndev; - int i, ret; - - am65_cpts_resume(common->cpts); - - for (i = 0; i < common->port_num; i++) { - port = &common->ports[i]; - ndev = port->ndev; - - if (!ndev) - continue; - - if (netif_running(ndev)) { - rtnl_lock(); - ret = am65_cpsw_nuss_ndo_slave_open(ndev); - rtnl_unlock(); - if (ret < 0) { - netdev_err(ndev, "failed to start: %d", ret); - return ret; - } - } - - netif_device_attach(ndev); - } - - return 0; -} -#endif /* CONFIG_PM_SLEEP */ - -static const struct dev_pm_ops am65_cpsw_nuss_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(am65_cpsw_nuss_suspend, am65_cpsw_nuss_resume) -}; - static struct platform_driver am65_cpsw_nuss_driver = { .driver = { .name = AM65_CPSW_DRV_NAME, .of_match_table = am65_cpsw_nuss_of_mtable, - .pm = &am65_cpsw_nuss_dev_pm_ops, }, .probe = am65_cpsw_nuss_probe, .remove = am65_cpsw_nuss_remove, From patchwork Tue Nov 29 13:34:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 27237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp341121wrr; Tue, 29 Nov 2022 05:39:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7IM3yubjry0ER5ZiOQ7EM+n8X8iL4EIncsCn3GJXJ66gHRR82r5pMrRTCxf+BgV5uL4wI1 X-Received: by 2002:aa7:da01:0:b0:46b:9f6e:4005 with SMTP id r1-20020aa7da01000000b0046b9f6e4005mr473170eds.203.1669729142817; Tue, 29 Nov 2022 05:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669729142; cv=none; d=google.com; s=arc-20160816; b=S7QRQaxlQHA5zw7U21e6/cuLl7JjCGDFkuwefk2ZP9ococ+yyhENh4NTuhjZ5Stjjw M+yt9c4TBWs4paJTPSOMuNDz1mWwH5GEshKAw3Pbe0ZF04wXvA5aq17gC7ZyHk+O18ve PcrNPRsQrfwXZS63XIjqjP6IJTBqrn65wMdKqKlmupN9wDa2t2cy3ToY0YxskZ30geTE 4hxAnayKdTMpoY/Dm57JUmX6hXHtXNd8SlikoUplluuFGkZII63LQbJDexDF88xvPvkP VtHWexGF+elDMzzt83FrcRmRRlt36lMQYOPp/Jua9pnebwDMMh0+dLgKwl8A0CrokVmm GH/A== 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=ueiGB1kx+CEVN02b87efzByjmekFEtjx3nhX589lXps=; b=PTfCh7pS9Pu4tq3OzyyZFn6huY/Z2RTaQHqKApigIbdz5sKc/iPsd0zmca35TxlCRu xQ/Yxm7+8aEwMRfmm2czFhHOvXo+GINKHt1Aowka0DD1McLtZ+QvkROttnX/wgPEwJPw tEYy61O6E4pdndCKtPUfabBTJFUPBAgHwoLCvol8omom3y5+3MMFd9IA+fIFL6YUEkwq pMA6j9kR/eJAybwiMfzY0ujbAJYiUfuO3VJrVMBIy/r0DcjDBG8yXEuOxhyW2sMvysDR /ovTh+iU2Blk7EBqGNaOyR4X8A7vBHryxt7FJEjp5cwv9/NOH3kxj2s0TNlIsa4bYv03 R8cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r37DakOn; 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 gs7-20020a1709072d0700b007bf8440bc14si6110650ejc.784.2022.11.29.05.38.37; Tue, 29 Nov 2022 05:39:02 -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=r37DakOn; 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 S233479AbiK2Nfi (ORCPT + 99 others); Tue, 29 Nov 2022 08:35:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232871AbiK2NfX (ORCPT ); Tue, 29 Nov 2022 08:35:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB041AF21; Tue, 29 Nov 2022 05:35:22 -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 9BA7B61733; Tue, 29 Nov 2022 13:35:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75A4EC43147; Tue, 29 Nov 2022 13:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669728921; bh=Akebxp0tkGdzPF5g6bdCVkwLyU9aYk0NF67KH+Y9yhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r37DakOnvpmhg3HoJ1pP2IUTeXJEo6WRa87Rw+S3akUM/mODLqekDpkw5Z0vk3Qej WxH5LdQ04trWBtCtMac16igtZpBiAwT2VQSyuQi523F/HiNA4hxn6dOQWSDYvqE7OJ aiPGTUiM+JCIrkxAQ94DuQwvJ4NdKr7hW168y34oYoDl4jaf80g2STRMg3cqJDtHQ7 mtt71YgNDBc+O28UuJDjV1Qv0rq7DbOSRnVeVsg9b1bnzbf0TnuSlyF9CbDuywNXaO BAfKdsos9wqEOu+7j7/BJbxFqQo0ZHS32JH1EvnuJvs00P/IUYUWDi7aIYDxEUc8dm 5hhbwrkjrQppw== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: andrew@lunn.ch, 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 v4 net-next 4/6] net: ethernet: ti: am65-cpsw: Add suspend/resume support Date: Tue, 29 Nov 2022 15:34:59 +0200 Message-Id: <20221129133501.30659-5-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221129133501.30659-1-rogerq@kernel.org> References: <20221129133501.30659-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?1750837906057723849?= X-GMAIL-MSGID: =?utf-8?q?1750837906057723849?= Add PM handlers for System suspend/resume. As DMA driver doesn't yet support suspend/resume we free up the DMA channels at suspend and acquire and initialize them at resume. In this revised approach we do not free the TX/RX IRQs at am65_cpsw_nuss_common_stop() as it causes problems. 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. To make this easier: - introduce am65_cpsw_nuss_remove_rx_chns() which is similar to am65_cpsw_nuss_remove_tx_chns(). These will be invoked in pm.suspend() to release the DMA channels and free up the IRQs. - move napi_add() and request_irq() calls to am65_cpsw_nuss_init_rx/tx_chns() so we can invoke them in pm.resume() to acquire the DMA channels and IRQs. As CPTS looses contect during suspend/resume, invoke the necessary CPTS suspend/resume helpers. ALE_CLEAR command is issued in cpsw_ale_start() so no need to issue it before the call to cpsw_ale_start(). Signed-off-by: Roger Quadros --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 222 ++++++++++++++++++----- 1 file changed, 173 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 4836960b0dd8..1c5a51439427 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -555,11 +556,26 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) struct am65_cpsw_common *common = am65_ndev_to_common(ndev); struct am65_cpsw_port *port = am65_ndev_to_port(ndev); int ret, i; + u32 reg; ret = pm_runtime_resume_and_get(common->dev); if (ret < 0) return ret; + /* Idle MAC port */ + cpsw_sl_ctl_set(port->slave.mac_sl, CPSW_SL_CTL_CMD_IDLE); + cpsw_sl_wait_for_idle(port->slave.mac_sl, 100); + cpsw_sl_ctl_reset(port->slave.mac_sl); + + /* soft reset MAC */ + cpsw_sl_reg_write(port->slave.mac_sl, CPSW_SL_SOFT_RESET, 1); + mdelay(1); + reg = cpsw_sl_reg_read(port->slave.mac_sl, CPSW_SL_SOFT_RESET); + if (reg) { + dev_err(common->dev, "soft RESET didn't complete\n"); + return -EBUSY; + } + /* Notify the stack of the actual queue counts. */ ret = netif_set_real_num_tx_queues(ndev, common->tx_ch_num); if (ret) { @@ -1533,6 +1549,32 @@ void am65_cpsw_nuss_remove_tx_chns(struct am65_cpsw_common *common) } } +static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common) +{ + 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; + } + } + +err: + return ret; +} + static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common) { u32 max_desc_num = ALIGN(AM65_CPSW_MAX_TX_DESC, MAX_SKB_FRAGS); @@ -1599,6 +1641,12 @@ static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common) dev_name(dev), tx_chn->id); } + 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: i = devm_add_action(dev, am65_cpsw_nuss_free_tx_chns, common); if (i) { @@ -1623,6 +1671,29 @@ static void am65_cpsw_nuss_free_rx_chns(void *data) 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(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) { struct am65_cpsw_rx_chn *rx_chn = &common->rx_chns; @@ -1710,6 +1781,18 @@ 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); + goto err; + } + err: i = devm_add_action(dev, am65_cpsw_nuss_free_rx_chns, common); if (i) { @@ -1981,6 +2064,7 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx) port->slave.phylink_config.dev = &port->ndev->dev; port->slave.phylink_config.type = PHYLINK_NETDEV; port->slave.phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; + port->slave.phylink_config.mac_managed_pm = true; /* MAC does PM */ if (phy_interface_mode_is_rgmii(port->slave.phy_if)) { phy_interface_set_rgmii(port->slave.phylink_config.supported_interfaces); @@ -2034,35 +2118,6 @@ 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) -{ - 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; - } - } - -err: return ret; } @@ -2528,18 +2583,13 @@ 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 = devm_request_irq(dev, common->rx_chns.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", - common->rx_chns.irq, ret); + ret = am65_cpsw_nuss_init_rx_chns(common); + if (ret) return ret; - } ret = am65_cpsw_nuss_register_devlink(common); if (ret) @@ -2584,10 +2634,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 { @@ -2736,14 +2784,6 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) am65_cpsw_nuss_get_ver(common); - /* init tx channels */ - ret = am65_cpsw_nuss_init_tx_chns(common); - if (ret) - goto err_of_clear; - ret = am65_cpsw_nuss_init_rx_chns(common); - if (ret) - goto err_of_clear; - ret = am65_cpsw_nuss_init_host_p(common); if (ret) goto err_of_clear; @@ -2828,10 +2868,94 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int am65_cpsw_nuss_suspend(struct device *dev) +{ + struct am65_cpsw_common *common = dev_get_drvdata(dev); + struct am65_cpsw_port *port; + struct net_device *ndev; + int i, ret; + + for (i = 0; i < common->port_num; i++) { + port = &common->ports[i]; + ndev = port->ndev; + + if (!ndev) + continue; + + netif_device_detach(ndev); + if (netif_running(ndev)) { + rtnl_lock(); + ret = am65_cpsw_nuss_ndo_slave_stop(ndev); + rtnl_unlock(); + if (ret < 0) { + netdev_err(ndev, "failed to stop: %d", ret); + return ret; + } + } + } + + am65_cpts_suspend(common->cpts); + + am65_cpsw_nuss_remove_rx_chns(common); + am65_cpsw_nuss_remove_tx_chns(common); + + return 0; +} + +static int am65_cpsw_nuss_resume(struct device *dev) +{ + struct am65_cpsw_common *common = dev_get_drvdata(dev); + struct am65_cpsw_port *port; + struct net_device *ndev; + int i, ret; + + 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++) { + port = &common->ports[i]; + ndev = port->ndev; + + if (!ndev) + continue; + + if (netif_running(ndev)) { + rtnl_lock(); + ret = am65_cpsw_nuss_ndo_slave_open(ndev); + rtnl_unlock(); + if (ret < 0) { + netdev_err(ndev, "failed to start: %d", ret); + return ret; + } + } + + netif_device_attach(ndev); + } + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops am65_cpsw_nuss_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(am65_cpsw_nuss_suspend, am65_cpsw_nuss_resume) +}; + static struct platform_driver am65_cpsw_nuss_driver = { .driver = { .name = AM65_CPSW_DRV_NAME, .of_match_table = am65_cpsw_nuss_of_mtable, + .pm = &am65_cpsw_nuss_dev_pm_ops, }, .probe = am65_cpsw_nuss_probe, .remove = am65_cpsw_nuss_remove, From patchwork Tue Nov 29 13:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 27238 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp341125wrr; Tue, 29 Nov 2022 05:39:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Ta8QklVFLvXTezIyby7NLirV+k0ZKLzWiisfKn5ZLGBSpLhjMveAaXXaXwnDYdyuG/mgf X-Received: by 2002:a05:6402:4289:b0:467:9864:9463 with SMTP id g9-20020a056402428900b0046798649463mr34706463edc.360.1669729143253; Tue, 29 Nov 2022 05:39:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669729143; cv=none; d=google.com; s=arc-20160816; b=A8CpPECNSFPAca7cOvhE/P+1YzoavEpfVwN0VHWMp5b2oOgPlNAvIQWeVp5PSVrXVz 8lZJqSQ4kD24nfvLw+Z9J7rLqD9Fyo4qED0uNVhwqVaebHjYZ0hENvRMeItW/E2+u6Jd OyuPrMD5GItef4+IrqeWlImuP0MhxYqr98i67uuMFgWHhnpcO2kPj0ZkP7+dTNJFxP/L jbXxwX06nxVd/UqUnV+kiI7A8urCEC+OxXSaqaOIXjLYIWjUS2M2K9+0mohxQorpwwlU PzL72xq5w4kuk+kMeNaHVhgRQpjESq685hHED1d6ytlbIvJ4knQTeNpaRvrC6gtqn/Zx BefQ== 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=qy8xA0zcpVafowRrUuOu/cISebPAGYri72aD3olq/Ig=; b=UxE3osrm99kceFHZ30nc2YNCrcRSBpoZLnpskYBLggRKSkNfE7yATb2ibqqu2ANzm5 QGlYnQj2ge3i1vKDXffqdU9G9VVcm7rD4ZeAvT6Eicq0aoAvNOZu8Fl2YcbvS9Se+MFb ouXfk97bDaj9/jzNne6zbidCQM/x9krAvKHxWZyrZh2BQSgbL2o3HTGzn2RZf4Sp4bqB kaHTq2flyo5CJf+RCwpRsHcG/DDxMiZCnUTuQEji/B9qA0vhOX4w1S71oG+5UFZf8A03 qg+EW0NY1e0f9D6tWGHK2Fg92oTvE0Mk6fMPcxgTabMht6gmeDPF8sqLP8cQ3xk6rpJM K+lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xun1aE70; 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 j11-20020aa7de8b000000b0044f2eb2de9asi11162753edv.444.2022.11.29.05.38.37; Tue, 29 Nov 2022 05:39:03 -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=Xun1aE70; 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 S230353AbiK2Nfl (ORCPT + 99 others); Tue, 29 Nov 2022 08:35:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232976AbiK2Nf0 (ORCPT ); Tue, 29 Nov 2022 08:35:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E6931DC6; Tue, 29 Nov 2022 05:35:25 -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 B7C416172F; Tue, 29 Nov 2022 13:35:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8363BC433D7; Tue, 29 Nov 2022 13:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669728924; bh=VRP1vnYIcXaScFgVI3vxzPn1UkCZHA4CW5xgKdTodRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xun1aE70YOFjbOsUl8B3zWhgVOzLJrtV49CZiipMOdZXsPP8Yqbyuk7o1s3VgyW3q 01XTIuEyXXw9FXeoFSPQD54c0AeNTRxw11YBWisKKqEkzscX/YhZYh7M3q6RDnEvyJ ZQ1rM6ZNnuKFnUFqoMCA8q7DQqnGTtDZvZox72PzU3fK4I7j+MKrAadAf+rYsHeUnO JZV3uezSb4sgq3LRGg+WIXEACAgjbpbjB5MSgfOSDzpbMsciaaHELmRwDvs4jXkGM6 ZxhXffFsSg20KAb7PtZZEuDUV3IDhjWY1SlS/Iov0dGzgMu57AMrp/SZ+V/YF0akjM q12sBFJzefjyg== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: andrew@lunn.ch, 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 v4 net-next 5/6] net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume Date: Tue, 29 Nov 2022 15:35:00 +0200 Message-Id: <20221129133501.30659-6-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221129133501.30659-1-rogerq@kernel.org> References: <20221129133501.30659-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?1750837905888743867?= X-GMAIL-MSGID: =?utf-8?q?1750837905888743867?= During suspend resume the context of PORT_VLAN_REG is lost so save it during suspend and restore it during resume for host port and slave ports. Signed-off-by: Roger Quadros Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 7 +++++++ drivers/net/ethernet/ti/am65-cpsw-nuss.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 1c5a51439427..3f430f8d8a26 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2872,10 +2872,12 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev) static int am65_cpsw_nuss_suspend(struct device *dev) { struct am65_cpsw_common *common = dev_get_drvdata(dev); + struct am65_cpsw_host *host_p = am65_common_get_host(common); struct am65_cpsw_port *port; struct net_device *ndev; int i, ret; + host_p->vid_context = readl(host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); for (i = 0; i < common->port_num; i++) { port = &common->ports[i]; ndev = port->ndev; @@ -2883,6 +2885,7 @@ static int am65_cpsw_nuss_suspend(struct device *dev) if (!ndev) continue; + port->vid_context = readl(port->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); netif_device_detach(ndev); if (netif_running(ndev)) { rtnl_lock(); @@ -2909,6 +2912,7 @@ static int am65_cpsw_nuss_resume(struct device *dev) struct am65_cpsw_port *port; struct net_device *ndev; int i, ret; + struct am65_cpsw_host *host_p = am65_common_get_host(common); ret = am65_cpsw_nuss_init_tx_chns(common); if (ret) @@ -2941,8 +2945,11 @@ static int am65_cpsw_nuss_resume(struct device *dev) } netif_device_attach(ndev); + writel(port->vid_context, port->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); } + writel(host_p->vid_context, host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); + return 0; } #endif /* CONFIG_PM_SLEEP */ diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h index 2c9850fdfcb6..e95cc37a7286 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h @@ -55,12 +55,16 @@ struct am65_cpsw_port { bool rx_ts_enabled; struct am65_cpsw_qos qos; struct devlink_port devlink_port; + /* Only for suspend resume context */ + u32 vid_context; }; struct am65_cpsw_host { struct am65_cpsw_common *common; void __iomem *port_base; void __iomem *stat_base; + /* Only for suspend resume context */ + u32 vid_context; }; struct am65_cpsw_tx_chn { From patchwork Tue Nov 29 13:35:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 27240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp341328wrr; Tue, 29 Nov 2022 05:39:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf5WKwZ343xhqV04XIS1U7fZZOqyI72yZ2ZfuupVCIBz4YxPgOp1J5O6F4TihpR8eBDHBCAb X-Received: by 2002:aa7:cd04:0:b0:46b:34c:5574 with SMTP id b4-20020aa7cd04000000b0046b034c5574mr12724498edw.175.1669729168708; Tue, 29 Nov 2022 05:39:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669729168; cv=none; d=google.com; s=arc-20160816; b=cN55h9TVi1D9k8f02hTocviHDRMoESGWvf4sCkvbx1O4BGP0t5lG7UDphDDJEEkqnJ z9i7cGSzGscy+KCb1UYSIePWjJdOH2Oaabx1LoX0R8bNAPL5mMIw3EoF5/JUyqFMNtCN 8XGIt9sXTUE7Al9E6W0FuVTofK5sA94x+xIoB2+XRsAXIX1CrC54dOaMoTXl+8nQAzQy MNgoxn8nQaJqTd2FxvvBewOwosZGd4RQaoXndtlRxdLaqJ7O4qhZPi2mlTx/bRzwrZ2i 61DsVfG1BKj+H0VFWyqigFtC17ra87RYQz5L9PQ/tfkc0Lil0yC2uGiyCyiO0b/kaVR4 Wuqw== 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=sZ52KJ3nv7738Zg5dI3GJa/OgbFWzGlArxKU+olS9h4=; b=LyL3zYndYgryIuFdB/wkOahOKAllj3Uv/85+5iaFMBeOlAVfyzJxsOyfk9x5QCF48j UKDw03AXuFWcUEcoN21MfJ2CPcMRE9uTYMBsB3m/Yf9DZpAR8imQ48IQnMeXDi5KEE4N 1NyhoJ22NCDz7DN4JY185Ujp+2aMFjnIRJulUE/69LnE/warwcpXCZrlO0CD1lsizlvF lttlO6AMy/R8nUpcJdNKZhOKFnEYG5bCSa2d4noRhrtIZyKVr+mwQkEAU1oixaNJZYSH qivPu/7GIdBtt6VuJGZy1q4bNhJzW8zoot1XqbOq+fUjJVucscoRMDFQ+lBbfJaAudsn vdag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=e2HC3MD3; 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 cs17-20020a170906dc9100b007ad96737de4si12470553ejc.624.2022.11.29.05.39.04; Tue, 29 Nov 2022 05:39: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=e2HC3MD3; 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 S232643AbiK2Nf5 (ORCPT + 99 others); Tue, 29 Nov 2022 08:35:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233312AbiK2Nfh (ORCPT ); Tue, 29 Nov 2022 08:35:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C15FB627E8; Tue, 29 Nov 2022 05:35:29 -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 7D659B8162D; Tue, 29 Nov 2022 13:35:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1C01C43470; Tue, 29 Nov 2022 13:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669728927; bh=kvstdPpBR+/mRxEi9E/PktQ1fiwMJVU4LvP10NqUmvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2HC3MD37hGupbzyOmeEO1aA6t3RiMy+VB3YJXmAB38sCF+25Y9wsyskR4D2Qfjl8 C6xfy8E9hDaGsGlNBeV2j+Bi1MHF2QiNIuGSfjsL9gC5FzwJqQoIB0Mmw/uxIzOIYt UWRW3uDBhJgJj4+r1DFdpzIMPsymm4Dstsqo9TbGJgUPVZpNNdzKdZrF0ilFUtt330 BuUjDQinKbWlqaxMzRahjuOP0OeveEtwCz9EAUU0QYco7gul9AKh4uoXpZ1ngSp+Ir J5/K5hQ9739ItNHPtxZWSWDa089ugBy/af8lR9TwpykJqXk1b6n+m7RQimbOhYxuqW cTwjGas2LDYNg== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: andrew@lunn.ch, 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 v4 net-next 6/6] net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume Date: Tue, 29 Nov 2022 15:35:01 +0200 Message-Id: <20221129133501.30659-7-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221129133501.30659-1-rogerq@kernel.org> References: <20221129133501.30659-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?1750837932997069817?= X-GMAIL-MSGID: =?utf-8?q?1750837932997069817?= On low power during system suspend the ALE table context is lost. Save the ALE context before suspend and restore it after resume. Signed-off-by: Roger Quadros Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 7 +++++++ drivers/net/ethernet/ti/am65-cpsw-nuss.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 3f430f8d8a26..43bb71a471ae 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2712,6 +2712,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) struct clk *clk; u64 id_temp; int ret, i; + int ale_entries; common = devm_kzalloc(dev, sizeof(struct am65_cpsw_common), GFP_KERNEL); if (!common) @@ -2807,6 +2808,10 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) goto err_of_clear; } + ale_entries = common->ale->params.ale_entries; + common->ale_context = devm_kzalloc(dev, + ale_entries * ALE_ENTRY_WORDS * sizeof(u32), + GFP_KERNEL); ret = am65_cpsw_init_cpts(common); if (ret) goto err_of_clear; @@ -2877,6 +2882,7 @@ static int am65_cpsw_nuss_suspend(struct device *dev) struct net_device *ndev; int i, ret; + cpsw_ale_dump(common->ale, common->ale_context); host_p->vid_context = readl(host_p->port_base + AM65_CPSW_PORT_VLAN_REG_OFFSET); for (i = 0; i < common->port_num; i++) { port = &common->ports[i]; @@ -2949,6 +2955,7 @@ 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); return 0; } diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h index e95cc37a7286..4b75620f8d28 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h @@ -149,6 +149,8 @@ struct am65_cpsw_common { struct net_device *hw_bridge_dev; struct notifier_block am65_cpsw_netdevice_nb; unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN]; + /* only for suspend/resume context restore */ + u32 *ale_context; }; struct am65_cpsw_ndev_stats {