From nobody Tue Feb 10 10:04:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1681693071; cv=none; d=zohomail.com; s=zohoarc; b=ljKkBiFbJGLtIjMX5lksRX8Llowq+34bly3SJDNg/EIlVZLs3Cbbd+PnBLD4smwM5zg5vdaJtiLbDfes8BAiC8b1oSzSU+1uRHvPHt+fpF1SNiLRPQ1VVU+NVDrzDxUVtzXYo6zIpohzJl32t4QA5EIXx4NKSjgdbOkDN2766Kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681693071; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JLzUjUqwh2cK/cV5w/VC27Tcuv4cHaxi4iP0m24nHbM=; b=HcdYg2z0wjXCNk6Agxj9q3uNnmx2IYKhHCdQH1Vy2iEYns+maL2HxiwAu6wwoeXDx/dregzoVW1bWLRjI120yhWHL5rewS53Nfb2Qf9lxORagPuAa2ON1tjqz8HHPNvyTZQr8zHarNtcyEThCikBvgY1S5m0Ais1kT6sws+32OU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681693071407397.72311760834384; Sun, 16 Apr 2023 17:57:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poD9o-0002H4-9s; Sun, 16 Apr 2023 20:55:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1poBdu-0000B6-6j for qemu-devel@nongnu.org; Sun, 16 Apr 2023 19:18:46 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poBdq-0004I3-AB for qemu-devel@nongnu.org; Sun, 16 Apr 2023 19:18:45 -0400 Received: by mail-pj1-x102b.google.com with SMTP id y11-20020a17090a600b00b0024693e96b58so23117684pji.1 for ; Sun, 16 Apr 2023 16:18:41 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:1800:f680:20ea:ba1c:5673:16e6]) by smtp.gmail.com with ESMTPSA id jl3-20020a170903134300b001a6b02659c0sm3087847plb.159.2023.04.16.16.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Apr 2023 16:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681687121; x=1684279121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JLzUjUqwh2cK/cV5w/VC27Tcuv4cHaxi4iP0m24nHbM=; b=jiIvTxaj+YzupizrdBiVggK0Vla27hKnsD9Pe7e9mvq2SkFsRs+Y5MZKsdk62Cq1fv DewJkdxYoJgZJuwblLwA8P7P6CrrdDy9DYO/nEXMXGQ/N0WYbPxfAz/Na9YPyqTUdw38 TTx7dOqwLeVAs9xzi3fXO1bWGsXiqYcyiT4PdiHUwMCqxKeuepF1z4j+zJdd+cs7PozR I/0fWWxVSUreFH9nUQHgiekqRIFaxFsTWncFdNbQfo89RK7hHiHXky5dHYe77OakIjso G1RpPvcNKqPDAgusR2OLx6naGyU6ORoBuPRoh4hRlLACBiXnFJ0c6udqjg9WlIOqvHSg LOvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681687121; x=1684279121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JLzUjUqwh2cK/cV5w/VC27Tcuv4cHaxi4iP0m24nHbM=; b=XI5uMU5z+sCBnIAHiVP2Fs9lH5dmR5CvOpGqOpYjmw4rtQ2FsrBVpC9i/hlH7vpaME aWJwFTCBDwl/XUqE2ZsXJBRWdLgHERnuvwxHzpVlsh8eEp7YMvmhEDwyijrKd2prO/I1 obRQmpDLuY/tl3pw7ai4Jzd2jXz91YXO4qpeM5+MoIWZPmaD3+X+ES/IWn/jQN1nPHMj 0pqh5h+/7cs0sGVlWSzfwvbrL48OtdPapcWLeUjxXRa9+25dG1tKocMUAO9yY0A/EFYW Q3z/fkb15eqIgE8YH8mAFdd6r05x/x/TyzN3yrSrfYTyBdrr45Ut/RuHXhPzbR2RISrG q7aQ== X-Gm-Message-State: AAQBX9ftEFtSeqWxjzeuRYFYINnXD2JFif1TPw8i6wPFpZv83V7QwKsc ID4PMwESP+Y5bqp1kH7rZNYZNA== X-Google-Smtp-Source: AKy350YHth252qyIm0iP2aK4H4VlwCudbFQW43tEfg1OGJTjpxxblyPzPb84KefAIx1qmHEj7Dh5nQ== X-Received: by 2002:a17:903:543:b0:1a3:cd4c:8d08 with SMTP id jo3-20020a170903054300b001a3cd4c8d08mr8468716plb.38.1681687121127; Sun, 16 Apr 2023 16:18:41 -0700 (PDT) From: Drew Fustini To: Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Nicolas Pitre , Adrien Ricciardi , =?UTF-8?q?Kornel=20Dul=C4=99ba?= Cc: Drew Fustini Subject: [RFC PATCH 5/8] hw/riscv: instantiate CBQRI controllers for an example SoC Date: Sun, 16 Apr 2023 16:20:47 -0700 Message-Id: <20230416232050.4094820-6-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230416232050.4094820-1-dfustini@baylibre.com> References: <20230416232050.4094820-1-dfustini@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=dfustini@baylibre.com; helo=mail-pj1-x102b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 16 Apr 2023 20:55:43 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @baylibre-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1681693073671100008 Content-Type: text/plain; charset="utf-8" From: Nicolas Pitre Instantiate a hypothetical CBQRI configuration for testing purposes with these properties: - L2 cache controllers - Resource type: Capacity - NCBLKS: 12 - Number of access types: 2 (code and data) - Usage monitoring not supported - Capacity allocation operations: CONFIG_LIMIT, READ_LIMIT - Last-level cache (LLC) controller - Resource type: Capacity - NCBLKS: 16 - Number of access types: 2 (code and data) - Usage monitoring operations: CONFIG_EVENT, READ_COUNTER - Event IDs supported: None, Occupancy - Capacity allocation ops: CONFIG_LIMIT, READ_LIMIT, FLUSH_RCID - Memory controllers - Resource type: Bandwidth - NBWBLKS: 1024 - MRBWB: 819 (80% of NBWBLKS) - Number of access types: 1 (no code/data differentiation) - Usage monitoring operations: CONFIG_EVENT, READ_COUNTER - Event IDs supported: None, Total read/write byte count, Total read byte count, Total write byte count - Bandwidth allocation operations: CONFIG_LIMIT, READ_LIMIT The memory map for the CBQRI controllers in this example SoC: Base addr Size 0x4820000 4KB Cluster 0 L2 cache controller 0x4821000 4KB Cluster 1 L2 cache controller 0x4828000 4KB Memory controller 0 0x4829000 4KB Memory controller 1 0x482A000 4KB Memory controller 2 0x482B000 4KB Shared LLC cache controller Signed-off-by: Nicolas Pitre Signed-off-by: Drew Fustini --- Note: this solution is not flexible enough for upstream inclusion. Future work will allow CBQRI controllers to be configured by command line options, and the controller will only be instantiated if the user specifies a valid configuration. hw/riscv/cbqri_example_soc.c | 124 +++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 hw/riscv/cbqri_example_soc.c diff --git a/hw/riscv/cbqri_example_soc.c b/hw/riscv/cbqri_example_soc.c new file mode 100644 index 000000000000..91240cdd105e --- /dev/null +++ b/hw/riscv/cbqri_example_soc.c @@ -0,0 +1,124 @@ +/* + * RISC-V Capacity and Bandwidth QoS Register Interface + * URL: https://github.com/riscv-non-isa/riscv-cbqri + * + * Copyright (c) 2023 BayLibre SAS + * + * This file contains an hypothetical CBQRI configuration instantiation + * for testing purposes. This ought to become configurable from the command + * line eventually. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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 f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/sysbus.h" +#include "target/riscv/cpu.h" +#include "hw/riscv/cbqri.h" + +/* + * Example hardware: + * + * - Global + * - Number of RCIDs - 64 + * - Number of MCIDs - 256 + * - L2 cache + * - NCBLKS - 12 + * - Number of access types - 2 (code and data) + * - Usage monitoring not supported + * - Capacity allocation operations - CONFIG_LIMIT, READ_LIMIT + * - LLC + * - NCBLKS - 16 + * - Number of access types - 2 (code and data) + * - Usage monitoring operations - CONFIG_EVENT, READ_COUNTER + * - Event IDs supported - None, Occupancy + * - Capacity allocation operations - CONFIG_LIMIT, READ_LIMIT, FLUSH_RC= ID + * - Memory controllers + * - NBWBLKS - 1024 + * - MRBWB - 80 (80%) + * - Usage monitoring operations - CONFIG_EVENT, READ_COUNTER + * - Event IDs supported - None, Total read/write byte count, + * - total read byte count, total write byte count + * - Bandwidth allocation operations - CONFIG_LIMIT, READ_LIMIT + * - Number of access types - 1 (no code/data differentiation) + * + * 0x04820000 Cluster 0 L2 cache controller + * 0x04821000 Cluster 1 L2 cache controller + * 0x0482B000 Shared LLC controller + * 0x04828000 Memory controller 0 + * 0x04829000 Memory controller 1 + * 0x0482A000 Memory controller 2 + */ + +#define CBQRI_NB_MCIDS 256 +#define CBQRI_NB_RCIDS 64 + +static const RiscvCbqriCapacityCaps example_soc_L2_cluster =3D { + .nb_mcids =3D CBQRI_NB_MCIDS, + .nb_rcids =3D CBQRI_NB_RCIDS, + .ncblks =3D 12, + .supports_at_data =3D true, + .supports_at_code =3D true, + .supports_alloc_op_config_limit =3D true, + .supports_alloc_op_read_limit =3D true, +}; + +static const RiscvCbqriCapacityCaps example_soc_LLC =3D { + .nb_mcids =3D CBQRI_NB_MCIDS, + .nb_rcids =3D CBQRI_NB_RCIDS, + .ncblks =3D 16, + .supports_at_data =3D true, + .supports_at_code =3D true, + .supports_alloc_op_config_limit =3D true, + .supports_alloc_op_read_limit =3D true, + .supports_alloc_op_flush_rcid =3D true, + .supports_mon_op_config_event =3D true, + .supports_mon_op_read_counter =3D true, + .supports_mon_evt_id_none =3D true, + .supports_mon_evt_id_occupancy =3D true, +}; + +static const RiscvCbqriBandwidthCaps example_soc_memory =3D { + .nb_mcids =3D CBQRI_NB_MCIDS, + .nb_rcids =3D CBQRI_NB_RCIDS, + .nbwblks =3D 1024, + .mrbwb =3D 1024 * 80 / 100, + .supports_alloc_op_config_limit =3D true, + .supports_alloc_op_read_limit =3D true, + .supports_mon_op_config_event =3D true, + .supports_mon_op_read_counter =3D true, + .supports_mon_evt_id_none =3D true, + .supports_mon_evt_id_rdwr_count =3D true, + .supports_mon_evt_id_rdonly_count =3D true, + .supports_mon_evt_id_wronly_count =3D true, +}; + +void example_soc_cbqri_init(void) +{ + riscv_cbqri_cc_create(0x04820000, &example_soc_L2_cluster, + "cluster 0 L2 cache controller"); + riscv_cbqri_cc_create(0x04821000, &example_soc_L2_cluster, + "cluster 1 L2 cache controller"); + riscv_cbqri_cc_create(0x0482B000, &example_soc_LLC, + "shared LLC controller"); + riscv_cbqri_bc_create(0x04828000, &example_soc_memory, + "memory controller 0"); + riscv_cbqri_bc_create(0x04829000, &example_soc_memory, + "memory controller 1"); + riscv_cbqri_bc_create(0x0482a000, &example_soc_memory, + "memory controller 2"); +} --=20 2.34.1