From nobody Wed Nov 12 01:50:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1566918884; cv=none; d=zoho.com; s=zohoarc; b=Jioz7w+5rOg3cKxZb2ukfiPp0dU0ocWZRVxOEL9piu3Ijqo/ehUa3Lp+Q31RY+lIRhPkFbutt/lMZMzPTNxID4yog6MGFmTsRhWnFa0Zy+zVKS3/O6AnOBegaS13QGYSobZ1KlYkqw4gbPTt5rX8B6jRzIJCGO2GQuk0yVz+tFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566918884; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=d7us2fu3ANyV0m5Az+EJmBw0pv/vpKhnOtU+MafJ4Gw=; b=Qb3io9yXw6xad8a93CWJlVmJikhr0/Gv9N734w5XvRIsaxEuI6yJLvPcl3gtg7D3LyWtXKe2yCROfmRd1DsYumRC8ejCVDxjA6E+WYmvWsj4ipMdd4qL42I7Q8410Fwkab5q1yyYUSuswxx3f9y3EAf8N37eCMDdavup8Qrz5dM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566918884438909.4926772791338; Tue, 27 Aug 2019 08:14:44 -0700 (PDT) Received: from localhost ([::1]:52509 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dBC-0002Nr-OI for importer@patchew.org; Tue, 27 Aug 2019 11:14:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46941) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwS-0003On-1g for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwO-0003ow-9E for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:26 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:38206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwL-0003bU-CK; Tue, 27 Aug 2019 10:59:21 -0400 Received: by mail-pf1-x443.google.com with SMTP id o70so14292415pfg.5; Tue, 27 Aug 2019 07:59:02 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.00 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=d7us2fu3ANyV0m5Az+EJmBw0pv/vpKhnOtU+MafJ4Gw=; b=uq+EV8N1IlJV9bRL7iLPiVLeUBJGzU4ZDSAZrtKNNVt4nD6Wh5w/CZ5/KOtzVRfsnQ qwYnxLuYyxaHhCrYDOq9zOqHhqH7Slmr3K1rBxtbK/9WugxZcyMqDs0vxMRkzEDhNrZY kHaER/02xdsoMg6GMFtSa/CWHZCZwm8HcFP4hvcMv6adkiYJrkLex2BKFd3MdygB0WUu uvIVavGFTKdrn5OOYvYpbJ71TwENKDYbq0YYf2TviOLHvpAbWELvmfvxTOQhIU4A1dn/ i28HVnrczu85nstJ/iOvKyzm6jiCWmfJ6faHZqvHhS1cPmy2bXJD04AC/1TaDR9T0CVE YcNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=d7us2fu3ANyV0m5Az+EJmBw0pv/vpKhnOtU+MafJ4Gw=; b=HwkJrBkrb9xGtt6AbG8xnxKv8QlFBM53ORxWUv9EoXMpN6Cy8Vydy6jfsHAqFiMmp/ KWYEBU/YDwo3rlZBWYLyWrzu9AzJeXM/f72FKsprxZNikOw6jLfh3QXi5sSF8Xcrc23H LU3Bq4szXRTTTkupAc8UB6GKATssueqfadn1WizVJ0z9rl310MbUP0HtIxXjgBL/DAkj JjNGoezxQkYSZle1PfVVFvNBqqFv4Yghdad4H2U2g3rGRd1EfalfplpsuHv8xTCNqh3X qxHSZjmf26yiw0kYhWyfG9+MbDJ0NgM8RSA+DcdppKFRQe+BaYV9HpQMQ2gaxIPfOHwJ FTmA== X-Gm-Message-State: APjAAAWFUlVKqKrwF73ntxIkdTrLKQOHn2XlsRLCBzty1wTM0oGH9EQ5 Wt/qzDtwJsaxGr7pNzDx1Oc= X-Google-Smtp-Source: APXvYqwOylZlWtK6LxsNDbmSpUoQhUeW0iJgmOuiN1XMnDQgc3DjafD11YlT9v0LikmGxM9trpmmEQ== X-Received: by 2002:a62:ee0e:: with SMTP id e14mr10365737pfi.31.1566917941905; Tue, 27 Aug 2019 07:59:01 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:24 -0700 Message-Id: <1566917919-25381-16-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v6 15/30] riscv: hart: Add a "hartid-base" property to RISC-V hart array X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" At present each hart's hartid in a RISC-V hart array is assigned the same value of its index in the hart array. But for a system that has multiple hart arrays, this is not the case any more. Add a new "hartid-base" property so that hartid number can be assigned based on the property value. Signed-off-by: Bin Meng --- Changes in v6: - use s->hartid_base directly, instead of an extra variable Changes in v5: None Changes in v4: - new patch to add a "hartid-base" property to RISC-V hart array Changes in v3: None Changes in v2: None hw/riscv/riscv_hart.c | 7 ++++--- include/hw/riscv/riscv_hart.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index 9deef869..7cfc835 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -27,6 +27,7 @@ =20 static Property riscv_harts_props[] =3D { DEFINE_PROP_UINT32("num-harts", RISCVHartArrayState, num_harts, 1), + DEFINE_PROP_UINT32("hartid-base", RISCVHartArrayState, hartid_base, 0), DEFINE_PROP_STRING("cpu-type", RISCVHartArrayState, cpu_type), DEFINE_PROP_END_OF_LIST(), }; @@ -37,7 +38,7 @@ static void riscv_harts_cpu_reset(void *opaque) cpu_reset(CPU(cpu)); } =20 -static void riscv_hart_realize(RISCVHartArrayState *s, int idx, +static void riscv_hart_realize(RISCVHartArrayState *s, int idx, uint32_t h= artid, char *cpu_type, Error **errp) { Error *err =3D NULL; @@ -45,7 +46,7 @@ static void riscv_hart_realize(RISCVHartArrayState *s, in= t idx, object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx], sizeof(RISCVCPU), cpu_type, &error_abort, NULL); - s->harts[idx].env.mhartid =3D idx; + s->harts[idx].env.mhartid =3D hartid; qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]); object_property_set_bool(OBJECT(&s->harts[idx]), true, "realized", &err); @@ -63,7 +64,7 @@ static void riscv_harts_realize(DeviceState *dev, Error *= *errp) s->harts =3D g_new0(RISCVCPU, s->num_harts); =20 for (n =3D 0; n < s->num_harts; n++) { - riscv_hart_realize(s, n, s->cpu_type, errp); + riscv_hart_realize(s, n, s->hartid_base + n, s->cpu_type, errp); } } =20 diff --git a/include/hw/riscv/riscv_hart.h b/include/hw/riscv/riscv_hart.h index 0671d88..1984e30 100644 --- a/include/hw/riscv/riscv_hart.h +++ b/include/hw/riscv/riscv_hart.h @@ -32,6 +32,7 @@ typedef struct RISCVHartArrayState { =20 /*< public >*/ uint32_t num_harts; + uint32_t hartid_base; char *cpu_type; RISCVCPU *harts; } RISCVHartArrayState; --=20 2.7.4