From owner-svn-src-head@freebsd.org Thu Aug 31 20:48:07 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15D87E05A97; Thu, 31 Aug 2017 20:48:07 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D8DD466EF7; Thu, 31 Aug 2017 20:48:06 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7VKm5xE014885; Thu, 31 Aug 2017 20:48:05 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7VKm559014884; Thu, 31 Aug 2017 20:48:05 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201708312048.v7VKm559014884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Thu, 31 Aug 2017 20:48:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323070 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 323070 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Aug 2017 20:48:07 -0000 Author: andrew Date: Thu Aug 31 20:48:05 2017 New Revision: 323070 URL: https://svnweb.freebsd.org/changeset/base/323070 Log: Add support for quirks while enabling secondary CPUs. This uses the fdt compatible string to check if the board is compatible with a given quirk. It's possible this will be moved later, however as it's currently only used by the MP code put it there. So far the only instance of a quirk is when the list of CPUs may be incorrect. This can happen on virtual machines with a hard coded devicetree, but where the user may then set the number of CPUs as an argument. This is the case on the ARM models so include the model specific compat strings for these, including the spelling mistake found in some of the OpenplatformPkg dtb files. Sponsored by: DARPA, AFRL Modified: head/sys/arm64/arm64/mp_machdep.c Modified: head/sys/arm64/arm64/mp_machdep.c ============================================================================== --- head/sys/arm64/arm64/mp_machdep.c Thu Aug 31 20:33:22 2017 (r323069) +++ head/sys/arm64/arm64/mp_machdep.c Thu Aug 31 20:48:05 2017 (r323070) @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #ifdef FDT #include #include +#include #include #endif @@ -74,6 +75,23 @@ __FBSDID("$FreeBSD$"); #include "pic_if.h" +#define MP_QUIRK_CPULIST 0x01 /* The list of cpus may be wrong, */ + /* don't panic if one fails to start */ +static uint32_t mp_quirks; + +#ifdef FDT +static struct { + const char *compat; + uint32_t quirks; +} fdt_quirks[] = { + { "arm,foundation-aarch64", MP_QUIRK_CPULIST }, + { "arm,fvp-base", MP_QUIRK_CPULIST }, + /* This is incorrect in some DTS files */ + { "arm,vfp-base", MP_QUIRK_CPULIST }, + { NULL, 0 }, +}; +#endif + typedef void intr_ipi_send_t(void *, cpuset_t, u_int); typedef void intr_ipi_handler_t(void *); @@ -465,13 +483,16 @@ start_cpu(u_int id, uint64_t target_cpu) * start the requested CPU. If psci_cpu_on returns PSCI_MISSING * to indicate we are unable to use it to start the given CPU. */ - KASSERT(err == PSCI_MISSING, + KASSERT(err == PSCI_MISSING || + (mp_quirks & MP_QUIRK_CPULIST) == MP_QUIRK_CPULIST, ("Failed to start CPU %u (%lx)\n", id, target_cpu)); pcpu_destroy(pcpup); kmem_free(kernel_arena, (vm_offset_t)dpcpu[cpuid - 1], DPCPU_SIZE); dpcpu[cpuid - 1] = NULL; + mp_ncpus--; + /* Notify the user that the CPU failed to start */ printf("Failed to start CPU %u (%lx)\n", id, target_cpu); } else @@ -556,6 +577,10 @@ cpu_init_fdt(u_int id, phandle_t node, u_int addr_size void cpu_mp_start(void) { +#ifdef FDT + phandle_t node; + int i; +#endif mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); @@ -570,6 +595,13 @@ cpu_mp_start(void) #endif #ifdef FDT case ARM64_BUS_FDT: + node = OF_peer(0); + for (i = 0; fdt_quirks[i].compat != NULL; i++) { + if (ofw_bus_node_is_compatible(node, + fdt_quirks[i].compat) != 0) { + mp_quirks = fdt_quirks[i].quirks; + } + } KASSERT(cpu0 >= 0, ("Current CPU was not found")); ofw_cpu_early_foreach(cpu_init_fdt, true); break;