From patchwork Tue Dec 6 09:44: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: 30175 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2725308wrr; Tue, 6 Dec 2022 01:46:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7KYapXCsOYo8V8sHcRMvvVsMzS3fTUKPIbW5ayuK90ufbQJHSbH+KIA2myusbM0BKvq9QV X-Received: by 2002:a63:d516:0:b0:477:857d:d264 with SMTP id c22-20020a63d516000000b00477857dd264mr59375613pgg.224.1670320004686; Tue, 06 Dec 2022 01:46:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670320004; cv=none; d=google.com; s=arc-20160816; b=q8J1yJKka7tM9nSZte3td0sgM37rZGHIW6T7+0BiOwjk1Nk16HyRvdZ2i7nSXFO4uP B7rrHDnFxFi6zHeS4LFN9YAyvxPS1knX8EG71DB1T0jaBiGQk16hCQwM7S3eDhbn63Fj fKH4jtWgYq4Cu+UvmzBFmJeiJpEbTbgj4flxG8N61pld3zbJuRqHo0iUUZ8M01IwSJ86 P4i4iR+NOj6Da4KIUMKbmjTb6i1ozbyM5lZS/0ON10R+ra3bOluErRcTHKLUnOxyYkSX Hx8UZy5oLHx+ckdKkuffrULd8FV7lwbyjm2UhGQXp9oZX2qvOahqhf9Kdkmof7xOTx1H FeoQ== 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=0doNRbfNpaAUvkVuRlqjZHWXhqQvzm9SS/6Xx3cTpDuVxlNF9ZgPuueE/DQpRgiY8C +H73MvF31NkFaVWYWk/ZN0UkTLxlQCwo3FiuXOR1/40v7nD/9vooGqk5KG2KOi+X+tV8 gW2ioQoFy2MHo5ZlLDspUOWQ9wWdKphRo9TzuD6A2w/oXgQjxmvTFSK204INKUFSLeX8 XNOI0owGUd+jQaKBj+IzAPxwn9TjSTPo78v9funEygOODYHdeIQLDZELBbX7N2JstvBj +NTxVH0sAJJb6oop0UHckvZkl6ovaV9UgHOC0BAe8GdinILKUyVhTvdlNj8STyS/agta xvRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="V6J8C2/c"; 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 35-20020a630f63000000b004783d7e5815si17289064pgp.326.2022.12.06.01.46.31; Tue, 06 Dec 2022 01:46:44 -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="V6J8C2/c"; 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 S232517AbiLFJpA (ORCPT + 99 others); Tue, 6 Dec 2022 04:45:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234665AbiLFJoc (ORCPT ); Tue, 6 Dec 2022 04:44:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F11531F617; Tue, 6 Dec 2022 01:44:31 -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 ACA08B818DC; Tue, 6 Dec 2022 09:44:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0EC3C43470; Tue, 6 Dec 2022 09:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670319869; bh=VSOHmo7sDplewfab+OwnRAyCOu/HX80NiUna1LwAweg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V6J8C2/cHCfR44VAIpwwg0tQFNPz++e5xG8Gh+/NrVd/0saykYQLSxzKq3eYQaDoC ooqDSDjZ6qsCCHMedJiDc057FQnogG7TAunxG3hLUBvuqmtJKCPltdrhgP2a225306 xPE7zMKM1qU2xuGeawsn2apbE88I2sDtSgKmth+12xW3N9wVdSyU7EOLPwnFyczoRy +6TXnVTD+fq9u9taY6tZfTG1xGGhQmDslbd4oKRuHuGQe/OlsbNnJJuOVp5uiImpib b467v6mjGUyQuyDa+FgMlJx9kPbN0ivKHeUYqfNZ5ArsNAV1h0UpbarKfduN9/jtGW XtcBAJLtxlK4A== 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 v5 net-next 1/6] Revert "net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume" Date: Tue, 6 Dec 2022 11:44:14 +0200 Message-Id: <20221206094419.19478-2-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221206094419.19478-1-rogerq@kernel.org> References: <20221206094419.19478-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?1751457469505807721?= X-GMAIL-MSGID: =?utf-8?q?1751457469505807721?= 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 Dec 6 09:44: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: 30178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2725674wrr; Tue, 6 Dec 2022 01:47:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf76fm9NktzFpItZoODS4we7ZruscwuWDM1e24yBUH6DOVQ7IP/ySawpIPGPUisiBWgp0Bmx X-Received: by 2002:a17:90b:4b42:b0:20a:e38c:8c5f with SMTP id mi2-20020a17090b4b4200b0020ae38c8c5fmr99941804pjb.217.1670320067254; Tue, 06 Dec 2022 01:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670320067; cv=none; d=google.com; s=arc-20160816; b=mKnsQogOGUWYZx5TnpjhjXsRZAF7t6HuR6/Ety9cQgU9XRDYvWRt+ikcycC8xB/F5U EJuMK3SFMeaJcTbN++t0XkD+/g2BpKfJ5h+GM3EvSDwujCQS5hJYMr5ftq/nuOQH85NS KPtcnShVenmV0vBS8MrqM7lgPEovkwZCLRY+sy40sSBwtO+Xgcc1ZAT+/MS3P7r+LkcZ k4jLJsVtL9mb0odQ0FcNsEJJJvhpqZATUmUVCyHJ1k9O0ABIXeA5HzQYzZa+DSgWKjNf qkVfptusf8D7FimmRLUQhQG3D+2nDmtSm7dLFUgGayhJcdo8sV2OI6HGdAXiOx+EIM+p slcQ== 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=V8WDAn5NafCvw97Hp2vC5PTYUKSJ0ikp59EgI3bk32lBANCHmp4ndB5SFPiCI4l1SI KTTgI2y2fX8Q0CIT2SP97xgeofdH/4Qi+zbaCaErxCfA15A35iVW9mmEkvGvx48Q/4jo eD+DsXr8Wk3k0aMY7tdOYw+0Y/W6a/oKlAir0ESx9l83RFjFeitac8UJVdPxNW/xPpQv EARplLrOTQVSmyyHKejy/DmmXmj5L/qe3Q4mRZZMEIPHIcBqlGw6+Y4l0wNDNDbsUZIB HGU6VBMSZ/+l8BqIXX6bsmesf/XDoXQkFfYyzYtO9I6yMYZq7RaEMnOwV8/yXcw2lcD0 GphQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DB4TuuoF; 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 ng9-20020a17090b1a8900b002190fb26b8csi21038033pjb.51.2022.12.06.01.47.32; Tue, 06 Dec 2022 01:47:47 -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=DB4TuuoF; 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 S235138AbiLFJpE (ORCPT + 99 others); Tue, 6 Dec 2022 04:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234152AbiLFJof (ORCPT ); Tue, 6 Dec 2022 04:44:35 -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 DC03E1FFB9; Tue, 6 Dec 2022 01:44: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 1188F615F2; Tue, 6 Dec 2022 09:44:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9680C433B5; Tue, 6 Dec 2022 09:44:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670319872; bh=qfseqzA5QeFGbDcdL8jAeZcM/YWcdxti75h4w7j1dOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DB4TuuoFEjC9yPus6kn+ASqRmWMtngOEm4CPxzS+jsRg+bvW9aaufDxTXlT4zChRN bzECIztBxEChh2Y09Sbk9DcHZei2MvX/2B3LhD+TD9OnR/kYfrrtCvkj/s7bCH0fHd HF/HWLsnMykmjigc+ZeqoWG3Q7Trp1jes4UXhPQ9++590/kyDzYPxykGx1Vhb6fY62 To93trYuhuI5OVUo/W/OJRin06TjvpeHtdmRi4YyxFIlMvvzjCDIUcmxKTMFf5exn6 5EkgEztdyW4akMgfk8KgZFQtsTN9rHwvn6GESo2CxnjvnzFevOyCJEgKq6bTdpICNz S37HH3CXH0mYw== 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 v5 net-next 2/6] Revert "net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume" Date: Tue, 6 Dec 2022 11:44:15 +0200 Message-Id: <20221206094419.19478-3-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221206094419.19478-1-rogerq@kernel.org> References: <20221206094419.19478-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?1751457534780287051?= X-GMAIL-MSGID: =?utf-8?q?1751457534780287051?= 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 Dec 6 09:44:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 30180 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2725738wrr; Tue, 6 Dec 2022 01:47:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf4wTc38vpXIT96XF9EcHA9GvNWyi1OBkKOIfakQ3eLghivbigOoJjVpHHMeG6waGlxgzjt6 X-Received: by 2002:a17:90a:d991:b0:219:767e:845 with SMTP id d17-20020a17090ad99100b00219767e0845mr27198493pjv.209.1670320077636; Tue, 06 Dec 2022 01:47:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670320077; cv=none; d=google.com; s=arc-20160816; b=tpLNdL9Sgu/qBCNlrr3ZqRqvon0xYNLsMUb9yZjgINHGbzMIZR3GlUwNOVpwjQ9kQ3 Xu1dSqEM65h/BHQlmN2e9b+qC4Ydb9JoeI+VVXSbQlmhc4BzR/h7sTmACpMpZV6qSrf/ ME8gWFq06D4M96ihYny3K7W8CMZpbJGnaU64UeHe8Ciq14uDEREIwca+rElLnnAWQuI6 yEJ93d6jOzJDL+2HC0yIUFZTBEN4/5hHLjnfGBAwE2tgVYzvDfLuXXX1Ls/n1GXqSmyf 92usNwDoh4MrcBIgeLHciKgAlZzfL9z6+5Gjqu+FdvZADalGVENZwD6gi23rMM1CwpDY UzNA== 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=XHyViwnE9igBE0Gf8Ud8TLdF+3mD9HwCOUetiMnP4oU7a6XgevNlGwXuD0dxd8oV4f UqPrXRqflD5wAjsaK5TqH22L7n/A+aFoMUncBKcAliE8w5GyEDLZUDkQG5+YC8GqI3ei GQzhjCaSVgmEfr0r8vOaPlJ7IdnOvtghcs+y+4JQX6RHsgtFef+Cb1lqJnu9460mib4v FdwbN4r2r0RQP+nF8MNUidiAunoKPACH63xVKt4AH0bWBNZLvllyKZ/wwYxDeyJfoC+W oS+4UPT4F5cBVQRzWiguKZykyTOm+7smsOEUnIgXU29Z8gVlpAWpgriiMV0oa4yzdFWh uypw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uN7AS7+p; 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 o6-20020a17090aac0600b0021859b5fe8asi16286320pjq.145.2022.12.06.01.47.44; Tue, 06 Dec 2022 01:47:57 -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=uN7AS7+p; 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 S234728AbiLFJpQ (ORCPT + 99 others); Tue, 6 Dec 2022 04:45:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbiLFJol (ORCPT ); Tue, 6 Dec 2022 04:44:41 -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 5D4AF1DDCE; Tue, 6 Dec 2022 01:44:38 -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 E0132B818DC; Tue, 6 Dec 2022 09:44:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2872C433D6; Tue, 6 Dec 2022 09:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670319875; bh=YUV//X6HxHjXUQ1u7/m0WgbXNCSgLyJRZ3XKO02tN/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uN7AS7+plpDJKhxaAzhxi4VHVpFHL7ZPMikxwAhj7G1XnfZWeyTB83BnMpW4OwDyu /r/zv8zs5hRR2x8utaoKBS68jB6qUCTVnzZWvS1LOzAM1zhQChEVmum+X7yUf6yeeQ CD2rICOrj/h++ZAoRhgWRalePMLFaWyVfhcW7+mY3efhQ71x3WJBRdkW9shE4R91a7 zHBK+7l8e9oB1s8XCc88R6T9RnDuDpkzmTGlgBZ2rv/1tgPV7nX0je465Ep9r9BVg7 bAAFgZ2BOBRm/Yk5wsL3Wicd1t4EWuYDBeMzlp+kRuumfV5VCvY4mTzTYddJDTSE8T vrSlMgt+vqTQQ== 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 v5 net-next 3/6] Revert "net: ethernet: ti: am65-cpsw: Add suspend/resume support" Date: Tue, 6 Dec 2022 11:44:16 +0200 Message-Id: <20221206094419.19478-4-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221206094419.19478-1-rogerq@kernel.org> References: <20221206094419.19478-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?1751457545440648931?= X-GMAIL-MSGID: =?utf-8?q?1751457545440648931?= 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 Dec 6 09:44:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 30176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2725515wrr; Tue, 6 Dec 2022 01:47:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pHC0Cj6LHx9vAokt0YQYJs4JSgFvRRjRKAptedM+ul1qP08v9PDAn26fx69DaFNKPXOg8 X-Received: by 2002:a17:906:a052:b0:7be:beb3:1343 with SMTP id bg18-20020a170906a05200b007bebeb31343mr35388778ejb.211.1670320035288; Tue, 06 Dec 2022 01:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670320035; cv=none; d=google.com; s=arc-20160816; b=FoXkoLA2phIAj2l7Zky550TYZbACdWB1PAQuA/mL/6eqp3V3AxNIKmhGDsszo21lSv tDSeOSWLg0Ap5G2MGPD171Vu1oLQPx5pnmmiR2lD1of3HdzsZUfmjDW/bvTQw+LYLE+Q 70Da5Ti/gmZ5CHJWVW2acIUztAIieZqcfERXa2c69diZ+Xsan0BxC/dh8HpY91zqJ0+W kSLgGRJjiyv9tkLDlayDZ+B0HfSvG4xLACe/CnyNNRoh3uyf+TtuS+G84hYELG2lj7Wk XZ0RNdFPyd1LXVceAbS2wwfCmGrOUDQOr24rmWb8Ll6lVGtqAoftr6mi8PdQFWhm0+kV 7TjQ== 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=Ta1GRQDtjUOoHDfDBwaR8bMwVMReoX54qApPe0d/z38=; b=Ub3GCwIAPJvJKGx0qPRl1Qx+u8FrC5PWimEwGd6CTRdMp5EyTO0aYeNxqF3/veUGEU 4D6PtozL9L0DbXz07xH0iPdxaKPsNP3CnioSkAtqo9mHDgG+eweS/vMw8PvEfZAkLbRP 3t1fS3O/ApYv9de1eaNy3ZrwDLh/IZpCQ45bheMnrP4i02PftbJTujlzNp8YwdxiFmWR o00zUC774xY9DTe43WoeXbX/Q2tHFnxjsYnNryKMDUNNjOmmKXmV3aAnGBPyWPX5d5ix wYUUM2Zmhpmqao66rNNNV3IYbHMA8V8m1/suJf90/bxp8DmYh4sWStXTK4IflP4HpQ6N 5LyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EMNxWSqe; 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 du16-20020a17090772d000b0078d112eaf80si12796028ejc.86.2022.12.06.01.46.48; Tue, 06 Dec 2022 01:47:15 -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=EMNxWSqe; 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 S233790AbiLFJpJ (ORCPT + 99 others); Tue, 6 Dec 2022 04:45:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231259AbiLFJom (ORCPT ); Tue, 6 Dec 2022 04:44:42 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42CF91B9CB; Tue, 6 Dec 2022 01:44:41 -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 E45EBB818E2; Tue, 6 Dec 2022 09:44:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 181BCC43470; Tue, 6 Dec 2022 09:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670319878; bh=KwOC16sAb3gp7rYWDcKaZTwcztj1jlcYqvinDHQ6C00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EMNxWSqe2VKpEtiPCe+S3UL5OOGMZ6vpunEmNil3pnKeVCw+jX5JFgywuCs0B+2rf onEM+3iTcL5mijhSlj3Ijh87YyFGMFA8oLKf0Q3UxY4D4MQpuGEAEwMp3M8CBW9l1r zPghL5fkgZtjF/BjhQa0IgY3CA25b30GY/RQhy4906PunEr1rTtUIAe+IO1ZxaH0fi ODV90cghurc4FQH9VFGmVnkxAkuvaS7Gtos0Om6/zci1WWyRSQVYy7szksl+DdVtlU cdFYVKkOTyBx9pTiQ2BV0mH4/tX758i7e+6CZytmMxm2MdeHE6OgbCfhV8J9klQEJF oLM1Mryy3BnjA== 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 v5 net-next 4/6] net: ethernet: ti: am65-cpsw: Add suspend/resume support Date: Tue, 6 Dec 2022 11:44:17 +0200 Message-Id: <20221206094419.19478-5-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221206094419.19478-1-rogerq@kernel.org> References: <20221206094419.19478-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?1751457501340863555?= X-GMAIL-MSGID: =?utf-8?q?1751457501340863555?= 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..d4618edd2f9c 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 -ETIMEDOUT; + } + /* 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 Dec 6 09:44:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 30182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2726378wrr; Tue, 6 Dec 2022 01:49:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Tl4ANz43qb6saFVJRut69GqxqvIluAv08ZTJOxhypfOb3AZiD3zylN4MQQ6Og/cpk65q1 X-Received: by 2002:a17:90a:384c:b0:219:ed2c:f253 with SMTP id l12-20020a17090a384c00b00219ed2cf253mr5271722pjf.211.1670320194370; Tue, 06 Dec 2022 01:49:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670320194; cv=none; d=google.com; s=arc-20160816; b=xmvpqXZBdAAczwzebY2OjWu0NGQ++JNGdpb+8ydubnUH2itnCKI+Z8DWaO1exL+jFu q4TX0gPTXoeJX5thsl2/sPUn6oiEkwWA36s7WghCJ3Cfy+bnE7lw8r/cbQW9SYbbkFqq WdW2lE6Oa5Ozbn5F6SSN63etY6L0WYi/poi+1ldgihR5w9c9dttg3PUs6k607t+kOyMm P2jkqmDTpCkXqvUl+Aro6WvIlVP5IwQ8HJ3wm2qi/gajfH2IdnTYOO3h6pSnwrKm+SFM tn+TkOts5yTm82rqLc5KKj0LrtqrB/dlX92BuFSB9MFzZgC0XGWA07oFZcJlF6NVNajv vXuQ== 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=CNELGMKAFdMZ+2W4yzHH1SKoaOxutRzuxXuMFKI1znY=; b=hI4pRLW19CzuAW9FZ+SIVMqbMEOkcd/n/u8jNjpAyte0lQGfE28LvLe56Hi/aniOxc nQ6MeLc/hJlHvSnjwyeKoOKK3vg0hJfE4D0SW7js7HS6UrPysvfPmOCXvVvy17PAKFKA lbx9xHvVV1X+W7xNDI2GR6Q66dcHInT+CoqpQ7+7n+yFuFdMOVDyf344N7zW60MjxKZa ICSqK0XZMl786Qh0bOm4DTWNjvtRGSdHPxJ8RDUVi2pHXNJvo9Bv2NeqjEv8anfz/+vx 8iKQcbn+YTL1R0eCBJI70zjWpIt8lH/hSDuAozPCvUf5ItTONLp81APEg+OHeUbfPYI5 CTFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qQfV1F1j; 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 n11-20020a63e04b000000b0047850e0e148si18069601pgj.778.2022.12.06.01.49.40; Tue, 06 Dec 2022 01:49: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=qQfV1F1j; 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 S233661AbiLFJpW (ORCPT + 99 others); Tue, 6 Dec 2022 04:45:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231434AbiLFJon (ORCPT ); Tue, 6 Dec 2022 04:44:43 -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 F21C91F9DC; Tue, 6 Dec 2022 01:44:42 -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 885B0611E0; Tue, 6 Dec 2022 09:44:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FABFC433D6; Tue, 6 Dec 2022 09:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670319881; bh=BYlR0o5X0xGA4XLptS1Any7Q7Cj6YM9GdILoyAJmUyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qQfV1F1jpWVzZbov5WFamXrdWEP66p2Wx4HS2k9xI4oyl7Dgy6v57SMWxDG2VW32g p62G5vXLr0AWVtZ6Ew/nO4AduLoXHiGvpcadaf+BpYjbV4lz1iuIz3BsLleJqLluWe I7q/Lt+i8Ia4zEp+FwWGrOVhvkcSswOxjc2OTIGHR5eZckEtnQGswbGgv2gbJhsQix t91EGMLd5LEtvTgkdwszdecNDeIBf19k0KjxyjrUof+ypVyhClUt8z8JjjvNNwmz3o SmAKFpfZ0L7mMntpupLHz9DdZkrpTzuH2TFbzDj879iEbSMtT6b1qu6Op/tFToNGOg umIZb03xKsVCQ== 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 v5 net-next 5/6] net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume Date: Tue, 6 Dec 2022 11:44:18 +0200 Message-Id: <20221206094419.19478-6-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221206094419.19478-1-rogerq@kernel.org> References: <20221206094419.19478-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?1751457667870208632?= X-GMAIL-MSGID: =?utf-8?q?1751457667870208632?= 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 d4618edd2f9c..ecf33c17ca96 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 Dec 6 09:44:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 30181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2726010wrr; Tue, 6 Dec 2022 01:48:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ocDgOIrQJEEIiFq36juuGG7Etn8oqUsmjWfYUAQY/GLQ0T5Kk69Yd2tJqAC4WnkVhWeBS X-Received: by 2002:a63:481c:0:b0:477:ec30:b2c7 with SMTP id v28-20020a63481c000000b00477ec30b2c7mr44298316pga.526.1670320127353; Tue, 06 Dec 2022 01:48:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670320127; cv=none; d=google.com; s=arc-20160816; b=bWoyTg4UOV+hIXkUG0G/oc2ZtCh9OJMxnMmVO54fdVIAlQ4gDmVlYv5qzaMq09EMJj KgMRhuPLIda+M9xQxAjTRK0Imwb+ZF1NpE4Dotn0MCOFG9jGnmxFe6y0qVmNMkCSJGfK Ce+yHPleTeQx/0nTGGkKpixvjLOppa52hkOm9UG5MABZXfuQm+kSw6dtzgUBDeJb35U8 lqXmZXOBLLVMPAXvhgkS+k9xz7ghTTrOnnl9A9QB30YPm7fNY45x7A7pr67eAJRiVX4Y F492kqXdO1qvkBVsorEg5SEnFGZsILFhDU6DSBgr38BEmyEAsEJpGtT0qsrMh/VVPar5 UypA== 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=Bx6+6uY1+ThLg5XwcO3eDBtJcIaZAem6og5Wl6xdlRs=; b=HnrXdq/Nj2DeEKAzwYuDwdu67oskF5n899RAP3BCUtr2VdGt7zTkInYU4yjMFcCeVI X6Qsz9PmvuSsiKtq3jN0axEJzqHZU+et3VpaUSH09JHD2fDG/lDjCeEIG8g88NR3Snae CusSn3/TtJ6hJGyEa8mNXpCgHWyvtxOARIq/KAtxT1kNELiJfY2gMUoaCBFOB7gQVSox 2aZJjSK49FVwdr5wx/77yGNkXDg843/D4Lycqtho7njOxr40JJNJVJnB+CyIr46tTU1/ frkuC544yEy5iWRowz4YmI4kaOEzzAWlM4s2ESRVOFV55XsFZBgZq7nD9Wm+fw4cNuiu Eo0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jOOlrv+4; 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 i18-20020aa78b52000000b00572ee9a0c46si15676124pfd.346.2022.12.06.01.48.34; Tue, 06 Dec 2022 01:48:47 -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=jOOlrv+4; 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 S234917AbiLFJp0 (ORCPT + 99 others); Tue, 6 Dec 2022 04:45:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiLFJos (ORCPT ); Tue, 6 Dec 2022 04:44:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B93EF1B7BA; Tue, 6 Dec 2022 01:44:47 -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 62483B818D8; Tue, 6 Dec 2022 09:44:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71ABEC433C1; Tue, 6 Dec 2022 09:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670319885; bh=5jhZ4rlNB57+cbmRPNMaOe67g3zWz4nSshCuRjsEt1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOOlrv+4z/WLphJNyTbfbV6yZUEZqghEpZ3g/LypadktX3gYCqGPilbiVSF1+dgOc lcqRTGk5kLts84EyF0FBBng+mTXsWsng0mSocpLZrAKoKbXTphgmDGCXIqK4uQmBgH 7b1V8OspK9RdMU5TFtwuF0vXDbz4k4I3PpHrHeH/eE0aX+ldX4xG41T46inNHT/IZc ACl+IYJ93dxL3tiCA5iPOhY/u7YN/XyTbRa5YIDv+kisCR3bgqXdoP4bj+JlUkjq/X MGTn1JxT0f6jzxO0SApfGjn1c7giaxuKV+qZI9MPRh5qgAS8V3zQb8K96JCPOWhVBO YTp17CkMIvlTg== 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 v5 net-next 6/6] net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume Date: Tue, 6 Dec 2022 11:44:19 +0200 Message-Id: <20221206094419.19478-7-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221206094419.19478-1-rogerq@kernel.org> References: <20221206094419.19478-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?1751457597695457203?= X-GMAIL-MSGID: =?utf-8?q?1751457597695457203?= 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 ecf33c17ca96..b8f7080434cb 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 {