From patchwork Sun Sep 1 02:52:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1156227 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PgGzwvMG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46LdFw1dnXz9sDB for ; Sun, 1 Sep 2019 12:58:44 +1000 (AEST) Received: from localhost ([::1]:47220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4G4f-0003JS-KM for incoming@patchwork.ozlabs.org; Sat, 31 Aug 2019 22:58:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47789) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4Fzm-0007gb-9u for qemu-devel@nongnu.org; Sat, 31 Aug 2019 22:53:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i4Fzk-0006Ye-DB for qemu-devel@nongnu.org; Sat, 31 Aug 2019 22:53:38 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:35665) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i4Fzk-0006XD-7l; Sat, 31 Aug 2019 22:53:36 -0400 Received: by mail-pg1-x541.google.com with SMTP id n4so5504361pgv.2; Sat, 31 Aug 2019 19:53:35 -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=Q/abYtrK+JkHer8RFeR3LhMg9DVMnKBW29F73+2gOzk=; b=PgGzwvMGgFfzNTrdAs6YY82PNS3C5tBnyyf5KKztqaXiKymQqSZwNrQmwIA7JEP2ga Mdpd0YgiR0P1KCr6rfV3yxwE2Enx+IQ15Iy21R2G25NO85xgVp69Z8Id/Sm9tZ7AT6L3 xnlEHZpqK2wLnRlWe5r2JiyotCaJ59psN+18wR3mk7MtTIUtZdAIRHHw+PyUH2taGCpS s4mdlKpaoNHjfk5w0ANWCz9i+ECeu8mcWF201Xgi8v5f3wiX1IkqprzQWWs0hDE37L9v eQuIqRnJmg1kEMBmOORVXgxHfcdz59UiEPm2YCPeQ0N7ExnYWskYLsAmAifmGGyo57kc I6Vg== 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=Q/abYtrK+JkHer8RFeR3LhMg9DVMnKBW29F73+2gOzk=; b=iVZNcZXud2dTeeHSpB0MsACHRdr6wg5eqTOMlSXZ5Vnl3Ca2BAdz0KSRwe96AmbVj9 bw9Z+9XKG77Jb0fvQhIXVf+tZALfgck1HemAQ5Qlu+pPCdwG7XIr+AcUyy61YgV0i3W7 EVgHBJzlgNkq9lL2p+F7yAb8ZOPEWMZJ/n9thSyqacGIeqy5ryR/vtUJdreC+SrYgvi6 0c3DFA1d6URW9/vOrhSrho+XSFsW8Ve8IiPqlNQNzrxVZFFvuTtn7T7SYuVKeUo0EDD+ 3UKTUrjfaYJkHN5E3zpY4/fMi/I6c6wRt5JF0TNQWpwiFkdHOxY+4MrEUie5qStY5gh0 FsGA== X-Gm-Message-State: APjAAAVoNbKLcIKd0vW7pLJbolbCsRbgFFtCQtJMAAfWJDbCHPipIc/D FzhjUwe4ZWclVkiIy9BBCok= X-Google-Smtp-Source: APXvYqywYVK5PQ9hcNI2R4F1gqSj8ZUW+XlhFpMCOdkNVHQ3jKNMe1oxXx+6lgcJ8p6bLs2Ru0hLsg== X-Received: by 2002:a17:90a:ae15:: with SMTP id t21mr6501066pjq.50.1567306415206; Sat, 31 Aug 2019 19:53:35 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id p10sm11453307pff.132.2019.08.31.19.53.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 31 Aug 2019 19:53:34 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Sat, 31 Aug 2019 19:52:56 -0700 Message-Id: <1567306391-2682-16-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1567306391-2682-1-git-send-email-bmeng.cn@gmail.com> References: <1567306391-2682-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::541 Subject: [Qemu-devel] [PATCH v7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Alistair Francis --- Changes in v7: - use `s->hartid_base + idx` directly 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 | 3 ++- include/hw/riscv/riscv_hart.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index 9deef869..e28db80 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -27,6 +27,7 @@ static Property riscv_harts_props[] = { 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(), }; @@ -45,7 +46,7 @@ static void riscv_hart_realize(RISCVHartArrayState *s, int idx, object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx], sizeof(RISCVCPU), cpu_type, &error_abort, NULL); - s->harts[idx].env.mhartid = idx; + s->harts[idx].env.mhartid = s->hartid_base + idx; qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]); object_property_set_bool(OBJECT(&s->harts[idx]), true, "realized", &err); 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 { /*< public >*/ uint32_t num_harts; + uint32_t hartid_base; char *cpu_type; RISCVCPU *harts; } RISCVHartArrayState;