Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4545011rdh; Wed, 29 Nov 2023 04:39:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjgvnKCuF/xtgx2Uqn5F0zxNIbZUkXLnKnJJz0ah/r2U/8Lkf+UZhHtWUi3nuetSdE1ev9 X-Received: by 2002:a05:6e02:338a:b0:35c:f2f6:7b26 with SMTP id bn10-20020a056e02338a00b0035cf2f67b26mr11765042ilb.32.1701261544078; Wed, 29 Nov 2023 04:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701261544; cv=none; d=google.com; s=arc-20160816; b=SxiXT7eIpg9YYch5RQgUJRyJ3TGgBTb+RbbD3gA8icdS2CGc+PGuMNb9Lm8d2uVgrk HLSB00yks7QKvCfGdDzufR28QwUXA1jBzOc8rU0CLPO7imY58pe76PLHuLpbXTN1wxXI KjCYSd+US5hnjDJNGnpnOMsaLyPPLJ6ZmfRzqy/ZY2+IXIMapt5/JvHh9V/DrgHxIH9n ujSFdLycrnzpEUdfZTEsHeC06iJzrq8jGS9KxJHydNCJldH4TGXancGEl7JjZ2y/COdG IblREIjh7gqx7dS/996481YH6lI1Q8y1x5QmtmEvckIIDMhNoDiZLrdDjVnHWhDDE7JP IKjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=u31lKWoxIntTcOsxtCYzOzGo/vWGMIlzZ9DKC3PC8p4=; fh=yC+xrKXnIBgA9JS1rOIkSwWe+Y6L/uZR6NfvACv5T8c=; b=fAAMkjxr03HNV/L+c8SKnqkfF/KP9aUaHwmmhkLW9WTj8feaGurhq5F4lilunjHJlP WWPRjQxI4nVsY/dMdqniBUaEArlwhwcdr0GVB8iU17otwMnWY8sgLiqfvdnlZsI35DPi l3invdKdIejPsaegolXZI2rP/qWhCuXfwa4Rlp9CXstIhTxnj8QZ2+vH3fZpe7veht8Z yGyPU8eF2bqaiYu9/e7jEGZu5oJSAzUD5uMHrDt0R7LV1YitPETQtXGTqaQju+PP8Cnb u22d/kCoesNyMfBKeTob8iCF7tVF2Cb0ZfKAJ/ceIIQ2qmH/8n+s9p31OgmZNM2bqrwP 9H2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ab1Sqfj2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f2-20020a625102000000b006cb11cc5a7asi13564742pfb.371.2023.11.29.04.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 04:39:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ab1Sqfj2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id ABD3E8031AE6; Wed, 29 Nov 2023 04:39:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbjK2Miu (ORCPT + 99 others); Wed, 29 Nov 2023 07:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjK2Mit (ORCPT ); Wed, 29 Nov 2023 07:38:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDA2A8F for ; Wed, 29 Nov 2023 04:38:55 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AFD5C433C8; Wed, 29 Nov 2023 12:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701261535; bh=YRPmgyXmnqLz1Gklpj9zRIaCJd4+aKMKj1bXHQYDK2M=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ab1Sqfj2yUckgCwxxT6h6QHlIZHnJcU3RukIWFlzdGyNJkIPO5tFBKi+g/cyBBHuv pHEN1otKZ20rY21owZpLSo1Chjo75m0OhzJffIIAPo57PjF6EZULlgnyoZ8jwgowKA kt/WZ0o/cDDPO8+sydvhB+ZbVY0iHeNcFK0JmMVif6tK96HvYvBz+8EZxL1ZjRDP3F kefgUk3n+g5Yz1bOOV5/23dEGFBxQMfeYM0dKEvPpOgd9dzrN5W6IeR1RrXy1t9aFe KdCuI1+4ICPvYC6a2ssJaXtInmFOFC4gD6pRdZW2P3VtZI9oBqj+qNM85/dLhqwKPi xYn+j9F1aL5dw== Message-ID: Date: Wed, 29 Nov 2023 14:38:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net: ethernet: ti: am65-cpsw: improve suspend/resume support for J7200 Content-Language: en-US To: Thomas Richard , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, s-vadapalli@ti.com, grygorii.strashko@ti.com, dan.carpenter@linaro.org, thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, u-kumar1@ti.com References: <20231128131936.600233-1-thomas.richard@bootlin.com> From: Roger Quadros In-Reply-To: <20231128131936.600233-1-thomas.richard@bootlin.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 04:39:01 -0800 (PST) Hi, On 28/11/2023 15:19, Thomas Richard wrote: > From: Gregory CLEMENT Subject is vague. Please be explicit about you are trying to do. > > On J7200 the SoC is off during suspend, so the clocks have to be What do you mean by SoC is off? I suppose you are referring to a certain low power state of the SoC? By "clocks have to be completely powered down" you mean they have to be gated in addition to be disabled? What happens if they are left ungated? Does it prevent SoC form entering the target low power state? > completely power down, and phy_set_mode_ext must be called again. Why must phy_set_mode_ext() be called again? > Not all SoCs behave like J7200 so can we please restrict this change to J7200? Thanks. > Signed-off-by: Gregory CLEMENT > Signed-off-by: Thomas Richard > --- > drivers/net/ethernet/ti/am65-cpsw-nuss.c | 25 ++++++++++++++++++++++++ > drivers/net/ethernet/ti/am65-cpts.c | 11 +++++++++-- > 2 files changed, 34 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > index ece9f8df98ae..e95ef30bd67f 100644 > --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c > +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > @@ -2115,6 +2115,27 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common) > return ret; > } > > +static int am65_cpsw_nuss_resume_slave_ports(struct am65_cpsw_common *common) > +{ > + struct device *dev = common->dev; > + int i; > + > + for (i = 1; i <= common->port_num; i++) { > + struct am65_cpsw_port *port; > + int ret; > + > + port = am65_common_get_port(common, i); > + > + ret = phy_set_mode_ext(port->slave.ifphy, PHY_MODE_ETHERNET, port->slave.phy_if); > + if (ret) { > + dev_err(dev, "port %d error setting phy mode %d\n", i, ret); > + return ret; > + } > + } > + > + return 0; > +} > + > static void am65_cpsw_pcpu_stats_free(void *data) > { > struct am65_cpsw_ndev_stats __percpu *stats = data; > @@ -3087,6 +3108,10 @@ static int am65_cpsw_nuss_resume(struct device *dev) > if (common->rx_irq_disabled) > disable_irq(common->rx_chns.irq); > > + ret = am65_cpsw_nuss_resume_slave_ports(common); > + if (ret) > + dev_err(dev, "failed to resume slave ports: %d", ret); > + > am65_cpts_resume(common->cpts); > > for (i = 0; i < common->port_num; i++) { > diff --git a/drivers/net/ethernet/ti/am65-cpts.c b/drivers/net/ethernet/ti/am65-cpts.c > index c66618d91c28..e6db5b61409a 100644 > --- a/drivers/net/ethernet/ti/am65-cpts.c > +++ b/drivers/net/ethernet/ti/am65-cpts.c > @@ -1189,7 +1189,11 @@ void am65_cpts_suspend(struct am65_cpts *cpts) > cpts->sr_cpts_ns = am65_cpts_gettime(cpts, NULL); > cpts->sr_ktime_ns = ktime_to_ns(ktime_get_real()); > am65_cpts_disable(cpts); > - clk_disable(cpts->refclk); > + > + /* During suspend the SoC can be power off, so let's not only > + * disable but also unprepare the clock > + */ > + clk_disable_unprepare(cpts->refclk); > > /* Save GENF state */ > memcpy_fromio(&cpts->sr_genf, &cpts->reg->genf, sizeof(cpts->sr_genf)); > @@ -1204,8 +1208,11 @@ void am65_cpts_resume(struct am65_cpts *cpts) > int i; > s64 ktime_ns; > > + /* During suspend the SoC can be power off, so let's not only > + * enable but also prepare the clock > + */ > + clk_prepare_enable(cpts->refclk); > /* restore state and enable CPTS */ > - clk_enable(cpts->refclk); > am65_cpts_write32(cpts, cpts->sr_rftclk_sel, rftclk_sel); > am65_cpts_set_add_val(cpts); > am65_cpts_write32(cpts, cpts->sr_control, control); -- cheers, -roger