Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp346785imn; Thu, 28 Jul 2022 02:28:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uAKWNQK3wKdhsSN+gA+cPbOkixplO3BmQOIWZJShpVw5GznJRIx+hJPOBsZ2VxNDUdk9fD X-Received: by 2002:a05:6402:430b:b0:43b:e639:8b25 with SMTP id m11-20020a056402430b00b0043be6398b25mr23101314edc.205.1659000481293; Thu, 28 Jul 2022 02:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659000481; cv=none; d=google.com; s=arc-20160816; b=y6/diTwPRenohEHlXWdEXnp+Ei4f+DCNDpV9Eyoed1ULGHTbOX3WI319USjUbdH3AF iNZLZZjJ+emjkFP5Wr9nn1MvRZVby/RH3NVgZrDTBHTtHhCbLOwZf7cQwhl70CjktCiw TY1gwp+9dlQUk6QBnvn0CPh1ZyddSJLDqmh2DKWB1ChnDZGs2y7PGLISRCk/PjOHDEUe aE9cSe37Hry/8NU2vpe0ZBWPMakwqfdJfR3lIJ7Tl106iQc8gteFhE8MNX3edYjjAQik Ir3/xCbifUyvTSvwCYkalrp/Z5G0oKoPq7GRqc/CENdOcaoZwxA+m0RaFQgbqPAS5V5Y PWhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ywBOOR3hRZ95Faea8Y6GMt4e6+qAIbLT8FcbUkq7ZHE=; b=UmxaacoFvhZmzgZyHeHG1QsOpQoIL9+TQAzrI/dhqdbBBk6q1/PyBJn0wU/IX1kbVU qsqMYCtTF4i2uFgSvjIwpTm3vk0TCXbaRmKNaGTB8EaFYRON8WhZfGLFE7wZXBHyV+gK ZG1z6vUSPs5Ah0BJCBtVXxrZbLxJnROxnwK6Bhi6GiJc20HCtGYO7aVExBCJJPIxx8t/ 8m+Cb9ojthex2ywlrijX8baiOOFos4bh9ASNsCAQMc5yBVFv27Kr85M1/RLlNoT/D0lU ec8gj4f0DJ0ighz0NAVexUlz4mt/F9r3DvNpuO3sfe6ARImfMO6LS9Qqj/PMnZVKHf7A p4dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FLMFlnMe; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a056402144b00b0043bd245c239si324070edx.328.2022.07.28.02.27.36; Thu, 28 Jul 2022 02:28:01 -0700 (PDT) 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=@linaro.org header.s=google header.b=FLMFlnMe; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235239AbiG1JUh (ORCPT + 99 others); Thu, 28 Jul 2022 05:20:37 -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-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" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 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