From nobody Tue Feb 10 00:59:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1649429282; cv=none; d=zohomail.com; s=zohoarc; b=h/y+eGIFleHrFhkuqdC9x0BlFLhLKItXdP8Jm5N9ow9ew6egbdxAMLoK0M+X8S+wcZ2vNvjAk89Q4a5h5nsnpWMI2sTr8HIcHRBGN4N/3M8b0J31MJJRTdGdy9JfbiJnXSZO5TO+kFrJKqWOde+ND+0kFGYX2z3hPnpcigivcsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649429282; 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=5zSoEvcrQQwqi7GYc6f0O7/9jPr6MDaUmhyGqTfq6Ic=; b=fN643tIqQuMw8D7cpu08+e+Din9gFbnmRFL2XCt5BzfEKP2jSiu9v8IHmS3UHROHyacKOmtZ91F0yKgCfUWQrGLfkMOEWgU/Ikl+8H7VPuo4e33EjaKjOITudjLXsAyuRBqkwlHrwY1xQXsJoc9d/6rtWOXBEbgaytG0Q75uv8I= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1649429282716974.3437218416419; Fri, 8 Apr 2022 07:48:02 -0700 (PDT) Received: from localhost ([::1]:47176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncpu5-0004GC-9e for importer@patchew.org; Fri, 08 Apr 2022 10:48:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncpPd-0007VE-GA for qemu-devel@nongnu.org; Fri, 08 Apr 2022 10:16:33 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:35813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncpPb-0002Uk-5W for qemu-devel@nongnu.org; Fri, 08 Apr 2022 10:16:33 -0400 Received: by mail-wr1-x42c.google.com with SMTP id w21so13101631wra.2 for ; Fri, 08 Apr 2022 07:16:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id i3-20020adffc03000000b0020616ee90dbsm11498849wrr.42.2022.04.08.07.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 07:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5zSoEvcrQQwqi7GYc6f0O7/9jPr6MDaUmhyGqTfq6Ic=; b=Pj1cJYTGUqBPF9V9k4dRX5TXxL4jk/EWBFUOzO/Ky8ZaJaBj08DP0v2Oy2MdJNm6ho 4cRCbvbIHV3oSp9CbFzDKBvi1UU9Xzp75ESDyhtMFBZFUoNdiVQ9hnNcUtiy/xxr6XXH oSZFrmz+LljeItSeDTY0lrrC/PZ/Ne/2WU6/5aTobA+ZAijh2HFqv5o2A7PolLgWnD3A eJ5z7a0ahQtIJbFgkMnuS3+ZeVQgdt4XWAmaceJ6rKVAPfhTz8ZFxlWr/sVU8VDJ6Mkb Ryj/wNCLnPh+w/hwMhukr9AXZFMNYMADqFKlpd4WJLEDDO6Y1jZ+nAIKKfi3SVqpDaVW bGog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5zSoEvcrQQwqi7GYc6f0O7/9jPr6MDaUmhyGqTfq6Ic=; b=6CSKfzIWG6I0J5B0EeE3zLwDQyVBKycbxTkzQMHeoJL416SUYj73PQenQYe6YAMbmU +15PYCvWjtfOxbjJ4q+vG377c6ig1GfRZW3Y6fuVRT6LMK4bVxcEm4gpTlCncYslJ+ut X0Pu1tqBdzme7TqiKvbTDiDaDjRplHS7iDmHbJfn8K2wKEiP1FTT/HxMe7goC65UvhFX P+FLYdvf6F8BFPtH2lv4erHLKAIf4dQEagECDQbjoeAOp5w3ktps3dYEKArX2zIZxvk0 XFU2MfPq7GsJK+CmH8XJDIG6tXI/O50PAuDMzqHtblj4dFPQeBOE0rE82wZ8o9GjDaQI dZuQ== X-Gm-Message-State: AOAM5319iWkfMaUEUTXmA9toCDw5wW9XSa1bSZdDwZF3GeT+o5Vau5hP yBZJ95mOeJMna3dbfwlRjYPywacBLZVy8Q== X-Google-Smtp-Source: ABdhPJzc8eYYVmq7+dfFNp434uhR7pRZ2sSNTTww/YRvDP9T1wyiTtc0lUN7/KPfc08u2EJGd1IA4A== X-Received: by 2002:adf:ea44:0:b0:206:1761:715a with SMTP id j4-20020adfea44000000b002061761715amr14798492wrn.534.1649427389843; Fri, 08 Apr 2022 07:16:29 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 40/41] hw/arm/virt: Abstract out calculation of redistributor region capacity Date: Fri, 8 Apr 2022 15:15:49 +0100 Message-Id: <20220408141550.1271295-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220408141550.1271295-1-peter.maydell@linaro.org> References: <20220408141550.1271295-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-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-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: , Cc: Marc Zyngier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1649429283005100001 Content-Type: text/plain; charset="utf-8" In several places in virt.c we calculate the number of redistributors that fit in a region of our memory map, which is the size of the region divided by the size of a single redistributor frame. For GICv4, the redistributor frame is a different size from that for GICv3. Abstract out the calculation of redistributor region capacity so that we have one place we need to change to handle GICv4 rather than several. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/hw/arm/virt.h | 9 +++++++-- hw/arm/virt.c | 11 ++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 7e76ee26198..360463e6bfb 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -185,11 +185,16 @@ OBJECT_DECLARE_TYPE(VirtMachineState, VirtMachineClas= s, VIRT_MACHINE) void virt_acpi_setup(VirtMachineState *vms); bool virt_is_acpi_enabled(VirtMachineState *vms); =20 +/* Return number of redistributors that fit in the specified region */ +static uint32_t virt_redist_capacity(VirtMachineState *vms, int region) +{ + return vms->memmap[region].size / GICV3_REDIST_SIZE; +} + /* Return the number of used redistributor regions */ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) { - uint32_t redist0_capacity =3D - vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; + uint32_t redist0_capacity =3D virt_redist_capacity(vms, VIRT_GIC_REDIS= T); =20 assert(vms->gic_version =3D=3D VIRT_GIC_VERSION_3); =20 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 594a3d0660a..577c1e65188 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -723,8 +723,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) } =20 if (vms->gic_version =3D=3D VIRT_GIC_VERSION_3) { - uint32_t redist0_capacity =3D - vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; + uint32_t redist0_capacity =3D virt_redist_capacity(vms, VIRT_GIC_R= EDIST); uint32_t redist0_count =3D MIN(smp_cpus, redist0_capacity); =20 nb_redist_regions =3D virt_gicv3_redist_region_count(vms); @@ -743,7 +742,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) =20 if (nb_redist_regions =3D=3D 2) { uint32_t redist1_capacity =3D - vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST= _SIZE; + virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); =20 qdev_prop_set_uint32(vms->gic, "redist-region-count[1]", MIN(smp_cpus - redist0_count, redist1_capacity)); @@ -2048,10 +2047,8 @@ static void machvirt_init(MachineState *machine) * many redistributors we can fit into the memory map. */ if (vms->gic_version =3D=3D VIRT_GIC_VERSION_3) { - virt_max_cpus =3D - vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; - virt_max_cpus +=3D - vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE; + virt_max_cpus =3D virt_redist_capacity(vms, VIRT_GIC_REDIST) + + virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); } else { virt_max_cpus =3D GIC_NCPU; } --=20 2.25.1