From patchwork Mon Jul 16 18:17:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 1201421 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 CB7D4E0038 for ; Mon, 16 Jul 2012 18:25:46 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sqpro-0007j4-Jr; Mon, 16 Jul 2012 18:17:56 +0000 Received: from mail-wi0-f201.google.com ([209.85.212.201]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SqprT-0007id-KV for linux-arm-kernel@lists.infradead.org; Mon, 16 Jul 2012 18:17:39 +0000 Received: by wibhm2 with SMTP id hm2so171471wib.0 for ; Mon, 16 Jul 2012 11:17:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=knj3OFUA5sJAG5yn2o9sgL/NxSjFSz7TeJIg9qlAisU=; b=PEEUzgSvk6RWD/Sb3BGGiSFvWInofjpaU3zZl9QpR0YjqNaL0jIj/rm/uD3SrSzTDf LI4VKbNNLMQyyZTp+1S7dPFp5JsN/Mkji3FNqCb4DRsGmkPXShjL8UowE5UlFtVbXXEd pp/wSRyAGNYhfOH5mpnnXyCcF+Lu1S+YgyGfcCrmkMA9jvUn1qNwScwZyFkFzCXV1/O5 6xQtYVx4vCHxL218jQvnVo78JhfcQvA4vcqMmG2krbfvnvAeEk64lLYcP4/On7f0yAV+ 72TFF7HRnx8HzN3FwUPzqI2O76X+b4Cm6Cc2MAxVEJjJTeZWDdxEiT9DlcMFHth4vHGI bFHA== Received: by 10.14.176.133 with SMTP id b5mr5518807eem.7.1342462650380; Mon, 16 Jul 2012 11:17:30 -0700 (PDT) Received: by 10.14.176.133 with SMTP id b5mr5518784eem.7.1342462650233; Mon, 16 Jul 2012 11:17:30 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id s44si9115059eeo.0.2012.07.16.11.17.30 (version=TLSv1/SSLv3 cipher=AES128-SHA); Mon, 16 Jul 2012 11:17:30 -0700 (PDT) Received: from walnut.mtv.corp.google.com (walnut.mtv.corp.google.com [172.18.104.116]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 0D0B820004E; Mon, 16 Jul 2012 11:17:30 -0700 (PDT) Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id 57554257A1E; Mon, 16 Jul 2012 11:17:29 -0700 (PDT) From: Colin Cross To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v6] ARM: vfp: Always save VFP state in vfp_pm_suspend on UP Date: Mon, 16 Jul 2012 11:17:20 -0700 Message-Id: <1342462640-18410-1-git-send-email-ccross@android.com> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQlFicxOmvMj9sLh6fTrs17m8wCN/mxF6VOt01E9yWJZA0dClbfMsl1BnVqCIetVJETElO+x4IwPsXuKhscak3Lu35wrsanupk3kjGhl2pPAVLETpNVquKdhG1A++Qppglf+qCaBLbLIT97WJnjZaSyBVeEOPrKGbeeJms0F25+k8cNeIZEOawAvl7MxH45G6jeseQgMVoaM0GT8lNPPBK5hCFcUuQ== X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.201 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Nicolas Pitre , Russell King , Daniel Drake , Barry Song , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Colin Cross , Ido Yariv 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 vfp_pm_suspend should save the VFP state in suspend after any lazy context switch. 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 Thread 2 initiates suspend vfp_pm_suspend is called with the VFP disabled, and the unsaved VFP context of Thread 1 in the registers Modify vfp_pm_suspend to save the VFP context whenever vfp_current_hw_state is not NULL. Includes a fix from Ido Yariv , who pointed out that on SMP systems, the state pointer can be pointing to a freed task struct if a task exited on another cpu, fixed by using #ifdef CONFIG_SMP in the new if clause. Cc: Russell King Cc: Barry Song Cc: Catalin Marinas Cc: Ido Yariv Cc: Daniel Drake Cc: Will Deacon Signed-off-by: Colin Cross --- arch/arm/vfp/vfpmodule.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 58696192..ce55f05 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -457,6 +457,12 @@ static int vfp_pm_suspend(void) /* disable, just in case */ fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); + } else if (vfp_current_hw_state[ti->cpu]) { +#ifndef CONFIG_SMP + fmxr(FPEXC, fpexc | FPEXC_EN); + vfp_save_state(vfp_current_hw_state[ti->cpu], fpexc); + fmxr(FPEXC, fpexc); +#endif } /* clear any information we had about last context state */