From patchwork Wed Nov 23 12:48:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 24962 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2788078wrr; Wed, 23 Nov 2022 05:29:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6u4c5/LCZsFlAqmG53uuv7U8hrt9oL5vwd3CCm9NUfENooJu4ZWlZ3MK75VZCqxLMbE5AO X-Received: by 2002:a17:902:d68b:b0:188:cca8:df29 with SMTP id v11-20020a170902d68b00b00188cca8df29mr14899297ply.148.1669210160877; Wed, 23 Nov 2022 05:29:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669210160; cv=none; d=google.com; s=arc-20160816; b=MaxKngN82rcVHcwrSE/D1fvUUSFcdskLByYgtbCt8Ez/SUE9RcXI37PbnKKy2waHW1 0FZ6RIILA3aqLahsmZHXTnvrRDLMZViHXWUSqTnKs0oDvHba3cdFT8mlfhZ4tsvdR1Fo EVHtoPnFVlb/pntLJ2pELUBRm2MYj/1Kl32AyzuR6rHZb/0oxbdQiGDZ/GrXa+IfYGzi h+4Te8I9Uhu3Rg6AQTt1p8Im3eG9Bixr9ttFfOrVEeTzorfwqjlf/YcrZ7LQUtC02M+s b+dkrbQnWyTrKJGz+vsmyS5xbLrDxNhdunHJCI4DlLfzey9aD6oIMW3QoxEe28M7w4Ok ld6Q== 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=SlsBlVzhskM47KVZFdF2p/quToi2RiBlIVc+AnTRb0h0HGw28wzEsj6PxPVCt8T0NG IHpTgRIB74P6o0YZG7JLirczXz8SgdqZWpF2zvEXkrvbm0XIXdf2sJJgJjB7/6dTfMtR NIIb/r51sdBeThvCUwzf+FtNlAGIe7WfMXhSmLQDnCw1pblm/hji1YbwROy5Pch91IQt SuUjAAp/k0s0O6oiDKz0kvUiD0B78sPYRoFIKpm/mu3ALFeN+8x4T+9R/4kPp6kW/mOk xndjyRfq7RnIrUZFzTjImb3fku461QZ2MZqfufV3v90cEBzR+q0XYs0HGmNk71QLHJRE ECvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sjxs0OeT; 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 t14-20020a17090a4e4e00b0020055731860si1759579pjl.105.2022.11.23.05.29.07; Wed, 23 Nov 2022 05:29:20 -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=Sjxs0OeT; 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 S238676AbiKWNEg (ORCPT + 99 others); Wed, 23 Nov 2022 08:04:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238241AbiKWNEM (ORCPT ); Wed, 23 Nov 2022 08:04:12 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35A2CCB942; Wed, 23 Nov 2022 04:48:52 -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 AF60AB81F6F; Wed, 23 Nov 2022 12:48:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06104C433C1; Wed, 23 Nov 2022 12:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669207724; bh=VSOHmo7sDplewfab+OwnRAyCOu/HX80NiUna1LwAweg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sjxs0OeT1QyRSn0QYyeQ+hztPPyni+GUrHrFs6UY6zD1rGhqVliq61xgK5VEVmKMT Cu9kXusPyTVaYCfGc6PwPD4p2tyc6hwJt6Ticav0EFJ1eDYFcnh91jlIJaMkWJlMTT sB63mubxbPNy0bUPfQveIzGZiMb5v9lC5FybmrUgUZTtCDX6BYn0al9dpnGX2EtuvU V1bnQ6Yb/zd262vAXL2ifZLn50fvpAcAECkxJhx754GyeT5QgXjyh6sGHllA4/BROa A8GX7PztRZFCjwiRxgV1dbk3SUzb9SKf0SwKpDFW1qUIHOPTMD1X83uO5NZ7f6GLsx dS2caVcoORLKw== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH v3 net-next 1/6] Revert "net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume" Date: Wed, 23 Nov 2022 14:48:30 +0200 Message-Id: <20221123124835.18937-2-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123124835.18937-1-rogerq@kernel.org> References: <20221123124835.18937-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?1750293713607603740?= X-GMAIL-MSGID: =?utf-8?q?1750293713607603740?= 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 Wed Nov 23 12:48:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 24972 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2788746wrr; Wed, 23 Nov 2022 05:30:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6TOK9wOxBDSCuTVxQYS+gB26mZt2BbKuFENGxFzv8H4IsxyCphmUVCOrQ5kpCP9QOWnm7y X-Received: by 2002:a17:906:b28f:b0:7ad:a942:4d6b with SMTP id q15-20020a170906b28f00b007ada9424d6bmr23257447ejz.379.1669210243596; Wed, 23 Nov 2022 05:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669210243; cv=none; d=google.com; s=arc-20160816; b=tzarbG0A5/XUlFIFaJnjGga6qNbJ2pHilxJqaxAd/aa0FeMZXaj9mkQAQ8ROFxuuLi FyiniOE5WN4QmOfZMH16VKzv9pzYEkxctP1gkc9cCtZ19BAJ1PKME/LOVBp8VwO5VH3J r+VpR7XBidORZZPFnkadOAjGbX5flfw2CurWNwUEWdZXzrSODQ87VpRc1gj9zkZzb/ev 3+deIUv/st+jKwfn8pjb+6Q2viMLPAJohntYDEL/YAD4nqK+4nxATDGj5VVoB1ev9Jb2 z/bXqCFfqXp/TVU7JRXVDvJdS+4nj7UqL1OGAE1af5ql1Bh+NaYDMRdq+NHE1b3SMdzA KzMg== 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=wUpOQQpxKbxbWFuhqrmrDs27tP+MTreqIdT2w/8UtWG9OO7fkRMmiNcDHWqkk0Ljyq zLEQofvlaQ/LRYX9cTTIKunCNNjxYYPpXCxAjKpsDC4UHFl/bYx7dVpJguJxgZnF0kn9 lFfJSZao5k3pqEgCW1JP5dsrvHBOdRdVDTUuyTKGyOsqNtvYqi5kwYH+40a3B/D8OO3/ 6hGZLeyqcBnwSZ7VS9kQb6AtQtUlJDik18G+DPd8/5IGafWvfPS/Acx7dVxnbL5jEbis wZxQTGMBzro9rinLoKt+fJu4Hxdz9smgoaUoRR6tlJGb+eqqcVurhN7gwRCpS0cciVlv oPaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KROc2jcg; 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 wu9-20020a170906eec900b007ad821844fcsi613502ejb.528.2022.11.23.05.30.16; Wed, 23 Nov 2022 05:30:43 -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=KROc2jcg; 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 S238642AbiKWNEp (ORCPT + 99 others); Wed, 23 Nov 2022 08:04:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238389AbiKWNER (ORCPT ); Wed, 23 Nov 2022 08:04:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C478CD94E; Wed, 23 Nov 2022 04:48:57 -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 E9C1861CA4; Wed, 23 Nov 2022 12:48:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA94DC433D6; Wed, 23 Nov 2022 12:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669207727; bh=qfseqzA5QeFGbDcdL8jAeZcM/YWcdxti75h4w7j1dOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KROc2jcghXsp1CD8QCeI0ACMxuNR7zBqDg33kLt1gnAfuqONaLMfKKk2HeQIAYfdb DHLcjD7qjcXn2otl3QBqlrs5SZawHhukr2GvSpkd/2E1A4/F7nmNGnqQnBeLI+wnOj hnGTTWL3gbliKy8DCY6H5KjQEgsi59zOyzjQyqBwQ6ntPZe29lggwz7QKoApwVUmYJ Au7GcRYE/FVr+yAxOc17A3CNrLpjKqStCpltoHMFcNwJ8LUWFfMEWY5AiV1LuGdJQK 9z69kTFl5iJlBqmb4SJAMy7I7T4Yg4QCrw/82NDqzTNMqyhCkAzUc7SOM1GBauK98s k0vTkRv1GfIaA== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH v3 net-next 2/6] Revert "net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume" Date: Wed, 23 Nov 2022 14:48:31 +0200 Message-Id: <20221123124835.18937-3-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123124835.18937-1-rogerq@kernel.org> References: <20221123124835.18937-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?1750293800277771784?= X-GMAIL-MSGID: =?utf-8?q?1750293800277771784?= 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 Wed Nov 23 12:48:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 24952 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2787543wrr; Wed, 23 Nov 2022 05:28:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf6543nXyikx3ANSeVjVFYD8+qIUfI/CFFWEz28Rx5CCZ7w9PqZiJUWIvjhUjBODN6gtOmwo X-Received: by 2002:a63:180a:0:b0:470:63e5:5c59 with SMTP id y10-20020a63180a000000b0047063e55c59mr7454837pgl.172.1669210094613; Wed, 23 Nov 2022 05:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669210094; cv=none; d=google.com; s=arc-20160816; b=iP7FfA9Mnq0yxI9D/INdUqJ5DvvzYIRZBSJccBW3d2dZj4hyiX8cwrFsWHrt5895vP c151H15VbMw903u5ETsNev8YMtb1QBTYEB3Kk8WQZn/9oBGTwqvlohF/Oy5hWf8LLnV+ Lffom/Odb/Au9sENWM4wws1Ey60cBcjvfE4eiwtHhg5hY5mlJwcTRI6MgQA5L5AHr9Nw RJR+0hdFghaXQ3lrbOK7YXCY+7NWCS6cwiArFzAAulkZ/zoOAH12DJJbRvXTBpawCazw 4B0NdhHb58ws9V76qPIgOwrNMGnWI6e7G79T6Gr+PttiqGVLza6LaOewQd6NJ6lv1Eac oskw== 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=or+RmIY2uBmaK5xu9qMeCCp5qN6VG1we6L1kP6kd6cqq833TsRnYacey4Ke3D6ggsa HpGvV7zETdb2NqZXCfn9/NyR1B5Uz/HtibyMjM/xAcUceP8nm8X2pKRekrvKWPaFUPOS t+FLyzBG7koPAV65T7fodvQ1xA8RuwVoHSAnvvTVrjp21TGqF3KeAtqHNI7MTstpxG2N bsLR3v3CwNrgB9VMaRlqUlfyfKhsmLqInUlbAHd0FPoA6/VnZWexxao+aXstbAY1XwIh EkvdoMCUbJ/acRxf9zHV8a6Z9woSYTaEAtUrnoSQduobYPiqx7m5T4JiyTNFCa6I+rbM +vlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g0v7R7rJ; 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 s144-20020a632c96000000b004776271965dsi9998170pgs.41.2022.11.23.05.28.01; Wed, 23 Nov 2022 05:28:14 -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=g0v7R7rJ; 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 S238476AbiKWNEl (ORCPT + 99 others); Wed, 23 Nov 2022 08:04:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238334AbiKWNEQ (ORCPT ); Wed, 23 Nov 2022 08:04:16 -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 E1E34CB9D7; Wed, 23 Nov 2022 04:48:54 -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 8352CB81F3E; Wed, 23 Nov 2022 12:48:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8129C43144; Wed, 23 Nov 2022 12:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669207730; bh=YUV//X6HxHjXUQ1u7/m0WgbXNCSgLyJRZ3XKO02tN/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g0v7R7rJ7xps+mYWhyBQnnqnyjlAn0sB5pSuJGkWzZRAmqvkUmG0v93Njhv6VV7+N LYWkAhSSYUHUvcMkrgsVtwB6b8dTl9wn8F+DN/OgFi3xW7zAf/eyRnOvmnxv7bIRaY ONYK9aB+lxW6GU9wQfMEiJaAfMr5ox996EfxLCke9lYVNM3VECt7CiX2HdDViiH7ij agHVghLqh7IfNMiMphMVYCuOhKmINpWK0HDe6ySILQK+Q5iNlP6+ys4ldETbSFYHsc nHaFI9ftow2fUYdZYmdqVs3T6mdt1xS0DuyRpzRg/fhl5ZSCArfSVGCovo9vRC96Xd uoQu9BFgXWSTA== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH v3 net-next 3/6] Revert "net: ethernet: ti: am65-cpsw: Add suspend/resume support" Date: Wed, 23 Nov 2022 14:48:32 +0200 Message-Id: <20221123124835.18937-4-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123124835.18937-1-rogerq@kernel.org> References: <20221123124835.18937-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?1750293644450702427?= X-GMAIL-MSGID: =?utf-8?q?1750293644450702427?= 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 Wed Nov 23 12:48:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 24954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2787575wrr; Wed, 23 Nov 2022 05:28:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4LVyzBxU+ip7vXgLx9RsdniCVTjYpf0tsYmdVpZR1WJp2z8GZ1Zl/xGFFhZVIDVo9CBfFI X-Received: by 2002:a62:542:0:b0:56c:45db:4481 with SMTP id 63-20020a620542000000b0056c45db4481mr30064297pff.86.1669210098904; Wed, 23 Nov 2022 05:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669210098; cv=none; d=google.com; s=arc-20160816; b=xBdAQqxyGZDmxM9+9Noa6NPNzSwR+shXpfnYkpfgWciwKhw2/C3+/NYTs9mgx3/UdR wwTRKV8nys/KueDyrmNuwht7k+uUh9+E7wAnV6oewjOonsY6vTFnQ7LovNdn4NHEoUTQ bQhHpmf85a31Fb4WOy8cVX3UiCepfgo4jcrZt3/Kv22O0RmTw3wfNMQWOGT/xOocKpVk adGbWMLuESr50+7NaEEbOg6yy43xhzYej4FQlA1UyAl9UY8FZem7ZW87qAHK50Lc1C0z BDvygojLfVKk1COsvXI6ctOn24SggK3h/SV9oLAJWhIZ712z2gCblQG3RV6u4J/enZjK mNEw== 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=gUimLy3I+iV2hErA9BbZWA3mO9haSOXalkNAYNcAtkY=; b=i0H234pR68IkqUTxPq0fflUm4oOFLP6Rflo1Sd0gwoYsVS0EluOEJ72S9oLEYl2xFe 7muCMh1Jr/djuUWXy9lKR1COyF4bdJ0GJFuCCBDZ/O7m5hSgi+l10oiabjkTlHphJYqL fwx0JuAMQKErNWqgAQjXYlEzyLJ7bPkFex3e5B1qpB+h9xw1lgooRCW0F3otm5X4C1rA grIX/KoLL35JrzqL2cL/H9wWTyRMEZEkXVrjVgBTxtkH7AA+YOZ5m7lujkWL/AO/NX+5 njjGLVDEEPwvdiiO8BtcWSqnFsDKgRwCeNWGGWoK5Hb3l4lxyoAX6g26Wpnrcm9ucupd 5tZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X9k1NHLJ; 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 16-20020a17090a0b9000b00218cf92fc62si1508365pjr.89.2022.11.23.05.28.05; Wed, 23 Nov 2022 05:28:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X9k1NHLJ; 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 S238693AbiKWNEs (ORCPT + 99 others); Wed, 23 Nov 2022 08:04:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238646AbiKWNEU (ORCPT ); Wed, 23 Nov 2022 08:04:20 -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 E320172985; Wed, 23 Nov 2022 04:48:58 -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 CCA3561C81; Wed, 23 Nov 2022 12:48:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CADB5C433D6; Wed, 23 Nov 2022 12:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669207733; bh=LamfmSe/9C2Q/ScikvZ3rt5zy3hv55+2DVyzODZxWmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9k1NHLJqvPLfMRbZB3xazLNOfFfTd0wpk2Myc2TSUqJ0Nejy3Y6x9jAErbkCe4uo UrOblEkXzrVUcpWaFSDxUNRCjalYogz7D+noVC0BacRXPS/liLRbAbyC+mIOYatsAY sujFm+b11KcvHWKrjZyeE/ZvKJPdIGPhA84Uf3qsVK2H/xw7WyUfuHUVLxU9cHH0f8 Yl8zwpU9rMMleCuRTXZ1QlvbYSYHmpKCfNdmygg4OB8hcawXpiMRrdHkBPQJWHBiyr CWkA2iyTbob1dWpd7+9g0Hmtpyrxuvo2fzY/zRi7kxdnsUYZYqTm6NngixsloVRGaN 8N7Bp4Iw++6kw== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH v3 net-next 4/6] net: ethernet: ti: am65-cpsw: Add suspend/resume support Date: Wed, 23 Nov 2022 14:48:33 +0200 Message-Id: <20221123124835.18937-5-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123124835.18937-1-rogerq@kernel.org> References: <20221123124835.18937-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?1750293648870112246?= X-GMAIL-MSGID: =?utf-8?q?1750293648870112246?= 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 | 170 ++++++++++++++++++++--- 1 file changed, 147 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 4836960b0dd8..0b59088e3728 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 @@ -132,6 +133,8 @@ NETIF_MSG_IFUP | NETIF_MSG_PROBE | NETIF_MSG_IFDOWN | \ NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) +static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common); + static void am65_cpsw_port_set_sl_mac(struct am65_cpsw_port *slave, const u8 *dev_addr) { @@ -555,11 +558,24 @@ 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_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) { @@ -1599,6 +1615,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 +1645,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 +1755,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 +2038,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,9 +2092,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; } @@ -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 Wed Nov 23 12:48:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 24953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2787573wrr; Wed, 23 Nov 2022 05:28:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6yiWYDND2pPGaJaXO2QmJ/Rq6J2puleZgiCG1LKPrdtguDsKuQh2J/bx5K6Dia3yNeEBC0 X-Received: by 2002:aa7:824f:0:b0:56e:8ed7:569f with SMTP id e15-20020aa7824f000000b0056e8ed7569fmr1326954pfn.19.1669210098752; Wed, 23 Nov 2022 05:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669210098; cv=none; d=google.com; s=arc-20160816; b=Nl84i1cn7W8Kn39UvWpI7KB8dt6ItV+ddPQLX6flvdwnsVbxZ5OK6dG9mrULBQiNT0 HKghE5y4rZQB2VTzEpq+iIRvjU7ZTsgIc3QeoOlbpLBZMvw6lm4BISEwJIvLU+CLjkA0 M+GhEZf6W1d9Wwa1tv3BjTZcXm8wq7e1Hc14paLkL7y9SSNw80Z49llKo2miz21lMKmu xSkVyQsVf1nyAWUT2fSw6c6Y6mbAd5w6IJR2rC5LfL5v+JjdoVbLiqo0LUGlUpk0IdYp 6Y0Gmc/C2u7+LrRSUn8NMBLqHXC+u4ED5pckbdfGwfie6maluj4O3ooHYjlim0JFH3Kt Rl8w== 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=ilwrayZ2R3cAZmt6nC0RSEm1iAdat/H1J02yI/Vm/vc=; b=dNTskwJD1Y9G5y5TS5kUsfmxzpJkinvTAdTQelTwfGD7w/Sr53LDyvlRaTJU5R/D+2 ObXirbwIRer0VgpCpxGklSznZvTCj0bh33E12BXv2/HrK3gy2xvBX02+l+J9gayQthSm m2tL4ySTnDJSkmTe9sCS93yfBZeNBBgOWA1/2SsPVE1gWawPmmXDCievq51jAzTVvq3m FncNDXI+ID1VJVTyxUgc4g8s3e2Jemg3AEv+pieH5duRyvvxw/mujGwWSpY1XgkbqJjj 0Yn12Y65hzLI0tWHtP3Ot4SBfMS4coLVnuJYDz/UJiX8RsT/xukUPK5awaE/mTmlDw8R 9YiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D922lsjr; 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 p7-20020a654907000000b0044ed36e4c57si17588729pgs.217.2022.11.23.05.28.05; Wed, 23 Nov 2022 05:28:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D922lsjr; 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 S238646AbiKWNF0 (ORCPT + 99 others); Wed, 23 Nov 2022 08:05:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238535AbiKWNFB (ORCPT ); Wed, 23 Nov 2022 08:05:01 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20554CEBA8; Wed, 23 Nov 2022 04:49:13 -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 71500B81FA3; Wed, 23 Nov 2022 12:48:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8612C43470; Wed, 23 Nov 2022 12:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669207736; bh=dvTLeoyNu7eFICLRoSnxH3F03RJcNb7dgmyKN7nwRnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D922lsjrolWkfRD+shTbR3JQGkpK6IwTTITljd7ow9jCKtsfavrU79wOlv8nA/Um7 wmubF2nSKyvickJFawnoQAIjw4AYPbE7vsV5BpFfOj8GykmfYFuzeU5SVN1f4mN7RN FhX8ce8rIUfRU7cVTGVjpXtqkmI9WNeCyWC8HZWE0kq9iX/1Wa6CfmDmvJrpksAf7E M544kEmYJVgjaxqFOvCVkF8NuHbQHJhi2FRmItUmnZ1wnDcUo9/XX392JOeRyv+4hx I2vrjmBSLXVOgyt79hzeJDUR59EihTqMVRiYaxhq+NUl1IIbTqlLFn3BQtQomQp255 /q8yZCOnCbi3Q== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH v3 net-next 5/6] net: ethernet: ti: am65-cpsw: retain PORT_VLAN_REG after suspend/resume Date: Wed, 23 Nov 2022 14:48:34 +0200 Message-Id: <20221123124835.18937-6-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123124835.18937-1-rogerq@kernel.org> References: <20221123124835.18937-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?1750293648679395477?= X-GMAIL-MSGID: =?utf-8?q?1750293648679395477?= 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 0b59088e3728..f5357afde527 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2875,7 +2875,9 @@ 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; @@ -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 Wed Nov 23 12:48:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 24957 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2788006wrr; Wed, 23 Nov 2022 05:29:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pbVE83PdFvMyYOoX+gmzJIO5Lfqgjt00eUmCOR+7hyXGPziKbDPUZbmmXsOG707QK1dpL X-Received: by 2002:a17:906:7f17:b0:78d:acf7:86a1 with SMTP id d23-20020a1709067f1700b0078dacf786a1mr24944195ejr.21.1669210154810; Wed, 23 Nov 2022 05:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669210154; cv=none; d=google.com; s=arc-20160816; b=GLaRpMK3LAqdIQU8t4hcUA3vMm1DvqO+SUs1ZitL4CFRPorKYwm0W5O2anYXENsGQ9 VsFB5pOsuzRN4QwajFH0e97U7Nbjv0g/lPlfdeChZlu9FzFSNecdzDus1Q4LQBfImJ6h WJzWPI7Tvs+H6NGSggaub3q3VMd5cw7Us0mTeu8J/0hsp5lo3b3SKME/9bUApXYbS8OR KmZy1LpOwx/rI0JCLFhBIiUcboGRhkbZAdjKZidpy8mSkKgSCOnaT5bzKKUrMj9bJM3q rHnkbNCgK9Islsrdlc6rBVQVcw2FcDaCWK8CjSe0lQ3p7eQByNz5BfroLXtO7/VOOpdD ldOw== 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=9K/AAGLiH2ple4wRXc/LYRxX2ON1zqiRaFPhIKYVyR0=; b=WAs9/PMXJST2p+z4kiiyYDmc51+UxVdamY+p/zQDvHYKWROlJ71qMFFPIzNd+1TM8h GQVLRsdZaSADImzhqButg5V0DNCJe4YqWDsJf+lye8oHHGz6U8YkqT7FpUj5CVEbhK0J SKYwodjWYJIYHVMacxtsmR3CXlgk2fktp6hVD7ORAL73J6WAVL7XbAkw9FRuLsx+ciSH obD3G68AoOD8FxLOVm7zmOdXZWdVm5h9Xz9v5P8i6LOslg6lRejeMUKg9czAwsTpDHwr QA6e5piATkCqY2bLbqVdOgs5dEe2SYmyTnRBfLvUgazb8TrCDLmNCes1WsJQpkSJM5/L 9ldA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="j/bcDk7k"; 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 hv8-20020a17090760c800b007aeec2bf18fsi15601583ejc.543.2022.11.23.05.28.48; Wed, 23 Nov 2022 05:29:14 -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="j/bcDk7k"; 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 S238535AbiKWNFa (ORCPT + 99 others); Wed, 23 Nov 2022 08:05:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238577AbiKWNFB (ORCPT ); Wed, 23 Nov 2022 08:05:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D636CEBB5; Wed, 23 Nov 2022 04:49: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 dfw.source.kernel.org (Postfix) with ESMTPS id A451B61C61; Wed, 23 Nov 2022 12:48:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5559C43144; Wed, 23 Nov 2022 12:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669207739; bh=o3Io+SK7lX1cC2f73bZPoDGBckcr/KVKDkRqhBF9SK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j/bcDk7krj5VnAJm2QAY4P6ukQmr50nr9VztKrPLZPPaAHHARlB6jDeG3CJe7ygK9 ajzzdKjAc2QfpF2CE4IYwJ3JEUOC+BJ/c0v6+WZaPjIOVTPdc5ZdnxRSTDpyHYlFxZ YH2We6ZPxg2x9fSSn8yDKw1rYBeFFJhm/n1CSHt8ilolU4AMupj5uTXVou9+f30F6j VZ7ruHQjgtlhEPGMXxc9H4QuOMQftV/WiJtoJ0yCDe3/rqaSPF+fwu2iu2FmOozO6k ZotEDFxugoZRZXAlfCmiy8buyVdCayVEkeBUKn4/WggsU+nvHnYZE3FyTD2j0MuDfM KqB9UuK0uof5g== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH v3 net-next 6/6] net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume Date: Wed, 23 Nov 2022 14:48:35 +0200 Message-Id: <20221123124835.18937-7-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123124835.18937-1-rogerq@kernel.org> References: <20221123124835.18937-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?1750293707439299427?= X-GMAIL-MSGID: =?utf-8?q?1750293707439299427?= 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 f5357afde527..72e4ee71f106 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) 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]; @@ -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 {