Release memory for CPUs that fail to init on ARM64

cpu_init_fdt will now release memory allocated for structures
serving CPUs that have failed to init.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3297
This commit is contained in:
Zbigniew Bodek 2015-09-16 23:46:20 +00:00
parent 18c72666ce
commit dbf66ac207

View File

@ -352,7 +352,6 @@ cpu_init_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg)
if (id == 0)
return (1);
CPU_SET(id, &all_cpus);
pcpup = &__pcpu[id];
pcpu_init(pcpup, id, sizeof(struct pcpu));
@ -371,8 +370,17 @@ cpu_init_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg)
pa = pmap_extract(kernel_pmap, (vm_offset_t)mpentry);
err = psci_cpu_on(target_cpu, pa, id);
if (err != PSCI_RETVAL_SUCCESS)
printf("Failed to start CPU %u\n", id);
if (err != PSCI_RETVAL_SUCCESS) {
/* Panic here if INVARIANTS are enabled */
KASSERT(0, ("Failed to start CPU %u (%lx)\n", id, target_cpu));
pcpu_destroy(pcpup);
kmem_free(kernel_arena, (vm_offset_t)dpcpu[id - 1], DPCPU_SIZE);
dpcpu[id - 1] = NULL;
/* Notify the user that the CPU failed to start */
printf("Failed to start CPU %u (%lx)\n", id, target_cpu);
} else
CPU_SET(id, &all_cpus);
return (1);
}