Author: ian
Date: Sun Mar  9 14:24:05 2014
New Revision: 262948
URL: http://svnweb.freebsd.org/changeset/base/262948

Log:
  Always call vfp_discard() on thread death, not just when the VFP is
  enabled.  In vfp_discard(), if the state in the VFP hardware belongs to
  the thread which is dying, NULL out pcpu fpcurthread to indicate the
  state currently in the hardware belongs to nobody.
  
  Submitted by: Juergen Weiss
  Pointy hat to:        me

Modified:
  head/sys/arm/arm/swtch.S
  head/sys/arm/arm/vfp.c
  head/sys/arm/include/vfp.h

Modified: head/sys/arm/arm/swtch.S
==============================================================================
--- head/sys/arm/arm/swtch.S    Sun Mar  9 13:23:49 2014        (r262947)
+++ head/sys/arm/arm/swtch.S    Sun Mar  9 14:24:05 2014        (r262948)
@@ -124,14 +124,11 @@ ENTRY(cpu_throw)
         * r5 = newtd
         */
 
-       GET_PCPU(r7, r9)
-
-#ifdef VFP
-       fmrx    r0, fpexc               /* This thread is dying, if the VFP */
-       tst     r0, #(VFPEXC_EN)        /* is enabled, go shut it down */
-       blne    _C_LABEL(vfp_discard)   /* without preserving its state. */
+#ifdef VFP                             /* This thread is dying, disable */
+       bl      _C_LABEL(vfp_discard)   /* VFP without preserving state. */
 #endif
 
+       GET_PCPU(r7, r9)
        ldr     r7, [r5, #(TD_PCB)]             /* r7 = new thread's PCB */
   
        /* Switch to lwp0 context */

Modified: head/sys/arm/arm/vfp.c
==============================================================================
--- head/sys/arm/arm/vfp.c      Sun Mar  9 13:23:49 2014        (r262947)
+++ head/sys/arm/arm/vfp.c      Sun Mar  9 14:24:05 2014        (r262948)
@@ -229,21 +229,23 @@ vfp_store(struct vfp_state *vfpsave, boo
 }
 
 /*
- * If the VFP hardware is on, the current thread was using it but now that
- * thread is dying.  Turn off the VFP and set pcpu fpcurthread to 0, to 
indicate
- * that the VFP hardware state does not belong to any thread.   Called only 
from
- * cpu_throw(), so we don't have to worry about a context switch here.
+ * The current thread is dying.  If the state currently in the hardware belongs
+ * to the current thread, set fpcurthread to NULL to indicate that the VFP
+ * hardware state does not belong to any thread.  If the VFP is on, turn it 
off.
+ * Called only from cpu_throw(), so we don't have to worry about a context
+ * switch here.
  */
 void
-vfp_discard()
+vfp_discard(struct thread *td)
 {
        u_int tmp;
 
+       if (PCPU_GET(fpcurthread) == td)
+               PCPU_SET(fpcurthread, NULL);
+
        tmp = fmrx(VFPEXC);
-       if (tmp & VFPEXC_EN) {
+       if (tmp & VFPEXC_EN)
                fmxr(VFPEXC, tmp & ~VFPEXC_EN);
-               PCPU_SET(fpcurthread, 0);
-       }
 }
 
 #endif

Modified: head/sys/arm/include/vfp.h
==============================================================================
--- head/sys/arm/include/vfp.h  Sun Mar  9 13:23:49 2014        (r262947)
+++ head/sys/arm/include/vfp.h  Sun Mar  9 14:24:05 2014        (r262948)
@@ -129,7 +129,7 @@
 #ifndef LOCORE
 void    vfp_init(void);
 void    vfp_store(struct vfp_state *, boolean_t);
-void    vfp_discard(void);
+void    vfp_discard(struct thread *);
 #endif
 
 #endif
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to