From owner-svn-src-all@freebsd.org Tue Jun 12 16:47:34 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9CF111005E47; Tue, 12 Jun 2018 16:47:34 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 392B26DE45; Tue, 12 Jun 2018 16:47:34 +0000 (UTC) (envelope-from br@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1AB7C54C6; Tue, 12 Jun 2018 16:47:34 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5CGlXPB099476; Tue, 12 Jun 2018 16:47:33 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5CGlX9j099475; Tue, 12 Jun 2018 16:47:33 GMT (envelope-from br@FreeBSD.org) Message-Id: <201806121647.w5CGlX9j099475@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 12 Jun 2018 16:47:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335005 - head/sys/riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: head/sys/riscv/riscv X-SVN-Commit-Revision: 335005 X-SVN-Commit-Repository: base 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.26 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: Tue, 12 Jun 2018 16:47:34 -0000 Author: br Date: Tue Jun 12 16:47:33 2018 New Revision: 335005 URL: https://svnweb.freebsd.org/changeset/base/335005 Log: Release secondary cores from WFI (wait for interrupt) by sending them an IPI. This does not work however yet in QEMU. As a temporary workaround set software interrupt pending bit manually on a local core to ensure WFI doesn't halt the hart. This is required to smpboot in QEMU. Sponsored by: DARPA, AFRL Modified: head/sys/riscv/riscv/mp_machdep.c Modified: head/sys/riscv/riscv/mp_machdep.c ============================================================================== --- head/sys/riscv/riscv/mp_machdep.c Tue Jun 12 16:45:52 2018 (r335004) +++ head/sys/riscv/riscv/mp_machdep.c Tue Jun 12 16:47:33 2018 (r335005) @@ -181,6 +181,7 @@ riscv64_cpu_attach(device_t dev) static void release_aps(void *dummy __unused) { + uintptr_t mask; int cpu, i; if (mp_ncpus == 1) @@ -191,6 +192,14 @@ release_aps(void *dummy __unused) atomic_store_rel_int(&aps_ready, 1); + /* Wake up the other CPUs */ + mask = 0; + + for (i = 1; i < mp_ncpus; i++) + mask |= (1 << i); + + sbi_send_ipi(&mask); + printf("Release APs\n"); for (i = 0; i < 2000; i++) { @@ -216,6 +225,11 @@ init_secondary(uint64_t cpu) /* Setup the pcpu pointer */ pcpup = &__pcpu[cpu]; __asm __volatile("mv gp, %0" :: "r"(pcpup)); + + /* Workaround: make sure wfi doesn't halt the hart */ + intr_disable(); + csr_set(sie, SIE_SSIE); + csr_set(sip, SIE_SSIE); /* Spin until the BSP releases the APs */ while (!aps_ready)