From patchwork Wed Aug 2 19:51:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 9877461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BC6656037D for ; Wed, 2 Aug 2017 19:52:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACE4128770 for ; Wed, 2 Aug 2017 19:52:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A17BF287C3; Wed, 2 Aug 2017 19:52:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4BA4B287CC for ; Wed, 2 Aug 2017 19:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject: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=vsAFISHZGEgOsqRg1wXArcaoZfBXD3TUKG0VyRgt74M=; b=IMA DOrokHrlaLPcKcQQNLzdgwb1sRcvJmYngVea9e9yPklcrn3M5dWijQUZvMh9Ugp0drSh287GKiRmq VRB24KzjLAKuk7Z1n57AAfo8Afft+IyBQDgmNyGM/1CUYa7oSZipEuQ1HRuER+kQzp+wppnt8Tlsv EN0z6NhRJ5Xo4BK2dYcLzl8cTm8IRDTdeHNs4/iIJ1EzoQKzUHKe88KTYujVzE1szFrK+BurlRk4a mMvh62GUzqmQ1zrlQPgaoFZUsVmE/mcN8/nuyPzb6Sg28SD7dp8ruwBGV8lAskf7K1Xwo+Q376UNJ jS8Sa5GPFajRKAHn8tBCfm5rG2aF2Bg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dczgp-000275-Nj; Wed, 02 Aug 2017 19:52:19 +0000 Received: from mail.kmu-office.ch ([2a02:418:6a02::a2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dczgi-00025e-NZ for linux-arm-kernel@lists.infradead.org; Wed, 02 Aug 2017 19:52:18 +0000 Received: from trochilidae.toradex.int (75-146-58-181-Washington.hfc.comcastbusiness.net [75.146.58.181]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 425225C0618; Wed, 2 Aug 2017 21:49:02 +0200 (CEST) From: Stefan Agner To: shawnguo@kernel.org, kernel@pengutronix.de Subject: [PATCH] soc: imx: gpcv2: fix regulator deferred probe Date: Wed, 2 Aug 2017 12:51:29 -0700 Message-Id: <20170802195129.20442-1-stefan@agner.ch> X-Mailer: git-send-email 2.13.3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1501703343; bh=EKRWjccIyxkVU2e1PPfrvjwSGntsYcBsGfMKZVCTD7U=; h=From:To:Cc:Subject:Date:Message-Id; b=ijnzvNyuxaOXgzgT5eoDAyp44KZKvONCSg56OZYGlEWiEQFqjPHvg4YfrM/iw/qtq1X4x9bT9A0E88p9QHryZuwC77vKwC9R5BTe02aNWOE6KfIRQ9RkYESd0IgMPf7/pgo5od9lH/y1hfZNk7hwv81f/Dx8H61BUv0329PHR+M= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170802_125216_907639_1CA119CB X-CRM114-Status: UNSURE ( 9.75 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabio Estevam , Andrey Smirnov , linux-arm-kernel@lists.infradead.org, Stefan Agner , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If a regulator requests a deferred probe, the power domain gets initialized twice. This leads to a list double add (without list debugging the kernel hangs due to the double add later): WARNING: CPU: 0 PID: 19 at lib/list_debug.c:31 __list_add_valid+0xbc/0xc4 list_add double add: new=c1229754, prev=c12383b4, next=c1229754. Initialize the power domain after we get the regulator. Also do not print an error in case the regulator defers probing. Cc: Fabio Estevam Cc: Andrey Smirnov Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Fixes: 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver") Signed-off-by: Stefan Agner Acked-by: Andrey Smirnov Tested-by: Andrey Smirnov --- Hi Shawn, Since this leads to a Kernel hang in v4.13-rc3, can you get this into v4.13 still? -- Stefan drivers/soc/imx/gpcv2.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c index 3039072911a5..afc7ecc3c187 100644 --- a/drivers/soc/imx/gpcv2.c +++ b/drivers/soc/imx/gpcv2.c @@ -200,16 +200,11 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev) domain->dev = &pdev->dev; - ret = pm_genpd_init(&domain->genpd, NULL, true); - if (ret) { - dev_err(domain->dev, "Failed to init power domain\n"); - return ret; - } - domain->regulator = devm_regulator_get_optional(domain->dev, "power"); if (IS_ERR(domain->regulator)) { if (PTR_ERR(domain->regulator) != -ENODEV) { - dev_err(domain->dev, "Failed to get domain's regulator\n"); + if (PTR_ERR(domain->regulator) != -EPROBE_DEFER) + dev_err(domain->dev, "Failed to get domain's regulator\n"); return PTR_ERR(domain->regulator); } } else { @@ -217,6 +212,12 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev) domain->voltage, domain->voltage); } + ret = pm_genpd_init(&domain->genpd, NULL, true); + if (ret) { + dev_err(domain->dev, "Failed to init power domain\n"); + return ret; + } + ret = of_genpd_add_provider_simple(domain->dev->of_node, &domain->genpd); if (ret) {