PERFORCE change 29439 for review
Peter Wemm
peter at FreeBSD.org
Tue Apr 22 14:01:56 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=29439
Change 29439 by peter at peter_overcee on 2003/04/22 14:00:55
integrate i386_hammer
Affected files ...
.. //depot/projects/hammer/sys/x86_64/include/bus_dma.h#4 integrate
.. //depot/projects/hammer/sys/x86_64/include/cpufunc.h#10 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/busdma_machdep.c#6 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/genassym.c#17 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/identcpu.c#8 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#65 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/sys_machdep.c#10 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/trap.c#24 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/tsc.c#3 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/vm_machdep.c#20 integrate
Differences ...
==== //depot/projects/hammer/sys/x86_64/include/bus_dma.h#4 (text+ko) ====
@@ -67,7 +67,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD: src/sys/i386/include/bus_dma.h,v 1.17 2003/01/29 07:25:26 scottl Exp $ */
+/* $FreeBSD: src/sys/i386/include/bus_dma.h,v 1.18 2003/04/10 23:03:33 mux Exp $ */
#ifndef _I386_BUS_DMA_H_
#define _I386_BUS_DMA_H_
@@ -89,16 +89,12 @@
struct uio;
/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
+ * Operations performed by bus_dmamap_sync().
*/
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
+#define BUS_DMASYNC_PREREAD 1
+#define BUS_DMASYNC_POSTREAD 2
+#define BUS_DMASYNC_PREWRITE 4
+#define BUS_DMASYNC_POSTWRITE 8
/*
* bus_dma_tag_t
@@ -234,7 +230,7 @@
/*
* Perform a syncronization operation on the given map.
*/
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
+void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, int);
#define bus_dmamap_sync(dmat, dmamap, op) \
if ((dmamap) != NULL) \
_bus_dmamap_sync(dmat, dmamap, op)
==== //depot/projects/hammer/sys/x86_64/include/cpufunc.h#10 (text+ko) ====
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/i386/include/cpufunc.h,v 1.130 2002/09/22 04:45:21 peter Exp $
+ * $FreeBSD: src/sys/i386/include/cpufunc.h,v 1.133 2003/04/20 02:59:13 obrien Exp $
*/
/*
==== //depot/projects/hammer/sys/x86_64/x86_64/busdma_machdep.c#6 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.39 2003/04/07 16:08:32 jake Exp $
+ * $FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.43 2003/04/15 03:11:03 mux Exp $
*/
#include <sys/param.h>
@@ -406,125 +406,6 @@
bus_dmamem_free_size(dmat, vaddr, map, dmat->maxsize);
}
-#define BUS_DMAMAP_NSEGS ((64 * 1024) / PAGE_SIZE + 1)
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int
-bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags)
-{
- vm_offset_t vaddr;
- vm_paddr_t paddr;
-#ifdef __GNUC__
- bus_dma_segment_t dm_segments[dmat->nsegments];
-#else
- bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
-#endif
- bus_dma_segment_t *sg;
- int seg;
- int error;
- vm_paddr_t nextpaddr;
-
- if (map == NULL)
- map = &nobounce_dmamap;
-
- error = 0;
- /*
- * If we are being called during a callback, pagesneeded will
- * be non-zero, so we can avoid doing the work twice.
- */
- if (dmat->lowaddr < ptoa((vm_paddr_t)Maxmem) &&
- map->pagesneeded == 0) {
- vm_offset_t vendaddr;
-
- /*
- * Count the number of bounce pages
- * needed in order to complete this transfer
- */
- vaddr = trunc_page((vm_offset_t)buf);
- vendaddr = (vm_offset_t)buf + buflen;
-
- while (vaddr < vendaddr) {
- paddr = pmap_kextract(vaddr);
- if (run_filter(dmat, paddr) != 0) {
-
- map->pagesneeded++;
- }
- vaddr += PAGE_SIZE;
- }
- }
-
- /* Reserve Necessary Bounce Pages */
- if (map->pagesneeded != 0) {
- mtx_lock(&bounce_lock);
- if (reserve_bounce_pages(dmat, map, 1) != 0) {
-
- /* Queue us for resources */
- map->dmat = dmat;
- map->buf = buf;
- map->buflen = buflen;
- map->callback = callback;
- map->callback_arg = callback_arg;
-
- STAILQ_INSERT_TAIL(&bounce_map_waitinglist, map, links);
- mtx_unlock(&bounce_lock);
- return (EINPROGRESS);
- }
- mtx_unlock(&bounce_lock);
- }
-
- vaddr = (vm_offset_t)buf;
- sg = &dm_segments[0];
- seg = 1;
- sg->ds_len = 0;
-
- nextpaddr = 0;
- do {
- bus_size_t size;
-
- paddr = pmap_kextract(vaddr);
- size = PAGE_SIZE - (paddr & PAGE_MASK);
- if (size > buflen)
- size = buflen;
-
- if (map->pagesneeded != 0 && run_filter(dmat, paddr)) {
- paddr = add_bounce_page(dmat, map, vaddr, size);
- }
-
- if (sg->ds_len == 0) {
- sg->ds_addr = paddr;
- sg->ds_len = size;
- } else if (paddr == nextpaddr) {
- sg->ds_len += size;
- } else {
- /* Go to the next segment */
- sg++;
- seg++;
- if (seg > dmat->nsegments)
- break;
- sg->ds_addr = paddr;
- sg->ds_len = size;
- }
- vaddr += size;
- nextpaddr = paddr + size;
- buflen -= size;
-
- } while (buflen > 0);
-
- if (buflen != 0) {
- printf("bus_dmamap_load: Too many segs! buf_len = 0x%lx\n",
- (u_long)buflen);
- error = EFBIG;
- }
-
- (*callback)(callback_arg, dm_segments, seg, error);
-
- return (0);
-}
-
/*
* Utility function to load a linear buffer. lastaddrp holds state
* between invocations (for multiple-buffer loads). segp contains
@@ -583,9 +464,22 @@
/* Reserve Necessary Bounce Pages */
if (map->pagesneeded != 0) {
mtx_lock(&bounce_lock);
- if (reserve_bounce_pages(dmat, map, 0) != 0) {
- mtx_unlock(&bounce_lock);
- return (ENOMEM);
+ if (flags & BUS_DMA_NOWAIT) {
+ if (reserve_bounce_pages(dmat, map, 0) != 0) {
+ mtx_unlock(&bounce_lock);
+ return (ENOMEM);
+ }
+ } else {
+ if (reserve_bounce_pages(dmat, map, 1) != 0) {
+ /* Queue us for resources */
+ map->dmat = dmat;
+ map->buf = buf;
+ map->buflen = buflen;
+ STAILQ_INSERT_TAIL(&bounce_map_waitinglist,
+ map, links);
+ mtx_unlock(&bounce_lock);
+ return (EINPROGRESS);
+ }
}
mtx_unlock(&bounce_lock);
}
@@ -657,6 +551,45 @@
return (buflen != 0 ? EFBIG : 0); /* XXX better return value here? */
}
+#define BUS_DMAMAP_NSEGS ((64 * 1024) / PAGE_SIZE + 1)
+
+/*
+ * Map the buffer buf into bus space using the dmamap map.
+ */
+int
+bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
+ bus_size_t buflen, bus_dmamap_callback_t *callback,
+ void *callback_arg, int flags)
+{
+#ifdef __GNUC__
+ bus_dma_segment_t dm_segments[dmat->nsegments];
+#else
+ bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
+#endif
+ bus_addr_t lastaddr = 0;
+ int error, nsegs = 0;
+
+ if (map != NULL) {
+ flags |= BUS_DMA_WAITOK;
+ map->callback = callback;
+ map->callback_arg = callback_arg;
+ }
+
+ error = _bus_dmamap_load_buffer(dmat, map, dm_segments, buf, buflen,
+ NULL, flags, &lastaddr, &nsegs, 1);
+
+ if (error == EINPROGRESS)
+ return (error);
+
+ if (error)
+ (*callback)(callback_arg, dm_segments, 0, error);
+ else
+ (*callback)(callback_arg, dm_segments, nsegs + 1, 0);
+
+ return (0);
+}
+
+
/*
* Like _bus_dmamap_load(), but for mbufs.
*/
@@ -676,6 +609,7 @@
KASSERT(m0->m_flags & M_PKTHDR,
("bus_dmamap_load_mbuf: no packet header"));
+ flags |= BUS_DMA_NOWAIT;
nsegs = 0;
error = 0;
if (m0->m_pkthdr.len <= dmat->maxsize) {
@@ -727,6 +661,7 @@
struct iovec *iov;
struct thread *td = NULL;
+ flags |= BUS_DMA_NOWAIT;
resid = uio->uio_resid;
iov = uio->uio_iov;
@@ -784,39 +719,32 @@
}
void
-_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, int op)
{
struct bounce_page *bpage;
if ((bpage = STAILQ_FIRST(&map->bpages)) != NULL) {
-
/*
* Handle data bouncing. We might also
* want to add support for invalidating
* the caches on broken hardware
*/
- switch (op) {
- case BUS_DMASYNC_PREWRITE:
+ if (op & BUS_DMASYNC_PREWRITE) {
while (bpage != NULL) {
bcopy((void *)bpage->datavaddr,
(void *)bpage->vaddr,
bpage->datacount);
bpage = STAILQ_NEXT(bpage, links);
}
- break;
+ }
- case BUS_DMASYNC_POSTREAD:
+ if (op & BUS_DMASYNC_POSTREAD) {
while (bpage != NULL) {
bcopy((void *)bpage->vaddr,
(void *)bpage->datavaddr,
bpage->datacount);
bpage = STAILQ_NEXT(bpage, links);
}
- break;
- case BUS_DMASYNC_PREREAD:
- case BUS_DMASYNC_POSTWRITE:
- /* No-ops */
- break;
}
}
}
==== //depot/projects/hammer/sys/x86_64/x86_64/genassym.c#17 (text+ko) ====
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
- * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.138 2003/02/23 22:12:07 jake Exp $
+ * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.140 2003/04/17 22:17:28 jhb Exp $
*/
#include "opt_compat.h"
@@ -75,13 +75,10 @@
ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
ASSYM(P_SFLAG, offsetof(struct proc, p_sflag));
-ASSYM(P_STATE, offsetof(struct proc, p_state));
ASSYM(P_UAREA, offsetof(struct proc, p_uarea));
ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
-ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan));
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
-ASSYM(TD_KSE, offsetof(struct thread, td_kse));
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
ASSYM(TD_INTR_NESTING_LEVEL, offsetof(struct thread, td_intr_nesting_level));
ASSYM(TD_CRITNEST, offsetof(struct thread, td_critnest));
==== //depot/projects/hammer/sys/x86_64/x86_64/identcpu.c#8 (text+ko) ====
@@ -38,7 +38,7 @@
* SUCH DAMAGE.
*
* from: Id: machdep.c,v 1.193 1996/06/18 01:22:04 bde Exp
- * $FreeBSD: src/sys/i386/i386/identcpu.c,v 1.120 2003/04/04 17:29:54 des Exp $
+ * $FreeBSD: src/sys/i386/i386/identcpu.c,v 1.121 2003/04/10 07:05:24 wes Exp $
*/
#include "opt_cpu.h"
@@ -80,6 +80,10 @@
SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
cpu_model, 0, "Machine model");
+static int hw_clockrate;
+SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
+ &hw_clockrate, 0, "CPU instruction clock rate");
+
static char cpu_brand[48];
static struct cpu_nameclass x86_64_cpus[] = {
@@ -148,6 +152,7 @@
printf("%s (", cpu_model);
switch(cpu_class) {
case CPUCLASS_K8:
+ hw_clockrate = (tsc_freq + 5000) / 1000000;
printf("%jd.%02d-MHz ",
(intmax_t)(tsc_freq + 4999) / 1000000,
(u_int)((tsc_freq + 4999) / 10000) % 100);
==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#65 (text+ko) ====
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.561 2003/04/02 23:53:28 peter Exp $
+ * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.562 2003/04/18 20:09:03 jhb Exp $
*/
#include "opt_atalk.h"
@@ -1420,7 +1420,9 @@
tp = td->td_frame;
+ PROC_LOCK(curthread->td_proc);
mcp->mc_onstack = sigonstack(tp->tf_rsp);
+ PROC_UNLOCK(curthread->td_proc);
mcp->mc_gs = td->td_pcb->pcb_gs;
mcp->mc_rdi = tp->tf_rdi;
mcp->mc_rsi = tp->tf_rsi;
==== //depot/projects/hammer/sys/x86_64/x86_64/sys_machdep.c#10 (text+ko) ====
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91
- * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.79 2003/03/06 04:47:47 rwatson Exp $
+ * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.80 2003/04/11 14:45:07 davidxu Exp $
*
*/
==== //depot/projects/hammer/sys/x86_64/x86_64/trap.c#24 (text+ko) ====
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
- * $FreeBSD: src/sys/i386/i386/trap.c,v 1.245 2003/03/31 22:41:32 jeff Exp $
+ * $FreeBSD: src/sys/i386/i386/trap.c,v 1.249 2003/04/22 08:12:03 davidxu Exp $
*/
/*
@@ -198,7 +198,8 @@
* and we shouldn't enable interrupts while holding a
* spin lock.
*/
- if (type != T_PAGEFLT && PCPU_GET(spinlocks) == NULL)
+ if (type != T_PAGEFLT && PCPU_GET(spinlocks) == NULL &&
+ frame.tf_eip != (int)cpu_switch_load_gs)
enable_intr();
}
}
@@ -232,18 +233,6 @@
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
- /*
- * First check that we shouldn't just abort.
- * But check if we are the single thread first!
- * XXX p_singlethread not locked, but should be safe.
- */
- if ((p->p_flag & P_WEXIT) && (p->p_singlethread != td)) {
- PROC_LOCK(p);
- mtx_lock_spin(&sched_lock);
- thread_exit();
- /* NOTREACHED */
- }
-
switch (type) {
case T_PRIVINFLT: /* privileged instruction fault */
ucode = type;
@@ -364,9 +353,6 @@
case T_PROTFLT: /* general protection fault */
case T_SEGNPFLT: /* segment not present fault */
- if (td->td_intr_nesting_level != 0)
- break;
-
/*
* Invalid %fs's and %gs's can be created using
* procfs or PT_SETREGS or by invalidating the
@@ -378,12 +364,20 @@
*/
if (frame.tf_rip == (long)cpu_switch_load_gs) {
PCPU_GET(curpcb)->pcb_gs = 0;
+ printf(
+ "Process %d has bad %%gs, reset to zero\n",
+ p->p_pid);
+#if 0
PROC_LOCK(p);
psignal(p, SIGBUS);
PROC_UNLOCK(p);
+#endif
goto out;
}
+ if (td->td_intr_nesting_level != 0)
+ break;
+
/*
* Invalid segment selectors and out of bounds
* %eip's and %esp's can be set up in user mode.
==== //depot/projects/hammer/sys/x86_64/x86_64/tsc.c#3 (text+ko) ====
@@ -23,18 +23,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/i386/i386/tsc.c,v 1.198 2003/04/04 23:54:46 tegge Exp $
+ * $FreeBSD: src/sys/i386/i386/tsc.c,v 1.199 2003/04/10 23:07:24 des Exp $
*/
#include "opt_clock.h"
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/timetc.h>
#include <sys/kernel.h>
-#include <sys/sysctl.h>
#include <sys/power.h>
+#include <sys/smp.h>
#include <machine/clock.h>
#include <machine/md_var.h>
#include <machine/specialreg.h>
@@ -43,6 +44,13 @@
int tsc_is_broken;
u_int tsc_present = 1;
+#ifdef SMP
+static int smp_tsc;
+SYSCTL_INT(_kern_timecounter, OID_AUTO, smp_tsc, CTLFLAG_RD, &smp_tsc, 0,
+ "Indicates whether the TSC is safe to use in SMP mode");
+TUNABLE_INT("kern.timecounter.smp_tsc", &smp_tsc);
+#endif
+
static unsigned tsc_get_timecount(struct timecounter *tc);
static struct timecounter tsc_timecounter = {
==== //depot/projects/hammer/sys/x86_64/x86_64/vm_machdep.c#20 (text+ko) ====
@@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.204 2003/03/30 05:24:52 jake Exp $
+ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.206 2003/04/21 15:05:05 davidxu Exp $
*/
#include "opt_isa.h"
@@ -184,6 +184,7 @@
{
struct mdproc *mdp;
+ /* Reset pc->pcb_gs and %gs before possibly invalidating it. */
mdp = &td->td_proc->p_md;
}
More information about the p4-projects
mailing list