Message ID | 20240102-j7200-pcie-s2r-v3-5-5c2e4a3fac1f@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-67152-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp471207dyb; Thu, 15 Feb 2024 07:20:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpliqOrq+3dn1NJIxkEsCJ93ZjJHo7P2VhPyCLEkA/VxfYZ7n4LuPowe+TdV7BBiL+9meGfmWz+GlubluQw1eP069iEw== X-Google-Smtp-Source: AGHT+IGfY4m91L+gOcR4TT2OMjADVkq4G4K1xEcxH1Ubgb74X6cxWyOotFv0xAI32f/oLGmDXbjO X-Received: by 2002:a0c:aa5d:0:b0:68f:1aa7:12bf with SMTP id e29-20020a0caa5d000000b0068f1aa712bfmr1478982qvb.22.1708010437984; Thu, 15 Feb 2024 07:20:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708010437; cv=pass; d=google.com; s=arc-20160816; b=XncLqYbNWphUUPEDCLmT5IgRQroqFbQpWWkQ0bCwICSMXIdWx2w/SUJLGB1CHC7Y4C mCLbp2V3JKre68+tiXiavtaG6Aa5uc8V7I7DsIL2WY9ksWYREF4GKcav1RLTu1ejiyBO /xOmBps4KtbypPm0veq7gGXocc9sN9RM+z2uEOQ/bXvStOGEP6wh3a+bcaqEk0jIEUk0 qbehveWd5pgSEeK0+6a/CmwyX2xAYE7yuCCoLbayri1bs9g9dqNMq3cBWIIZA7bsfxBx MLr578xXz9KNj9Izi53xeyuLyUNxoto4nsWTzfz3zPURHMuOnjkuXFoOtgpMSSF9cJj1 2ppw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=R9wanZgvZg9ml7GqR5bBizFjTTL8Y7tpLwMVbRWiGTQ=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=TpSLNsmsJ+dismm2Rw98lNEq/o4uP0DistO0YYWou61pKCCx1rQMKLajBwSxmxRu2y WH8CTkZ3ON1q2vUg3OwzH9uNDSg/HNrWP5rKrJSXuyZoARmH/RXHlYzC5CWTmWV9LYMx SiVez7UPL7EaWby/SIJyAd3q7Rth+biDTUEN4p1WkQEBNsywlr7hjz4zvmliBdEhnALX jdrUvi1AbsKpI47PmBKLv36HDxm4J4jkjkCRmkpISsqqqa/iOTTZwCE7IH7rZzkR3pvd 3kPUEIEJ4ZwsKs/eSSdbK9SoMtYxl2V4ATbggsRLHDatKcGWRdEUJJjGMIlWKjj5MkV5 jVsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=h2c3O0R+; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-67152-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67152-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c7-20020a056214224700b0068cc3b0f1e4si1752941qvc.411.2024.02.15.07.20.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:20:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67152-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=h2c3O0R+; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-67152-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67152-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A89481C22BF8 for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 15:20:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1E9F1350DF; Thu, 15 Feb 2024 15:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="h2c3O0R+" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 BF179132C01; Thu, 15 Feb 2024 15:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708010289; cv=none; b=BPlSfYHVCa/1LRYpJfcWjgz5yI6s8PgIkWiKqS2fGZwANFGwPtwRCzZLY7cUPBrLpnd8CT4AtTtr7e660LEkojYL/hMBHZz4mEBnuKMab42u5GA8FZm5eu3Py7qqKRvOt1tes5OmDsP9Og8DpkLgG5iNQzEIyueZR0QUUH+rkFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708010289; c=relaxed/simple; bh=/7nB9yFoEPjkjgmvlVF2TD3aOLwcM3Gr0Gyc2U7/mrg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HoYDLUdVjbEKKkdzpyJW0G3BKVIPsOmGq6zCDWLWJnmcp48cy33gOKZGQJCGlNTqEUrIQHNDOhQI7zpI5GxX9B5A6pxLyNs6yhrCW1jb5KSuFEDLwLVh5JRUI5ORSEhX/PxpuznxU0TWZqghgYjs2lv8vedEdKV9/LopU9ZyhOI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=h2c3O0R+; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 1CEBA24000F; Thu, 15 Feb 2024 15:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708010285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R9wanZgvZg9ml7GqR5bBizFjTTL8Y7tpLwMVbRWiGTQ=; b=h2c3O0R+H0aCNoaovxhZxz4fVFJgW/NkDJL4iE9MA9Bz5bB4Q8VUtl+qcZNa1VkafuNCvG Nh2QWFaXefaOXRuJwA1HeepNj94AJ5PRbtA5XvajB96K8R6+iEDM+Eua9YE9Ry7Iye7X4u Ec83gQy1b/PELMMhtjR8ynHlH9HaanPxGx4KfuDnTvSHlQ+bLIKxoFwKsVjb/2xmTkp+gh G0qRYloGTPFpOywJdOMsviEGR+p1ktX0l7KhCK+ZJYyBSBw56F87l6sgyFk0v+JehhmYXQ O90Sg5w+vvRoktD0MEwuP7eeBpOVjN1azXxru/XFZELdZ9L7jN4/MwooN/BlaQ== From: Thomas Richard <thomas.richard@bootlin.com> Date: Thu, 15 Feb 2024 16:17:50 +0100 Subject: [PATCH v3 05/18] mux: add mux_chip_resume() function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240102-j7200-pcie-s2r-v3-5-5c2e4a3fac1f@bootlin.com> References: <20240102-j7200-pcie-s2r-v3-0-5c2e4a3fac1f@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v3-0-5c2e4a3fac1f@bootlin.com> To: Linus Walleij <linus.walleij@linaro.org>, Bartosz Golaszewski <brgl@bgdev.pl>, Andy Shevchenko <andy@kernel.org>, Tony Lindgren <tony@atomide.com>, Haojian Zhuang <haojian.zhuang@linaro.org>, Vignesh R <vigneshr@ti.com>, Aaro Koskinen <aaro.koskinen@iki.fi>, Janusz Krzysztofik <jmkrzyszt@gmail.com>, Andi Shyti <andi.shyti@kernel.org>, Peter Rosin <peda@axentia.se>, Vinod Koul <vkoul@kernel.org>, Kishon Vijay Abraham I <kishon@kernel.org>, Philipp Zabel <p.zabel@pengutronix.de>, Lorenzo Pieralisi <lpieralisi@kernel.org>, =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= <kw@linux.com>, Rob Herring <robh@kernel.org>, Bjorn Helgaas <bhelgaas@google.com> 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, Thomas Richard <thomas.richard@bootlin.com> X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790978752950406894 X-GMAIL-MSGID: 1790978752950406894 |
Series |
Add suspend to ram support for PCIe on J7200
|
|
Commit Message
Thomas Richard
Feb. 15, 2024, 3:17 p.m. UTC
The mux_chip_resume() function restores a mux_chip using the cached state
of each mux.
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
---
drivers/mux/core.c | 30 ++++++++++++++++++++++++++++++
include/linux/mux/driver.h | 1 +
2 files changed, 31 insertions(+)
Comments
On Thu, Feb 15, 2024 at 04:17:50PM +0100, Thomas Richard wrote: > The mux_chip_resume() function restores a mux_chip using the cached state > of each mux. .. > +int mux_chip_resume(struct mux_chip *mux_chip) > +{ > + int global_ret = 0; > + int ret, i; > + > + for (i = 0; i < mux_chip->controllers; ++i) { > + struct mux_control *mux = &mux_chip->mux[i]; > + > + if (mux->cached_state == MUX_CACHE_UNKNOWN) > + continue; > + > + ret = mux_control_set(mux, mux->cached_state); > + if (ret < 0) { > + dev_err(&mux_chip->dev, "unable to restore state\n"); > + if (!global_ret) > + global_ret = ret; Hmm... This will record the first error and continue. > + } > + } > + return global_ret; So here, we actually will get stale data in case there are > 1 failures. > +}
On 2/15/24 16:29, Andy Shevchenko wrote: > On Thu, Feb 15, 2024 at 04:17:50PM +0100, Thomas Richard wrote: >> The mux_chip_resume() function restores a mux_chip using the cached state >> of each mux. > > ... > >> +int mux_chip_resume(struct mux_chip *mux_chip) >> +{ >> + int global_ret = 0; >> + int ret, i; >> + >> + for (i = 0; i < mux_chip->controllers; ++i) { >> + struct mux_control *mux = &mux_chip->mux[i]; >> + >> + if (mux->cached_state == MUX_CACHE_UNKNOWN) >> + continue; >> + >> + ret = mux_control_set(mux, mux->cached_state); >> + if (ret < 0) { >> + dev_err(&mux_chip->dev, "unable to restore state\n"); >> + if (!global_ret) >> + global_ret = ret; > > Hmm... This will record the first error and continue. In the v2 we talked about this with Peter Rosin. In fact, in the v1 (mux_chip_resume() didn't exists yet, everything was done in the mmio driver) I had the same behavior: try to restore all muxes and in case of error restore the first one. I don't know what is the right solution. I just restored the behavior I had in v1. > >> + } >> + } >> + return global_ret; > > So here, we actually will get stale data in case there are > 1 failures. Yes, indeed. But we will have an error message for each failure. > >> +} >
On Fri, Feb 16, 2024 at 08:52:17AM +0100, Thomas Richard wrote: > On 2/15/24 16:29, Andy Shevchenko wrote: > > On Thu, Feb 15, 2024 at 04:17:50PM +0100, Thomas Richard wrote: .. > >> +int mux_chip_resume(struct mux_chip *mux_chip) > >> +{ > >> + int global_ret = 0; > >> + int ret, i; > >> + > >> + for (i = 0; i < mux_chip->controllers; ++i) { > >> + struct mux_control *mux = &mux_chip->mux[i]; > >> + > >> + if (mux->cached_state == MUX_CACHE_UNKNOWN) > >> + continue; > >> + > >> + ret = mux_control_set(mux, mux->cached_state); > >> + if (ret < 0) { > >> + dev_err(&mux_chip->dev, "unable to restore state\n"); > >> + if (!global_ret) > >> + global_ret = ret; > > > > Hmm... This will record the first error and continue. > > In the v2 we talked about this with Peter Rosin. > > In fact, in the v1 (mux_chip_resume() didn't exists yet, everything was > done in the mmio driver) I had the same behavior: try to restore all > muxes and in case of error restore the first one. > > I don't know what is the right solution. I just restored the behavior I > had in v1. Okay, I believe you know what you are doing, folks. But to me this approach sounds at bare minimum "unusual". Because the failures here are not fatal and recording the first one may or may not make sense and it's so fragile as it completely implementation-dependent. > >> + } > >> + } > >> + return global_ret; > > > > So here, we actually will get stale data in case there are > 1 failures. > > Yes, indeed. But we will have an error message for each failure. Which is also problematic. PM calls may easily spam the logs and outshadow really important messages (like oopses).
On 2/16/24 16:07, Andy Shevchenko wrote: > On Fri, Feb 16, 2024 at 08:52:17AM +0100, Thomas Richard wrote: >> On 2/15/24 16:29, Andy Shevchenko wrote: >>> On Thu, Feb 15, 2024 at 04:17:50PM +0100, Thomas Richard wrote: > > ... > >>>> +int mux_chip_resume(struct mux_chip *mux_chip) >>>> +{ >>>> + int global_ret = 0; >>>> + int ret, i; >>>> + >>>> + for (i = 0; i < mux_chip->controllers; ++i) { >>>> + struct mux_control *mux = &mux_chip->mux[i]; >>>> + >>>> + if (mux->cached_state == MUX_CACHE_UNKNOWN) >>>> + continue; >>>> + >>>> + ret = mux_control_set(mux, mux->cached_state); >>>> + if (ret < 0) { >>>> + dev_err(&mux_chip->dev, "unable to restore state\n"); >>>> + if (!global_ret) >>>> + global_ret = ret; >>> >>> Hmm... This will record the first error and continue. >> >> In the v2 we talked about this with Peter Rosin. >> >> In fact, in the v1 (mux_chip_resume() didn't exists yet, everything was >> done in the mmio driver) I had the same behavior: try to restore all >> muxes and in case of error restore the first one. >> >> I don't know what is the right solution. I just restored the behavior I >> had in v1. > > Okay, I believe you know what you are doing, folks. But to me this approach > sounds at bare minimum "unusual". Because the failures here are not fatal > and recording the first one may or may not make sense and it's so fragile > as it completely implementation-dependent. I guess if there is an error, the resume is completely dead so no need to continue. If it's okay for Peter I can return on first failure. Regards,
diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 775816112932..5db5a7698ad1 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -215,6 +215,36 @@ void mux_chip_free(struct mux_chip *mux_chip) } EXPORT_SYMBOL_GPL(mux_chip_free); +/** + * mux_chip_resume() - restores the mux-chip state + * @mux_chip: The mux-chip to resume. + * + * Restores the mux-chip state. + * + * Return: Zero on success or a negative errno on error. + */ +int mux_chip_resume(struct mux_chip *mux_chip) +{ + int global_ret = 0; + int ret, i; + + for (i = 0; i < mux_chip->controllers; ++i) { + struct mux_control *mux = &mux_chip->mux[i]; + + if (mux->cached_state == MUX_CACHE_UNKNOWN) + continue; + + ret = mux_control_set(mux, mux->cached_state); + if (ret < 0) { + dev_err(&mux_chip->dev, "unable to restore state\n"); + if (!global_ret) + global_ret = ret; + } + } + return global_ret; +} +EXPORT_SYMBOL_GPL(mux_chip_resume); + static void devm_mux_chip_release(struct device *dev, void *res) { struct mux_chip *mux_chip = *(struct mux_chip **)res; diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h index 18824064f8c0..2a7e5ec5d540 100644 --- a/include/linux/mux/driver.h +++ b/include/linux/mux/driver.h @@ -88,6 +88,7 @@ struct mux_chip *mux_chip_alloc(struct device *dev, int mux_chip_register(struct mux_chip *mux_chip); void mux_chip_unregister(struct mux_chip *mux_chip); void mux_chip_free(struct mux_chip *mux_chip); +int mux_chip_resume(struct mux_chip *mux_chip); struct mux_chip *devm_mux_chip_alloc(struct device *dev, unsigned int controllers,