summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2011-05-13 16:42:05 +0000
committerattilio <attilio@FreeBSD.org>2011-05-13 16:42:05 +0000
commitdcae8c96267648ce6ae3191f642d5ddd62d0b319 (patch)
treec08d4dee0bf7768439f6baa6b5051733407a8280 /sys/mips
parenta0db972f622c3a9dd2d45cdd27cc47dd31961dbb (diff)
downloadFreeBSD-src-dcae8c96267648ce6ae3191f642d5ddd62d0b319.zip
FreeBSD-src-dcae8c96267648ce6ae3191f642d5ddd62d0b319.tar.gz
Add the cpuset_t conversion for mips.
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/cavium/octeon_mp.c14
-rw-r--r--sys/mips/include/_types.h1
-rw-r--r--sys/mips/include/hwfunc.h4
-rw-r--r--sys/mips/include/pmap.h3
-rw-r--r--sys/mips/include/smp.h4
-rw-r--r--sys/mips/mips/mp_machdep.c55
-rw-r--r--sys/mips/mips/pmap.c36
-rw-r--r--sys/mips/rmi/xlr_machdep.c12
-rw-r--r--sys/mips/sibyte/sb_scd.c13
9 files changed, 98 insertions, 44 deletions
diff --git a/sys/mips/cavium/octeon_mp.c b/sys/mips/cavium/octeon_mp.c
index 78eafa6..5e494b8 100644
--- a/sys/mips/cavium/octeon_mp.c
+++ b/sys/mips/cavium/octeon_mp.c
@@ -102,10 +102,20 @@ platform_init_ap(int cpuid)
mips_wbflush();
}
-cpumask_t
+cpuset_t
platform_cpu_mask(void)
{
- return (octeon_bootinfo->core_mask);
+ cpuset_t cpumask;
+
+ CPU_ZERO(&cpumask);
+
+ /*
+ * XXX: hack in order to simplify CPU set building, assuming that
+ * core_mask is 32-bits.
+ */
+ memcpy(&cpumask, &octeon_bootinfo->core_mask,
+ sizeof(octeon_bootinfo->core_mask));
+ return (cpumask);
}
struct cpu_group *
diff --git a/sys/mips/include/_types.h b/sys/mips/include/_types.h
index 4d57e20..2f23db6 100644
--- a/sys/mips/include/_types.h
+++ b/sys/mips/include/_types.h
@@ -73,7 +73,6 @@ typedef unsigned long long __uint64_t;
* Standard type definitions.
*/
typedef __int32_t __clock_t; /* clock()... */
-typedef unsigned int __cpumask_t;
typedef double __double_t;
typedef double __float_t;
#ifdef __mips_n64
diff --git a/sys/mips/include/hwfunc.h b/sys/mips/include/hwfunc.h
index 683aedb..4e6ddf5 100644
--- a/sys/mips/include/hwfunc.h
+++ b/sys/mips/include/hwfunc.h
@@ -28,6 +28,8 @@
#ifndef _MACHINE_HWFUNC_H_
#define _MACHINE_HWFUNC_H_
+#include <sys/_cpuset.h>
+
struct trapframe;
struct timecounter;
/*
@@ -91,7 +93,7 @@ extern int platform_processor_id(void);
/*
* Return the cpumask of available processors.
*/
-extern cpumask_t platform_cpu_mask(void);
+extern cpuset_t platform_cpu_mask(void);
/*
* Return the topology of processors on this platform
diff --git a/sys/mips/include/pmap.h b/sys/mips/include/pmap.h
index e710635..90375eb 100644
--- a/sys/mips/include/pmap.h
+++ b/sys/mips/include/pmap.h
@@ -58,6 +58,7 @@
#ifndef LOCORE
#include <sys/queue.h>
+#include <sys/_cpuset.h>
#include <sys/_lock.h>
#include <sys/_mutex.h>
@@ -83,7 +84,7 @@ struct pmap {
pd_entry_t *pm_segtab; /* KVA of segment table */
TAILQ_HEAD(, pv_entry) pm_pvlist; /* list of mappings in
* pmap */
- cpumask_t pm_active; /* active on cpus */
+ cpuset_t pm_active; /* active on cpus */
struct {
u_int32_t asid:ASID_BITS; /* TLB address space tag */
u_int32_t gen:ASIDGEN_BITS; /* its generation number */
diff --git a/sys/mips/include/smp.h b/sys/mips/include/smp.h
index 58aaf03..0fcca9a 100644
--- a/sys/mips/include/smp.h
+++ b/sys/mips/include/smp.h
@@ -17,6 +17,8 @@
#ifdef _KERNEL
+#include <sys/_cpuset.h>
+
#include <machine/pcb.h>
/*
@@ -33,7 +35,7 @@
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);
void smp_init_secondary(u_int32_t cpuid);
void mpentry(void);
diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c
index e945736..eb36d6f 100644
--- a/sys/mips/mips/mp_machdep.c
+++ b/sys/mips/mips/mp_machdep.c
@@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/cpuset.h>
#include <sys/ktr.h>
#include <sys/proc.h>
#include <sys/lock.h>
@@ -80,15 +81,16 @@ ipi_all_but_self(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;
- CTR3(KTR_SMP, "%s: cpus: %x, ipi: %x\n", __func__, cpus, ipi);
-
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
- if ((cpus & pc->pc_cpumask) != 0)
+ if (CPU_OVERLAP(&cpus, &pc->pc_cpumask)) {
+ CTR3(KTR_SMP, "%s: pc: %p, ipi: %x\n", __func__, pc,
+ ipi);
ipi_send(pc, ipi);
+ }
}
}
@@ -108,7 +110,7 @@ static int
mips_ipi_handler(void *arg)
{
int cpu;
- cpumask_t cpumask;
+ cpuset_t cpumask;
u_int ipi, ipi_bitmap;
int bit;
@@ -148,14 +150,14 @@ mips_ipi_handler(void *arg)
tlb_save();
/* Indicate we are stopped */
- atomic_set_int(&stopped_cpus, cpumask);
+ CPU_OR_ATOMIC(&stopped_cpus, &cpumask);
/* Wait for restart */
- while ((started_cpus & cpumask) == 0)
+ while (!CPU_OVERLAP(&started_cpus, &cpumask))
cpu_spinwait();
- atomic_clear_int(&started_cpus, cpumask);
- atomic_clear_int(&stopped_cpus, cpumask);
+ CPU_NAND_ATOMIC(&started_cpus, &cpumask);
+ CPU_NAND_ATOMIC(&stopped_cpus, &cpumask);
CTR0(KTR_SMP, "IPI_STOP (restart)");
break;
case IPI_PREEMPT:
@@ -200,14 +202,21 @@ start_ap(int cpuid)
void
cpu_mp_setmaxid(void)
{
- cpumask_t cpumask;
+ cpuset_t cpumask;
+ int cpu, last;
cpumask = platform_cpu_mask();
- mp_ncpus = bitcount32(cpumask);
+ mp_ncpus = 0;
+ last = 1;
+ while ((cpu = cpusetobj_ffs(&cpumask)) != 0) {
+ last = cpu;
+ mp_ncpus++;
+ CPU_CLR(cpu, &cpumask);
+ }
if (mp_ncpus <= 0)
mp_ncpus = 1;
- mp_maxid = min(fls(cpumask), MAXCPU) - 1;
+ mp_maxid = min(last, MAXCPU) - 1;
}
void
@@ -233,16 +242,16 @@ void
cpu_mp_start(void)
{
int error, cpuid;
- cpumask_t cpumask;
+ cpuset_t cpumask, ocpus;
mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);
- all_cpus = 0;
+ CPU_ZERO(&all_cpus);
cpumask = platform_cpu_mask();
- while (cpumask != 0) {
- cpuid = ffs(cpumask) - 1;
- cpumask &= ~(1 << cpuid);
+ while (!CPU_EMPTY(&cpumask)) {
+ cpuid = cpusetobj_ffs(&cpumask) - 1;
+ CPU_CLR(cpuid, &cpumask);
if (cpuid >= MAXCPU) {
printf("cpu_mp_start: ignoring AP #%d.\n", cpuid);
@@ -257,15 +266,19 @@ cpu_mp_start(void)
if (bootverbose)
printf("AP #%d started!\n", cpuid);
}
- all_cpus |= 1 << cpuid;
+ CPU_SET(cpuid, &all_cpus);
}
- PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask));
+ ocpus = all_cpus;
+ CPU_CLR(PCPU_GET(cpuid), &ocpus);
+ PCPU_SET(other_cpus, ocpus);
}
void
smp_init_secondary(u_int32_t cpuid)
{
+ cpuset_t ocpus;
+
/* TLB */
mips_wr_wired(0);
tlb_invalidate_all();
@@ -303,7 +316,9 @@ smp_init_secondary(u_int32_t cpuid)
CTR1(KTR_SMP, "SMP: AP CPU #%d launched", PCPU_GET(cpuid));
/* Build our map of 'other' CPUs. */
- PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask));
+ ocpus = all_cpus;
+ CPU_CLR(PCPU_GET(cpuid), &ocpus);
+ PCPU_SET(other_cpus, ocpus);
if (bootverbose)
printf("SMP: AP CPU #%d launched.\n", PCPU_GET(cpuid));
diff --git a/sys/mips/mips/pmap.c b/sys/mips/mips/pmap.c
index 7f0f4f0..f7ea660 100644
--- a/sys/mips/mips/pmap.c
+++ b/sys/mips/mips/pmap.c
@@ -471,7 +471,7 @@ pmap_create_kernel_pagetable(void)
PMAP_LOCK_INIT(kernel_pmap);
kernel_pmap->pm_segtab = kernel_segmap;
- kernel_pmap->pm_active = ~0;
+ CPU_FILL(&kernel_pmap->pm_active);
TAILQ_INIT(&kernel_pmap->pm_pvlist);
kernel_pmap->pm_asid[0].asid = PMAP_ASID_RESERVED;
kernel_pmap->pm_asid[0].gen = 0;
@@ -630,10 +630,14 @@ pmap_invalidate_all_local(pmap_t pmap)
tlb_invalidate_all();
return;
}
- if (pmap->pm_active & PCPU_GET(cpumask))
+ sched_pin();
+ if (CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) {
+ sched_unpin();
tlb_invalidate_all_user(pmap);
- else
+ } else {
+ sched_unpin();
pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
+ }
}
#ifdef SMP
@@ -667,12 +671,16 @@ pmap_invalidate_page_local(pmap_t pmap, vm_offset_t va)
tlb_invalidate_address(pmap, va);
return;
}
- if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation))
+ sched_pin();
+ if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation)) {
+ sched_unpin();
return;
- else if (!(pmap->pm_active & PCPU_GET(cpumask))) {
+ } else if (!CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) {
pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
+ sched_unpin();
return;
}
+ sched_unpin();
tlb_invalidate_address(pmap, va);
}
@@ -716,12 +724,16 @@ pmap_update_page_local(pmap_t pmap, vm_offset_t va, pt_entry_t pte)
tlb_update(pmap, va, pte);
return;
}
- if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation))
+ sched_pin();
+ if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation)) {
+ sched_unpin();
return;
- else if (!(pmap->pm_active & PCPU_GET(cpumask))) {
+ } else if (!CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) {
pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
+ sched_unpin();
return;
}
+ sched_unpin();
tlb_update(pmap, va, pte);
}
@@ -1041,7 +1053,7 @@ pmap_pinit0(pmap_t pmap)
PMAP_LOCK_INIT(pmap);
pmap->pm_segtab = kernel_segmap;
- pmap->pm_active = 0;
+ CPU_ZERO(&pmap->pm_active);
pmap->pm_ptphint = NULL;
for (i = 0; i < MAXCPU; i++) {
pmap->pm_asid[i].asid = PMAP_ASID_RESERVED;
@@ -1102,7 +1114,7 @@ pmap_pinit(pmap_t pmap)
ptdva = MIPS_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(ptdpg));
pmap->pm_segtab = (pd_entry_t *)ptdva;
- pmap->pm_active = 0;
+ CPU_ZERO(&pmap->pm_active);
pmap->pm_ptphint = NULL;
for (i = 0; i < MAXCPU; i++) {
pmap->pm_asid[i].asid = PMAP_ASID_RESERVED;
@@ -2948,8 +2960,8 @@ pmap_activate(struct thread *td)
oldpmap = PCPU_GET(curpmap);
if (oldpmap)
- atomic_clear_32(&oldpmap->pm_active, PCPU_GET(cpumask));
- atomic_set_32(&pmap->pm_active, PCPU_GET(cpumask));
+ CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask));
+ CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask));
pmap_asid_alloc(pmap);
if (td == curthread) {
PCPU_SET(segbase, pmap->pm_segtab);
@@ -3283,7 +3295,7 @@ pmap_kextract(vm_offset_t va)
pt_entry_t *ptep;
/* Is the kernel pmap initialized? */
- if (kernel_pmap->pm_active) {
+ if (!CPU_EMPTY(&kernel_pmap->pm_active)) {
/* It's inside the virtual address range */
ptep = pmap_pte(kernel_pmap, va);
if (ptep) {
diff --git a/sys/mips/rmi/xlr_machdep.c b/sys/mips/rmi/xlr_machdep.c
index 4a1734a..7181a5c 100644
--- a/sys/mips/rmi/xlr_machdep.c
+++ b/sys/mips/rmi/xlr_machdep.c
@@ -614,11 +614,17 @@ platform_processor_id(void)
return (xlr_hwtid_to_cpuid[xlr_cpu_id()]);
}
-cpumask_t
+cpuset_t
platform_cpu_mask(void)
{
-
- return (~0U >> (32 - (xlr_ncores * xlr_threads_per_core)));
+ cpuset_t cpumask;
+ int i, s;
+
+ CPU_ZERO(&cpumask);
+ s = xlr_ncores * xlr_threads_per_core;
+ for (i = 0; i < s; i++)
+ CPU_SET(i, &cpumask);
+ return (cpumask);
}
struct cpu_group *
diff --git a/sys/mips/sibyte/sb_scd.c b/sys/mips/sibyte/sb_scd.c
index e5ac23c..f2035d8 100644
--- a/sys/mips/sibyte/sb_scd.c
+++ b/sys/mips/sibyte/sb_scd.c
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/bus.h>
+#include <sys/cpuset.h>
#include <machine/resource.h>
#include <machine/hwfunc.h>
@@ -242,11 +243,17 @@ sb_clear_mailbox(int cpu, uint64_t val)
sb_store64(regaddr, val);
}
-cpumask_t
+cpuset_t
platform_cpu_mask(void)
{
-
- return (~0U >> (32 - SYSREV_NUM_PROCESSORS(sb_read_sysrev())));
+ cpuset_t cpumask;
+ int i, s;
+
+ CPU_ZERO(&cpumask);
+ s = SYSREV_NUM_PROCESSORS(sb_read_sysrev());
+ for (i = 0; i < s; i++)
+ CPU_SET(i, &cpumask);
+ return (cpumask);
}
#endif /* SMP */
OpenPOWER on IntegriCloud