Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp877309imn; Tue, 26 Jul 2022 11:48:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vMwyqXkfAUUu03MSAt9b11AOu5k7IC7V+VnCXeBCJcLT0808A0ocFQqdhHIsAnHjmA6j9E X-Received: by 2002:a17:907:d8d:b0:72f:75:9bbd with SMTP id go13-20020a1709070d8d00b0072f00759bbdmr15324274ejc.148.1658861304395; Tue, 26 Jul 2022 11:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658861304; cv=none; d=google.com; s=arc-20160816; b=uYAOgdXAzviPJ9F4Fl050zjiNg2Lc22SjCpLVotmSE5YjwbMNJIIsaWQjhHVk3I2hk WFyII0SwDBMAJPxt65mfuEwc7UEi8R00vcqMcsEqwTewBL0R8vIXkZ65qQvr94t9ohgM j5Lc2xtN0mwLhx15MUDrcQVfYvKaxcfejyomQsApAm5ViLiF//rrqTxVG58CtZXK6n7U fobh+coXGSZ33qp/061/vjBW+ikSvmSGyjQoEr5fWDbkLXOsM3WYoKfZO35fVAykKNSb v18cQlUiQbYS727JWrTtlV9F1c0iEAXbeNn4cuQfc4ndTymGoux+Mb64Eo2B4ySbc3YO dTsQ== 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; bh=5+m7EBDqZU/jW3BuYu28PjO80Us2rcYeVmkBo88WcRQ=; b=rsWfR7m7KAcASjJ524MmRI2Ov+RW1ehPJdhnyAvYcF0FyVb4HSrxkjpMLQRZ5feNKo NYftQkf16QJ4XuvPt3/7Z7ftNOqKZyrpDMcbtkgJTHcAPM4vvt9ApvjJkNkD0w3JT9Zj o+7rtt1oZfRBkUKDKpUWQ1tVQyjghQnJ2woBZhCpGldI5NMlTBjiH95Izh1ZvaCtCNsi aR8INL1uVnXkvEiIqxm89pDN5Sf84leap3g6bdZqXyjbS2jalsO7bPC8xnoBvArbjbPe xvKrmag0wvJETzLbziuElQ5Ej17I0ACv+7dtw2sX3+D2bmLpeJ+iilTOT9vUvyRzCiv0 vVjw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg39-20020a170907972700b00715867834e3si18102711ejc.506.2022.07.26.11.47.59; Tue, 26 Jul 2022 11:48:24 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239466AbiGZSdc (ORCPT + 99 others); Tue, 26 Jul 2022 14:33:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbiGZSda (ORCPT ); Tue, 26 Jul 2022 14:33:30 -0400 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7528F1FCD7; Tue, 26 Jul 2022 11:33:29 -0700 (PDT) Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-31f1d1c82c8so59051057b3.8; Tue, 26 Jul 2022 11:33:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=5+m7EBDqZU/jW3BuYu28PjO80Us2rcYeVmkBo88WcRQ=; b=T+mwv+9ekmkrYeOZY28nPu71f6I3WE0oVub5EJ9bIXm3a9h52CP5huB1pJvIqfNbPa muDsSytg8X/xbuXnZT1Lf1B93JqDa7HuwnKcXtCmeGUdnH+tayiDiRj3OA+wXfaOaWwD guWUvL/nh4JTgJNLEN6fyUeljl8QlL5PwSS2wZ+siDc5wqX1qZu4nOU8ASfqWMo/TT5w lW/b4dPtnqyHMgWFewy4yiMtj2bgN9/+lnsxvwjffxD8FepcesOJgozRLmUZUCam2Drr UNQjw62TZziDUMIf2JGmSS9GAgWu95rAZet41DfOnJskz+1ehyf2VllaBsV403Ws2rsp pGdg== X-Gm-Message-State: AJIora/BYhSc+kcb4bTebkj5ibVuMn4QFy0ynLCu2eHjtUlkAN2HiWG+ +t3EEi92DGzZm5VFo0YT85AT8XuEwo/BB3gxRLumuCvy X-Received: by 2002:a81:1b97:0:b0:2db:640f:49d8 with SMTP id b145-20020a811b97000000b002db640f49d8mr15609044ywb.326.1658860408658; Tue, 26 Jul 2022 11:33:28 -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: "Rafael J. Wysocki" Date: Tue, 26 Jul 2022 20:33:17 +0200 Message-ID: Subject: Re: [PATCH v6 1/2] power: domain: handle genpd correctly when needing interrupts To: Ulf Hansson Cc: Martin Kepplinger , "Rafael J. Wysocki" , 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=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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, 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? > Beside this, I think the $subject patch looks good to me. Or not?