From patchwork Sun Jul 15 21:53:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 1199531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id EB8C23FC33 for ; Sun, 15 Jul 2012 21:56:42 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SqWlu-0002nq-Dn; Sun, 15 Jul 2012 21:54:34 +0000 Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SqWlZ-0002m1-RG for linux-arm-kernel@lists.infradead.org; Sun, 15 Jul 2012 21:54:21 +0000 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20120715215359.LQER14795.mtaout02-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com>; Sun, 15 Jul 2012 22:53:59 +0100 Received: from zog.reactivated.net ([86.14.215.141]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20120715215344.RSMC10303.aamtaout02-winn.ispmail.ntl.com@zog.reactivated.net>; Sun, 15 Jul 2012 22:53:44 +0100 Received: by zog.reactivated.net (Postfix, from userid 1000) id 4DAB99D401E; Sun, 15 Jul 2012 22:53:42 +0100 (BST) From: Daniel Drake To: linux@arm.linux.org.uk Subject: [PATCH v5] ARM: vfp: Always save VFP state in vfp_pm_suspend Message-Id: <20120715215342.4DAB99D401E@zog.reactivated.net> Date: Sun, 15 Jul 2012 22:53:42 +0100 (BST) X-Cloudmark-Analysis: v=1.1 cv=AUhbpHVS+xhHrj9wLCYAQoYnFLYUZdbP8UM0GmH2jwk= c=1 sm=0 a=vOQYJeb49sgA:10 a=vJ1w_8FsMGIA:10 a=n8i27M1mAAAA:8 a=4UtWO5riAAAA:8 a=pGLkceISAAAA:8 a=7CQSdrXTAAAA:8 a=drOt6m5kAAAA:8 a=B0OueT-NFkgEo3oXAf8A:9 a=l-DpWgN-I90A:10 a=rXZLD9m7qZoA:10 a=Shd8Sdw-9eQA:10 a=MSl-tDqOz04A:10 a=ESTKKtUg-DoA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [81.103.221.48 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: catalin.marinas@arm.com, 21cnbao@gmail.com, rongjun.ying@csr.com, binghua.duan@csr.com, ccross@android.com, cjb@laptop.org, linux-arm-kernel@lists.infradead.org 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 From: Colin Cross vfp_pm_suspend should save the VFP state any time there is a vfp_current_hw_state. If it only saves when the VFP is enabled, the state can get lost when, on a UP system: Thread 1 uses the VFP Context switch occurs to thread 2, VFP is disabled but the VFP context is not saved to allow lazy save and restore Thread 2 initiates suspend vfp_pm_suspend is called with the VFP disabled, but the context has not been saved. Modify vfp_pm_suspend to save the VFP context whenever vfp_current_hw_state is set. Signed-off-by: Colin Cross Cc: Binghua Duan Signed-off-by: Rongjun Ying Signed-off-by: Barry Song <21cnbao@gmail.com> Reviewed-by: Catalin Marinas --- arch/arm/vfp/vfpmodule.c | 4 ++++ 1 file changed, 4 insertions(+) Fixes a real-life issue found on OLPC laptops: http://lists.arm.linux.org.uk/lurker/message/20120715.044946.c30fff2b.en.html v4->v5: last_VFP_context has been renamed to vfp_current_hw_state. diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 58696192..c86fc52 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -457,6 +457,10 @@ static int vfp_pm_suspend(void) /* disable, just in case */ fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); + } else if (vfp_current_hw_state[ti->cpu]) { + fmxr(FPEXC, fpexc | FPEXC_EN); + vfp_save_state(vfp_current_hw_state[ti->cpu], fpexc); + fmxr(FPEXC, fpexc); } /* clear any information we had about last context state */