svn commit: r221697 - in projects/largeSMP/sys/powerpc: aim booke
include powerpc
Attilio Rao
attilio at FreeBSD.org
Mon May 9 16:16:16 UTC 2011
Author: attilio
Date: Mon May 9 16:16:15 2011
New Revision: 221697
URL: http://svn.freebsd.org/changeset/base/221697
Log:
Add the powerpc support.
Note that there is a dirty hack for calling openpic_write(), but
nwhitehorn approved it.
Discussed with: nwhitehorn
Modified:
projects/largeSMP/sys/powerpc/aim/mmu_oea.c
projects/largeSMP/sys/powerpc/aim/mmu_oea64.c
projects/largeSMP/sys/powerpc/booke/pmap.c
projects/largeSMP/sys/powerpc/include/_types.h
projects/largeSMP/sys/powerpc/include/openpicvar.h
projects/largeSMP/sys/powerpc/include/pmap.h
projects/largeSMP/sys/powerpc/include/smp.h
projects/largeSMP/sys/powerpc/powerpc/intr_machdep.c
projects/largeSMP/sys/powerpc/powerpc/mp_machdep.c
projects/largeSMP/sys/powerpc/powerpc/openpic.c
projects/largeSMP/sys/powerpc/powerpc/pic_if.m
Modified: projects/largeSMP/sys/powerpc/aim/mmu_oea.c
==============================================================================
--- projects/largeSMP/sys/powerpc/aim/mmu_oea.c Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/aim/mmu_oea.c Mon May 9 16:16:15 2011 (r221697)
@@ -118,11 +118,14 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
+#include <sys/queue.h>
+#include <sys/cpuset.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/msgbuf.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/sched.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/vmmeter.h>
@@ -838,7 +841,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
PMAP_LOCK_INIT(kernel_pmap);
for (i = 0; i < 16; i++)
kernel_pmap->pm_sr[i] = EMPTY_SEGMENT + i;
- kernel_pmap->pm_active = ~0;
+ CPU_FILL(&kernel_pmap->pm_active);
/*
* Set up the Open Firmware mappings
@@ -960,7 +963,9 @@ moea_activate(mmu_t mmu, struct thread *
pm = &td->td_proc->p_vmspace->vm_pmap;
pmr = pm->pmap_phys;
- pm->pm_active |= PCPU_GET(cpumask);
+ sched_pin();
+ CPU_OR(&pm->pm_active, PCPU_PTR(cpumask));
+ sched_unpin();
PCPU_SET(curpmap, pmr);
}
@@ -970,7 +975,9 @@ moea_deactivate(mmu_t mmu, struct thread
pmap_t pm;
pm = &td->td_proc->p_vmspace->vm_pmap;
- pm->pm_active &= ~PCPU_GET(cpumask);
+ sched_pin();
+ CPU_NAND(&pm->pm_active, PCPU_PTR(cpumask));
+ sched_unpin();
PCPU_SET(curpmap, NULL);
}
Modified: projects/largeSMP/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- projects/largeSMP/sys/powerpc/aim/mmu_oea64.c Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/aim/mmu_oea64.c Mon May 9 16:16:15 2011 (r221697)
@@ -118,11 +118,14 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
+#include <sys/queue.h>
+#include <sys/cpuset.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/msgbuf.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/sched.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/vmmeter.h>
@@ -845,7 +848,7 @@ moea64_mid_bootstrap(mmu_t mmup, vm_offs
#endif
kernel_pmap->pmap_phys = kernel_pmap;
- kernel_pmap->pm_active = ~0;
+ CPU_FILL(&kernel_pmap->pm_active);
PMAP_LOCK_INIT(kernel_pmap);
@@ -1013,7 +1016,9 @@ moea64_activate(mmu_t mmu, struct thread
pmap_t pm;
pm = &td->td_proc->p_vmspace->vm_pmap;
- pm->pm_active |= PCPU_GET(cpumask);
+ sched_pin();
+ CPU_OR(&pm->pm_active, PCPU_PTR(cpumask));
+ sched_unpin();
#ifdef __powerpc64__
PCPU_SET(userslb, pm->pm_slb);
@@ -1028,7 +1033,9 @@ moea64_deactivate(mmu_t mmu, struct thre
pmap_t pm;
pm = &td->td_proc->p_vmspace->vm_pmap;
- pm->pm_active &= ~(PCPU_GET(cpumask));
+ sched_pin();
+ CPU_NAND(&pm->pm_active, PCPU_PTR(cpumask));
+ sched_unpin();
#ifdef __powerpc64__
PCPU_SET(userslb, NULL);
#else
Modified: projects/largeSMP/sys/powerpc/booke/pmap.c
==============================================================================
--- projects/largeSMP/sys/powerpc/booke/pmap.c Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/booke/pmap.c Mon May 9 16:16:15 2011 (r221697)
@@ -1228,7 +1228,7 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset
PTE_VALID;
}
/* Mark kernel_pmap active on all CPUs */
- kernel_pmap->pm_active = ~0;
+ CPU_FILL(&kernel_pmap->pm_active);
/*******************************************************/
/* Final setup */
@@ -1483,7 +1483,7 @@ mmu_booke_pinit(mmu_t mmu, pmap_t pmap)
PMAP_LOCK_INIT(pmap);
for (i = 0; i < MAXCPU; i++)
pmap->pm_tid[i] = TID_NONE;
- pmap->pm_active = 0;
+ CPU_ZERO(&kernel_pmap->pm_active);
bzero(&pmap->pm_stats, sizeof(pmap->pm_stats));
bzero(&pmap->pm_pdir, sizeof(pte_t *) * PDIR_NENTRIES);
TAILQ_INIT(&pmap->pm_ptbl_list);
@@ -1838,7 +1838,7 @@ mmu_booke_activate(mmu_t mmu, struct thr
mtx_lock_spin(&sched_lock);
- atomic_set_int(&pmap->pm_active, PCPU_GET(cpumask));
+ CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask));
PCPU_SET(curpmap, pmap);
if (pmap->pm_tid[PCPU_GET(cpuid)] == TID_NONE)
@@ -1867,7 +1867,9 @@ mmu_booke_deactivate(mmu_t mmu, struct t
CTR5(KTR_PMAP, "%s: td=%p, proc = '%s', id = %d, pmap = 0x%08x",
__func__, td, td->td_proc->p_comm, td->td_proc->p_pid, pmap);
- atomic_clear_int(&pmap->pm_active, PCPU_GET(cpumask));
+ sched_pin();
+ CPU_NAND_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask));
+ sched_unpin();
PCPU_SET(curpmap, NULL);
}
Modified: projects/largeSMP/sys/powerpc/include/_types.h
==============================================================================
--- projects/largeSMP/sys/powerpc/include/_types.h Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/include/_types.h Mon May 9 16:16:15 2011 (r221697)
@@ -72,7 +72,6 @@ typedef unsigned long long __uint64_t;
* Standard type definitions.
*/
typedef __uint32_t __clock_t; /* clock()... */
-typedef unsigned int __cpumask_t;
typedef double __double_t;
typedef double __float_t;
#ifdef __LP64__
Modified: projects/largeSMP/sys/powerpc/include/openpicvar.h
==============================================================================
--- projects/largeSMP/sys/powerpc/include/openpicvar.h Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/include/openpicvar.h Mon May 9 16:16:15 2011 (r221697)
@@ -57,7 +57,7 @@ int openpic_common_attach(device_t, uint
/*
* PIC interface.
*/
-void openpic_bind(device_t dev, u_int irq, cpumask_t cpumask);
+void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask);
void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity);
void openpic_dispatch(device_t, struct trapframe *);
void openpic_enable(device_t, u_int, u_int);
Modified: projects/largeSMP/sys/powerpc/include/pmap.h
==============================================================================
--- projects/largeSMP/sys/powerpc/include/pmap.h Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/include/pmap.h Mon May 9 16:16:15 2011 (r221697)
@@ -66,6 +66,7 @@
#include <sys/queue.h>
#include <sys/tree.h>
+#include <sys/_cpuset.h>
#include <sys/_lock.h>
#include <sys/_mutex.h>
#include <machine/sr.h>
@@ -98,7 +99,7 @@ struct pmap {
#else
register_t pm_sr[16];
#endif
- cpumask_t pm_active;
+ cpuset_t pm_active;
struct pmap *pmap_phys;
struct pmap_statistics pm_stats;
@@ -175,7 +176,7 @@ void slb_free_user_cache(struct slb **);
struct pmap {
struct mtx pm_mtx; /* pmap mutex */
tlbtid_t pm_tid[MAXCPU]; /* TID to identify this pmap entries in TLB */
- cpumask_t pm_active; /* active on cpus */
+ cpuset_t pm_active; /* active on cpus */
struct pmap_statistics pm_stats; /* pmap statistics */
/* Page table directory, array of pointers to page tables. */
Modified: projects/largeSMP/sys/powerpc/include/smp.h
==============================================================================
--- projects/largeSMP/sys/powerpc/include/smp.h Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/include/smp.h Mon May 9 16:16:15 2011 (r221697)
@@ -40,9 +40,11 @@
#ifndef LOCORE
+#include <sys/_cpuset.h>
+
void ipi_all_but_self(int ipi);
void ipi_cpu(int cpu, u_int ipi);
-void ipi_selected(cpumask_t cpus, int ipi);
+void ipi_selected(cpuset_t cpus, int ipi);
struct cpuref {
uintptr_t cr_hwref;
Modified: projects/largeSMP/sys/powerpc/powerpc/intr_machdep.c
==============================================================================
--- projects/largeSMP/sys/powerpc/powerpc/intr_machdep.c Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/powerpc/intr_machdep.c Mon May 9 16:16:15 2011 (r221697)
@@ -67,6 +67,7 @@
#include <sys/kernel.h>
#include <sys/queue.h>
#include <sys/bus.h>
+#include <sys/cpuset.h>
#include <sys/interrupt.h>
#include <sys/ktr.h>
#include <sys/lock.h>
@@ -98,7 +99,7 @@ struct powerpc_intr {
u_int intline;
u_int vector;
u_int cntindex;
- cpumask_t cpu;
+ cpuset_t cpu;
enum intr_trigger trig;
enum intr_polarity pol;
};
@@ -205,7 +206,7 @@ intr_lookup(u_int irq)
#ifdef SMP
i->cpu = all_cpus;
#else
- i->cpu = 1;
+ CPU_SETOF(0, &i->cpu);
#endif
for (vector = 0; vector < INTR_VECTORS && vector <= nvectors;
@@ -296,7 +297,7 @@ powerpc_assign_intr_cpu(void *arg, u_cha
if (cpu == NOCPU)
i->cpu = all_cpus;
else
- i->cpu = 1 << cpu;
+ CPU_SETOF(cpu, &i->cpu);
if (!cold && i->pic != NULL && i->pic == root_pic)
PIC_BIND(i->pic, i->intline, i->cpu);
Modified: projects/largeSMP/sys/powerpc/powerpc/mp_machdep.c
==============================================================================
--- projects/largeSMP/sys/powerpc/powerpc/mp_machdep.c Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/powerpc/mp_machdep.c Mon May 9 16:16:15 2011 (r221697)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/bus.h>
+#include <sys/cpuset.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/pcpu.h>
@@ -157,7 +158,7 @@ cpu_mp_start(void)
cpu.cr_cpuid);
goto next;
}
- if (all_cpus & (1 << cpu.cr_cpuid)) {
+ if (CPU_ISSET(cpu.cr_cpuid, &all_cpus)) {
printf("SMP: cpu%d: skipped - duplicate ID\n",
cpu.cr_cpuid);
goto next;
@@ -174,9 +175,9 @@ cpu_mp_start(void)
pc->pc_cpuid = bsp.cr_cpuid;
pc->pc_bsp = 1;
}
- pc->pc_cpumask = 1 << pc->pc_cpuid;
+ CPU_SETOF(pc->pc_cpuid, &pc->pc_cpumask);
pc->pc_hwref = cpu.cr_hwref;
- all_cpus |= pc->pc_cpumask;
+ CPU_OR(&all_cpus, &pc->pc_cpumask);
next:
error = platform_smp_next_cpu(&cpu);
}
@@ -214,7 +215,8 @@ cpu_mp_unleash(void *dummy)
smp_cpus = 0;
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
cpus++;
- pc->pc_other_cpus = all_cpus & ~pc->pc_cpumask;
+ pc->pc_other_cpus = all_cpus;
+ CPU_NAND(&pc->pc_other_cpus, &pc->pc_cpumask);
if (!pc->pc_bsp) {
if (bootverbose)
printf("Waking up CPU %d (dev=%x)\n",
@@ -236,7 +238,7 @@ cpu_mp_unleash(void *dummy)
pc->pc_cpuid, pc->pc_pir, pc->pc_awake);
smp_cpus++;
} else
- stopped_cpus |= (1 << pc->pc_cpuid);
+ CPU_SET(pc->pc_cpuid, &stopped_cpus);
}
ap_awake = 1;
@@ -276,7 +278,7 @@ SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_
int
powerpc_ipi_handler(void *arg)
{
- cpumask_t self;
+ cpuset_t self;
uint32_t ipimask;
int msg;
@@ -311,11 +313,11 @@ powerpc_ipi_handler(void *arg)
savectx(&stoppcbs[PCPU_GET(cpuid)]);
self = PCPU_GET(cpumask);
savectx(PCPU_GET(curpcb));
- atomic_set_int(&stopped_cpus, self);
- while ((started_cpus & self) == 0)
+ CPU_OR_ATOMIC(&stopped_cpus, &self);
+ while (!CPU_OVERLAP(&started_cpus, &self))
cpu_spinwait();
- atomic_clear_int(&started_cpus, self);
- atomic_clear_int(&stopped_cpus, self);
+ CPU_NAND_ATOMIC(&started_cpus, &self);
+ CPU_NAND_ATOMIC(&stopped_cpus, &self);
CTR1(KTR_SMP, "%s: IPI_STOP (restart)", __func__);
break;
case IPI_HARDCLOCK:
@@ -343,12 +345,12 @@ ipi_send(struct pcpu *pc, int ipi)
/* Send an IPI to a set of cpus. */
void
-ipi_selected(cpumask_t cpus, int ipi)
+ipi_selected(cpuset_t cpus, int ipi)
{
struct pcpu *pc;
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
- if (cpus & pc->pc_cpumask)
+ if (CPU_OVERLAP(&cpus, &pc->pc_cpumask))
ipi_send(pc, ipi);
}
}
Modified: projects/largeSMP/sys/powerpc/powerpc/openpic.c
==============================================================================
--- projects/largeSMP/sys/powerpc/powerpc/openpic.c Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/powerpc/openpic.c Mon May 9 16:16:15 2011 (r221697)
@@ -231,7 +231,7 @@ openpic_common_attach(device_t dev, uint
*/
void
-openpic_bind(device_t dev, u_int irq, cpumask_t cpumask)
+openpic_bind(device_t dev, u_int irq, cpuset_t cpumask)
{
struct openpic_softc *sc;
@@ -240,7 +240,12 @@ openpic_bind(device_t dev, u_int irq, cp
return;
sc = device_get_softc(dev);
- openpic_write(sc, OPENPIC_IDEST(irq), cpumask);
+
+ /*
+ * XXX: openpic_write() is very special and just needs a 32 bits mask.
+ * For the moment, just play dirty and get the first half word.
+ */
+ openpic_write(sc, OPENPIC_IDEST(irq), (long)cpumask & 0xffffffff);
}
void
Modified: projects/largeSMP/sys/powerpc/powerpc/pic_if.m
==============================================================================
--- projects/largeSMP/sys/powerpc/powerpc/pic_if.m Mon May 9 15:59:34 2011 (r221696)
+++ projects/largeSMP/sys/powerpc/powerpc/pic_if.m Mon May 9 16:16:15 2011 (r221697)
@@ -28,6 +28,7 @@
#
#include <sys/bus.h>
+#include <sys/cpuset.h>
#include <machine/frame.h>
INTERFACE pic;
@@ -35,7 +36,7 @@ INTERFACE pic;
METHOD void bind {
device_t dev;
u_int irq;
- cpumask_t cpumask;
+ cpuset_t cpumask;
};
METHOD void config {
More information about the svn-src-projects
mailing list