Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/alpha Cleanup and simplify PCU FP support. Nuke MD...
details: https://anonhg.NetBSD.org/src/rev/734ebff7d369
branches: trunk
changeset: 329254:734ebff7d369
user: matt <matt%NetBSD.org@localhost>
date: Fri May 16 19:18:21 2014 +0000
description:
Cleanup and simplify PCU FP support. Nuke MDLWP_FPUSED.
diffstat:
sys/arch/alpha/alpha/compat_13_machdep.c | 6 +++---
sys/arch/alpha/alpha/compat_16_machdep.c | 11 +++++------
sys/arch/alpha/alpha/core_machdep.c | 6 +++---
sys/arch/alpha/alpha/fp_complete.c | 17 +++++++++--------
sys/arch/alpha/alpha/machdep.c | 11 ++++-------
sys/arch/alpha/alpha/process_machdep.c | 7 +++----
sys/arch/alpha/alpha/vm_machdep.c | 6 +++---
sys/arch/alpha/include/alpha.h | 13 ++++++++++---
sys/arch/alpha/include/proc.h | 9 +--------
9 files changed, 41 insertions(+), 45 deletions(-)
diffs (truncated from 313 to 300 lines):
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/alpha/compat_13_machdep.c
--- a/sys/arch/alpha/alpha/compat_13_machdep.c Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/alpha/compat_13_machdep.c Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_13_machdep.c,v 1.20 2012/02/06 02:14:10 matt Exp $ */
+/* $NetBSD: compat_13_machdep.c,v 1.21 2014/05/16 19:18:21 matt Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.20 2012/02/06 02:14:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.21 2014/05/16 19:18:21 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -94,7 +94,7 @@
/* XXX ksc.sc_ownedfp ? */
pcb = lwp_getpcb(l);
- fpu_discard();
+ fpu_discard(true);
memcpy(&pcb->pcb_fp, (struct fpreg *)ksc.sc_fpregs,
sizeof(struct fpreg));
/* XXX ksc.sc_fp_control ? */
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/alpha/compat_16_machdep.c
--- a/sys/arch/alpha/alpha/compat_16_machdep.c Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/alpha/compat_16_machdep.c Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_16_machdep.c,v 1.18 2012/02/06 02:14:10 matt Exp $ */
+/* $NetBSD: compat_16_machdep.c,v 1.19 2014/05/16 19:18:21 matt Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
#include <machine/cpu.h>
#include <machine/reg.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.18 2012/02/06 02:14:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.19 2014/05/16 19:18:21 matt Exp $");
#ifdef DEBUG
@@ -133,7 +133,7 @@
/* save the floating-point state, if necessary, then copy it. */
fpu_save();
- frame.sf_sc.sc_ownedfp = fpu_used_p(l);
+ frame.sf_sc.sc_ownedfp = fpu_valid_p(l);
memcpy((struct fpreg *)frame.sf_sc.sc_fpregs, &pcb->pcb_fp,
sizeof(struct fpreg));
frame.sf_sc.sc_fp_control = alpha_read_fp_c(l);
@@ -281,12 +281,11 @@
alpha_pal_wrusp(ksc.sc_regs[R_SP]);
pcb = lwp_getpcb(l);
- fpu_discard();
+ fpu_discard(true);
memcpy(&pcb->pcb_fp, (struct fpreg *)ksc.sc_fpregs,
sizeof(struct fpreg));
pcb->pcb_fp.fpr_cr = ksc.sc_fpcr;
- l->l_md.md_flags = (ksc.sc_fp_control & MDLWP_FP_C)
- | (ksc.sc_ownedfp ? MDLWP_FPUSED : 0);
+ l->l_md.md_flags = ksc.sc_fp_control & MDLWP_FP_C;
mutex_enter(p->p_lock);
/* Restore signal stack. */
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/alpha/core_machdep.c
--- a/sys/arch/alpha/alpha/core_machdep.c Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/alpha/core_machdep.c Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: core_machdep.c,v 1.8 2014/01/01 18:57:15 dsl Exp $ */
+/* $NetBSD: core_machdep.c,v 1.9 2014/05/16 19:18:21 matt Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.8 2014/01/01 18:57:15 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.9 2014/05/16 19:18:21 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -70,7 +70,7 @@
pcu_save_all(l);
cpustate.md_tf = *l->l_md.md_tf;
cpustate.md_tf.tf_regs[FRAME_SP] = alpha_pal_rdusp(); /* XXX */
- if (fpu_used_p(l)) {
+ if (fpu_valid_p(l)) {
cpustate.md_fpstate = ((struct pcb *)lwp_getpcb(l))->pcb_fp;
} else
memset(&cpustate.md_fpstate, 0, sizeof(cpustate.md_fpstate));
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/alpha/fp_complete.c
--- a/sys/arch/alpha/alpha/fp_complete.c Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/alpha/fp_complete.c Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fp_complete.c,v 1.16 2014/05/16 00:48:41 rmind Exp $ */
+/* $NetBSD: fp_complete.c,v 1.17 2014/05/16 19:18:21 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -35,7 +35,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.16 2014/05/16 00:48:41 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.17 2014/05/16 19:18:21 matt Exp $");
#include "opt_compat_osf1.h"
@@ -408,10 +408,11 @@
if ((md_flags & MDLWP_FP_C) == fp_c)
return;
l->l_md.md_flags = (md_flags & ~MDLWP_FP_C) | fp_c;
- fpu_load();
- alpha_pal_wrfen(1);
- fp_c_to_fpcr(l);
- alpha_pal_wrfen(0);
+ if (md_flags & MDLWP_FPACTIVE) {
+ alpha_pal_wrfen(1);
+ fp_c_to_fpcr(l);
+ alpha_pal_wrfen(0);
+ }
}
uint64_t
@@ -733,9 +734,9 @@
*/
if ((flags & PCU_VALID) == 0) {
atomic_inc_ulong(&fpevent_use.ev_count);
- fpu_mark_used(l);
- } else
+ } else {
atomic_inc_ulong(&fpevent_reuse.ev_count);
+ }
alpha_pal_wrfen(1);
restorefpstate(&pcb->pcb_fp);
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/alpha/machdep.c Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.344 2014/03/24 20:06:31 christos Exp $ */
+/* $NetBSD: machdep.c,v 1.345 2014/05/16 19:18:21 matt Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.344 2014/03/24 20:06:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.345 2014/05/16 19:18:21 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1614,12 +1614,10 @@
tfp->tf_regs[FRAME_A3] = l->l_proc->p_psstrp; /* a3 = ps_strings */
tfp->tf_regs[FRAME_T12] = tfp->tf_regs[FRAME_PC]; /* a.k.a. PV */
- l->l_md.md_flags &= ~MDLWP_FPUSED;
if (__predict_true((l->l_md.md_flags & IEEE_INHERIT) == 0)) {
l->l_md.md_flags &= ~MDLWP_FP_C;
pcb->pcb_fp.fpr_cr = FPCR_DYN(FP_RN);
}
- fpu_discard();
}
/*
@@ -1795,7 +1793,7 @@
*flags |= _UC_CPU | _UC_TLSBASE;
/* Save floating point register context, if any, and copy it. */
- if (fpu_used_p(l)) {
+ if (fpu_valid_p(l)) {
fpu_save();
(void)memcpy(&mcp->__fpregs, &pcb->pcb_fp,
sizeof (mcp->__fpregs));
@@ -1844,11 +1842,10 @@
/* Restore floating point register context, if any. */
if (flags & _UC_FPU) {
/* If we have an FP register context, get rid of it. */
- fpu_discard();
+ fpu_discard(true);
(void)memcpy(&pcb->pcb_fp, &mcp->__fpregs,
sizeof (pcb->pcb_fp));
l->l_md.md_flags = mcp->__fpregs.__fp_fpcr & MDLWP_FP_C;
- fpu_mark_used(l);
}
return (0);
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/alpha/process_machdep.c
--- a/sys/arch/alpha/alpha/process_machdep.c Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/alpha/process_machdep.c Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.28 2014/01/04 00:10:02 dsl Exp $ */
+/* $NetBSD: process_machdep.c,v 1.29 2014/05/16 19:18:21 matt Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@@ -54,7 +54,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.28 2014/01/04 00:10:02 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.29 2014/05/16 19:18:21 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -127,8 +127,7 @@
{
struct pcb *pcb = lwp_getpcb(l);
- fpu_discard();
- fpu_mark_used(l);
+ fpu_discard(true);
memcpy(&pcb->pcb_fp, regs, sizeof(struct fpreg));
return (0);
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/alpha/vm_machdep.c
--- a/sys/arch/alpha/alpha/vm_machdep.c Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/alpha/vm_machdep.c Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.112 2012/02/19 21:06:00 rmind Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.113 2014/05/16 19:18:21 matt Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.112 2012/02/19 21:06:00 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.113 2014/05/16 19:18:21 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -88,7 +88,7 @@
pcb2 = lwp_getpcb(l2);
l2->l_md.md_tf = l1->l_md.md_tf;
- l2->l_md.md_flags = l1->l_md.md_flags & (MDLWP_FPUSED | MDLWP_FP_C);
+ l2->l_md.md_flags = l1->l_md.md_flags & MDLWP_FP_C;
l2->l_md.md_astpending = 0;
/*
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/include/alpha.h
--- a/sys/arch/alpha/include/alpha.h Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/include/alpha.h Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: alpha.h,v 1.33 2014/05/16 00:48:41 rmind Exp $ */
+/* $NetBSD: alpha.h,v 1.34 2014/05/16 19:18:21 matt Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -113,6 +113,13 @@
void fpu_state_save(struct lwp *);
void fpu_state_release(struct lwp *);
+static inline bool
+fpu_valid_p(struct lwp *l)
+{
+ KASSERT(l == curlwp);
+ return pcu_valid_p(&fpu_ops);
+}
+
static inline void
fpu_load(void)
{
@@ -126,9 +133,9 @@
}
static inline void
-fpu_discard(void)
+fpu_discard(bool valid_p)
{
- pcu_discard(&fpu_ops, false);
+ pcu_discard(&fpu_ops, valid_p);
}
void alpha_patch(bool);
diff -r 821afcede0ca -r 734ebff7d369 sys/arch/alpha/include/proc.h
--- a/sys/arch/alpha/include/proc.h Fri May 16 18:50:28 2014 +0000
+++ b/sys/arch/alpha/include/proc.h Fri May 16 19:18:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.21 2012/02/06 02:14:13 matt Exp $ */
+/* $NetBSD: proc.h,v 1.22 2014/05/16 19:18:21 matt Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -61,7 +61,6 @@
* C99 API's, the use of the MDLWP_FP_C bits is defined variously in
* ieeefp.h and fpu.h.
*/
-#define MDLWP_FPUSED 0x00000001 /* LWP used the FPU */
#define MDLWP_FP_C 0x007ffffe /* Extended FP_C Quadword bits */
Home |
Main Index |
Thread Index |
Old Index