From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D167C19F2C for ; Thu, 28 Jul 2022 09:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235488AbiG1JUi (ORCPT ); Thu, 28 Jul 2022 05:20:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234427AbiG1JUg (ORCPT ); Thu, 28 Jul 2022 05:20:36 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC84648CA1 for ; Thu, 28 Jul 2022 02:20:34 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id bf9so1925598lfb.13 for ; Thu, 28 Jul 2022 02:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ywBOOR3hRZ95Faea8Y6GMt4e6+qAIbLT8FcbUkq7ZHE=; b=FLMFlnMeKZxsVr2c45CmvBS+qrnhsIuZ0il6XWUWSJOHskOe3htKisNWoRGcqQJ6Bc IwKoYwCJgIag0uNUSvZRp9i60AKPHNAVzP1lduRtVgkklONHYiYRv/3jIzwJE0mFx74d 2ZpSqbV6dQzFqj8auMplx9uRoDOc95fnky0nB56ssFA3bfjG/ppdIPore4Rifm9+MfCt JM0Nqo6IXJ/X36tB7PJXO4bclIdjzw4jGnRBQxLpIO6YJ6UvnH1XG/2qn4p9+0RkexuM 5NDGhoJSc7lbi1btPg+xk8t6eJ0NqkOsznAqqpFx7Lbc3gyUiIwyM/38FQZKqN9ZEQo0 MeOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ywBOOR3hRZ95Faea8Y6GMt4e6+qAIbLT8FcbUkq7ZHE=; b=dKyCVA6gldW/lmkvHYpMyAve5kClhUIrvoxOnZBEUgN+wGuRYaM5h5rBtn+vIEm9O1 2NmHJnhnCVGaIvpQAqvWOOub2DN0aVZpYz7lQwC/se2RTL2jD5s/1b82mUZRnnaA0Adf gE5gA41TYIU5AufQvBOI0YJ7JCzjUJzSFLNKQ41gKcw+k5insIHps4NaRX1NAtk+FO+t acjxoTj47apPH86cbS/4gDStFon7Lirct8/ii/hiW8SjyCfPrGe5VJ8gkDx13QS1Licl Q7qnUOJi/h2h9qpuubHwJJIPZivjhyBxkpJlwXson3RPkERRbSEycc2Z/QiIQuQ2CJTx J/Hg== X-Gm-Message-State: AJIora+NYHo2y3dg9KjtVC5yahogOKVpE6KHdpInGg007Z4Fk1fEME6E /InpNmWi1gAwXwj4PQRcFyMx/G9ODPf7a3vACksprg== X-Google-Smtp-Source: AGRyM1v4zQOyf52XZG8OieodKUUIY6pg6LY/9dvoTrTj2RYsX1V1xy0G18hqalRKNzt7C6arApkKcjQdf5akPoM6wQk= X-Received: by 2002:a05:6512:32c5:b0:48a:af79:601e with SMTP id f5-20020a05651232c500b0048aaf79601emr3638569lfg.373.1659000033025; Thu, 28 Jul 2022 02:20:33 -0700 (PDT) MIME-Version: 1.0 References: <20220726083257.1730630-1-martin.kepplinger@puri.sm> <20220726083257.1730630-2-martin.kepplinger@puri.sm> In-Reply-To: From: Ulf Hansson Date: Thu, 28 Jul 2022 11:19:56 +0200 Message-ID: Subject: Re: [PATCH v6 1/2] power: domain: handle genpd correctly when needing interrupts To: "Rafael J. Wysocki" Cc: Martin Kepplinger , Kevin Hilman , Rob Herring , Krzysztof Kozlowski , Shawn Guo , Sascha Hauer , Fabio Estevam , Pavel Machek , kernel@puri.sm, dl-linux-imx , Mark Brown , Lucas Stach , aford173@gmail.com, Linux PM , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List , Linux ARM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Jul 2022 at 20:33, Rafael J. Wysocki wrote: > > On Tue, Jul 26, 2022 at 5:07 PM Ulf Hansson wrote: > > > > On Tue, 26 Jul 2022 at 10:33, Martin Kepplinger > > wrote: > > > > > > If for example the power-domains' power-supply node (regulator) needs > > > interrupts to work, the current setup with noirq callbacks cannot > > > work; for example a pmic regulator on i2c, when suspending, usually already > > > times out during suspend_noirq: > > > > > > [ 41.024193] buck4: failed to disable: -ETIMEDOUT > > > > > > So fix system suspend and resume for these power-domains by using the > > > "outer" suspend/resume callbacks instead. Tested on the imx8mq-librem5 board, > > > but by looking at the dts, this will fix imx8mq-evk and possibly many other > > > boards too. > > > > > > This is designed so that genpd providers just say "this genpd needs > > > interrupts" (by setting the flag) - without implying an implementation. > > > > > > Initially system suspend problems had been discussed at > > > https://lore.kernel.org/linux-arm-kernel/20211002005954.1367653-8-l.stach@pengutronix.de/ > > > which led to discussing the pmic that contains the regulators which > > > serve as power-domain power-supplies: > > > https://lore.kernel.org/linux-pm/573166b75e524517782471c2b7f96e03fd93d175.camel@puri.sm/T/ > > > > > > Signed-off-by: Martin Kepplinger > > > --- > > > drivers/base/power/domain.c | 13 +++++++++++-- > > > include/linux/pm_domain.h | 5 +++++ > > > 2 files changed, 16 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > > > index 5a2e0232862e..58376752a4de 100644 > > > --- a/drivers/base/power/domain.c > > > +++ b/drivers/base/power/domain.c > > > @@ -130,6 +130,7 @@ static const struct genpd_lock_ops genpd_spin_ops = { > > > #define genpd_is_active_wakeup(genpd) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP) > > > #define genpd_is_cpu_domain(genpd) (genpd->flags & GENPD_FLAG_CPU_DOMAIN) > > > #define genpd_is_rpm_always_on(genpd) (genpd->flags & GENPD_FLAG_RPM_ALWAYS_ON) > > > +#define genpd_irq_on(genpd) (genpd->flags & GENPD_FLAG_IRQ_ON) > > > > > > static inline bool irq_safe_dev_in_sleep_domain(struct device *dev, > > > const struct generic_pm_domain *genpd) > > > @@ -2065,8 +2066,15 @@ int pm_genpd_init(struct generic_pm_domain *genpd, > > > genpd->domain.ops.runtime_suspend = genpd_runtime_suspend; > > > genpd->domain.ops.runtime_resume = genpd_runtime_resume; > > > genpd->domain.ops.prepare = genpd_prepare; > > > - genpd->domain.ops.suspend_noirq = genpd_suspend_noirq; > > > - genpd->domain.ops.resume_noirq = genpd_resume_noirq; > > > + > > > + if (genpd_irq_on(genpd)) { > > > + genpd->domain.ops.suspend = genpd_suspend_noirq; > > > + genpd->domain.ops.resume = genpd_resume_noirq; > > > + } else { > > > + genpd->domain.ops.suspend_noirq = genpd_suspend_noirq; > > > + genpd->domain.ops.resume_noirq = genpd_resume_noirq; > > > > As we discussed previously, I am thinking that it may be better to > > move to using genpd->domain.ops.suspend_late and > > genpd->domain.ops.resume_early instead. > > Should I take this as a change request? Yes. > > > Beside this, I think the $subject patch looks good to me. > > Or not? The patch needs to be updated before I give it my blessing, but the only changes that are needed are the minor things I pointed out above. Sorry if it was not clear enough. Kind regards Uffe