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 {