From patchwork Wed Jan 9 11:12:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhilash Kesavan X-Patchwork-Id: 1952021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 86F7CDF25A for ; Wed, 9 Jan 2013 11:07:23 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TstSI-0003Bo-V4; Wed, 09 Jan 2013 11:04:23 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TstSB-0003A7-SP for linux-arm-kernel@lists.infradead.org; Wed, 09 Jan 2013 11:04:19 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MGC00D22UQCTO00@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 09 Jan 2013 20:04:13 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.124]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 81.85.12699.DAE4DE05; Wed, 09 Jan 2013 20:04:13 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-38-50ed4ead4d09 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id F0.85.12699.CAE4DE05; Wed, 09 Jan 2013 20:04:13 +0900 (KST) Received: from abhilash-ubuntu.sisodomain.com ([107.108.73.92]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MGC008XKUQTXZ30@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 09 Jan 2013 20:04:12 +0900 (KST) From: Abhilash Kesavan To: linux-arm-kernel@lists.infradead.org, kgene.kim@samsung.com, ben-linux@fluff.org, kyungmin.park@samsung.com, broonie@opensource.wolfsonmicro.com, heiko@sntech.de Subject: [PATCH] ARM: SAMSUNG: Gracefully exit on suspend failure Date: Wed, 09 Jan 2013 16:42:32 +0530 Message-id: <1357729952-14881-1-git-send-email-a.kesavan@samsung.com> X-Mailer: git-send-email 1.7.9.5 DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrELMWRmVeSWpSXmKPExsWyRsSkRnet39sAg39H+C02Pb7G6sDosXlJ fQBjFJdNSmpOZllqkb5dAlfG7S17WQuuq1cc3X2PuYFxu0IXIyeHhICJROfHjywQtpjEhXvr 2boYuTiEBJYySvya/wkowQFW1LOTAyI+nVGiZ809RpAGIYHtTBJn1xaA2GwCehIL/n1lBikS EVjJKDGlYyk7SIJZQEdiw/z1YBuEBRwldiyaBhZnEVCVWL9xAVicV8BVovnhBFaIZQoScybZ QJQISHybfAjqBlmJTQfAxksI7GCTePJ3LiPE0ZISB1fcYJnAKLiAkWEVo2hqQXJBcVJ6rpFe cWJucWleul5yfu4mRmBAnf73THoH46oGi0OMAhyMSjy8jJ5vA4RYE8uKK3MPMUpwMCuJ8Ab7 AoV4UxIrq1KL8uOLSnNSiw8x+gBdMpFZSjQ5HxjseSXxhsYm5qbGppZGRmampjiElcR5GU89 CRASSE8sSc1OTS1ILYIZx8TBKdXAyH9xTui5OxvEHza9d7z761ODfG2LlOXVTnW3S3FahpFy 6+2Uup+KmkXJen+MX/S+b59L6843LgbJWS/EbCtNxewvnU027uIuO+DxKbbh5/memcqzWj9z vjv7b566zt67Z5wkhcpzX/jZVFQ9eFBfKfX5kPbGQ05x3zkue+5uvfByuVXx08hGJZbijERD Leai4kQASBppy1UCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRmVeSWpSXmKPExsVy+t9jQd21fm8DDKY+ZLPY9PgaqwOjx+Yl 9QGMUQ2MNhmpiSmpRQqpecn5KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlA U5UUyhJzSoFCAYnFxUr6dpgmhIa46VrANEbo+oYEwfUYGaCBhDWMGbe37GUtuK5ecXT3PeYG xu0KXYwcHBICJhI9Ozm6GDmBTDGJC/fWs3UxcnEICUxnlOhZc48RJCEksJ1J4uzaAhCbTUBP YsG/r8wgRSICKxklpnQsZQdJMAvoSGyYv54FxBYWcJTYsWgaWJxFQFVi/cYFYHFeAVeJ5ocT WCEWK0jMmWQzgZF7ASPDKkbR1ILkguKk9FwjveLE3OLSvHS95PzcTYzgcH0mvYNxVYPFIUYB DkYlHl5Gz7cBQqyJZcWVuYcYJTiYlUR4g32BQrwpiZVVqUX58UWlOanFhxh9gJZPZJYSTc4H xlJeSbyhsYm5qbGppYmFiZklDmElcV7GU08ChATSE0tSs1NTC1KLYMYxcXBKNTDKLVSOsHXa ZRDL5S26RdJ2nvPBGQK/lrKmecvlpUl6b/DfE+w8efuDJzXa//bKnQxgPFSXHVNk4tcj6Pp6 Eutki9VS8QY/Ek7Vh+VUKjh/nXZQdvrnvph3S/JyVze/Tf75zoY7PrHs6tn9pV82a19eyfAj 56llUsavhLgYSRb5GMklWed445RYijMSDbWYi4oTAd2FASOEAgAA X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130109_060417_035486_CD240DC6 X-CRM114-Status: GOOD ( 14.24 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.34 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Abhilash Kesavan X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org As per the Exynos5250 User Manual: When there are pending interrupt events, WFI/WFE instruction are ignored. To cancel the power-down sequence follow these steps: 1) Disable system power-down through CENTRAL_SEQ_CONFIGURATION and CENTRAL_SEQ_CONFIGURATION_DMC registers 2) Clear WAKEUP_STAT register 3) Enable interrupt service routine for CPU Code for early wakeup for exynos already exists; remove the panic on suspend failure, clear the wakeup state register and return error from cpu_suspend to indicate a failed suspend (to a user daemon). Older Samsung SoCs have similar panics and I have removed them all. Haven't touched the S3C2410 sleep code. Signed-off-by: Abhilash Kesavan --- arch/arm/mach-exynos/pm.c | 6 ++++-- arch/arm/mach-s3c24xx/pm-s3c2412.c | 3 ++- arch/arm/mach-s3c24xx/pm-s3c2416.c | 3 ++- arch/arm/mach-s3c64xx/pm.c | 3 ++- arch/arm/mach-s5p64x0/pm.c | 4 ++-- arch/arm/mach-s5pv210/pm.c | 4 ++-- arch/arm/plat-samsung/pm.c | 5 ++++- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c index f459afd..55df38cd 100644 --- a/arch/arm/mach-exynos/pm.c +++ b/arch/arm/mach-exynos/pm.c @@ -92,8 +92,8 @@ static int exynos_cpu_suspend(unsigned long arg) /* issue the standby signal into the pm unit. */ cpu_do_idle(); - /* we should never get past here */ - panic("sleep resumed to originator?"); + pr_err("Failed to suspend the system\n"); + return -EBUSY; } static void exynos_pm_prepare(void) @@ -283,6 +283,8 @@ static void exynos_pm_resume(void) if (!(tmp & S5P_CENTRAL_LOWPWR_CFG)) { tmp |= S5P_CENTRAL_LOWPWR_CFG; __raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION); + /* clear the wakeup state register */ + __raw_writel(0x0, S5P_WAKEUP_STAT); /* No need to perform below restore code */ goto early_wakeup; } diff --git a/arch/arm/mach-s3c24xx/pm-s3c2412.c b/arch/arm/mach-s3c24xx/pm-s3c2412.c index 206765c..a7bc30d 100644 --- a/arch/arm/mach-s3c24xx/pm-s3c2412.c +++ b/arch/arm/mach-s3c24xx/pm-s3c2412.c @@ -48,7 +48,8 @@ static int s3c2412_cpu_suspend(unsigned long arg) s3c2412_sleep_enter(); - panic("sleep resumed to originator?"); + pr_err("Failed to suspend the system\n"); + return -EBUSY; } static void s3c2412_pm_prepare(void) diff --git a/arch/arm/mach-s3c24xx/pm-s3c2416.c b/arch/arm/mach-s3c24xx/pm-s3c2416.c index 1bd4817..97a8d70 100644 --- a/arch/arm/mach-s3c24xx/pm-s3c2416.c +++ b/arch/arm/mach-s3c24xx/pm-s3c2416.c @@ -34,7 +34,8 @@ static int s3c2416_cpu_suspend(unsigned long arg) s3c2412_sleep_enter(); - panic("sleep resumed to originator?"); + pr_err("Failed to suspend the system\n"); + return -EBUSY; } static void s3c2416_pm_prepare(void) diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c index f6b13a2..4d1accc 100644 --- a/arch/arm/mach-s3c64xx/pm.c +++ b/arch/arm/mach-s3c64xx/pm.c @@ -297,7 +297,8 @@ static int s3c64xx_cpu_suspend(unsigned long arg) /* we should never get past here */ - panic("sleep resumed to originator?"); + pr_err("Failed to suspend the system\n"); + return -EBUSY; } /* mapping of interrupts to parts of the wakeup mask */ diff --git a/arch/arm/mach-s5p64x0/pm.c b/arch/arm/mach-s5p64x0/pm.c index 9cba18b..710651d 100644 --- a/arch/arm/mach-s5p64x0/pm.c +++ b/arch/arm/mach-s5p64x0/pm.c @@ -103,8 +103,8 @@ static int s5p64x0_cpu_suspend(unsigned long arg) "mcr p15, 0, %0, c7, c10, 4\n\t" "mcr p15, 0, %0, c7, c0, 4" : : "r" (tmp)); - /* we should never get past here */ - panic("sleep resumed to originator?"); + pr_err("Failed to suspend the system\n"); + return -EBUSY; } /* mapping of interrupts to parts of the wakeup mask */ diff --git a/arch/arm/mach-s5pv210/pm.c b/arch/arm/mach-s5pv210/pm.c index 736bfb1..c584f49 100644 --- a/arch/arm/mach-s5pv210/pm.c +++ b/arch/arm/mach-s5pv210/pm.c @@ -104,8 +104,8 @@ static int s5pv210_cpu_suspend(unsigned long arg) "mcr p15, 0, %0, c7, c10, 4\n\t" "wfi" : : "r" (tmp)); - /* we should never get past here */ - panic("sleep resumed to originator?"); + pr_err("Failed to suspend the system\n"); + return -EBUSY; } static void s5pv210_pm_prepare(void) diff --git a/arch/arm/plat-samsung/pm.c b/arch/arm/plat-samsung/pm.c index 1507028..aa4b06d 100644 --- a/arch/arm/plat-samsung/pm.c +++ b/arch/arm/plat-samsung/pm.c @@ -243,6 +243,7 @@ int (*pm_cpu_sleep)(unsigned long); static int s3c_pm_enter(suspend_state_t state) { + int ret; /* ensure the debug is initialised (if enabled) */ s3c_pm_debug_init(); @@ -300,7 +301,9 @@ static int s3c_pm_enter(suspend_state_t state) * we resume as it saves its own register state and restores it * during the resume. */ - cpu_suspend(0, pm_cpu_sleep); + ret = cpu_suspend(0, pm_cpu_sleep); + if (ret) + return ret; /* restore the system state */