Change the way SMP startup works to match the new multi-AP features in

locore64.S introduced in r327358.

MFC after:	3 weeks
This commit is contained in:
nwhitehorn 2017-12-30 20:24:33 +00:00
parent d1a4c9dcd1
commit a1b658d4a1

View File

@ -103,6 +103,8 @@ static platform_def_t ps3_platform = {
PLATFORM_DEF(ps3_platform);
static int ps3_boot_pir = 0;
static int
ps3_probe(platform_t plat)
{
@ -129,6 +131,9 @@ ps3_attach(platform_t plat)
/* Set a breakpoint to make NULL an invalid address */
lv1_set_dabr(0x7 /* read and write, MMU on */, 2 /* kernel accesses */);
/* Record our PIR at boot for later */
ps3_boot_pir = mfspr(SPR_PIR);
return (0);
}
@ -189,7 +194,7 @@ ps3_smp_first_cpu(platform_t plat, struct cpuref *cpuref)
{
cpuref->cr_cpuid = 0;
cpuref->cr_hwref = cpuref->cr_cpuid;
cpuref->cr_hwref = ps3_boot_pir;
return (0);
}
@ -202,7 +207,7 @@ ps3_smp_next_cpu(platform_t plat, struct cpuref *cpuref)
return (ENOENT);
cpuref->cr_cpuid++;
cpuref->cr_hwref = cpuref->cr_cpuid;
cpuref->cr_hwref = !ps3_boot_pir;
return (0);
}
@ -212,7 +217,7 @@ ps3_smp_get_bsp(platform_t plat, struct cpuref *cpuref)
{
cpuref->cr_cpuid = 0;
cpuref->cr_hwref = cpuref->cr_cpuid;
cpuref->cr_hwref = ps3_boot_pir;
return (0);
}
@ -220,21 +225,21 @@ ps3_smp_get_bsp(platform_t plat, struct cpuref *cpuref)
static int
ps3_smp_start_cpu(platform_t plat, struct pcpu *pc)
{
/* loader(8) is spinning on 0x40 == 0 right now */
uint32_t *secondary_spin_sem = (uint32_t *)(0x40);
/* kernel is spinning on 0x40 == -1 right now */
volatile uint32_t *secondary_spin_sem = (uint32_t *)(0x40);
int remote_pir = pc->pc_hwref;
int timeout;
if (pc->pc_hwref != 1)
return (ENXIO);
ap_pcpu = pc;
*secondary_spin_sem = 1;
powerpc_sync();
DELAY(1);
/* Try both PIR values, looping a few times: the HV likes moving us */
timeout = 10000;
while (!pc->pc_awake && timeout--)
while (!pc->pc_awake && timeout--) {
*secondary_spin_sem = remote_pir;
powerpc_sync();
DELAY(100);
remote_pir = !remote_pir;
}
return ((pc->pc_awake) ? 0 : EBUSY);
}