From patchwork Wed Dec 8 13:47:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger X-Patchwork-Id: 12695353 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 75C58C433F5 for ; Wed, 8 Dec 2021 13:50:03 +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:References:In-Reply-To: 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: List-Owner; bh=PmP+2RGXPy2WRbkOiVAnxY23W+7bCrE8QIpD/WuY5NE=; b=RXb1Hladufo7uu tHrUtTmqaCXSdiL6LU1Tdg4MjodntfnL1iNjqwkn8DHzbMxROjjlbXgvFAo1+59qdqYBpkAutNbCK ud9LWAk5AjuKUNljfJOAAI7YZwdDu74MqcT5rB27qtKHQnIRybYmrjYX3TuKbAIZF6FAZ3Sc7aAxg Gpcd6B/ffnS73ECApYNntyuaEgorfdZsIDDEAk/XTJvAQz3kPHACydPeWsO1K0hRVQT/WVvmCyzbo rfWaQUDDft9CPhFF5skBrhiMlSQ9pcMUL0C2kmowyS2sDDrqwQuBVoOlGrLsCQpz+/TSED6mRrs8z VK0mh/xQI01kRWh8q+sA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muxJD-00Crtw-0b; Wed, 08 Dec 2021 13:48:35 +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 1muxJ8-00Crsk-U4 for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 13:48:32 +0000 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 453BADF33E; Wed, 8 Dec 2021 05:47: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 l-SkG54PBIr2; Wed, 8 Dec 2021 05:47:56 -0800 (PST) From: Martin Kepplinger To: l.stach@pengutronix.de Cc: aford173@gmail.com, devicetree@vger.kernel.org, festevam@gmail.com, frieder.schrempf@kontron.de, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, marex@denx.de, patchwork-lst@pengutronix.de, robh@kernel.org, shawnguo@kernel.org, tharvey@gateworks.com, Martin Kepplinger Subject: [PATCH] hack: soc: imx: gpcv2: avoid unbalanced powering off of one device Date: Wed, 8 Dec 2021 14:47:25 +0100 Message-Id: <20211208134725.3328030-1-martin.kepplinger@puri.sm> In-Reply-To: <20211002005954.1367653-8-l.stach@pengutronix.de> References: <20211002005954.1367653-8-l.stach@pengutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211208_054831_013926_A68994AB X-CRM114-Status: GOOD ( 14.76 ) 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 Hi Lucas, I've posted this hack with a report here a few days back: https://lore.kernel.org/linux-arm-kernel/20211122115145.177196-1-martin.kepplinger@puri.sm/ But now that I see these suspend/resume callback additions things again go wrong on my imx8mq system. With a v5.16-rc4 based tree and printing on regulator enable/disable, system suspend + resume looks like so: [ 47.559681] imx-pgc imx-pgc-domain.5: enable [ 47.584679] imx-pgc imx-pgc-domain.0: disable [ 47.646592] imx-pgc imx-pgc-domain.5: disable [ 47.823627] imx-pgc imx-pgc-domain.5: enable [ 47.994805] imx-pgc imx-pgc-domain.5: disable [ 48.664018] imx-pgc imx-pgc-domain.5: enable [ 48.805828] imx-pgc imx-pgc-domain.5: disable [ 49.909579] imx-pgc imx-pgc-domain.6: enable [ 50.013079] imx-pgc imx-pgc-domain.6: failed to enable regulator: -110 [ 50.013686] imx-pgc imx-pgc-domain.5: enable [ 50.120224] imx-pgc imx-pgc-domain.5: failed to enable regulator: -110 [ 50.120324] imx-pgc imx-pgc-domain.0: enable [ 53.703468] imx-pgc imx-pgc-domain.0: disable [ 53.746368] imx-pgc imx-pgc-domain.5: disable [ 53.754452] imx-pgc imx-pgc-domain.5: failed to disable regulator: -5 [ 53.765045] imx-pgc imx-pgc-domain.6: disable [ 53.822269] imx-pgc imx-pgc-domain.6: failed to disable regulator: -5 But my main point is that the situation is a bit hard to understand right now. when transitioning to system suspend we expect (if disabled) enable+disable to happen, right? and after resuming: enable (+ runtime disable). Makes sense functinally, but I wonder if we could implement it a bit clearer? Anyway I'm also not sure whether imx8mq might be different than your imx8mm system. When I revert your one patch and add my hack below again, things work again and the system resumes without errors. Can you imagine what might be missing here? thanks a lot for working on this! 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 07610bf87854..898886c9d799 100644 --- a/drivers/soc/imx/gpcv2.c +++ b/drivers/soc/imx/gpcv2.c @@ -319,6 +319,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);