From patchwork Wed Jan 22 01:58:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bobby Eshleman X-Patchwork-Id: 11345015 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A53171820 for ; Wed, 22 Jan 2020 05:15:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7EE182465A for ; Wed, 22 Jan 2020 05:15:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oRP3L/ae" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EE182465A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iu8LE-0005GN-4t; Wed, 22 Jan 2020 05:14:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iu5LM-0006Bs-7A for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 02:02:08 +0000 X-Inumbo-ID: 0ae3b8ac-3cbb-11ea-9fd7-bc764e2007e4 Received: from mail-yw1-xc42.google.com (unknown [2607:f8b0:4864:20::c42]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0ae3b8ac-3cbb-11ea-9fd7-bc764e2007e4; Wed, 22 Jan 2020 02:01:02 +0000 (UTC) Received: by mail-yw1-xc42.google.com with SMTP id n184so2501153ywc.3 for ; Tue, 21 Jan 2020 18:01:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c+peo1lNWpi8ay2FPpKP+1+5l21PnbXHs4DF9skrc64=; b=oRP3L/aelcF4tFkz0CMIRBrm2HlIEpmOVLczmta75UDs/rtMRw2G30h57Zn6Fq3my6 +xeKZvZgEKoSru1pXuRrIDqgfpCEZzTicSTxauS1Ay7WfbK7U8QXv7TMGM4bSb2+mlwF xlIATscjyH5x82kDgHzuXt6Q9iUWf/PrvmXgU6TwhsCodyBodfaxAgR/AUrcdj14QSby d7xLAEk/X+sUnDc9p5pCSfwtPDaKOjrWEmkd4QskksMrOnR6HJP+qQCI3aChEHvu/mwJ +4nJuj7hAl0JiG42n99hffwDOtdNXicMhFRfPJ/uqTdPU7SfZTFQYvxE2ivfKpFOOy6p 51Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c+peo1lNWpi8ay2FPpKP+1+5l21PnbXHs4DF9skrc64=; b=qPGHXttJJNUxhr8zT5/nd8WS0PtW48qybWfs4GwGC+CigGuCC6SubERTB64TsMu/y0 MIBTWVPnpz7pU7XPDW/buruJLS7cadK1HVF99M/FkENhnJskoxRBv3rFfxP/ALqYZsZs brcJtZQfuVVGD7ibSMrkoNh050IlM7J83WrGCgiUPFfXTzyHuXPKU7Tbjt18PrPypjzY 0uTbDhlGu5U0vVZmNBwvlXGEUKJ7g4DT7U6UZgKF60Fz8ydPz5UDFIUy3Wl+JfzU8v0B uOet3RI4NjzP6wNIYGoQowHb8/0Qj2oIYreXQDgWxwoyLIDLvrv3TpiouQ88KajQ6mgP fPlg== X-Gm-Message-State: APjAAAV/dQLB9akbHYPQRs86mgBUVXjd6eQ7qarHeP93N/Q0a3C+nTe4 eA5ZtkJnqz15qeZKYm+Fw+vii7SLpJDwMQ== X-Google-Smtp-Source: APXvYqx2r1H43IY+7X3aOHEgvtbRX+Vb4XbeqgOWzkZ1D0QjticLeKguljW5ZRjLMx7EBRI5lokZlQ== X-Received: by 2002:a81:758a:: with SMTP id q132mr5634978ywc.162.1579658462108; Tue, 21 Jan 2020 18:01:02 -0800 (PST) Received: from bobbye-pc.knology.net ([216.186.244.35]) by smtp.gmail.com with ESMTPSA id q185sm17504248ywh.61.2020.01.21.18.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 18:01:01 -0800 (PST) From: Bobby Eshleman To: xen-devel@lists.xenproject.org Date: Tue, 21 Jan 2020 19:58:59 -0600 Message-Id: X-Mailer: git-send-email 2.25.0 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 22 Jan 2020 05:14:01 +0000 Subject: [Xen-devel] [RFC XEN PATCH 20/23] riscv: Add smpboot.c X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Bobby Eshleman , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Bobby Eshleman , Dan Robertson , Alistair Francis Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Alistair Francis Signed-off-by: Alistair Francis --- xen/arch/riscv/smpboot.c | 114 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 xen/arch/riscv/smpboot.c diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c new file mode 100644 index 0000000000..f125179a3e --- /dev/null +++ b/xen/arch/riscv/smpboot.c @@ -0,0 +1,114 @@ +/* + * Dummy smpboot support + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +cpumask_t cpu_online_map; +cpumask_t cpu_present_map; +cpumask_t cpu_possible_map; + +/* Fake one node for now. See also include/asm-arm/numa.h */ +nodemask_t __read_mostly node_online_map = { { [0] = 1UL } }; + +/* Boot cpu data */ +struct init_info init_data = +{ +}; + +/* Shared state for coordinating CPU teardown */ +static bool cpu_is_dead; + +/* ID of the PCPU we're running on */ +DEFINE_PER_CPU(unsigned int, cpu_id); +/* XXX these seem awfully x86ish... */ +/* representing HT siblings of each logical CPU */ +DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_mask); +/* representing HT and core siblings of each logical CPU */ +DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask); + +/* + * By default non-boot CPUs not identical to the boot CPU will be + * parked. + */ +static bool __read_mostly opt_hmp_unsafe = false; +boolean_param("hmp-unsafe", opt_hmp_unsafe); + +int __cpu_up(unsigned int cpu) +{ + printk("Bringing up CPU%d\n", cpu); + + console_start_sync(); /* Secondary may use early_printk */ + + /* TODO */ + + return 0; +} + +/* Shut down the current CPU */ +void __cpu_disable(void) +{ + unsigned int cpu = get_processor_id(); + + /* TODO */ + + /* It's now safe to remove this processor from the online map */ + cpumask_clear_cpu(cpu, &cpu_online_map); + + smp_mb(); + + /* Return to caller; eventually the IPI mechanism will unwind and the + * scheduler will drop to the idle loop, which will call stop_cpu(). */ +} + +void __cpu_die(unsigned int cpu) +{ + unsigned int i = 0; + + while ( !cpu_is_dead ) + { + mdelay(100); + cpu_relax(); + process_pending_softirqs(); + if ( (++i % 10) == 0 ) + printk(KERN_ERR "CPU %u still not dead...\n", cpu); + smp_mb(); + } + cpu_is_dead = false; + smp_mb(); +} + +void stop_cpu(void) +{ + local_irq_disable(); + cpu_is_dead = true; + + /* TODO */ + + while ( 1 ) + wait_for_interrupt(); +}