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 92C22C00140 for ; Tue, 26 Jul 2022 18:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239513AbiGZSdd (ORCPT ); Tue, 26 Jul 2022 14:33:33 -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-Google-Smtp-Source: AGRyM1v+eroIuT8BybBIl9+jRpYcBVPNVsJgdQpI7FwfWSz8KlUO5x9QDs65P5xz9wsvnf6SnKWfixXAYLgYtgF4C14= 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" 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? 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B62B8C04A68 for ; Tue, 26 Jul 2022 18:34:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MIjUSYD2HSMk2cqhn2BE3mfxfyixNDCjNlce8a192lA=; b=ixNm8KcO8TNCam SCn78YKIkrvywlAcHjxTxEVStRf5VlkjYMlQ09YsqyYYFiGAbLWwf15nLgVWBEmfIfK9nb1ySVSn3 niU8vfFASsLoHnhNZEQXAq3oscWGw33qow2hXwnpkGgWNhsrtvJ7gz37qA+xxj55mDDnOm3Kvg/pK xh3gKZukp2AfyBaE8gAVytUGY3XEO5E4VXffScB45b2OiO5G0HlNcnL+AX/2uhlqbeGRxaD2Tr+bL pBcN+TDOhyJKWTqugBViTM8YfWsepR8QLKhw1aka7Att77Ky7IpEmYnksAybz73iH76fHFjGcfM2i QzruruaowWNfRzmZ6/fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGPN8-0029QG-4U; Tue, 26 Jul 2022 18:33:34 +0000 Received: from mail-yw1-f181.google.com ([209.85.128.181]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGPN5-0029NZ-56 for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2022 18:33:32 +0000 Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-31e7055a61dso151954207b3.11 for ; 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=Q+JcQKvHxtIdThmp5F1v7XA6FKyCOgENwq0WEKyqOLTEwQqOSaLL+GBLeoPo9PGZM8 aNGFT9FxzybmCUdqjSsZP3NyUSbN/vHljFDIoVytzl4xPmfGO0XLfwscXyMvdCML9BYQ 7v+zvcuaQlEZN/c4dwqa6eaFA1+I+08Dsm2OfQhQlTqjmbLElZdOoxevRiq32CVKNUgO 2gn185Xxp4blq41xMNXzpyly9hUmDGRRzkJnQHCZpkYj/GsBgvopJimO0FJ3MaItOWW5 gflhJR+w4+A3oM7yvdqWQsn0EytukDpuX+La/KlGs5cwA51BBOKYt2ttzwHAlFoaf5Ea hwkQ== X-Gm-Message-State: AJIora9tt8pFBd9DdnMooEYN7vrkm+92GRiUABPfTIUFLOLDirtZn1j9 zz8nCjsxeJS3+s0jshMkXA0a1Ct0+xI6clboeWc= X-Google-Smtp-Source: AGRyM1v+eroIuT8BybBIl9+jRpYcBVPNVsJgdQpI7FwfWSz8KlUO5x9QDs65P5xz9wsvnf6SnKWfixXAYLgYtgF4C14= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220726_113331_217650_26D23D94 X-CRM114-Status: GOOD ( 31.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel