From owner-p4-projects@FreeBSD.ORG Sun Apr 1 21:52:18 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E6DA416A401; Sun, 1 Apr 2007 21:52:17 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 847D916A405 for ; Sun, 1 Apr 2007 21:52:17 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 75FC613C44B for ; Sun, 1 Apr 2007 21:52:17 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l31LqHlb022638 for ; Sun, 1 Apr 2007 21:52:17 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l31LqHuB022635 for perforce@freebsd.org; Sun, 1 Apr 2007 21:52:17 GMT (envelope-from marcel@freebsd.org) Date: Sun, 1 Apr 2007 21:52:17 GMT Message-Id: <200704012152.l31LqHuB022635@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Cc: Subject: PERFORCE change 117140 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2007 21:52:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=117140 Change 117140 by marcel@marcel_xcllnt on 2007/04/01 21:52:12 Create PCPU structures for all CPUs. Reduce dependency on MAXCPU by allocating PCPU structures on demand. Affected files ... .. //depot/projects/powerpc/sys/powerpc/include/pcpu.h#6 edit .. //depot/projects/powerpc/sys/powerpc/powerpc/machdep.c#8 edit .. //depot/projects/powerpc/sys/powerpc/powerpc/mp_machdep.c#9 edit .. //depot/projects/powerpc/sys/powerpc/powerpc/ofw_machdep.c#7 edit Differences ... ==== //depot/projects/powerpc/sys/powerpc/include/pcpu.h#6 (text+ko) ==== @@ -40,6 +40,7 @@ int pc_inside_intr; \ struct pmap *pc_curpmap; /* current pmap */ \ struct thread *pc_fputhread; /* current fpu user */ \ + int pc_bsp:1; \ int pc_awake:1; \ register_t pc_tempsave[CPUSAVE_LEN]; \ register_t pc_disisave[CPUSAVE_LEN]; \ ==== //depot/projects/powerpc/sys/powerpc/powerpc/machdep.c#8 (text+ko) ==== @@ -127,8 +127,8 @@ int cold = 1; -struct pcpu __pcpu[MAXCPU]; -struct trapframe frame0; +static struct pcpu pcpu0; +static struct trapframe frame0; vm_offset_t kstack0; vm_offset_t kstack0_phys; @@ -290,7 +290,7 @@ /* * Set up per-cpu data. */ - pc = &__pcpu[0]; + pc = &pcpu0; pcpu_init(pc, 0, sizeof(struct pcpu)); pc->pc_curthread = &thread0; pc->pc_curpcb = thread0.td_pcb; ==== //depot/projects/powerpc/sys/powerpc/powerpc/mp_machdep.c#9 (text+ko) ==== @@ -37,6 +37,8 @@ #include +MALLOC_DEFINE(M_SMP, "smp", "SMP specific datastructures"); + volatile static int ap_awake; volatile static int ap_spin; @@ -45,9 +47,9 @@ void cpu_mp_setmaxid(void) { + char buf[8]; phandle_t dev, root; int res; - char buf[8]; mp_ncpus = 0; @@ -93,6 +95,57 @@ void cpu_mp_start(void) { + char buf[8]; + struct pcpu *pc; + ihandle_t inst; + phandle_t bsp, chosen, dev, root; + int cpuid, res; + + /* Get the p-handle of the BSP. */ + chosen = OF_finddevice("/chosen"); + if (chosen != -1) { + res = OF_getprop(chosen, "cpu", &inst, sizeof(inst)); + bsp = (res > 0) ? OF_instance_to_package(inst) : -1; + } else + bsp = -1; + + root = OF_peer(0); + dev = OF_child(root); + while (dev != 0) { + res = OF_getprop(dev, "name", buf, sizeof(buf)); + if (res > 0 && !strcmp(buf, "cpus")) + break; + dev = OF_peer(dev); + } + KASSERT(dev != 0, ("%s: dev == 0", __func__)); + for (dev = OF_child(dev); dev != 0; dev = OF_peer(dev)) { + res = OF_getprop(dev, "device_type", buf, sizeof(buf)); + if (res < 0 || strcmp(buf, "cpu") != 0) + continue; + res = OF_getprop(dev, "reg", &cpuid, sizeof(cpuid)); + if (res < 0) + continue; + cpuid &= 0xff; + if (cpuid >= MAXCPU) { + printf("SMP: cpu%d: skipped -- ID out of range\n", + cpuid); + continue; + } + if (all_cpus & (1 << cpuid)) { + printf("SMP: cpu%d: skipped - duplicate ID\n", cpuid); + continue; + } + if (dev != bsp) { + pc = (struct pcpu *)malloc(sizeof(*pc), M_SMP, + M_WAITOK); + pcpu_init(pc, cpuid, sizeof(*pc)); + } else { + KASSERT(cpuid == 0, ("%s: cpuid != 0", __func__)); + pc = pcpup; + pc->pc_bsp = 1; + } + all_cpus |= 1 << cpuid; + } } void @@ -106,7 +159,7 @@ if (pc == NULL) continue; printf("cpu%d", i); - if (i == 0) + if (pc->pc_bsp) printf(" (BSP)"); printf("\n"); } @@ -152,6 +205,9 @@ static void ipi_send(struct pcpu *pc, int ipi) { + /* + * + */ } /* Send an IPI to a set of cpus. */ ==== //depot/projects/powerpc/sys/powerpc/powerpc/ofw_machdep.c#7 (text+ko) ==== @@ -63,7 +63,6 @@ static struct mem_region OFfree[OFMEM_REGIONS + 3]; extern register_t ofmsr[5]; -extern struct pcpu __pcpu[MAXCPU]; extern struct pmap ofw_pmap; static int (*ofwcall)(void *);