Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2387402rdb; Wed, 21 Feb 2024 06:17:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW6FxG6rZlxGbT46GzW9FYDjGuKa0c1ecp8ak37QMUY2xucm+JJXCacLHldyUiXCXV3NnfuEXSh5sbeZY7+1k41UCtmgKmFM0tdzy7XLA== X-Google-Smtp-Source: AGHT+IHkXQcp390G795SNxcerAHV3yzpDcLvQWpMcTtITdckv4WsbJv0kgShYRapEoJvca+GaMQW X-Received: by 2002:a05:6830:2707:b0:6e4:4218:c12c with SMTP id j7-20020a056830270700b006e44218c12cmr14685834otu.33.1708525055648; Wed, 21 Feb 2024 06:17:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708525055; cv=pass; d=google.com; s=arc-20160816; b=NDnmskz1D3OW8UJL18KxaSrBxf+HNqsic6JKBr2/mPg3gNBfG+BP97y9qo/h0Fx526 rTMPmZda2v8LNGqpBVr2Ek8ASPrY813ewmO/QZVipGpyJoT4CVntXjrH59b8GiCiduhm SZRfwyju6eT51N1+Ojp1gQygL7EvY3QQ58Xhvp8lwJEt1BQjHq4BTUH1N+Mm15/h7jwc uRYwNFwzH0sz7pClIMhFky2TI39EFepcQ0bzVTx9Fm6xguUrb7S5f7Ard4qdnkHdebZT g46QPwvmVd+QYQIB6TEHPt8L7ZTl/GMwKILb5hsMFoGMRN/nQxxDSq9ThrmmyHKH/vCw jRSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id; bh=Q2RUE95fc1zQwRBp9kOw8oty4/YAIxvwaIU3KFEmWsY=; fh=kztSNHlUNJI4SsRjK2Bee+WkvN0s1Sy1dOX1gAvd77c=; b=z8kzxftm3TPgB9EFePiKiiZCnKLxwgjMQ10a0NAMSl+ANFioC0CfdPHGcdRUq5KsJK fZDg36iz5WSEzk3E7ATBZ6LFHC7naAz9Hwe0Uucm97BnYh+OwXzRZTcDr80UsbWwbI/h BI1+YQMpLUAwJ+vBoZjQWZmAncvd94QLXdQUCJ/ff6ZaJlZabNceh01BPkF79uM7eHUn lh30Bzgb0g9nPr3cmREij1V/ErCAkoLjPLtkridwXH6C7PijurdZX8Ygym2XY16HWIEs L3Cib9vqSQwwJ0t56Vy0W/MVZvNrTGr2XLjmLoKIa/EXHxeQFXk1BdutCIgsRuOctwkg D3ng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-74835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74835-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p10-20020a056a000b4a00b006e04a017037si6196016pfo.209.2024.02.21.06.17.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 06:17:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-74835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74835-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A8354B283B5 for ; Wed, 21 Feb 2024 13:59:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51B137C09C; Wed, 21 Feb 2024 13:59:10 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FEAF79DAE for ; Wed, 21 Feb 2024 13:59:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708523949; cv=none; b=OG8+f9wBTGL8Z/Ene1UAWuKNM0oeyTeyobjy4D5tPl09DxaXzmpu9A4zdeE7k4cWGY5KeSK37sFMSEgKKoGrmkGJbAabsZbDw4q4Xlfrdh+4Mgbw28zCJrXTljtPuxP6/Bkm7ZjYAzkWkRyaW069YSdSdEUfJYzxRcLEleCUPbE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708523949; c=relaxed/simple; bh=SPoiOVe9t7+lJy32KOx/8m4/OcgmeATJO9xiMhnNQl8=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=dRGqshdgs6mRaZ2q8VBbtBC7FV1ph7kFIDmRwbGB6J2ATxXhmDoMK1nn+Qczk1iylblwHKh8+3OYJwS0ZHXOVfotccYoiOR+Zopt/BSJKvACXSW2nNnsev9YCqO4jUlSZIjykLBhk9ki+f3dihuAlkAWcZN2B0zKVRC/I4prVng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rcn7W-0000Lo-VY; Wed, 21 Feb 2024 14:58:46 +0100 Received: from [2a0a:edc0:0:900:1d::4e] (helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcn7U-0023E5-1L; Wed, 21 Feb 2024 14:58:44 +0100 Received: from pza by lupine with local (Exim 4.96) (envelope-from ) id 1rcn7T-000AN8-35; Wed, 21 Feb 2024 14:58:43 +0100 Message-ID: <338419fd10ffcc62b135d924f766d66af8186346.camel@pengutronix.de> Subject: Re: [PATCH v3 14/18] phy: cadence-torrent: add suspend and resume support From: Philipp Zabel To: Thomas Richard , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Lorenzo Pieralisi , Krzysztof =?UTF-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com Date: Wed, 21 Feb 2024 14:58:43 +0100 In-Reply-To: <113b7f2e-1313-4ebf-a403-e5fcae8f01ca@bootlin.com> References: <20240102-j7200-pcie-s2r-v3-0-5c2e4a3fac1f@bootlin.com> <20240102-j7200-pcie-s2r-v3-14-5c2e4a3fac1f@bootlin.com> <113b7f2e-1313-4ebf-a403-e5fcae8f01ca@bootlin.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org On Mi, 2024-02-21 at 14:41 +0100, Thomas Richard wrote: > On 2/21/24 14:09, Philipp Zabel wrote: > > On Do, 2024-02-15 at 16:17 +0100, Thomas Richard wrote: > > > Add suspend and resume support. > > >=20 > > > The already_configured flag is cleared during the suspend stage to fo= rce > > > the PHY initialization during the resume stage. > > >=20 > > > Based on the work of Th=C3=A9o Lebrun > > >=20 > > > Signed-off-by: Thomas Richard > > > --- > > > drivers/phy/cadence/phy-cadence-torrent.c | 54 +++++++++++++++++++++= ++++++++++ > > > 1 file changed, 54 insertions(+) > > >=20 > > > diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/= cadence/phy-cadence-torrent.c > > > index 52cadca4c07b..f8945a11e7ca 100644 > > > --- a/drivers/phy/cadence/phy-cadence-torrent.c > > > +++ b/drivers/phy/cadence/phy-cadence-torrent.c > > > @@ -3005,6 +3005,59 @@ static void cdns_torrent_phy_remove(struct pla= tform_device *pdev) > > > cdns_torrent_clk_cleanup(cdns_phy); > > > } > > > =20 > > > +static int cdns_torrent_phy_suspend_noirq(struct device *dev) > > > +{ > > > + struct cdns_torrent_phy *cdns_phy =3D dev_get_drvdata(dev); > > > + int i; > > > + > > > + reset_control_assert(cdns_phy->phy_rst); > > > + reset_control_assert(cdns_phy->apb_rst); > > > + for (i =3D 0; i < cdns_phy->nsubnodes; i++) > > > + reset_control_assert(cdns_phy->phys[i].lnk_rst); > > > + > > > + if (cdns_phy->already_configured) > > > + cdns_phy->already_configured =3D 0; > > > + else > > > + clk_disable_unprepare(cdns_phy->clk); > > > + > > > + return 0; > > > +} > > > + > > > +static int cdns_torrent_phy_resume_noirq(struct device *dev) > > > +{ > > > + struct cdns_torrent_phy *cdns_phy =3D dev_get_drvdata(dev); > > > + int node =3D cdns_phy->nsubnodes; > > > + int ret, i; > > > + > > > + ret =3D cdns_torrent_clk(cdns_phy); > > > + if (ret) > > > + goto clk_cleanup; > > > + > > > + /* Enable APB */ > > > + reset_control_deassert(cdns_phy->apb_rst); > > > + > > > + if (cdns_phy->nsubnodes > 1) { > > > + ret =3D cdns_torrent_phy_configure_multilink(cdns_phy); > > > + if (ret) > > > + goto put_lnk_rst; > > > + } > > > + > > > + return 0; > > > + > > > +put_lnk_rst: > > > + for (i =3D 0; i < node; i++) > > > + reset_control_assert(cdns_phy->phys[i].lnk_rst); > >=20 > > The same cleanup is found in probe. Would it be cleaner to move this > > into cdns_torrent_phy_configure_multilink() instead of duplicating it > > here? >=20 > Hello Philipp, >=20 > Yes I could, but from my point of view, it would not be cleaner. > This cleanup is called from many places in the probe: > - > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/phy/cadence/phy-= cadence-torrent.c#L2948 > - > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/phy/cadence/phy-= cadence-torrent.c#L2954 > - > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/phy/cadence/phy-= cadence-torrent.c#L2960 > > If I add this cleanup in cdns_torrent_phy_configure_multilink(), yes I > could remove it from cdns_torrent_phy_resume_noirq(), but I should keep > it in the probe. And I should modify the probe to jump to clk_cleanup if > cdns_torrent_phy_configure_multilink() fails. I see it now. If it can't be consolidated, it's not useful to move it around. >=20 regards Philipp