From patchwork Thu Aug 7 00:39:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 377697 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 82756140085 for ; Thu, 7 Aug 2014 10:43:37 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XFBlE-0005Gm-PV; Thu, 07 Aug 2014 00:40:52 +0000 Received: from mail-yh0-x22b.google.com ([2607:f8b0:4002:c01::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XFBlB-0005Cu-QD for linux-arm-kernel@lists.infradead.org; Thu, 07 Aug 2014 00:40:50 +0000 Received: by mail-yh0-f43.google.com with SMTP id 29so2411202yhl.30 for ; Wed, 06 Aug 2014 17:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Od+j2DJA0C4RZQW/q8ZhiKvzd3U/R7hktn3A955e3y4=; b=zxLNT4rq84412n/bH502ZKTiDLM1sDDluYo/z6xN1+WVGqLLI979PeLX0YPumRuCnf m/eEJhcyNukCa1QkbXOu0uUPcqlsSMOi2YEM5TsK2v1DTAyPBOTEiRoA+xtgTN1cPfGk HWd4JOly9ZeLjxv31AbDXun5sioOBt6xK8KCrQVXSiYvn6ddlpuu3cSc7Xn8YLr8Kfhw rFakSib0S28KF51rPMvBq+IwiHFxGYLHq4BNem1NHn75YTvKMark9ouK3gqvLwOWOptU KbZEqGsSLkdoIGztk96oKM2o6SMYBhhUXmw5LhKAi2TXEWL4xLrlqXtHDbKOohoy1nh7 2N1Q== X-Received: by 10.236.110.110 with SMTP id t74mr257629yhg.162.1407372027228; Wed, 06 Aug 2014 17:40:27 -0700 (PDT) Received: from localhost.localdomain ([201.82.52.106]) by mx.google.com with ESMTPSA id k29sm4643979yha.33.2014.08.06.17.40.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Aug 2014 17:40:26 -0700 (PDT) From: Fabio Estevam To: shawn.guo@freescale.com Subject: [PATCH] ARM: mx6: Fix suspend/resume with PCI Date: Wed, 6 Aug 2014 21:39:58 -0300 Message-Id: <1407371998-11437-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140806_174049_912557_F54A507E X-CRM114-Status: GOOD ( 18.25 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (festevam[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Cc: r65037@freescale.com, Fabio Estevam , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org From: Fabio Estevam When PCI is used and a suspend/resume sequence is done we see the following kernel hang: root@freescale /$ echo mem > /sys/power/state [ 16.099018] PM: Syncing filesystems ... done. [ 16.141010] Freezing user space processes ... (elapsed 0.002 seconds) done. [ 16.150840] Freezing remaining freezable tasks ... (elapsed 0.003 seconds) done. [ 16.199438] random: nonblocking pool is initialized [ 16.229639] PM: suspend of devices complete after 64.793 msecs [ 16.235488] PM: suspend devices took 0.070 seconds [ 16.245301] PM: late suspend of devices complete after 4.968 msecs [ 16.257063] PM: noirq suspend of devices complete after 5.538 msecs [ 16.263425] Disabling non-boot CPUs ... [ 16.274666] CPU1: shutdown [ 16.286351] CPU2: shutdown [ 16.294169] CPU3: shutdown [ 16.299551] Enabling non-boot CPUs ... [ 16.304155] CPU1: Booted secondary processor [ 16.305717] CPU1 is up [ 16.313078] CPU2: Booted secondary processor [ 16.313456] CPU2 is up [ 16.320778] CPU3: Booted secondary processor [ 16.321174] CPU3 is up (hangs here) Implement a workaround for the erratum ERR005723: "PCIe does not support L2 Power Down", which consists in toggling bit 18 (TEST_POWERDOWN) of GPR1 register. Tested on a mx6qsabresd TO1.2 revC2. Reported-by: Shawn Guo Signed-off-by: Fabio Estevam Tested-by: Bjørn Erik Nilsen --- Richard, Is there any better method to fix this issue? Or should we do the same as in the FSL kernel? I also tried to add pm ops into the imx6 pci driver and did the toggle there, but I still got the kernel hang. arch/arm/mach-imx/pm-imx6.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c index 5c3af8f..92511cf 100644 --- a/arch/arm/mach-imx/pm-imx6.c +++ b/arch/arm/mach-imx/pm-imx6.c @@ -341,6 +341,23 @@ static int imx6q_suspend_finish(unsigned long val) static int imx6q_pm_enter(suspend_state_t state) { + struct regmap *gpr; + gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); + if (IS_ERR(gpr)) { + pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n"); + return PTR_ERR(gpr); + } + + /* + * L2 can exit by 'reset' or Inband beacon (from remote EP) + * toggling phy_powerdown has same effect as 'inband beacon' + * So, toggle bit18 of GPR1 as a workaround of erratum + * ERR005723 - "PCIe does not support L2 Power Down" + */ + if (IS_ENABLED(CONFIG_PCI_IMX6) && !cpu_is_imx6sx()) + regmap_update_bits(gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_TEST_PD, + IMX6Q_GPR1_PCIE_TEST_PD); + switch (state) { case PM_SUSPEND_STANDBY: imx6q_set_lpm(STOP_POWER_ON); @@ -383,6 +400,16 @@ static int imx6q_pm_enter(suspend_state_t state) return -EINVAL; } + /* + * L2 can exit by 'reset' or Inband beacon (from remote EP) + * toggling phy_powerdown has same effect as 'inband beacon' + * So, toggle bit18 of GPR1 as a workaround of erratum + * ERR005723 - "PCIe does not support L2 Power Down" + */ + if (IS_ENABLED(CONFIG_PCI_IMX6) && !cpu_is_imx6sx()) + regmap_update_bits(gpr, IOMUXC_GPR1, IMX6Q_GPR1_PCIE_TEST_PD, + !IMX6Q_GPR1_PCIE_TEST_PD); + return 0; }