MFC: r291121

Merge from r290547:
Since r289279 bufinit() uses mp_ncpus so adapt to what x86 does and
set this variable already in cpu_mp_setmaxid().
While at it, rename cpu_cpuid_prop() to cpu_portid_prop() as well as
the MD cpuid variable to portid to avoid confusion with the MI use
of "cpuid" and make some variable static/global in order to reduce
stack usage.

PR:		204685
This commit is contained in:
marius 2015-12-27 14:39:47 +00:00
parent 8ff50a25ee
commit f90fadc507
3 changed files with 32 additions and 32 deletions

View File

@ -47,9 +47,9 @@ extern vm_paddr_t kstack0_phys;
struct pcpu;
struct md_utrap;
const char *cpu_cpuid_prop(u_int cpu_impl);
uint32_t cpu_get_mid(u_int cpu_impl);
void cpu_identify(u_long vers, u_int clock, u_int id);
const char *cpu_portid_prop(u_int cpu_impl);
void cpu_setregs(struct pcpu *pc);
int is_physical_memory(vm_paddr_t addr);
struct md_utrap *utrap_alloc(void);

View File

@ -249,7 +249,7 @@ find_bsp(phandle_t node, uint32_t bspid, u_int cpu_impl)
{
char type[sizeof("cpu")];
phandle_t child;
uint32_t cpuid;
uint32_t portid;
for (; node != 0; node = OF_peer(node)) {
child = OF_child(node);
@ -263,10 +263,10 @@ find_bsp(phandle_t node, uint32_t bspid, u_int cpu_impl)
continue;
if (strcmp(type, "cpu") != 0)
continue;
if (OF_getprop(node, cpu_cpuid_prop(cpu_impl), &cpuid,
sizeof(cpuid)) <= 0)
if (OF_getprop(node, cpu_portid_prop(cpu_impl),
&portid, sizeof(portid)) <= 0)
continue;
if (cpuid == bspid)
if (portid == bspid)
return (node);
}
}
@ -274,7 +274,7 @@ find_bsp(phandle_t node, uint32_t bspid, u_int cpu_impl)
}
const char *
cpu_cpuid_prop(u_int cpu_impl)
cpu_portid_prop(u_int cpu_impl)
{
switch (cpu_impl) {

View File

@ -119,9 +119,11 @@ struct mtx ipi_mtx;
cpu_ipi_selected_t *cpu_ipi_selected;
cpu_ipi_single_t *cpu_ipi_single;
static vm_offset_t mp_tramp;
static u_int cpuid_to_mid[MAXCPU];
static u_int cpuids = 1;
static volatile cpuset_t shutdown_cpus;
static char ipi_pbuf[CPUSETBUFSIZ];
static vm_offset_t mp_tramp;
static void ap_count(phandle_t node, u_int mid, u_int cpu_impl);
static void ap_start(phandle_t node, u_int mid, u_int cpu_impl);
@ -165,13 +167,12 @@ static void
foreach_ap(phandle_t node, void (*func)(phandle_t node, u_int mid,
u_int cpu_impl))
{
char type[sizeof("cpu")];
static char type[sizeof("cpu")];
phandle_t child;
u_int cpuid;
uint32_t cpu_impl;
uint32_t cpu_impl, portid;
/* There's no need to traverse the whole OFW tree twice. */
if (mp_maxid > 0 && mp_ncpus >= mp_maxid + 1)
if (mp_maxid > 0 && cpuids > mp_maxid)
return;
for (; node != 0; node = OF_peer(node)) {
@ -188,13 +189,13 @@ foreach_ap(phandle_t node, void (*func)(phandle_t node, u_int mid,
sizeof(cpu_impl)) <= 0)
panic("%s: couldn't determine CPU "
"implementation", __func__);
if (OF_getprop(node, cpu_cpuid_prop(cpu_impl), &cpuid,
sizeof(cpuid)) <= 0)
panic("%s: couldn't determine CPU module ID",
if (OF_getprop(node, cpu_portid_prop(cpu_impl),
&portid, sizeof(portid)) <= 0)
panic("%s: couldn't determine CPU port ID",
__func__);
if (cpuid == PCPU_GET(mid))
if (portid == PCPU_GET(mid))
continue;
(*func)(node, cpuid, cpu_impl);
(*func)(node, portid, cpu_impl);
}
}
}
@ -208,16 +209,17 @@ cpu_mp_setmaxid(void)
CPU_SETOF(curcpu, &all_cpus);
mp_ncpus = 1;
mp_maxid = 0;
foreach_ap(OF_child(OF_peer(0)), ap_count);
mp_ncpus = MIN(mp_ncpus, MAXCPU);
mp_maxid = mp_ncpus - 1;
}
static void
ap_count(phandle_t node __unused, u_int mid __unused, u_int cpu_impl __unused)
{
mp_maxid++;
mp_ncpus++;
}
int
@ -306,7 +308,7 @@ ap_start(phandle_t node, u_int mid, u_int cpu_impl)
u_int cpuid;
uint32_t clock;
if (mp_ncpus > MAXCPU)
if (cpuids > mp_maxid)
return;
if (OF_getprop(node, "clock-frequency", &clock, sizeof(clock)) <= 0)
@ -334,7 +336,7 @@ ap_start(phandle_t node, u_int mid, u_int cpu_impl)
csa->csa_tick = csa->csa_stick = 0;
intr_restore(s);
cpuid = mp_ncpus++;
cpuid = cpuids++;
cpuid_to_mid[cpuid] = mid;
cpu_identify(csa->csa_ver, clock, cpuid);
@ -659,7 +661,6 @@ cheetah_ipi_single(u_int cpu, u_long d0, u_long d1, u_long d2)
static void
cheetah_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
{
char pbuf[CPUSETBUFSIZ];
register_t s;
u_long ids;
u_int bnp;
@ -675,14 +676,14 @@ cheetah_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
("%s: outstanding dispatch", __func__));
ids = 0;
for (i = 0; i < IPI_RETRIES * mp_ncpus; i++) {
for (i = 0; i < IPI_RETRIES * smp_cpus; i++) {
s = intr_disable();
stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0);
stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1);
stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2);
membar(Sync);
bnp = 0;
for (cpu = 0; cpu < mp_ncpus; cpu++) {
for (cpu = 0; cpu < smp_cpus; cpu++) {
if (CPU_ISSET(cpu, &cpus)) {
stxa(AA_INTR_SEND | (cpuid_to_mid[cpu] <<
IDC_ITID_SHIFT) | bnp << IDC_BN_SHIFT,
@ -698,7 +699,7 @@ cheetah_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
;
intr_restore(s);
bnp = 0;
for (cpu = 0; cpu < mp_ncpus; cpu++) {
for (cpu = 0; cpu < smp_cpus; cpu++) {
if (CPU_ISSET(cpu, &cpus)) {
if ((ids & (IDR_NACK << (2 * bnp))) == 0)
CPU_CLR(cpu, &cpus);
@ -710,10 +711,10 @@ cheetah_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
}
if (kdb_active != 0 || panicstr != NULL)
printf("%s: couldn't send IPI (cpus=%s ids=0x%lu)\n",
__func__, cpusetobj_strprint(pbuf, &cpus), ids);
__func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids);
else
panic("%s: couldn't send IPI (cpus=%s ids=0x%lu)",
__func__, cpusetobj_strprint(pbuf, &cpus), ids);
__func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids);
}
static void
@ -760,7 +761,6 @@ jalapeno_ipi_single(u_int cpu, u_long d0, u_long d1, u_long d2)
static void
jalapeno_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
{
char pbuf[CPUSETBUFSIZ];
register_t s;
u_long ids;
u_int cpu;
@ -775,13 +775,13 @@ jalapeno_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
("%s: outstanding dispatch", __func__));
ids = 0;
for (i = 0; i < IPI_RETRIES * mp_ncpus; i++) {
for (i = 0; i < IPI_RETRIES * smp_cpus; i++) {
s = intr_disable();
stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0);
stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1);
stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2);
membar(Sync);
for (cpu = 0; cpu < mp_ncpus; cpu++) {
for (cpu = 0; cpu < smp_cpus; cpu++) {
if (CPU_ISSET(cpu, &cpus)) {
stxa(AA_INTR_SEND | (cpuid_to_mid[cpu] <<
IDC_ITID_SHIFT), ASI_SDB_INTR_W, 0);
@ -795,7 +795,7 @@ jalapeno_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
if ((ids &
(IDR_CHEETAH_ALL_BUSY | IDR_CHEETAH_ALL_NACK)) == 0)
return;
for (cpu = 0; cpu < mp_ncpus; cpu++)
for (cpu = 0; cpu < smp_cpus; cpu++)
if (CPU_ISSET(cpu, &cpus))
if ((ids & (IDR_NACK <<
(2 * cpuid_to_mid[cpu]))) == 0)
@ -803,8 +803,8 @@ jalapeno_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
}
if (kdb_active != 0 || panicstr != NULL)
printf("%s: couldn't send IPI (cpus=%s ids=0x%lu)\n",
__func__, cpusetobj_strprint(pbuf, &cpus), ids);
__func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids);
else
panic("%s: couldn't send IPI (cpus=%s ids=0x%lu)",
__func__, cpusetobj_strprint(pbuf, &cpus), ids);
__func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids);
}