From patchwork Sun Dec 21 22:52:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 5525531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 39C4F9F2F7 for ; Sun, 21 Dec 2014 23:07:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42BA92013D for ; Sun, 21 Dec 2014 23:07:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 227B620121 for ; Sun, 21 Dec 2014 23:07:17 +0000 (UTC) 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 1Y2pYV-0001RA-Ba; Sun, 21 Dec 2014 23:04:55 +0000 Received: from mail-la0-x22f.google.com ([2a00:1450:4010:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y2pYR-0001OC-2c for linux-arm-kernel@lists.infradead.org; Sun, 21 Dec 2014 23:04:52 +0000 Received: by mail-la0-f47.google.com with SMTP id hz20so3115980lab.6 for ; Sun, 21 Dec 2014 15:04:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=p1cPRI8e/an2fr1xVjpgtpQ8VbvUZvcYuxc6sOeROy0=; b=cwXKPOlvZdqlskbEJY2ibx3cXhHHgcG+7BhIcZPSRGSx1Wy7DjXq0wE1SbqzET2G8S KXbFtcp5umj6jQ67K4fVltdRwPkN4fZ2jv5qlFnJUkr+lg4A4iidTGbcTwW4Eaw8P+H/ peWG4upxHWXtPF7VEWRDN0P6VgWli2HTnOp8cVna3XklUtTbPM1Yac4pxlxtB8d2gCUR erk0lhrUDd8uUiGCvmiGUCeBMcqCJae2OUzViGMrnkxJEQG4OUOIQQS80nTrwLgAmbxf A2oldyFWfuyBj2+PvOQn2GgNYEM7y+nuJKnO/ZyXeNAn1Uae1z1LOykW/+dL1+P3Scw9 7GTw== X-Received: by 10.112.101.100 with SMTP id ff4mr18945009lbb.94.1419203066557; Sun, 21 Dec 2014 15:04:26 -0800 (PST) Received: from localhost.localdomain (ppp91-77-120-206.pppoe.mtu-net.ru. [91.77.120.206]) by mx.google.com with ESMTPSA id c5sm4585515laa.34.2014.12.21.15.04.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 21 Dec 2014 15:04:25 -0800 (PST) From: Dmitry Osipenko To: digetx@gmail.com, Stephen Warren , Thierry Reding , Alexandre Courbot , Joseph Lo Subject: [PATCH] ARM: tegra: Use PMC scratch register 40 for tegra_resume() location store Date: Mon, 22 Dec 2014 01:52:33 +0300 Message-Id: <1419202392-1159-1-git-send-email-digetx@gmail.com> X-Mailer: git-send-email 2.2.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141221_150451_326201_B95080E6 X-CRM114-Status: GOOD ( 13.08 ) X-Spam-Score: -0.8 (/) Cc: linux-arm-kernel@lists.infradead.org, Russell King , Stefano Stabellini , Sekhar Nori , linux-kernel@vger.kernel.org, Haojian Zhuang , stable@vger.kernel.org, linux-tegra@vger.kernel.org, Shawn Guo , Christoffer Dall X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 7232398abc6a ("ARM: tegra: Convert PMC to a driver") changed tegra_resume() location storing from late to early and as result broke suspend on tegra20. PMC scratch register 41 was used by tegra lp1 suspend core code for storing physical memory address of common resume function and in the same time used by tegra20 cpuidle driver for storing cpu1 "resettable" status, so it implied strict order of scratch register use. Fix it by using scratch 40 instead of 41 for tegra_resume() location store. Signed-off-by: Dmitry Osipenko Fixes: 7232398abc6a (ARM: tegra: Convert PMC to a driver) Cc: # v3.17+ --- I see 2 other solutions: 1) Replace PMC driver PM ops with syscore 2) Move tegra_resume() storing back to tegra arch suspend code For me originally proposed solution looks best, but I'm not aware of any special use of scratch 40 outside kernel and bootloader, so please let me know if there is any issue with it. It works just fine on my tablet. arch/arm/mach-tegra/sleep-tegra20.S | 4 ++-- arch/arm/mach-tegra/sleep-tegra30.S | 4 ++-- arch/arm/mach-tegra/sleep.h | 1 + drivers/soc/tegra/pmc.c | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-tegra/sleep-tegra20.S b/arch/arm/mach-tegra/sleep-tegra20.S index be4bc5f..3574785 100644 --- a/arch/arm/mach-tegra/sleep-tegra20.S +++ b/arch/arm/mach-tegra/sleep-tegra20.S @@ -327,7 +327,7 @@ tegra20_iram_start: * system clock running on the same PLL that it suspended at), and * jumps to tegra_resume to restore virtual addressing and PLLX. * The physical address of tegra_resume expected to be stored in - * PMC_SCRATCH41. + * PMC_SCRATCH40. * * NOTE: THIS *MUST* BE RELOCATED TO TEGRA_IRAM_LPx_RESUME_AREA. */ @@ -401,7 +401,7 @@ exit_selfrefresh_loop: str r1, [r0, #EMC_REQ_CTRL] mov32 r0, TEGRA_PMC_BASE - ldr r0, [r0, #PMC_SCRATCH41] + ldr r0, [r0, #PMC_SCRATCH40] ret r0 @ jump to tegra_resume ENDPROC(tegra20_lp1_reset) diff --git a/arch/arm/mach-tegra/sleep-tegra30.S b/arch/arm/mach-tegra/sleep-tegra30.S index 5d8d13a..234959c 100644 --- a/arch/arm/mach-tegra/sleep-tegra30.S +++ b/arch/arm/mach-tegra/sleep-tegra30.S @@ -314,7 +314,7 @@ tegra30_iram_start: * system clock running on the same PLL that it suspended at), and * jumps to tegra_resume to restore virtual addressing. * The physical address of tegra_resume expected to be stored in - * PMC_SCRATCH41. + * PMC_SCRATCH40. * * NOTE: THIS *MUST* BE RELOCATED TO TEGRA_IRAM_LPx_RESUME_AREA. */ @@ -529,7 +529,7 @@ zcal_done: __no_dual_emc_chanl: mov32 r0, TEGRA_PMC_BASE - ldr r0, [r0, #PMC_SCRATCH41] + ldr r0, [r0, #PMC_SCRATCH40] ret r0 @ jump to tegra_resume ENDPROC(tegra30_lp1_reset) diff --git a/arch/arm/mach-tegra/sleep.h b/arch/arm/mach-tegra/sleep.h index 92d46ec..23c42d0 100644 --- a/arch/arm/mach-tegra/sleep.h +++ b/arch/arm/mach-tegra/sleep.h @@ -33,6 +33,7 @@ #define PMC_SCRATCH37 0x130 #define PMC_SCRATCH38 0x134 #define PMC_SCRATCH39 0x138 +#define PMC_SCRATCH40 0x13C #define PMC_SCRATCH41 0x140 #ifdef CONFIG_ARCH_TEGRA_2x_SOC diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index a2c0ceb..51bfdeb 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -68,7 +68,7 @@ #define PMC_CPUPWRGOOD_TIMER 0xc8 #define PMC_CPUPWROFF_TIMER 0xcc -#define PMC_SCRATCH41 0x140 +#define PMC_SCRATCH40 0x13C #define IO_DPD_REQ 0x1b8 #define IO_DPD_REQ_CODE_IDLE (0 << 30) @@ -742,14 +742,14 @@ static int tegra_pmc_probe(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int tegra_pmc_suspend(struct device *dev) { - tegra_pmc_writel(virt_to_phys(tegra_resume), PMC_SCRATCH41); + tegra_pmc_writel(virt_to_phys(tegra_resume), PMC_SCRATCH40); return 0; } static int tegra_pmc_resume(struct device *dev) { - tegra_pmc_writel(0x0, PMC_SCRATCH41); + tegra_pmc_writel(0x0, PMC_SCRATCH40); return 0; }