1 From: Catalin Marinas <catalin.marinas@arm.com>
2 Subject: Re: [PATCH] ARM: vfp: Always save VFP state in vfp_pm_suspend
3 Date: Mon, 14 Feb 2011 11:42:22 +0000
4 Organization: ARM Limited
6 Message-ID: <1297683742.30092.11.camel@e102109-lin.cambridge.arm.com>
7 References: <1297638813-1315-1-git-send-email-ccross@android.com>
9 Content-Type: text/plain; charset=UTF-8
10 Content-Transfer-Encoding: 8BIT
11 Cc: linux-arm-kernel@lists.infradead.org,
12 Russell King <linux@arm.linux.org.uk>,
13 linux-kernel@vger.kernel.org
14 To: Colin Cross <ccross@android.com>
15 X-From: linux-kernel-owner@vger.kernel.org Mon Feb 14 12:42:45 2011
16 Return-path: <linux-kernel-owner@vger.kernel.org>
17 Envelope-to: glk-linux-kernel-3@lo.gmane.org
18 Received: from vger.kernel.org ([209.132.180.67])
19 by lo.gmane.org with esmtp (Exim 4.69)
20 (envelope-from <linux-kernel-owner@vger.kernel.org>)
22 for glk-linux-kernel-3@lo.gmane.org; Mon, 14 Feb 2011 12:42:45 +0100
23 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
24 id S1753535Ab1BNLmi (ORCPT <rfc822;glk-linux-kernel-3@m.gmane.org>);
25 Mon, 14 Feb 2011 06:42:38 -0500
26 Received: from service87.mimecast.com ([94.185.240.25]:56758 "HELO
27 service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
28 with SMTP id S1752997Ab1BNLmg convert rfc822-to-8bit (ORCPT
29 <rfc822;linux-kernel@vger.kernel.org>);
30 Mon, 14 Feb 2011 06:42:36 -0500
31 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21])
32 by service87.mimecast.com;
33 Mon, 14 Feb 2011 11:42:31 +0000
34 Received: from [10.1.77.95] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959);
35 Mon, 14 Feb 2011 11:42:28 +0000
36 In-Reply-To: <1297638813-1315-1-git-send-email-ccross@android.com>
37 X-Mailer: Evolution 2.28.1
38 X-OriginalArrivalTime: 14 Feb 2011 11:42:28.0658 (UTC) FILETIME=[41F09120:01CBCC3C]
39 X-MC-Unique: 111021411423105201
40 Sender: linux-kernel-owner@vger.kernel.org
42 List-ID: <linux-kernel.vger.kernel.org>
43 X-Mailing-List: linux-kernel@vger.kernel.org
44 Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1099685>
46 On Sun, 2011-02-13 at 23:13 +0000, Colin Cross wrote:
47 > vfp_pm_suspend should save the VFP state any time there is
48 > a last_VFP_context. If it only saves when the VFP is enabled,
49 > the state can get lost when, on a UP system:
50 > Thread 1 uses the VFP
51 > Context switch occurs to thread 2, VFP is disabled but the
52 > VFP context is not saved to allow lazy save and restore
53 > Thread 2 initiates suspend
54 > vfp_pm_suspend is called with the VFP disabled, but the
55 > context has not been saved.
57 At this point is it guaranteed that the thread won't migrate to another
58 CPU? If not, we should use get/put_cpu.
60 > --- a/arch/arm/vfp/vfpmodule.c
61 > +++ b/arch/arm/vfp/vfpmodule.c
62 > @@ -415,13 +415,12 @@ static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state)
63 > struct thread_info *ti = current_thread_info();
64 > u32 fpexc = fmrx(FPEXC);
66 > - /* if vfp is on, then save state for resumption */
67 > - if (fpexc & FPEXC_EN) {
68 > + /* save state for resume */
69 > + if (last_VFP_context[ti->cpu]) {
70 > printk(KERN_DEBUG "%s: saving vfp state\n", __func__);
71 > - vfp_save_state(&ti->vfpstate, fpexc);
73 > - /* disable, just in case */
74 > - fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
75 > + fmxr(FPEXC, fpexc | FPEXC_EN);
76 > + vfp_save_state(last_VFP_context[ti->cpu], fpexc);
77 > + fmxr(FPEXC, fpexc & ~FPEXC_EN);
80 We may want to set the last_VFP_context to NULL so that after resuming
81 (to the same thread) we force the VFP reload from the vfpstate
82 structure. The vfp_support_entry code ignores the reloading if the
83 last_VFP_context is the same as vfpstate.