From owner-svn-src-all@freebsd.org Sun Feb 28 13:44:00 2016 Return-Path: Delivered-To: svn-src-all@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 BFF69AB0C4E; Sun, 28 Feb 2016 13:44:00 +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 9B7721C65; Sun, 28 Feb 2016 13:44:00 +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 u1SDhxcj035421; Sun, 28 Feb 2016 13:43:59 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1SDhxAi035414; Sun, 28 Feb 2016 13:43:59 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201602281343.u1SDhxAi035414@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sun, 28 Feb 2016 13:43:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296158 - in head/sys: arm/arm arm/conf arm/qemu conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Feb 2016 13:44:01 -0000 Author: andrew Date: Sun Feb 28 13:43:58 2016 New Revision: 296158 URL: https://svnweb.freebsd.org/changeset/base/296158 Log: Add SMP support to the ARM PLATFORM code. This will allow us to have different methods to start the secondary cores in a kernel built for multiple SoCs, e.g. with the Allwinner A20 and A31. Sponsored by: ABT systems Ltd Differential Revision: https://reviews.freebsd.org/D5466 Added: head/sys/arm/qemu/virt_mp.h (contents, props changed) Modified: head/sys/arm/arm/platform.c head/sys/arm/arm/platform_if.m head/sys/arm/conf/VIRT head/sys/arm/qemu/virt_machdep.c head/sys/arm/qemu/virt_mp.c head/sys/conf/options.arm Modified: head/sys/arm/arm/platform.c ============================================================================== --- head/sys/arm/arm/platform.c Sun Feb 28 10:40:09 2016 (r296157) +++ head/sys/arm/arm/platform.c Sun Feb 28 13:43:58 2016 (r296158) @@ -177,3 +177,18 @@ platform_late_init(void) PLATFORM_LATE_INIT(plat_obj); } +#if defined(SMP) && defined(PLATFORM_SMP) +void +platform_mp_setmaxid(void) +{ + + PLATFORM_MP_SETMAXID(plat_obj); +} + +void +platform_mp_start_ap(void) +{ + + PLATFORM_MP_START_AP(plat_obj); +} +#endif Modified: head/sys/arm/arm/platform_if.m ============================================================================== --- head/sys/arm/arm/platform_if.m Sun Feb 28 10:40:09 2016 (r296157) +++ head/sys/arm/arm/platform_if.m Sun Feb 28 13:43:58 2016 (r296158) @@ -57,6 +57,12 @@ CODE { { return; } + + static void platform_default_mp_setmaxid(platform_t plat) + { + mp_ncpus = 1; + mp_maxid = 0; + } }; /** @@ -114,3 +120,16 @@ METHOD void late_init { platform_t _plat; }; +/** + * @brief Called by cpu_mp_setmaxid() to set mp_maxid and mp_ncpus. + */ +METHOD void mp_setmaxid { + platform_t _plat; +} DEFAULT platform_default_mp_setmaxid; + +/** + * @brief Called by cpu_mp_start to start the secondary processors. + */ +METHOD void mp_start_ap { + platform_t _plat; +}; Modified: head/sys/arm/conf/VIRT ============================================================================== --- head/sys/arm/conf/VIRT Sun Feb 28 10:40:09 2016 (r296157) +++ head/sys/arm/conf/VIRT Sun Feb 28 13:43:58 2016 (r296158) @@ -26,6 +26,7 @@ include "../qemu/std.virt" options HZ=100 options SCHED_ULE # 4BSD scheduler options PLATFORM +options PLATFORM_SMP options SMP # Enable multiple cores # Debugging for use in -current Modified: head/sys/arm/qemu/virt_machdep.c ============================================================================== --- head/sys/arm/qemu/virt_machdep.c Sun Feb 28 10:40:09 2016 (r296157) +++ head/sys/arm/qemu/virt_machdep.c Sun Feb 28 13:43:58 2016 (r296158) @@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include "platform_if.h" struct arm32_dma_range * @@ -86,6 +88,11 @@ static platform_method_t virt_methods[] PLATFORMMETHOD(platform_devmap_init, virt_devmap_init), PLATFORMMETHOD(platform_lastaddr, virt_lastaddr), +#ifdef SMP + PLATFORMMETHOD(platform_mp_start_ap, virt_mp_start_ap), + PLATFORMMETHOD(platform_mp_setmaxid, virt_mp_setmaxid), +#endif + PLATFORMMETHOD_END, }; Modified: head/sys/arm/qemu/virt_mp.c ============================================================================== --- head/sys/arm/qemu/virt_mp.c Sun Feb 28 10:40:09 2016 (r296157) +++ head/sys/arm/qemu/virt_mp.c Sun Feb 28 13:43:58 2016 (r296158) @@ -38,12 +38,15 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include #include +#include + static int running_cpus; static boolean_t @@ -57,7 +60,7 @@ virt_maxid(u_int id, phandle_t node, u_i } void -platform_mp_setmaxid(void) +virt_mp_setmaxid(platform_t plat) { mp_maxid = PCPU_GET(cpuid); @@ -85,7 +88,7 @@ virt_start_ap(u_int id, phandle_t node, } void -platform_mp_start_ap(void) +virt_mp_start_ap(platform_t plat) { ofw_cpu_early_foreach(virt_start_ap, true); Added: head/sys/arm/qemu/virt_mp.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/qemu/virt_mp.h Sun Feb 28 13:43:58 2016 (r296158) @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2016 Andrew Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _QEMU_VIRT_MP_H_ +#define _QEMU_VIRT_MP_H_ + +void virt_mp_start_ap(platform_t plat); +void virt_mp_setmaxid(platform_t plat); + +#endif /* _QEMU_VIRT_MP_H_ */ Modified: head/sys/conf/options.arm ============================================================================== --- head/sys/conf/options.arm Sun Feb 28 10:40:09 2016 (r296157) +++ head/sys/conf/options.arm Sun Feb 28 13:43:58 2016 (r296158) @@ -34,6 +34,7 @@ LINUX_BOOT_ABI opt_global.h LOADERRAMADDR opt_global.h PHYSADDR opt_global.h PLATFORM opt_global.h +PLATFORM_SMP opt_global.h SOCDEV_PA opt_global.h SOCDEV_VA opt_global.h PV_STATS opt_pmap.h