From patchwork Mon Nov 22 11:51:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger X-Patchwork-Id: 12693314 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 144CEC433EF for ; Mon, 22 Nov 2021 12:15:22 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UkZMagebwzBQq0kIXDZ+uE7EuPji8DovcxKb7m4mGo8=; b=PV/klev+3miqNm /b++o5w8MPZjQxbgMoNLm4p0RKYoati1vuwPQsetYarXkARhh24oNveFzXE0hvLGZ4CcytzwBR17W xgvtI5yFlw+XBHQmrt8CY3TNtLJ9/aYIzRBEAXiWDs6BPgv8fD+zEs7l/way9H3QRRJebATZcuc9l N8ZPmf47ArDUjyH0OKT2AsPZZvA7b5cj0AC3jKaOVJpR35buH3vwx/ieZAalPxmlJn7gJZd6491QM Zqsk5QxWf0GIgbc5P2yi8V38ymy6ELehImF6cFLgau6REtdF4hABH2HT0ixEN8X8qXpn0PgQ2aAvR O/PcL8JlrlvEpeki2SUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp8Ca-00GHck-Dk; Mon, 22 Nov 2021 12:13:40 +0000 Received: from comms.puri.sm ([159.203.221.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mp7rb-00GATM-77 for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 11:52:00 +0000 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 545DCE13E7; Mon, 22 Nov 2021 03:51:57 -0800 (PST) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AKUhHz9mPKVs; Mon, 22 Nov 2021 03:51:56 -0800 (PST) From: Martin Kepplinger To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com Cc: peng.fan@nxp.com, l.stach@pengutronix.de, kernel@puri.sm, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH] soc: imx: gpcv2: avoid unbalanced powering off during system suspend Date: Mon, 22 Nov 2021 12:51:45 +0100 Message-Id: <20211122115145.177196-1-martin.kepplinger@puri.sm> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211122_035159_305569_689195F1 X-CRM114-Status: GOOD ( 14.21 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Yes, I don't yet sign-off on this - I'm not sure whether this works around a probem in the power domain (or regulator?) core: When tranisioning to system sleep on imx8mq I see the following errors (and resuming doesn't succeed): [ 2594.505465] ldo5: Underflow of regulator enable count [ 2594.524045] imx-pgc imx-pgc-domain.0: failed to disable regulator: -22 [ 2594.531352] imx-pgc imx-pgc-domain.5: failed to disable regulator: -5 [ 2594.547119] imx-pgc imx-pgc-domain.6: failed to disable regulator: -5 So I started debugging the "ldo5" regulator that is the power-supply for the imx8mq mipi power domain "0" (on the imx8mq-librem5 board). During runtime-pm only, things are fine. When transitioning to system suspend, I at least see genpd_power_off() executing after the "System suspend is in progress" check, where it's supposed to have returned early already (due to genpd->prepared_count > 0). That leads to the unbalance power-off. While this patch "fixes" my problem, where is the root cause of this? Thank you for your help in this! so long, martin --- drivers/soc/imx/gpcv2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c index b8d52d8d29db..4b1b9176127f 100644 --- a/drivers/soc/imx/gpcv2.c +++ b/drivers/soc/imx/gpcv2.c @@ -318,6 +318,9 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd) u32 reg_val, pgc; int ret; + if (pm_runtime_suspended(domain->dev)) + return 0; + /* Enable reset clocks for all devices in the domain */ if (!domain->keep_clocks) { ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks);