From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990599; cv=none; d=zohomail.com; s=zohoarc; b=I3x1bTvkxvyJ4kFccYjD56DNZtJKq3cBELXKAVzokKJj7jQnwp0vTYd3ifyQRik2gkcONknORLFeRDob7dvCDTyk5T41PTgTSNV0Q0L0BKlo6yB93SC8w7YD+XuZgU1Vkj4wZyMRbnBNu9eUeEJfZU9mg5WlNCh+8i0NF6Hajzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990599; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+AiU5u1szj4m62C8lzFgzOgJ+/Sqd4AxtmLtn0OIHZ8=; b=mHjZV6w7E5ROB1H9tXNHGH0l75ZkeVn+VGKaBGcbivKkzHbVzTUfuTBEnP1TGaHHSoF7aEjmsVLbOSzzt3hPYng7GGkRHnoWSOK5DzFVPSdzT3Xwe9ITraxUt95DvMn1ZUsfHzodccm4hH7iHKgtYnjhXrWLdklKOaqViTSyx60= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990599750278.5924999672127; Wed, 5 Aug 2026 21:29:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphn-0002rh-6W; Thu, 06 Aug 2026 00:27:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphb-0002pN-B4 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:32 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphZ-0003Bx-6W for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:31 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675Nb2ts4063270 for ; Thu, 6 Aug 2026 04:27:28 GMT Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv5x5kg9p-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:27 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e7b87ce77so1118181a91.0 for ; Wed, 05 Aug 2026 21:27:27 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= +AiU5u1szj4m62C8lzFgzOgJ+/Sqd4AxtmLtn0OIHZ8=; b=nZieFNdrmYCDvGJD +Lnxe/8uoesniQJ5fxCFiyIk8Fu6oPnFNN2vEX8blVfCzcdcnFSB6l5Z36rk+ax2 Nb87QTpUwziKVjf16h7+6r6mmn8f/6hxlg/OyhSDG8tobxjczNiv+kS54PGwal9b tRIscn6dT+pL2w6x8AMZxiXpx1Rz/0AALICWq6rG+RDc2DNuOfDPgC8uthjQDIn1 xigIgxOLazRrAOIMxWcgYbEqq79ZDEE5/JXqAkThLik/tkrYTivSvyQv7aK87WY3 H7i4dwMfwyQ835jyXawn/4PuBoKyMpHgagH+8IHvsl14/9H/XxraFMP1+lRr+hrF 11qj0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990447; x=1786595247; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=+AiU5u1szj4m62C8lzFgzOgJ+/Sqd4AxtmLtn0OIHZ8=; b=BG5eyMu4em0CZ8wd6VCXvHWmW9XByJVBzVikq4IFcEJmjYM+cegVaJ1d4dULo9hWxD /+3eopAP0De4Yec3HXLR0WOwi/6CTzmBdk+RxaAeH4kQXjAlE7omaUI96w2igqhCy67O 4NzUUsVz+bEh/OvKarmLXSKPOryKIt6WiTUPtiRGXHk1CA7KFb/u4cEN9k9yB6pxKSpb Lnm7P/Kbjw7PA94EaOCNZRzc/0sq4BH7PbA/E2ghohsI+VgpayjvfPMExb5TziDV6wsc /Rv1jqhR7TkMQnT3iOfyojLVY3eCzFMqmjfVUZblCjDEQJmnq845AxxHkcAYGg2IrsD4 4gXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990447; x=1786595247; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+AiU5u1szj4m62C8lzFgzOgJ+/Sqd4AxtmLtn0OIHZ8=; b=hsACtnznNloRXHObbbQwn0InUdkgDRUAZ/ay8XSwSwkxmfpb71cqHTDWRheFe0hIFl I2Z7xH4AqtSrEytF21lwCMMpAHe9BDPYRGf+DDo1/e3SqyhOzOq10O3xE0qmzRE0dBSX wiRuhpYtakRRG6Q1VgAlh0ZC6YrdF+FhI2PVvTmYiO0mrlwvTk5U2w/1rPD+ED3hJMz5 +0fjRW7DXR0SSGjOhZ032iD+u/DPNWBBaxYh8ihB9ICwOSEf+Agbw817sYUg/Oi2jIra GlssWOb5KPGeTvpMs7IK7qPXrpJzlJy9F4BoJ7W6kSBcSvqM076/BJIR0RZHhS30nTmU y8jQ== X-Gm-Message-State: AOJu0YzNJL3Z/9a2R4k+GdwR79FTw4pSwLyobJuKbR18+TE2OWd1vOhE qWPqd5IXXypTNpixWZDM/UrK/utXpjPm5BJqi/DQzJVCe64za5B+1cf3uqhbDnNLCALyRNgHDFy aTjcs4te1lV2KkARHSqRe7tcFdc8FjlGcAVe6vGFmCf2G3Rz6druUO9ZfZkJ8QCBBMA== X-Gm-Gg: AR+sD10eEACtFcFuWb/NouVZl16HT+fAog61NtKh6wr8zqvVyKBoaKc1if7dMq4hZ0x qrbyE96rcPMLTCBOZwn3qHdY5Nsc0/mGp6/lr+3omvJ+1vQxZJnBXfEDBIyHo2DJZRaPY/0Zq+V HfXzTyGLitG89EObogZv2yjbXzCqcGiB6iwvnsBCZD7kbQ5mR8/zZb8TIz/bM7cwKW8BuoQRGoU mfBT13CnkKnt9fQ/O2fIpmSGeSez1y89qqOhbs5wGtFT/fwLvLeEwFqmchjT5h/HTjmlYMgQ0ey Qhwz61DYKkBXsRLgnHsZ64QeWFlX7oR0svtt/Nfl7QDM8qibQSkoXhALjUq237sSIf3gZdMmHni 7TzpTz/1TtApLpM3mB04w6Ur9aRZ1uNsqGunAuRZTcNA/i6vH X-Received: by 2002:a17:90a:c88e:b0:38e:488f:7068 with SMTP id 98e67ed59e1d1-3903c5373b4mr13687744a91.2.1785990447104; Wed, 05 Aug 2026 21:27:27 -0700 (PDT) X-Received: by 2002:a17:90a:c88e:b0:38e:488f:7068 with SMTP id 98e67ed59e1d1-3903c5373b4mr13687698a91.2.1785990446592; Wed, 05 Aug 2026 21:27:26 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 01/18] hw/hexagon: add hex-subsys Date: Wed, 5 Aug 2026 21:27:06 -0700 Message-Id: <20260806042723.3785369-2-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX5qvfhdGatt3j 4u8lMPZ9Zl5wqnyOzqvxXkeU+fU09rZA9P8yW37O+ocZMYbOKX5Ir+cADLamXRYKRXdOUTVksre NSQx80pWiClRtje7MTiMiay9p4VUFsiJdWLUmAPOSzsftvWgvvABakyIfP5eqJFsDRnujkUSfO3 xkoj0KFtEbGh14wsEOH7kLmz7YOmR+J79AhV7wsdjM3ozPKzVotB1UgoBGEaKULDGsW1senWPuP 4YoCDBAh/iYqeeRc5pjMyVGqUW0Lo5yajvLvZhCVoSnEUjlI9jZrBL+XaWh49NaJVNSb/9ZgDKp z3ryDcU6TCCGcF2dT7sEvCC5qYDFnhQH4424NcocbFvZfyfVno/6srmkaBn2spi50nUVDwMYh6D BBgnOgTqn5yNUv8xDa5YTLztVRn8Hl5kt0J38+v0FvWZr6eX4R5lFO81160kA6VWOhvyCeHU48Z B73iC+BhAbntIphurdA== X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXzfhcWH/i1NUs ryjwqHyQqLH7ciWEOZR/hJ+xiomjH7i58gQFr2ugfFxZqCEYQmRtuFVcODRwAWlx9TMVN6dgpdI guGThNymmDPwsxQ6I7h81MGWxVdWNI4= X-Proofpoint-GUID: 4jKAVmnlmuMsJFunOx6pkwK_Sxe8KDOY X-Authority-Analysis: v=2.4 cv=cIbQdFeN c=1 sm=1 tr=0 ts=6a740d2f cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=8oo-Xqheu1KagxFlSIAA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-ORIG-GUID: 4jKAVmnlmuMsJFunOx6pkwK_Sxe8KDOY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 clxscore=1015 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990600558158500 The virt and DSP machine models build the same core subsystem, let's abstract out that part. Start with the DDR and config table ROM setup. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hex-subsys.h | 17 +++++++++++++++++ hw/hexagon/hex-subsys.c | 32 ++++++++++++++++++++++++++++++++ hw/hexagon/hexagon_dsp.c | 17 ++--------------- hw/hexagon/virt.c | 14 ++------------ hw/hexagon/meson.build | 1 + 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 include/hw/hexagon/hex-subsys.h create mode 100644 hw/hexagon/hex-subsys.c diff --git a/include/hw/hexagon/hex-subsys.h b/include/hw/hexagon/hex-subsy= s.h new file mode 100644 index 00000000000..6bcde303f2e --- /dev/null +++ b/include/hw/hexagon/hex-subsys.h @@ -0,0 +1,17 @@ +/* + * Hexagon subsystem helpers shared between the machine models. + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_HEXAGON_HEX_SUBSYS_H +#define HW_HEXAGON_HEX_SUBSYS_H + +#include "hw/hexagon/hexagon.h" + +/* Create the subsystem shared by every Hexagon machine. */ +void hex_subsys_create(HexagonCommonMachineState *hms, + const struct hexagon_machine_config *m_cfg); + +#endif /* HW_HEXAGON_HEX_SUBSYS_H */ diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c new file mode 100644 index 00000000000..d146ee0c075 --- /dev/null +++ b/hw/hexagon/hex-subsys.c @@ -0,0 +1,32 @@ +/* + * Hexagon subsystem helpers shared between the machine models. + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/hexagon/hex-subsys.h" +#include "hw/core/loader.h" +#include "system/address-spaces.h" + +void hex_subsys_create(HexagonCommonMachineState *hms, + const struct hexagon_machine_config *m_cfg) +{ + MachineState *machine =3D MACHINE(hms); + MemoryRegion *sysmem =3D get_system_memory(); + + /* Main DDR at the reset vector. */ + memory_region_init_ram(&hms->ram, NULL, "ddr.ram", machine->ram_size, + &error_fatal); + memory_region_add_subregion(sysmem, 0x0, &hms->ram); + + /* Config-table ROM and the blob that backs it. */ + memory_region_init_rom(&hms->cfgtable_rom, NULL, "config_table.rom", + sizeof(m_cfg->cfgtable), &error_fatal); + memory_region_add_subregion(sysmem, m_cfg->cfgbase, &hms->cfgtable_rom= ); + rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable, + sizeof(m_cfg->cfgtable), m_cfg->cfgbase, + &address_space_memory); +} diff --git a/hw/hexagon/hexagon_dsp.c b/hw/hexagon/hexagon_dsp.c index aa493993229..f94f7fd4e11 100644 --- a/hw/hexagon/hexagon_dsp.c +++ b/hw/hexagon/hexagon_dsp.c @@ -14,6 +14,7 @@ #include "hw/core/boards.h" #include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" @@ -108,7 +109,6 @@ static void hexagon_common_init(MachineState *machine, = Rev_t rev, { HexagonCommonMachineState *hms =3D HEXAGON_COMMON_MACHINE(machine); HexagonDspMachineState *dms =3D HEXAGON_DSP_MACHINE(machine); - MemoryRegion *address_space; DeviceState *glob_regs_dev; DeviceState *tlb_dev; =20 @@ -120,16 +120,7 @@ static void hexagon_common_init(MachineState *machine,= Rev_t rev, =20 machine->enable_graphics =3D 0; =20 - address_space =3D get_system_memory(); - - memory_region_init_rom(&hms->cfgtable_rom, NULL, "config_table.rom", - sizeof(m_cfg->cfgtable), &error_fatal); - memory_region_add_subregion(address_space, m_cfg->cfgbase, - &hms->cfgtable_rom); - - memory_region_init_ram(&hms->ram, NULL, "ddr.ram", - machine->ram_size, &error_fatal); - memory_region_add_subregion(address_space, 0x0, &hms->ram); + hex_subsys_create(hms, m_cfg); =20 glob_regs_dev =3D qdev_new(TYPE_HEXAGON_GLOBALREG); object_property_add_child(OBJECT(machine), "global-regs", @@ -162,10 +153,6 @@ static void hexagon_common_init(MachineState *machine,= Rev_t rev, OBJECT(tlb_dev), &error_fatal); qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal); } - - rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable, - sizeof(m_cfg->cfgtable), m_cfg->cfgbase, - &address_space_memory); } =20 static void init_mc(MachineClass *mc) diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index b7504725026..ad0bc4f1329 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -13,6 +13,7 @@ #include "hw/core/clock.h" #include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" @@ -244,9 +245,7 @@ static void virt_init(MachineState *ms) vms->apb_clk =3D clock_new(OBJECT(ms), "apb-pclk"); clock_set_hz(vms->apb_clk, 24000000); =20 - memory_region_init_ram(&vms->parent_obj.ram, NULL, "ddr.ram", - ms->ram_size, &error_fatal); - memory_region_add_subregion(vms->sys, 0x0, &vms->parent_obj.ram); + hex_subsys_create(&vms->parent_obj, m_cfg); =20 if (m_cfg->l2tcm_size) { memory_region_init_ram(&vms->tcm, NULL, "tcm.ram", m_cfg->l2tcm_si= ze, @@ -255,11 +254,6 @@ static void virt_init(MachineState *ms) &vms->tcm); } =20 - memory_region_init_rom(&vms->parent_obj.cfgtable_rom, NULL, - "config_table.rom", sizeof(m_cfg->cfgtable), - &error_fatal); - memory_region_add_subregion(vms->sys, m_cfg->cfgbase, - &vms->parent_obj.cfgtable_rom); fdt_add_hvx(vms, m_cfg); =20 gsregs_dev =3D qdev_new(TYPE_HEXAGON_GLOBALREG); @@ -302,10 +296,6 @@ static void virt_init(MachineState *ms) clk_phandle =3D fdt_add_clocks(vms); fdt_add_uart(vms, VIRT_UART0, clk_phandle); =20 - rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable, - sizeof(m_cfg->cfgtable), m_cfg->cfgbase, - &address_space_memory); - hexagon_load_fdt(vms); } =20 diff --git a/hw/hexagon/meson.build b/hw/hexagon/meson.build index bade3a32921..720a5d54dcc 100644 --- a/hw/hexagon/meson.build +++ b/hw/hexagon/meson.build @@ -1,6 +1,7 @@ hexagon_ss =3D ss.source_set() hexagon_ss.add(files('hexagon_tlb.c')) hexagon_ss.add(files('hexagon_globalreg.c')) +hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hex-subsys.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c')) =20 --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990487; cv=none; d=zohomail.com; s=zohoarc; b=TnyTYonTAXdlrXXuScjRZ0j38lM7zaTKWIloaCMVQLMOqJhkg179tyo1g6idtICiqT69ssPEZKHuIX3vGaoTTs+EmwxRioXr2UzRbUFWuQcgmA8RFBrJgGizgW+YJanQus41rwuv3d0r46k5NxyAADXTo/TeAjfLFE2hjjbtB9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990487; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ePXkyVxEno0JPHqjrZ3ngTZknDbEiohL6PsqlnyeIQU=; b=k5kPInytlOeLa8kZep1lD5C76L4l8C8KJ0c5K7LtOhhDFetCIwW0OLEWlwTYa6MHrkISyD9rvnHqxvPdHn2bkbIOAg3+NVaYRvZyOfQIPDHlM7YtzPTCMsgA6gU2A/dgtVKifgVYqy8ZqoYIncN8+78dk8+QSadD2p92nVtNqqo= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990486981579.7563791956776; Wed, 5 Aug 2026 21:28:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphk-0002r3-Qe; Thu, 06 Aug 2026 00:27:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphc-0002pQ-J7 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:32 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrpha-0003C4-Ua for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:32 -0400 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763wnku1070843 for ; Thu, 6 Aug 2026 04:27:29 GMT Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvjucg363-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:29 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38dbe39ce62so531767a91.0 for ; Wed, 05 Aug 2026 21:27:29 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ePXkyVxEno0JPHqjrZ3ngTZknDbEiohL6PsqlnyeIQU=; b=kvzlkc/qJ6qzuZm8 07qzZOcQHM+NfwsWvMaclinIg/1VpEXv5cZq5xpACW12Mr+XQptEBxONQ/ogq8WV YN/JziOPa7VaeD11XZy2e6CZMsXCea5HAJxYQH00UvKn6ElCl/XuKn2eSLTA8769 Z+n8gXk8YMhtunfD18k0njl98WJg/iYPMhiy9lGE7F1MuuJvf1bjm3CvBcomsSOA EFJeM2UPvu6znBmPf5Pis184SExUPfquceIxZ0BwsFWy997N14ndx6nYuEF+s3fA YCZjOdB8pcvoB0aEsrSJl8TjnMyKKLCvD8kP8hJ0b90Bek3Y3j3YLszHBkQMSlKE iOHymA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990448; x=1786595248; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=ePXkyVxEno0JPHqjrZ3ngTZknDbEiohL6PsqlnyeIQU=; b=dtZrWUoC95PfveY0EVMaCHFhOCuRuFTVLWv6NRnThdyHoZnYgNuIWzBe1wyCIQboPz YKIkg5sMnhFc/F+9OZ/cObLdT4ml+RbkV2XWN1bijQZ/Bc1X/sM5og6Ij2o6W0bHdIdf KxNUwZFhjRbLfTDMIEaSgMYmRaFa9jmu/dSx0i7M46xSgplWx/1pPR/mbdLoFAdVuP0J /kTCGhGUj66hmbO14t7qVf2i5nLe0pUJ/SP7cTPNLyMZu+ESYLsMf/yGfyITVWc94eqC m+LoOI+ZpDQ/lMFYSYF6u4qZqtB7zeWOT2WU5ckKtVsq2xi0q4p98C/NTJlyGcNqEfm2 T2XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990448; x=1786595248; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ePXkyVxEno0JPHqjrZ3ngTZknDbEiohL6PsqlnyeIQU=; b=lzmxS936OrROSqBtmvj1GuHzEcbENSc/JfMcdNoOdK7A14HOzYxe6FrNUHMy2yv5dX HHzeNyPEF+OXK0DWDScZkycsj+ory9DbTcN3//brtlKctcMksusVzCrKT5gqIwYgReBj Rscd8llHJTn8dHFHaf+8qHReppuGfENsKAe/L9NHXpgNKfAypBMskhEl5M4iOJHf+CYQ B5TBGNKtHjWW9Oc0FGKXsP+jy1hDfwU7aW/MCFYM4ZHh7pLUd3FtbPJqy9od+UEcqrn3 e3+np3Azx+J3ZVQvIjm3blBo0LNIXZ6WLJAIj9/A7kTXN+qLLliNLT2MaOddWwUhE7uJ WDUw== X-Gm-Message-State: AOJu0YwsrA7whGKBaFeoFY0TWHTnjcWPvA7MUh3ajF+AjgwA12jO6Vi4 hSF3wNWzPOyrXCb8VD3mGIpFi8qEUkBhPlRbuVgm/6XydH2DxWvefeqbpOM9Jqk9oTC0XcdhojO C9Gd91FY9l4E2c+elnxXMMVSo06x9GWKjguQvcVDu1k3n+F5Il138FootqX8Xq0U7HA== X-Gm-Gg: AR+sD12ylSmxxFMfPXhT/HRJ/9ZAIuJrvRFiBWw6GGYSE6ESCpvVzjRejEOpePAhKCs 2aJ5Vhzww9lnfXHCa3x8G2fqXeN1x1Y0i4wWrgc3OQwYTRRgFFzHPlz6CoNzNaEywEOc0ZFQgk7 vcsEk4Pks3pwH6HwtkUI9A81UOWzAp658aY3/cwF1QgCY/Rcn+d1nmQsT70W+cdrwknt8ykYJiJ BgSCoKBZHAQv3DQ9TMm7GJh8euxbRro9+MbY2l87EmrKQuF7ZJR7Cj9CIGQKskH7pDCn7dZjuaV veYlFy1lYHxrX66j1N68HmELXIWe3+MQO99GLFaIPzDkD/gyBywaTFKMwBgPY9P+d6NaTcanqzY ZhG1XioLzM1YK3JmIOSkuqzIMHzSaB+YKx3CNpDP0gAG6bgyu X-Received: by 2002:a17:90b:578f:b0:380:86d8:8162 with SMTP id 98e67ed59e1d1-39083b3dab1mr2221597a91.18.1785990448419; Wed, 05 Aug 2026 21:27:28 -0700 (PDT) X-Received: by 2002:a17:90b:578f:b0:380:86d8:8162 with SMTP id 98e67ed59e1d1-39083b3dab1mr2221576a91.18.1785990447984; Wed, 05 Aug 2026 21:27:27 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 02/18] hw/hexagon: move VTCM to the common machine state Date: Wed, 5 Aug 2026 21:27:07 -0700 Message-Id: <20260806042723.3785369-3-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX1dfewhbu53lI aDWl0cUY1M9mzlBQUl6JHjkH3sRhQBW6Ux+r7d//UZRufOTFIemsihQNHzodBcHZZCLC3dm49AR OGFpOTdsQfqlUWKoWSLw2aXOw7LAHTY= X-Proofpoint-GUID: 8U7gSWiCQAujNGAgHf5OCInv-5OS2ihb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX19UoJiWNr5cV wMSnuAtH9cQYnhsUyYpqn/6bkNQzisKKgqnJF9BunQbPowtmyUdF3vbjPCB89N8jM6HwYeZbpOU 2f8c6bokQxNZOkvgizhmwhxvd/7+zXc38e8Q0hjUfObgQZqBDzVi2Gy8t9XYWUcKdRfqdEMQ3Qx IvAWCuF5/B9D25EG5o9MIZLnSKtKopI6BLrDgUIKv8YGlNu1jvY6cPBxvPK22wHL4xBf/0STNGT ra7vkdhkiyZGTVzFxFI8GXqna8xOf+T/YUFueN+gDZqeFqINI0TmFCj8h4TgQL0Ko+Xizg+z/J6 AOXja1Uor4JF0MYLNliviESSgIfDyGfLqJXcTqAwX2go/1tqaRNe4K5kLtqjs2kttgVUQQpIX4Z mmePsijOWDpQIVNseWsfDnpdtY6vazOJjI4b33ufRtk7Kxbp/Ugsd487UmqZFCNByA1lvRnFWD4 nFde8fNCbDIMqjf2NLw== X-Authority-Analysis: v=2.4 cv=Mo1iLWae c=1 sm=1 tr=0 ts=6a740d31 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=31cAqr7vU2O6cbMaemAA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-ORIG-GUID: 8U7gSWiCQAujNGAgHf5OCInv-5OS2ihb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 adultscore=0 malwarescore=0 bulkscore=0 clxscore=1015 suspectscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990488515158500 The VTCM is described by the config table, so every machine can set it up the same way. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/virt.h | 1 - hw/hexagon/hex-subsys.c | 8 ++++++++ hw/hexagon/virt.c | 5 ----- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h index 1034b09c2ac..9c73cadb16d 100644 --- a/include/hw/hexagon/hexagon.h +++ b/include/hw/hexagon/hexagon.h @@ -156,6 +156,7 @@ struct HexagonCommonMachineState { =20 MemoryRegion ram; MemoryRegion cfgtable_rom; + MemoryRegion vtcm; }; =20 #endif diff --git a/include/hw/hexagon/virt.h b/include/hw/hexagon/virt.h index fcb47762194..cf0cd2f8f22 100644 --- a/include/hw/hexagon/virt.h +++ b/include/hw/hexagon/virt.h @@ -17,7 +17,6 @@ struct HexagonVirtMachineState { int fdt_size; MemoryRegion *sys; MemoryRegion tcm; - MemoryRegion vtcm; MemoryRegion bios; Clock *apb_clk; }; diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c index d146ee0c075..0c20cf02e7d 100644 --- a/hw/hexagon/hex-subsys.c +++ b/hw/hexagon/hex-subsys.c @@ -29,4 +29,12 @@ void hex_subsys_create(HexagonCommonMachineState *hms, rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable, sizeof(m_cfg->cfgtable), m_cfg->cfgbase, &address_space_memory); + + if (m_cfg->cfgtable.vtcm_size_kb > 0) { + memory_region_init_ram(&hms->vtcm, NULL, "vtcm.ram", + m_cfg->cfgtable.vtcm_size_kb * 1024, + &error_fatal); + memory_region_add_subregion(sysmem, m_cfg->cfgtable.vtcm_base << 1= 6, + &hms->vtcm); + } } diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index ad0bc4f1329..53eaafaf85a 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -75,11 +75,6 @@ static void fdt_add_hvx(HexagonVirtMachineState *vms, const MachineState *ms =3D MACHINE(vms); uint32_t vtcm_size_bytes =3D m_cfg->cfgtable.vtcm_size_kb * 1024; if (vtcm_size_bytes > 0) { - memory_region_init_ram(&vms->vtcm, NULL, "vtcm.ram", vtcm_size_byt= es, - &error_fatal); - memory_region_add_subregion(vms->sys, m_cfg->cfgtable.vtcm_base <<= 16, - &vms->vtcm); - qemu_fdt_add_subnode(ms->fdt, "/soc/vtcm"); qemu_fdt_setprop_string(ms->fdt, "/soc/vtcm", "compatible", "qcom,hexagon_vtcm"); --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990594; cv=none; d=zohomail.com; s=zohoarc; b=XO2a0aTZ8YCECT8Bq7o+8fToWKlaO9m8tlm6gIKtD20hIHTGbx2ZREkPwU9teDIHe8FCD+Nsg7q4fgTl7degO8byqXEWQcXpupDhMembXqauLZ5fwhyjikDgoWqX6EI80kEj5Wr5C/F6BQHrRbn+r8o+9ZCrKtcbCjUATR5bfy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990594; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g1tiyLQ3EKrlQ/RaE8cv4ghdv2DywA6xfpNa3o6wXb8=; b=kfhcNZAJ75n0ZsHXWNYV2N2sECqvM3MzKfOOJA/+Rv6EixtXwsMbwKbSKcpWsAWPxLQ7ryvXcoiQ8YP4ZxtcCcs3nxMdBh2Yx7hMkRl3ogawOK5NnQTK0Zpp3apqwRpj8IjNPlIgk++3ULDyaaii2W4EtC+YcIUgo/MT8KxWHZk= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178599059428314.12986484625867; Wed, 5 Aug 2026 21:29:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphn-0002rW-0z; Thu, 06 Aug 2026 00:27:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphe-0002pn-C7 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:34 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphc-0003CO-Cj for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:34 -0400 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763wXm8775152 for ; Thu, 6 Aug 2026 04:27:31 GMT Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvju8g348-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:31 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-38e54b6556aso2008493a91.2 for ; Wed, 05 Aug 2026 21:27:30 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= g1tiyLQ3EKrlQ/RaE8cv4ghdv2DywA6xfpNa3o6wXb8=; b=Cn+iy/1eAmO0so2I JBncy9pq4zUpjQWCqUprgJRscVKpoEdwG6iadTlG/Dtj4f89iwmTlIbHFgnfLw4q 6zYWA7VzUnTOD5bjjiqKzAnfo0xa1hq0RiKo741S4j0Yqn3DHvSyZ8iYtg2qNdZO VB0BCc5fIt8KIXrNXmASOiZiXZaF7RuVnZTwvpWkq1Csa1MjCDH7HhlAmtBDwmNr texpjIe3+b6yiAoIgQrlJd9NOTWlrOIrBL8Lsmz0GXMlMOnbWgbdb1jd6D9qKSI5 GD90MpJMKXZUE0733CMzHqSysKdS3GELrfOkVKK5stvmjZxxY/eNt13+HM71YI// xZXVSw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990450; x=1786595250; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=g1tiyLQ3EKrlQ/RaE8cv4ghdv2DywA6xfpNa3o6wXb8=; b=AibbCDxLAJ7xRq6Q7sUbrUT2+5RNuLscoMuypC6+loQBGTXtxjC3yh/rGeuQ0lZeW/ RH4QSxYrfXvGFsWxM0YCgGiAxmLEnXHEAZCpP/4WiSRnn4cVL9mbobTN7KxeJ7qkCMu2 mLwrrOUpNSuUATVaAdZHjmui3dXKHE+sXtE47dTXEq4DgWoiEr70T4ndDS1rlmBCLa0r fG2ROjB6yBblLcC0PAh4o5cOu0hhp4IHnULQjUdWmkTARIN4W1OHhuUKSCA6KrDqsFEf bDcFkhNFfdIbIZarhh4f31PXCaCazTTytwJ9O8Nxuz8zLO7o2vNMtY0xwEEO3QvzcUV0 cutQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990450; x=1786595250; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=g1tiyLQ3EKrlQ/RaE8cv4ghdv2DywA6xfpNa3o6wXb8=; b=eJk2pXCihGWb2bWniAQVOeVS0UOdc5qmQrJh0BmWkefziRHjz0Zsvbn13Febiqjg8p 21JkpX4Q1zfLW2VQZ9Ppf2rD1bZQejOFcm7IcDkudFfqqTSvmBOKDpo1OnjcJ0TP9XR5 ReuqWW/obKOdYnaiv+P8EgYjQapmTqdMVIGOXDwBPvUcTE7wB6/y9LjH3RtC2wgk4W5e t+s/kJAhitBnKWT4pEhylD1oGNx8uLCjS+UKc3DSBN330ZjzjAzUf+5v3uAgwFOKw19I RVckhPKZ/7y65TTkmbbdpTPUaEaqieP7eeim40w+FEYECrop/ccE8+fZrtx7fO2TFF9R HNzw== X-Gm-Message-State: AOJu0Yzb2M+V9z9ItHMgDDZ+no4Spr+4357NTGiAsc+yYY3Y0LGnjZOH bGHt3oBOHCOpg1RI7km/bydD6BAcnuGKgwf9mc2Pr+Pr0ASQwnH19XDrhxUMd3ccO3ztEM5ib4g lzqlFm6B7UOnYvjiMmJrO28Kh61apc6jSt0UCnVu2nTypJn3622Y7ift8baU+PHGQOg== X-Gm-Gg: AR+sD13P9IM1+EgEXZQrkQNGlUnxZ8Dtb3xyQ21ldj1jPei378nmGMopKRGy2FjZf24 YxbFwOcQMiDhJz4wiVbcMW4AXqZMO+Z7xz1WNZIEJWngWgYTbx1KbCmRriUJAwQIjl3KT8dX9Zs miWt1FnfG8Ky8iNx4PMXtwykq+SvjEX6ZdkJhmq8JO4srKvzteOWiGlkdXmfCmTT9m8ISBfmGHR 5F5iI4TiK0yEzzgAOltFkD3LffgqmvvSwRfs+34a7Mb9XNxmDfjTW2A+1eeMH7kTPGWtRPTrcWK lzWdzZscGw7iH9OXmCiNBjAZqv9nDQKCQgaC+Go8o/K/PLBnZ/SYVCV/BgcxASVQPLNElvY5/s5 1/0Pk+EUJ+BtKl+2kOc6GlizF8npo5eRO0O5nlpLHJICi9zd6 X-Received: by 2002:a17:90b:2d84:b0:38e:11ba:992c with SMTP id 98e67ed59e1d1-3903c58ece8mr11977613a91.12.1785990449905; Wed, 05 Aug 2026 21:27:29 -0700 (PDT) X-Received: by 2002:a17:90b:2d84:b0:38e:11ba:992c with SMTP id 98e67ed59e1d1-3903c58ece8mr11977574a91.12.1785990449382; Wed, 05 Aug 2026 21:27:29 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 03/18] hw/hexagon: move global registers to hex-subsys Date: Wed, 5 Aug 2026 21:27:08 -0700 Message-Id: <20260806042723.3785369-4-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: F4tzMGDigjfI6l9o17wtbs5svxdpC92G X-Proofpoint-ORIG-GUID: F4tzMGDigjfI6l9o17wtbs5svxdpC92G X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX8WAQQWoAb5M6 ADiY1T71MuV+BOXYi7dbHcf2is56KFt0w0KuTKNnpfBP188sLv/zLgDT+sh4BvnNtWQlMsXmxOr bIF2wuEzQ+Nyn/bQ/nUA6r+wr05DaRAGFPxu8U0yNR/ZrwDvOkFraVrypvjEgcCU2763LJkel4d +2R51FLOy6Qs2ghG95BXyJETn8/F0BiX45B4FVetkx7VSwM08jvtWriH2KQ6rwfFU4V6hE+DWQ1 frJFgJCEPbk0yK1QW8dLuxlON0ngaVY6GZhS8okV0mj8i995C+B5kRkuIpnUCFPFmnAlKBe/i2Q brd33pWL7r5Z5AevBxlaLf3UCdW5TmXupj3q3Q0KBqo63sNwocd9AlnVaibAlH7uOwpwoz16kxU PsuLwqCL5F9+sZ8n2PNsi/8teswSVkqAOmfQP9ZA582CaPtAbEaPsCqiW7+Iqnn5HAr1vh6ecXD fP1gf54yjKhRX7oZlFw== X-Authority-Analysis: v=2.4 cv=K5cS2SWI c=1 sm=1 tr=0 ts=6a740d33 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=T2wWRslM62IwIIzloqEA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX8yejddNRLPLr apr7mCczt1710e8Lc6h1St3Ok1w1jftpug+ptnzQ3twazUqV9+zHir/S9FN8OKhno624Nrxe82z 78PuRA73lZPofQlcis54EVxsj3yw4tM= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990594530158500 Both machines create the global register device the same way, so let hex-subsys own it and link it to each CPU as it is realized. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hex-subsys.h | 6 +++++- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 29 ++++++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 15 ++------------- hw/hexagon/virt.c | 23 +++++------------------ 5 files changed, 41 insertions(+), 33 deletions(-) diff --git a/include/hw/hexagon/hex-subsys.h b/include/hw/hexagon/hex-subsy= s.h index 6bcde303f2e..087c105cfa4 100644 --- a/include/hw/hexagon/hex-subsys.h +++ b/include/hw/hexagon/hex-subsys.h @@ -9,9 +9,13 @@ #define HW_HEXAGON_HEX_SUBSYS_H =20 #include "hw/hexagon/hexagon.h" +#include "hw/core/qdev.h" =20 /* Create the subsystem shared by every Hexagon machine. */ void hex_subsys_create(HexagonCommonMachineState *hms, - const struct hexagon_machine_config *m_cfg); + const struct hexagon_machine_config *m_cfg, Rev_t r= ev); + +/* Realize a CPU into the subsystem. */ +void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu); =20 #endif /* HW_HEXAGON_HEX_SUBSYS_H */ diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h index 9c73cadb16d..ef5700082cc 100644 --- a/include/hw/hexagon/hexagon.h +++ b/include/hw/hexagon/hexagon.h @@ -157,6 +157,7 @@ struct HexagonCommonMachineState { MemoryRegion ram; MemoryRegion cfgtable_rom; MemoryRegion vtcm; + DeviceState *glob_regs; }; =20 #endif diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c index 0c20cf02e7d..6789b6bb23d 100644 --- a/hw/hexagon/hex-subsys.c +++ b/hw/hexagon/hex-subsys.c @@ -8,11 +8,29 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/hexagon/hex-subsys.h" +#include "hw/hexagon/hexagon_globalreg.h" #include "hw/core/loader.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/qdev.h" +#include "hw/core/sysbus.h" #include "system/address-spaces.h" =20 +static DeviceState *globalreg_create(HexagonCommonMachineState *hms, + const struct hexagon_machine_config *= m_cfg, + Rev_t rev) +{ + DeviceState *glob_regs =3D qdev_new(TYPE_HEXAGON_GLOBALREG); + + object_property_add_child(OBJECT(hms), "global-regs", OBJECT(glob_regs= )); + qdev_prop_set_uint64(glob_regs, "config-table-addr", m_cfg->cfgbase); + qdev_prop_set_uint32(glob_regs, "dsp-rev", rev); + sysbus_realize_and_unref(SYS_BUS_DEVICE(glob_regs), &error_fatal); + + return glob_regs; +} + void hex_subsys_create(HexagonCommonMachineState *hms, - const struct hexagon_machine_config *m_cfg) + const struct hexagon_machine_config *m_cfg, Rev_t r= ev) { MachineState *machine =3D MACHINE(hms); MemoryRegion *sysmem =3D get_system_memory(); @@ -37,4 +55,13 @@ void hex_subsys_create(HexagonCommonMachineState *hms, memory_region_add_subregion(sysmem, m_cfg->cfgtable.vtcm_base << 1= 6, &hms->vtcm); } + + hms->glob_regs =3D globalreg_create(hms, m_cfg, rev); +} + +void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu) +{ + object_property_set_link(OBJECT(cpu), "global-regs", + OBJECT(hms->glob_regs), &error_fatal); + qdev_realize_and_unref(cpu, NULL, &error_fatal); } diff --git a/hw/hexagon/hexagon_dsp.c b/hw/hexagon/hexagon_dsp.c index f94f7fd4e11..8599f5883bf 100644 --- a/hw/hexagon/hexagon_dsp.c +++ b/hw/hexagon/hexagon_dsp.c @@ -15,7 +15,6 @@ #include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "qapi/error.h" @@ -109,7 +108,6 @@ static void hexagon_common_init(MachineState *machine, = Rev_t rev, { HexagonCommonMachineState *hms =3D HEXAGON_COMMON_MACHINE(machine); HexagonDspMachineState *dms =3D HEXAGON_DSP_MACHINE(machine); - DeviceState *glob_regs_dev; DeviceState *tlb_dev; =20 memset(&hexagon_binfo, 0, sizeof(hexagon_binfo)); @@ -120,14 +118,7 @@ static void hexagon_common_init(MachineState *machine,= Rev_t rev, =20 machine->enable_graphics =3D 0; =20 - hex_subsys_create(hms, m_cfg); - - glob_regs_dev =3D qdev_new(TYPE_HEXAGON_GLOBALREG); - object_property_add_child(OBJECT(machine), "global-regs", - OBJECT(glob_regs_dev)); - qdev_prop_set_uint64(glob_regs_dev, "config-table-addr", m_cfg->cfgbas= e); - qdev_prop_set_uint32(glob_regs_dev, "dsp-rev", rev); - sysbus_realize_and_unref(SYS_BUS_DEVICE(glob_regs_dev), &error_fatal); + hex_subsys_create(hms, m_cfg, rev); =20 tlb_dev =3D qdev_new(TYPE_HEXAGON_TLB); object_property_add_child(OBJECT(machine), "tlb", OBJECT(tlb_dev)); @@ -147,11 +138,9 @@ static void hexagon_common_init(MachineState *machine,= Rev_t rev, if (i =3D=3D 0) { hexagon_init_bootstrap(dms, cpu); } - object_property_set_link(OBJECT(cpu), "global-regs", - OBJECT(glob_regs_dev), &error_fatal); object_property_set_link(OBJECT(cpu), "tlb", OBJECT(tlb_dev), &error_fatal); - qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal); + hex_subsys_realize_cpu(hms, DEVICE(cpu)); } } =20 diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index 53eaafaf85a..290783d511f 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -14,7 +14,6 @@ #include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" @@ -226,9 +225,7 @@ static void virt_init(MachineState *ms) { HexagonVirtMachineState *vms =3D HEXAGON_VIRT_MACHINE(ms); const struct hexagon_machine_config *m_cfg =3D &v68n_1024; - DeviceState *gsregs_dev; DeviceState *tlb_dev; - DeviceState *cpu0; int32_t clk_phandle; =20 create_fdt(vms); @@ -240,7 +237,7 @@ static void virt_init(MachineState *ms) vms->apb_clk =3D clock_new(OBJECT(ms), "apb-pclk"); clock_set_hz(vms->apb_clk, 24000000); =20 - hex_subsys_create(&vms->parent_obj, m_cfg); + hex_subsys_create(&vms->parent_obj, m_cfg, v68_rev); =20 if (m_cfg->l2tcm_size) { memory_region_init_ram(&vms->tcm, NULL, "tcm.ram", m_cfg->l2tcm_si= ze, @@ -251,42 +248,32 @@ static void virt_init(MachineState *ms) =20 fdt_add_hvx(vms, m_cfg); =20 - gsregs_dev =3D qdev_new(TYPE_HEXAGON_GLOBALREG); - object_property_add_child(OBJECT(ms), "global-regs", OBJECT(gsregs_dev= )); - qdev_prop_set_uint64(gsregs_dev, "config-table-addr", m_cfg->cfgbase); - qdev_prop_set_uint32(gsregs_dev, "dsp-rev", v68_rev); - sysbus_realize_and_unref(SYS_BUS_DEVICE(gsregs_dev), &error_fatal); - tlb_dev =3D qdev_new(TYPE_HEXAGON_TLB); object_property_add_child(OBJECT(ms), "tlb", OBJECT(tlb_dev)); qdev_prop_set_uint32(tlb_dev, "num-entries", m_cfg->cfgtable.jtlb_size_entries); sysbus_realize_and_unref(SYS_BUS_DEVICE(tlb_dev), &error_fatal); =20 - cpu0 =3D NULL; for (int i =3D 0; i < ms->smp.cpus; i++) { HexagonCPU *cpu =3D HEXAGON_CPU(object_new(ms->cpu_type)); qemu_register_reset(do_cpu_reset, cpu); =20 if (i =3D=3D 0) { - cpu0 =3D DEVICE(cpu); if (ms->kernel_filename) { uint64_t entry =3D load_kernel(vms); - qdev_prop_set_uint32(cpu0, "exec-start-addr", entry); + qdev_prop_set_uint32(DEVICE(cpu), "exec-start-addr", entry= ); } else if (ms->firmware) { uint64_t entry =3D load_bios(vms); - qdev_prop_set_uint32(cpu0, "exec-start-addr", entry); + qdev_prop_set_uint32(DEVICE(cpu), "exec-start-addr", entry= ); } } qdev_prop_set_uint32(DEVICE(cpu), "htid", i); qdev_prop_set_bit(DEVICE(cpu), "start-powered-off", (i !=3D 0)); - object_property_set_link(OBJECT(cpu), "global-regs", - OBJECT(gsregs_dev), &error_fatal); object_property_set_link(OBJECT(cpu), "tlb", OBJECT(tlb_dev), &error_fatal); - - qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal); + hex_subsys_realize_cpu(&vms->parent_obj, DEVICE(cpu)); } + fdt_add_cpu_nodes(vms); clk_phandle =3D fdt_add_clocks(vms); fdt_add_uart(vms, VIRT_UART0, clk_phandle); --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990577; cv=none; d=zohomail.com; s=zohoarc; b=Ks5yitK4b7e7L6fIdltaAYpO96SugBEWh4hMjpMEgJkfmo3JzQdP2XeST52FJg6OxmaH75Z/uVqzmJbT8QgigdPXb5cGZWKjqZmchHJClbHXBKzo7zojqBOjJTmn131xf+xK6yuezS7A+ZR4ByHweCGzlJz53nphRfr6YvuN4XY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990577; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tOukWTJNy11ihKe0HGTFZQymqy/N77aZU0OGWHRrnP0=; b=TWk+d0PyTuPglIZ72bOyOhpycRwJAoTcD5i1ZSZbsGxZwKnBMY/JCZTt//VwB0oyoR01QIrP5bVo9TQu7YlhkqIRxR8DaBtvitdc5Dsuq1xFb8psDPJarubV6Oz++xg4BP/xFtPABQFrDTWun0YVY3TkpHZAm7QyzEoUZyMKj8U= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990577956105.26698647409341; Wed, 5 Aug 2026 21:29:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphl-0002r7-1w; Thu, 06 Aug 2026 00:27:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphf-0002q0-Dh for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:36 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphd-0003CX-A2 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:34 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675NbDZu267108 for ; Thu, 6 Aug 2026 04:27:32 GMT Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv3w6c1j0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:31 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cb835525b10so2185009a12.2 for ; Wed, 05 Aug 2026 21:27:31 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= tOukWTJNy11ihKe0HGTFZQymqy/N77aZU0OGWHRrnP0=; b=XlJGOqvOvCx1HhMO lPWKlO9JVnwp9kfCkSnXkPKkFITsfTpFJi+Xb9R1WXyOR6mPS9uxwlkIwC2msvHw LiIfhyl8DABlJ9S/aug/ZMEY3c8sglVE0f43Yt/J2p64ovcDttwqNhcvWZaJr+bd GpO1Sr2oG/IEqJeZFizBCroYiuYw4mHfQc5Nc+rxeKVAf04Qg0OKuVrhdkdUDutA BzceTKn/rrvNvPSMEK2n14llUt7I3szx9YaX96ia2fR7TXzcOv7elW1vKjHK0SXz fV/ZwM2SUUm6i40EhUY+CiiWBBNcQ+DXRR1pEdLu2C7HuuMD3bDu7ogSb6rlOa4i BeAUxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990451; x=1786595251; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=tOukWTJNy11ihKe0HGTFZQymqy/N77aZU0OGWHRrnP0=; b=kTBiC1PTWW6gQUserE4FG6eUqeMPKCcZ1pWCh4p+U1ZJ6hzB8aCmU96HHCc5XaKkCM T/bVh1Fy6qG6uM3BzlUrOsDMEHE98gLpMemQxcIYHqeFPuiHY6AhgOApBcY7bT0EV3O4 5ME1t9wGu7yvn05V2garUut56iQwaO8RqOBwlLtw0DDQQYWS6LvUJZpILp8BTI+WCt3H HVyX1SXqH56Qn4iHBF5wyZBG3p5q4GTWC/12i9epEgEUQpeGnSj0mJBsFBZoY8nTwWO/ ual351dUYV+29d76tSm/poYuhH9OfTDvIdaMcw0/WqaLM01wta8vYEevyO3w8aky7+L3 QmNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990451; x=1786595251; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tOukWTJNy11ihKe0HGTFZQymqy/N77aZU0OGWHRrnP0=; b=e6oPt7fEOSr5OYhlmxTduey8JSSFsDA5K9WjuWxde4poPuMFRPSFsoXwqKs/cns2lj dKS9asgVOYF67votQ93tvvXyYjN6KFblLfybBeTedUZMCLdZNGbMGZdmdrw0bGG62+3s vow/izLEEbgTbhu1FI1tpevNe/fq8kwBS5F5IxyFyinFc4VqETMHxtnglf3EOBawoaud VDULmdJmKbR9SPQEw0SLAJZ+kopszauutbBCXgwHgRunO582ORY6yMWHBU2DDalKq2rZ N4y6tV7+FFwLOtpAHf2d6CfhfR6uYxd0v0kh9QDBrpiYBG3SfMOGPBXnq9DOwcrn7MM9 FJbg== X-Gm-Message-State: AOJu0Yz9CE9Y7Rwrr7rlzVI6ZAlD4Cc1s1+toUI1Dg/MLbenblVhiIQa +AN+FvUzGWMQdpQsHS5dYmB6wwL2sKlGBe6Et6bRtMuHrThawITGvsDOGrT1Lcq/kl5b/UxgOU5 AYCVhNCZuzbKTy/NnAaO4UMll5Ng++sfHepUg11WrEMdGtOj9sqfRvNcmvZXbj0V/Kg== X-Gm-Gg: AR+sD13NoslbFesg1yz52QSkyPpNlEZjWMifS5LK49sjt9KDIKJOo4vQu5Ehy8ZoIiF Vg4L5HsReN9VAFw3rF3Jnd+2shRo7JHQr0jOIxVdTadP7pvXhXC1Lx4FGaJRzBtxtgeP/xKTjMX k5WrCe77DdZ7J5+6YmEnYyTNskvfmpOeNqIpAU0vhP88txGhMqhH6iJOS2+nvRdX7J9S/GqhWo9 BiRS1rLNW62mMt1ef27QE+zTX7WHFGo5pe+iJjnBEGAdlJpRBwSEmFNdJ67389fp1ELQtBHPjAV 8aeRJhEFFECDZIwn6fRamaFNjcvrRVZDWV5aRBjUsvjwP/ElIYg3bZfMuF6gU3NyVYF5f2z0GCC Eij1i3V29THtXBfy/OjvrWRK3gCLxM2dHTb7HarTzHVZ1MMSF X-Received: by 2002:a05:6a21:70c8:b0:3c3:b226:f165 with SMTP id adf61e73a8af0-3cb8603af69mr13575068637.35.1785990451271; Wed, 05 Aug 2026 21:27:31 -0700 (PDT) X-Received: by 2002:a05:6a21:70c8:b0:3c3:b226:f165 with SMTP id adf61e73a8af0-3cb8603af69mr13575014637.35.1785990450784; Wed, 05 Aug 2026 21:27:30 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 04/18] hw/hexagon: move the TLB to hex-subsys Date: Wed, 5 Aug 2026 21:27:09 -0700 Message-Id: <20260806042723.3785369-5-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: vw-mKuuNnFwefkMGmDqq7ywXzlpDb34p X-Proofpoint-ORIG-GUID: vw-mKuuNnFwefkMGmDqq7ywXzlpDb34p X-Authority-Analysis: v=2.4 cv=a48AM0SF c=1 sm=1 tr=0 ts=6a740d33 cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=qVS_p__ePFo4ISZweN8A:9 a=QEXdDO2ut3YA:10 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX43N/4jAW4aOL z6MkZZtcGNRZKe5qY7V9wUJCcLfk26nw0TJHodGh0RoSAWEUEHmVz//Ga7Foiec3142CDISt2KE XI+c1IJAw8YADxo83b0MzI2qGXzzxaA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXwjxW2wCo0hu1 1Hdco2bQ1EgwelOsSK5WnJJ7vSOKk1JW+v67zINxxOaHfBa6ffPIDtLiQR2Hd76Rbnk4wHtJmG8 4vt2vLpjJRLYgAjc3GbUxWTUIoTi87FYLy70OAwlGvtsuxtVzs5zARBoeeLtqLNVz8a1eBsm1ir s0ShZ4uDQpvIEYPX/GYI9827dzZYa8z9ob1lhBbZYcEjDqsvdi4dPOiYVwp/X4Z0Br9wUEysy20 V3d2NlFIM8o6jnlT1x8JKkdVZqy+wSiQveopRO0s/1v4yXnuBM4kixc2V9bayZdkuqaukvZNUUg 20rthsumaRadY9opWUY8rwBhNci54NOkajv4eoGwiPewznT2RyD0qlvQOceYN4LEL/52gzn1RvM p8HsqEOPbtHACz5Ko5bVGKLEAt6LgJlqoishRi7gAztBai1WvzJB0BcJrsNgshwJ0wDilQwI/54 KkXrDFNBVky1e8um0ow== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990578710158500 The TLB device is sized from the config table, so both machines create it identically. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 16 ++++++++++++++++ hw/hexagon/hexagon_dsp.c | 10 ---------- hw/hexagon/virt.c | 10 ---------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h index ef5700082cc..6edd93f478a 100644 --- a/include/hw/hexagon/hexagon.h +++ b/include/hw/hexagon/hexagon.h @@ -158,6 +158,7 @@ struct HexagonCommonMachineState { MemoryRegion cfgtable_rom; MemoryRegion vtcm; DeviceState *glob_regs; + DeviceState *tlb; }; =20 #endif diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c index 6789b6bb23d..ac7e29604eb 100644 --- a/hw/hexagon/hex-subsys.c +++ b/hw/hexagon/hex-subsys.c @@ -9,6 +9,7 @@ #include "qapi/error.h" #include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev.h" @@ -29,6 +30,18 @@ static DeviceState *globalreg_create(HexagonCommonMachin= eState *hms, return glob_regs; } =20 +static DeviceState *tlb_create(HexagonCommonMachineState *hms, + const struct hexagon_machine_config *m_cfg) +{ + DeviceState *tlb =3D qdev_new(TYPE_HEXAGON_TLB); + + object_property_add_child(OBJECT(hms), "tlb", OBJECT(tlb)); + qdev_prop_set_uint32(tlb, "num-entries", m_cfg->cfgtable.jtlb_size_ent= ries); + sysbus_realize_and_unref(SYS_BUS_DEVICE(tlb), &error_fatal); + + return tlb; +} + void hex_subsys_create(HexagonCommonMachineState *hms, const struct hexagon_machine_config *m_cfg, Rev_t r= ev) { @@ -57,11 +70,14 @@ void hex_subsys_create(HexagonCommonMachineState *hms, } =20 hms->glob_regs =3D globalreg_create(hms, m_cfg, rev); + hms->tlb =3D tlb_create(hms, m_cfg); } =20 void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu) { object_property_set_link(OBJECT(cpu), "global-regs", OBJECT(hms->glob_regs), &error_fatal); + object_property_set_link(OBJECT(cpu), "tlb", OBJECT(hms->tlb), + &error_fatal); qdev_realize_and_unref(cpu, NULL, &error_fatal); } diff --git a/hw/hexagon/hexagon_dsp.c b/hw/hexagon/hexagon_dsp.c index 8599f5883bf..25e8550fba2 100644 --- a/hw/hexagon/hexagon_dsp.c +++ b/hw/hexagon/hexagon_dsp.c @@ -15,7 +15,6 @@ #include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "qapi/error.h" #include "qemu/error-report.h" @@ -108,7 +107,6 @@ static void hexagon_common_init(MachineState *machine, = Rev_t rev, { HexagonCommonMachineState *hms =3D HEXAGON_COMMON_MACHINE(machine); HexagonDspMachineState *dms =3D HEXAGON_DSP_MACHINE(machine); - DeviceState *tlb_dev; =20 memset(&hexagon_binfo, 0, sizeof(hexagon_binfo)); if (machine->kernel_filename) { @@ -120,12 +118,6 @@ static void hexagon_common_init(MachineState *machine,= Rev_t rev, =20 hex_subsys_create(hms, m_cfg, rev); =20 - tlb_dev =3D qdev_new(TYPE_HEXAGON_TLB); - object_property_add_child(OBJECT(machine), "tlb", OBJECT(tlb_dev)); - qdev_prop_set_uint32(tlb_dev, "num-entries", - m_cfg->cfgtable.jtlb_size_entries); - sysbus_realize_and_unref(SYS_BUS_DEVICE(tlb_dev), &error_fatal); - for (int i =3D 0; i < machine->smp.cpus; i++) { HexagonCPU *cpu =3D HEXAGON_CPU(object_new(machine->cpu_type)); qemu_register_reset(do_cpu_reset, cpu); @@ -138,8 +130,6 @@ static void hexagon_common_init(MachineState *machine, = Rev_t rev, if (i =3D=3D 0) { hexagon_init_bootstrap(dms, cpu); } - object_property_set_link(OBJECT(cpu), "tlb", - OBJECT(tlb_dev), &error_fatal); hex_subsys_realize_cpu(hms, DEVICE(cpu)); } } diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index 290783d511f..b9e0bbb704c 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -14,7 +14,6 @@ #include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev-clock.h" @@ -225,7 +224,6 @@ static void virt_init(MachineState *ms) { HexagonVirtMachineState *vms =3D HEXAGON_VIRT_MACHINE(ms); const struct hexagon_machine_config *m_cfg =3D &v68n_1024; - DeviceState *tlb_dev; int32_t clk_phandle; =20 create_fdt(vms); @@ -248,12 +246,6 @@ static void virt_init(MachineState *ms) =20 fdt_add_hvx(vms, m_cfg); =20 - tlb_dev =3D qdev_new(TYPE_HEXAGON_TLB); - object_property_add_child(OBJECT(ms), "tlb", OBJECT(tlb_dev)); - qdev_prop_set_uint32(tlb_dev, "num-entries", - m_cfg->cfgtable.jtlb_size_entries); - sysbus_realize_and_unref(SYS_BUS_DEVICE(tlb_dev), &error_fatal); - for (int i =3D 0; i < ms->smp.cpus; i++) { HexagonCPU *cpu =3D HEXAGON_CPU(object_new(ms->cpu_type)); qemu_register_reset(do_cpu_reset, cpu); @@ -269,8 +261,6 @@ static void virt_init(MachineState *ms) } qdev_prop_set_uint32(DEVICE(cpu), "htid", i); qdev_prop_set_bit(DEVICE(cpu), "start-powered-off", (i !=3D 0)); - object_property_set_link(OBJECT(cpu), "tlb", - OBJECT(tlb_dev), &error_fatal); hex_subsys_realize_cpu(&vms->parent_obj, DEVICE(cpu)); } =20 --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990561; cv=none; d=zohomail.com; s=zohoarc; b=k/nORf4jsp0ATmjweGO5dO4o7QwEtwoz7nbjUxvNjKuWnY0BrCbSLmLC6DsovKEPo8c4qs4V/rpaZHMMF7mSACuyEqSZL2bsxng74DRKPzLHgGyCvvOSM+PuDKgeecckFEcj8FK8+tBjvwnpZ5ro3YewpNS+L9+shSHGWZ/8bjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990561; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9u/0w42v2vFMP3uRRs+opwlvMahtw2WinpbNt+P46cg=; b=PUXknXRWHp3Q7zvIn4pzPe9O6ar9g0t9qx+GyyaLACMpx2R6jTJ2Fp3FnbsQW/2AqYK5zkjmuX3XW/oYzTtyTmamqVhl6PagQQtS1HjIo4bCLx3/WFiQXTib00hliRtM4dWOxQrhtMjqQro2i46ZILR2QbUn9nV0umgtfihcIZM= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990561648397.25210145289793; Wed, 5 Aug 2026 21:29:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphp-0002rx-SF; Thu, 06 Aug 2026 00:27:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphg-0002q4-NV for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:36 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphe-0003Cq-Tj for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:36 -0400 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675NblWd226729 for ; Thu, 6 Aug 2026 04:27:34 GMT Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv2r64bv9-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:33 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-c89704da8c7so2646895a12.0 for ; Wed, 05 Aug 2026 21:27:33 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 9u/0w42v2vFMP3uRRs+opwlvMahtw2WinpbNt+P46cg=; b=QLrH78DoV8bQlzDZ JpWmoN+B82FMSOefduVyS2YWldQqqDECTchZYEgUsXRIsh/E4uoyVF+nI7xerWdD fSWMBntKl/wWModUIdMm54dQLdxH8rPO6cYhVWSp3SgvQhRycZ+VgvpM0f5DKIMA NJL0dcR5BKvwa6EflsfqmsT3+M/AC2gmHxgj+FK17nEtg2V971vSR3R8NXbraZJF WQx68nQDpDDGD3XTSTy8vbhqpBb86Aq5F4yqsWORqxbX4qtFHAQ62wP1zawgW4Sw /3aVlYgxL0GRrmj3jVuUR1h1UHzPW9SmLWbA0r+Mv/JMCW1bTCcPaWZ3ZrBDfs03 wbKBew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990453; x=1786595253; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=9u/0w42v2vFMP3uRRs+opwlvMahtw2WinpbNt+P46cg=; b=eJmRkROhmnZj5ItvFp35932wK86cmgDYQbs/XdbxMAr03FHjpoyD05uEk9Hx32dWEi RL3suvGE607Vpc9bBBeTczyO4It0wKih0GWwZBVBC3EybaUwgSysETrR6wHM31x0drEl kvG2PltUEQcHHYRbIXepVSxwrTQGZvXcQJL2TmaIBqLGpgvqGW0Hf7VEHbkQci7UhNjh HB7vKtPRcSrleoAZLSLBcgpcDJeS/wgUvFULtOEvosg4BpwaIw3u1/Quiel9GrAF+Lil js7PmVal8kBqKqCVfSfhRQJqpy9CpoyjqsN1LB08QOuD4LaKUcjr3ieP/cVpwkgt38ia 8AYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990453; x=1786595253; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9u/0w42v2vFMP3uRRs+opwlvMahtw2WinpbNt+P46cg=; b=F5McYlvDiXQM/2PDbLg/zMGcJ3+xvhpOACRbr/oHyWEgWOZgy0UrnndnP0ij9PuAPc pA1Ri0IE6a//UHF3jbuA88EPemRjWE8vi/7xE1QhZGvrX2FDxZ6H9fiEkaG2TQOY0Jhx Yr5NEiAtPExB1OpLh3fezdSys9yrbgrSKk1XweV3ArXfayirppgDEWTHstBldUKS4OD4 WvIeJegUckiS31SotsXVkusdtbpHufTINtXjTX+mo3b11xHISAV8ESi0icXXRJT97Aoh WUdUPRxI+HjrE5PWBtRCoVw6Q6qg2/vJmbco+46VfxAi6Ucdo9W9ZJvNWzlrNJ9VA0XD odkg== X-Gm-Message-State: AOJu0Yxa5pYT6XW6Qufba1LPQ8xIbAwkUb1WlVNDCDxUMbHuhcCVfMfQ Q8qjjdCENduBhD4f2i3aEAIOA5eSoiR1CwfRYtHUEYhxVX/oQJ9yM9ibE6TefvelwgMTyHs4+2D YidmS4bMEn/GCfZqWIbmI2vHVgQ3g470Z67dr1z2d/7SEWrsBThdwP0YTum46MKWJ6g== X-Gm-Gg: AR+sD13TcUb7icWlx37mluvPMM8HbptDdo44ezdHcRzIYF5lbi6Lq1RAdRYT5N7uUDw iJ4R9Pc2wo98saf1NLLLnthRi29Xq6tKiXZ5M3rKXxA1sMbYfc84C3xg0bA87OKcdxFZVnCVhrS BZ4KYJ0lxFQd9J2paSacApHyvKHT4nFyyRKP8k0gdmymx11KHrOfir86+6FOWW76S0yGrwyFKWE tpmHwoUAdz3LKMPdTrl1vtH9ysKQD8h419vywKX8X8dsrk2lVqS3fCFMIqIcRKIE9/GlknVMo7Y r+a9ql37cYT2Pb0QUYVyogchXrFor9LUAWiVB3AYtl1WbTkUbpksWV/WA3QJBjLevXrGrwgXAax imQ7Zr+xjbllxN884S9J5gnzwcLROm5oU1huct+7mF1Czn3X8 X-Received: by 2002:a05:6300:220a:b0:3c3:a1e6:a626 with SMTP id adf61e73a8af0-3cb86026fc3mr15644738637.32.1785990452785; Wed, 05 Aug 2026 21:27:32 -0700 (PDT) X-Received: by 2002:a05:6300:220a:b0:3c3:a1e6:a626 with SMTP id adf61e73a8af0-3cb86026fc3mr15644687637.32.1785990452341; Wed, 05 Aug 2026 21:27:32 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 05/18] hw/hexagon: group the CPUs in a cluster Date: Wed, 5 Aug 2026 21:27:10 -0700 Message-Id: <20260806042723.3785369-6-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=WrIb99fv c=1 sm=1 tr=0 ts=6a740d35 cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=mAn_JYengK_D836fKFgA:9 a=QEXdDO2ut3YA:10 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-GUID: 4jFJ7fzznw4L7T66g3kX4I4rsl7QaBqr X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX5BHSnc8JIyJQ TjYMl8+lrsE/4vlAEKtegJtJcWvAyLKx8IhSy2NpX0db2Lj8qSbk2AFVBGDcwIhtuMUhupSNV4L pHc2L4fCSqvrJ1/V3wqZ46cpdYNXacg= X-Proofpoint-ORIG-GUID: 4jFJ7fzznw4L7T66g3kX4I4rsl7QaBqr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXxWBAbBJepCbP g17HOVvKiI+fpUXQcjQuZVt6FW9DZfk2kDZ44Dj22N41+NZy266kxO6g7RGubj2gvjaqYFH2xTP usiq9j+3SZzqFx65k6Dak/gvHX513toZkaZiErbmEN+cAWvqnp8niBHkZE6mgLMFC7/OA+4E0DY TATkNMgEc7RnYR9KAg1hDfd43ysmUmmz8Qi4wh+xRIbMR+UXfg92K0zLXYxF8ZdtSWrHwr9Mw3Y ZNvrVXqzOJT3HZRoDaCuZKzQohH4CiwRKfkAgZv3QRSlriBmtMU5D61pUpMhxe1Rlqwj/hTi3Is CJGnsynnkfczP5n/EqUy0C+RaJaV58TdtYFx4fYY8OY3ZSPDinEUH0K7553lAyPeli+LT0D6kfc QMpvTCRpHmjVDwVZ21V/PMA5aO9YqP9xTbfEx8+vljQxHJOo+mxeKydUsj+lt8CE20WjHw4vIr8 g+YbaffbIorCFTrRlcQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990562571158500 The CPUs are now grouped in a TYPE_CPU_CLUSTER. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hex-subsys.h | 12 +++++++++++- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 30 +++++++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 11 ++++++++++- hw/hexagon/virt.c | 11 ++++++++++- hw/hexagon/Kconfig | 1 + 6 files changed, 62 insertions(+), 4 deletions(-) diff --git a/include/hw/hexagon/hex-subsys.h b/include/hw/hexagon/hex-subsy= s.h index 087c105cfa4..6d0d5e1da86 100644 --- a/include/hw/hexagon/hex-subsys.h +++ b/include/hw/hexagon/hex-subsys.h @@ -15,7 +15,17 @@ void hex_subsys_create(HexagonCommonMachineState *hms, const struct hexagon_machine_config *m_cfg, Rev_t r= ev); =20 -/* Realize a CPU into the subsystem. */ +/* + * Parent a CPU into the subsystem's cluster and wire its links. Call for + * every CPU before hex_subsys_realize_cluster(), then realize each CPU wi= th + * hex_subsys_realize_cpu(). + */ +void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu); + +/* Realize the CPU cluster, once all CPUs have been parented into it. */ +void hex_subsys_realize_cluster(HexagonCommonMachineState *hms); + +/* Realize a CPU previously parented via hex_subsys_add_cpu(). */ void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu); =20 #endif /* HW_HEXAGON_HEX_SUBSYS_H */ diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h index 6edd93f478a..31669a829f8 100644 --- a/include/hw/hexagon/hexagon.h +++ b/include/hw/hexagon/hexagon.h @@ -157,6 +157,7 @@ struct HexagonCommonMachineState { MemoryRegion ram; MemoryRegion cfgtable_rom; MemoryRegion vtcm; + DeviceState *cluster; DeviceState *glob_regs; DeviceState *tlb; }; diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c index ac7e29604eb..6fad6fe0a4d 100644 --- a/hw/hexagon/hex-subsys.c +++ b/hw/hexagon/hex-subsys.c @@ -10,6 +10,7 @@ #include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev.h" @@ -42,6 +43,16 @@ static DeviceState *tlb_create(HexagonCommonMachineState= *hms, return tlb; } =20 +static DeviceState *cluster_create(HexagonCommonMachineState *hms) +{ + DeviceState *cluster =3D qdev_new(TYPE_CPU_CLUSTER); + + object_property_add_child(OBJECT(hms), "cluster", OBJECT(cluster)); + qdev_prop_set_uint32(cluster, "cluster-id", 0); + + return cluster; +} + void hex_subsys_create(HexagonCommonMachineState *hms, const struct hexagon_machine_config *m_cfg, Rev_t r= ev) { @@ -69,15 +80,32 @@ void hex_subsys_create(HexagonCommonMachineState *hms, &hms->vtcm); } =20 + hms->cluster =3D cluster_create(hms); hms->glob_regs =3D globalreg_create(hms, m_cfg, rev); hms->tlb =3D tlb_create(hms, m_cfg); } =20 -void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu) +void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu) { + object_property_add_child(OBJECT(hms->cluster), "cpu[*]", OBJECT(cpu)); object_property_set_link(OBJECT(cpu), "global-regs", OBJECT(hms->glob_regs), &error_fatal); object_property_set_link(OBJECT(cpu), "tlb", OBJECT(hms->tlb), &error_fatal); +} + +void hex_subsys_realize_cluster(HexagonCommonMachineState *hms) +{ + /* + * The cluster must be realized after its CPUs have been parented into= it + * (see hex_subsys_add_cpu()) but before any CPU is itself realized, s= ince + * qdev_realize_and_unref() on a CPU latches cluster_index into the TCG + * cflags at that point. + */ + qdev_realize_and_unref(hms->cluster, NULL, &error_fatal); +} + +void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu) +{ qdev_realize_and_unref(cpu, NULL, &error_fatal); } diff --git a/hw/hexagon/hexagon_dsp.c b/hw/hexagon/hexagon_dsp.c index 25e8550fba2..1db5d681665 100644 --- a/hw/hexagon/hexagon_dsp.c +++ b/hw/hexagon/hexagon_dsp.c @@ -118,6 +118,8 @@ static void hexagon_common_init(MachineState *machine, = Rev_t rev, =20 hex_subsys_create(hms, m_cfg, rev); =20 + g_autofree HexagonCPU **cpus =3D g_new(HexagonCPU *, machine->smp.cpus= ); + for (int i =3D 0; i < machine->smp.cpus; i++) { HexagonCPU *cpu =3D HEXAGON_CPU(object_new(machine->cpu_type)); qemu_register_reset(do_cpu_reset, cpu); @@ -130,7 +132,14 @@ static void hexagon_common_init(MachineState *machine,= Rev_t rev, if (i =3D=3D 0) { hexagon_init_bootstrap(dms, cpu); } - hex_subsys_realize_cpu(hms, DEVICE(cpu)); + hex_subsys_add_cpu(hms, DEVICE(cpu)); + cpus[i] =3D cpu; + } + + hex_subsys_realize_cluster(hms); + + for (int i =3D 0; i < machine->smp.cpus; i++) { + hex_subsys_realize_cpu(hms, DEVICE(cpus[i])); } } =20 diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index b9e0bbb704c..dc1d5b6aa24 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -246,6 +246,8 @@ static void virt_init(MachineState *ms) =20 fdt_add_hvx(vms, m_cfg); =20 + g_autofree HexagonCPU **cpus =3D g_new(HexagonCPU *, ms->smp.cpus); + for (int i =3D 0; i < ms->smp.cpus; i++) { HexagonCPU *cpu =3D HEXAGON_CPU(object_new(ms->cpu_type)); qemu_register_reset(do_cpu_reset, cpu); @@ -261,7 +263,14 @@ static void virt_init(MachineState *ms) } qdev_prop_set_uint32(DEVICE(cpu), "htid", i); qdev_prop_set_bit(DEVICE(cpu), "start-powered-off", (i !=3D 0)); - hex_subsys_realize_cpu(&vms->parent_obj, DEVICE(cpu)); + hex_subsys_add_cpu(&vms->parent_obj, DEVICE(cpu)); + cpus[i] =3D cpu; + } + + hex_subsys_realize_cluster(&vms->parent_obj); + + for (int i =3D 0; i < ms->smp.cpus; i++) { + hex_subsys_realize_cpu(&vms->parent_obj, DEVICE(cpus[i])); } =20 fdt_add_cpu_nodes(vms); diff --git a/hw/hexagon/Kconfig b/hw/hexagon/Kconfig index 52065ab3b22..121c548bbb9 100644 --- a/hw/hexagon/Kconfig +++ b/hw/hexagon/Kconfig @@ -2,6 +2,7 @@ config HEX_DSP bool default y depends on HEXAGON + select CPU_CLUSTER =20 config HEX_VIRT bool --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990607; cv=none; d=zohomail.com; s=zohoarc; b=mp/DMfs7dQPObSi+d4Z3uHECpSx+0n15kHPlNw/KtVUDd44/Xrb4c1SgGoWJ67Uh63n7Sb5Hd8WcGAhYAV7AggzOvr0bHFRVScI10V2Qg8eM/qFUPrODIGkTBubaJ7vLGzikdujpp4Z48Ow4sm878dOSkSgI8Y/I0sSCw29euWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990607; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vivGOooEOVtBJmxvbSxjoSTPRhQMYKZC+TeOUjGdkH0=; b=C6yhmiYstjT68Zj1IWVgJiLjBxtpYspFHZFqRWEGvoMQ0mYRTDx+w8aKXT2w7UkOYYtgrGCgITOyxAjzeOCkD0XzPdFhpS3Qafh8bVGe80ZhUwvKsQDfSVhwaxGou9gqmyNNTigDeV9wxL7Nsw3PKiYAMgdUm6dqvpDk+AIETJQ= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990607314823.3887428482644; Wed, 5 Aug 2026 21:30:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrpht-0002tE-Kt; Thu, 06 Aug 2026 00:27:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphh-0002qT-K1 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:38 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphg-0003D2-2w for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:37 -0400 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763x6UX1071254 for ; Thu, 6 Aug 2026 04:27:35 GMT Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvjud02vh-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:34 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cab041eced3so2598844a12.1 for ; Wed, 05 Aug 2026 21:27:34 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= vivGOooEOVtBJmxvbSxjoSTPRhQMYKZC+TeOUjGdkH0=; b=HS9HB2IggkTEMthn rIyrQnBNKUDs4kHC2duBuOAibzNgX3/0LrpZ+HUisZRunAR3wEfEhfXhAXVQVjUB /sXIQ+YsU2VyN2ySLxNgzGZ6gEeTGTvLZFaWr6pDKwVDkN+vp3FfxvWCpo1zMrIm XKNOD/Ss80olg6rxS7hhUEe4GZsJ2/HwmcnTKu8bvd2qvvM4NXhFBakoO6GcJlQW 7H3JROz3wDZ8KqLrNhvy9qkZDtnjc8rAGxV1FdrU7v3alnFwI+3b3Xlp8veC0UhW dkpOp41KHHXcQ2Ba1mWPH3r3+Ka5sn0Gig+9crS46tnLyVkeGOGbXahY9iEXvEuC U5dxRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990454; x=1786595254; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=vivGOooEOVtBJmxvbSxjoSTPRhQMYKZC+TeOUjGdkH0=; b=W7srMRljCWVmsxSSw0MQ2Rmpzo29iWXrTNA85JDHVUB3huKDqtMd4yNtXJqMJRBacc my6+l+zFJgRTDi+IJq1s7Ozo8oTf9MF/4LwRxjUYsrYfeMqVQiE5yCqr9c6bGZLaUjJV 5LvRC0TAUek+A8kXktmLiQ2e2W9ICBZjhDN1fpGhQbRzN6KR1vU7y40pO8OMKWXS6lhq AF3Tv23w6AzkfdwAbQybAcZrt0eKtqyAA2cG/g4+e9Jb5iBoN3lyX9lGdy59R3CarzQu tb1C0toNEAW/lAWSfEYmE05FNGQaV/FbhZJR/INrbZIIFKjI0Me4LNdYto3ekDvYPGS6 XetA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990454; x=1786595254; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vivGOooEOVtBJmxvbSxjoSTPRhQMYKZC+TeOUjGdkH0=; b=g1+Pljyo/owLCZM1RlMVkw1al+3a7LgLCHAolWBa6HpR4hfgy4VMJyuD8p1n9ym7Cj AqCF2pGUte08CItAsTD5lkc6Vf+Jlm4d7UrZbfSbwe/HCGc68Q8vuedBr0VUbk30i+WC CjOHKTfDkQUf7kaiNSeYTSVom0vkzhySHbzidMINlLj9BXmWowM+ubg1cyqEARnaDMUv rsLVs+61tVRbHwbpO7RzFM7nILYNcc5axUOn0ffhz3qgCSUT4+w8tLT4if7Hu4dPvAdu o32+BTxAW5NBb+Pr3KGmrAVb6kCVAUUgMHajJ5dyS3b7At9lx7hTAAwckAWShdEk/vsz gmlQ== X-Gm-Message-State: AOJu0YyGP2mx8OUdai+V9ozs4UhgCGj8bpqClr37hadANBvVd+xc8HqX dwjAGO/QOYryQwIIUi30PelQJGKaqLPFiGHi2uRraHkmwwbJysOIi2KlqfpWixdV1+n7Vz0PlRL J08bn+mNhpXcJzTP9D5lTNCHN0IoXcWqSfU5HusXVsLaep4XmJx1Jq+G1wOvaobMYPw== X-Gm-Gg: AR+sD10TmkOEaG066BCWlQT16HWPyqb3SGuTZeXBTVya/4XtUcz+xpi9T3s7nKenu4F 2LUPSCLTNyCv0WZOcBAUVKmXlrHA2XFvkJwdv3Tn3Ebp2llnGuJuUSpw6OSxiyOVcfXOiBh29HR ysRW/JKSWmbEjitY84A33B0tncMsw9y5ezqzYqMCgcCaTvuzaIKWfRJS8GiYtp90lF+DcVmSYVm 2I5JBdN3qL8/3ooA6yjjxgwDz1D4BYsbyRs0t9JDMFaq40n4G2GBzu7qjnYC0Vslaz8Wd5UJf0W 07uk+A23ptAy8A4n2A2MsBoP2+TUhUEuZWilm3dp384bMIQJegerJDyQENiF4ebn6LB38zZIJsE 5nnfKmDAPlfobvAv7HYBDmyfEQnamUf2RLB/oX857U3VPmWwr X-Received: by 2002:a05:6a21:3a48:b0:3b4:61f:1fec with SMTP id adf61e73a8af0-3cb85df12ddmr15161325637.2.1785990453862; Wed, 05 Aug 2026 21:27:33 -0700 (PDT) X-Received: by 2002:a05:6a21:3a48:b0:3b4:61f:1fec with SMTP id adf61e73a8af0-3cb85df12ddmr15161266637.2.1785990453416; Wed, 05 Aug 2026 21:27:33 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 06/18] bitops.h: Add find_first_bit32() Date: Wed, 5 Aug 2026 21:27:11 -0700 Message-Id: <20260806042723.3785369-7-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX1xP601kikoGM jv0qkXOX882I0XlURvRQEUjhiJolBsJk+ToDCqi+i41JHNBh/7Q7Gm+ZG0ajUhDtTPKBLiM4F7u 6NXkrROjGHNzYTls3iLUgiRpJMmWs7gNptAj5hjLhDLm9WOlhpVKPInIQi0w3bu3lTVZTrk2ns0 fteMejOqZ6gB8+6plG7/wI2vFWeGd7JDyEQQ2+yCfBccioklb2+qkQ6YOGixZWvZVZCoteUENPv EkVrrl7FgpY6d0l9GzE7huBGibwNmsTlb5fCH4IZa6oiC3N3gYUnb0JOAMAz+RVlzoAGQ4ZFu56 gxOmHAeAD+9ageRs5G3HumBQNPXXQEZlvanVbH/+N5yPbLH1fxwPTINY/X+kcKO7Xi1mKgKmfQy hmsJmwj+M1OkWkSnNeGf2ZbhB10iKTo/7sJd792EX24k4afhiEHC08BVDbefzYe70EQjLAmeX22 XwBzBxWMbFGfGRvp01Q== X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX+Qgtl8xKYqaO ag1AMHrZWrIMML9gJb4/S0IwuB5wZtDJJFt+GYlC2+j1ikIqLUAmCoERqUuX8DEaLR9ZwSpwbYT bgiwA/N8WZf4ylQtoGGmn+9OeOtPurA= X-Proofpoint-GUID: qV00s71kLRB1gxtNA80QzmCLuJDjAVbp X-Proofpoint-ORIG-GUID: qV00s71kLRB1gxtNA80QzmCLuJDjAVbp X-Authority-Analysis: v=2.4 cv=DeInbPtW c=1 sm=1 tr=0 ts=6a740d36 cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=w2bVgGKsJa40EddZz84A:9 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 bulkscore=0 priorityscore=1501 adultscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990608571158500 set_bit32()/test_bit32()/etc already let devices operate on guest-visible uint32_t register arrays without depending on the host's 'unsigned long' size. Add find_first_bit32() so callers need not cast a uint32_t array to 'unsigned long *'. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/qemu/bitops.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h index c7b838a6283..f7363a5479f 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -43,10 +43,9 @@ * be some guest-visible register view of the bit array. * * We do not currently implement uint32_t versions of find_last_bit(), - * find_next_bit(), find_next_zero_bit(), find_first_bit() or - * find_first_zero_bit(), because we haven't yet needed them. If you - * need them you should implement them similarly to the 'unsigned long' - * versions. + * find_next_bit(), find_next_zero_bit() or find_first_zero_bit(), + * because we haven't yet needed them. If you need them you should + * implement them similarly to the 'unsigned long' versions. * * You can declare a bitmap to be used with these functions via the * DECLARE_BITMAP and DECLARE_BITMAP32 macros in bitmap.h. @@ -382,6 +381,29 @@ static inline int test_bit32(long nr, const uint32_t *= addr) return 1U & (addr[BIT32_WORD(nr)] >> (nr & 31)); } =20 +/** + * find_first_bit32 - find the first set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit, + * or @size if there is no set bit in the bitmap. + */ +static inline uint32_t find_first_bit32(const uint32_t *addr, uint32_t siz= e) +{ + uint32_t result; + + for (result =3D 0; result < size; result +=3D 32) { + uint32_t tmp =3D *addr++; + if (tmp) { + result +=3D ctz32(tmp); + return result < size ? result : size; + } + } + /* Not found */ + return size; +} + /** * DOC: Miscellaneous bit operations on single values * --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990571; cv=none; d=zohomail.com; s=zohoarc; b=Zb7SYEHUzxDnwaG6uQLTClpcSzQdl1M+46w/BaxgrdkSMbx1pY0OU9tpLIDLxw1VttisAac8SBVrGBK/q5NnAfoo/6kFbyIarnrPaJkW2XTyGpvb4hz0IsLjxChCaMjYUxbeAhkTNvG6PSSaihgwnEuOZnpLzsjf94V+P/QwqtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990571; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BVSXRnGB4/pSR1KgpeWIwneeEc1wTGl4yaaXnAKKIQo=; b=VHbZfwDd6mJDxeXNNPttXGFGeETHYB2eOextBACWmiBdg/SK8Y6aGs85yMPShyEhgbewj63TveCVUuvN9AbJWtv8HoZ5liFBlX9rRazhprdCK3JWOi0KjOH+yC2U8AVvOluhiNrHK6JR8NzjQq1RoSAjslNeEYO5fWt9W9f+cM4= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990571840286.58272534171715; Wed, 5 Aug 2026 21:29:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphs-0002su-SZ; Thu, 06 Aug 2026 00:27:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphm-0002rR-IT for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:42 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphi-0003DK-Td for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:42 -0400 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763whnS775331 for ; Thu, 6 Aug 2026 04:27:38 GMT Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvju8g34n-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:37 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-38e22137fb3so2384518a91.0 for ; Wed, 05 Aug 2026 21:27:37 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= BVSXRnGB4/pSR1KgpeWIwneeEc1wTGl4yaaXnAKKIQo=; b=N2JbBheksXRU2K49 RBa4f1KVR4Gnv5rCwV1FG28jJjp3ai/OGtKLwZNz8bihV/W1K+YwzV/jxvxMLPf1 sj0uLVsCrV3lmtd6/dQ74npndT/QkdxsEgjc0KL7U/SwD8YFzL8y+9Rc+rjf2Sta xYX0Y79FRQN1a5eUYFCLcIfGPz3XJUei3bKtasnNqZbmxlF7mwPZqQXT/UFj65/z iZ+meGgql0TEZgtB8iToBPSQP1Rb649eyBhVTCl5YvN8ELA4gg9rhjiJwHpvpzbb caWcoWdBpAKirlPfX2FE1isFGeSi5o/I/aI2d3L+pjFXAOaUDnoulpcFZFi2EF7o iVIvQQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990457; x=1786595257; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=BVSXRnGB4/pSR1KgpeWIwneeEc1wTGl4yaaXnAKKIQo=; b=LxnrOW2bBrBrwDMOR97rYiTKE3BBsKA1WeH6aAiY737RCniWzAYdkfDEFsUGaj3LN1 20lR/VoCUeCESKq7VaBo7zXJ6Rk/EcIpDa7RjVXssY+k+I0bRux58GAHnk1V9qC2wfpg Oq4n7hJ3prZ7jM+10YjaDuZmea9x2nvq+pot3lvZfy6B3hBR4Kna0/ZRm49JygadXrlW N6jn00xxnxBovuKGOqIBkN3RyC2nhajZybm7w9J5aHkttvmStkyezMRsVDlYHzwCtVLq bM45V770IcW9OJg4jj2QDrcIW0Y4gY8Og6UE2oRj4yGlMRmkn8UiFBrdEgQQd1jEN/I0 4Nvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990457; x=1786595257; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BVSXRnGB4/pSR1KgpeWIwneeEc1wTGl4yaaXnAKKIQo=; b=MlEQiuQliMVRlS4zBSVO6yCsodAqNzAS+hFccpCgpb4P1WPuA421psMMDhSqTBLb// /B9b06KZguu8yZTbL2A1f95M9QWoTrEWdTAcT38mmai1FJ7rwYhjX8FHtA2m3DdrpctJ A1pTjl5DW9KqL3wI1YHi63uo+2BC4OV+bEKykI+wWfEVzQ0v0nssn0TiJDrEBtpzFsPM VHoPjmyWxYsNV6gV90KViyX6Yi+iR6lkxCIK7kuXrCYSfjISfLMjxgxcGSZYdza9/9sB ATa3Cz6DsFPc5a2+4eyV059W1qRYxG+PjA/h8mMO5pNzAHm3BpMKMSbZ8+k+UMtykmWP Qneg== X-Gm-Message-State: AOJu0YxjETmGUQs5wx+9JVTe1VaRhJ9QwlxLC+saOQdMY7aU4VD3QLSD 1KG61UoPSiqt3VURtcMuzh3WZ3DILlvtjuFfXK4RXj7iTI1urr2PFOi0URGXrAp7DwPjCfQ6P7U yvbuOeZY2KHdv/lP2T39o1SdlNskJTZ3k2yWi6Qk05JWt4s/O2Y5qHAi36CkfITUQUw== X-Gm-Gg: AR+sD11zPW4oTh4tO98PYWSbG5U+XZh0H7r08yVxQntrOmnbAJdX3SrYG2sKa7b9dC+ kFJk0KZYfjOatm/89CoYwZpC0bX5MlP7Q9YDvTSLa3QP4fMBdAa5M+vEKMHHm4VpFXTQG716NNK 98TQAypGl+H3HT+KatSsqgEljhZCjB4GIGjKQpcUkNdt2pFkwzRAxp+IbEVAbIK2bIG1iMaAvxG ADMitV/I+svB0eewAYhZ2e1qIwibQKPK/heNZiscUnpwC1QBPnzGtfDQjbzZdpB3bx3g/vDpytn h2k5wGUjv17Ke433wuC5M8Pt4iAg6l9LWyG3Wl8AbNC+PuGJvSa9EiofpElpI8TglyS1+TwRWJi b422ERwl3UkKENly9AfwLZZksZRE6bhyl5KtId13MR/zM6ra4 X-Received: by 2002:a17:90b:4fc9:b0:38e:740f:9764 with SMTP id 98e67ed59e1d1-3903c5f6477mr12251203a91.18.1785990456583; Wed, 05 Aug 2026 21:27:36 -0700 (PDT) X-Received: by 2002:a17:90b:4fc9:b0:38e:740f:9764 with SMTP id 98e67ed59e1d1-3903c5f6477mr12251138a91.18.1785990455983; Wed, 05 Aug 2026 21:27:35 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Sid Manning , Matheus Tavares Bernardino , Damien Hedde Subject: [PATCH v5 07/18] hw/intc: Add l2vic interrupt controller Date: Wed, 5 Aug 2026 21:27:12 -0700 Message-Id: <20260806042723.3785369-8-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: R-ycYdmyq1P6UsdB13ZM_lGRyIlhQo8S X-Proofpoint-ORIG-GUID: R-ycYdmyq1P6UsdB13ZM_lGRyIlhQo8S X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX7mmsPDP9O3r/ APRf2b2mwPLoPEmEnnXyEkaMZg/v1vLO49+56KXI6c6iEfC/Ki1MH4KmZ9Nmh9GaZnyO+7QELhI fdUVUCzwy8Ag0sWdQryXITtXtJryQWdVuVf6WzDRTYi37EVFjTM0t8WgAPeIBxSx0Wjjb7Ldw7L tAuwS4TNj/EnDsQyMl4kJrf2+4TTp2p+FTaT+CkHe3uwZOKhh1IabNJvr1e9xR1KdNTRl1rkiHp d2LO0LkKDsYYvL6BAAtfrKwYfUpFwkCy0EzpAiH6M6JQT4ruc1UyiuQAi++lyJE5j9EUKtRv9Vb FpSdCXoiSmXV/Qi10nTINaYG6o3EyuGkGQEmHOQ1wz5uAO9VwWIyE6z0KcdF1y+0VkDypTMiiVy BiYy6ht+K5K1hW7SZ6eMNmpeXECxtHhRDgZ6rwm0zMXNqHTtPHaqxKrDfNvjD9yJZm0Y4yXg5GK pilg4Xgssa3yBL+RbwA== X-Authority-Analysis: v=2.4 cv=K5cS2SWI c=1 sm=1 tr=0 ts=6a740d3a cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=NEAV23lmAAAA:8 a=COk6AnOGAAAA:8 a=EUspDBNiAAAA:8 a=VjGsYNusyyFeigA112kA:9 a=QEXdDO2ut3YA:10 a=iS9zxrgQBfv6-_F4QbHw:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX+iRKBp0livDt BlodOzPqTOD+9n4aGYYOZLAGDtzhy00gsdetjeVfpDHd+OgvLpCuQSy8iOO278uhWAS3yatWy+L V+SJtS0D0nJPqsF6s+EWhf4ENZOSU5k= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990572508158500 From: Sid Manning The Hexagon DSP requires an L2VIC to route up to 1024 external interrupt sources through 4 VID output groups into the core's 8 interrupt inputs. Add a device model for it. Co-authored-by: Matheus Tavares Bernardino Co-authored-by: Damien Hedde Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- MAINTAINERS | 3 + docs/devel/hexagon-l2vic.rst | 55 ++++ docs/devel/index-internals.rst | 1 + include/hw/intc/hex-l2vic.h | 61 ++++ target/hexagon/cpu.h | 2 + hw/intc/hex-l2vic.c | 556 +++++++++++++++++++++++++++++++++ target/hexagon/cpu.c | 2 + target/hexagon/op_helper.c | 16 +- hw/hexagon/Kconfig | 1 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 12 files changed, 705 insertions(+), 1 deletion(-) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 include/hw/intc/hex-l2vic.h create mode 100644 hw/intc/hex-l2vic.c diff --git a/MAINTAINERS b/MAINTAINERS index 902db77218e..56b12a1af04 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -250,6 +250,8 @@ M: Brian Cain R: Pierrick Bouvier S: Supported F: target/hexagon/ +F: hw/intc/hex-l2vic.c +F: include/hw/intc/hex-l2vic.h X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/ @@ -262,6 +264,7 @@ F: gdbstub/gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst F: docs/system/hexagon/ F: docs/devel/hexagon-sys.rst +F: docs/devel/hexagon-l2vic.rst T: git https://github.com/qualcomm/qemu.git hex-next =20 Hexagon idef-parser diff --git a/docs/devel/hexagon-l2vic.rst b/docs/devel/hexagon-l2vic.rst new file mode 100644 index 00000000000..9cb2a86871e --- /dev/null +++ b/docs/devel/hexagon-l2vic.rst @@ -0,0 +1,55 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Hexagon L2 Vectored Interrupt Controller +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + +.. code-block:: none + + +-------------+ +----------------------+ + | l2vic | | hexagon core | + | | | | + IRQ in ---->| | | | + IRQ in ---->| VID0 -|----------------->| irq2 | + ... ---->| | | | | + IRQ in ---->| | | v | + | ... | | | + | | | / | | \ | + IRQ in ---->| | | t0 t1 t2 t3 ...| + IRQ in ---->| VIDN -| | | + ... ---->| | | | + IRQ in ---->| | | Global SREG File | + | | | | + | State | | | + | [ ] <--|=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D|=3D=3D> [ VID ] | + | [ ] <--|=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D|=3D=3D> [ VID1 ] | + | | | | + +-------------+ +----------------------+ + +L2VIC/Core Integration +---------------------- + +* hexagon core supports 8 external interrupt sources +* l2vic supports 1024 input interrupts mapped among 4 output interrupts +* l2vic has four output signals: { VID0, VID1, VID2, VID3 } +* l2vic device has a bank of registers per-VID that can be used to query + the status or assert new interrupts. +* Interrupts are 'steered' to threads based on { thread priority, 'EX' sta= te, + thread interrupt mask, thread interrupt enable, global interrupt enable, + etc. }. +* Any hardware thread could conceivably handle any input interrupt, depend= ent + on state. +* The system register transfer instruction can read the VID0-VID3 values f= rom + the l2vic when reading from hexagon core system registers "VID" and "VID= 1". +* When l2vic VID0 has multiple active interrupts, it pulses the VID0 output + IRQ and stores the IRQ number for the VID0 register field. Only after t= his + interrupt is cleared can the l2vic pulse the VID0 output IRQ again and p= rovide + the next interrupt number on the VID0 register. +* The ``ciad`` instruction clears the l2vic input interrupt and un-disable= s the + core interrupt. If some/an l2vic VID0 interrupt is pending when this oc= curs, + the next interrupt should fire and any subsequent reads of the VID regis= ter + should reflect the newly raised interrupt. +* In QEMU, on an external interrupt or an unmasked-pending interrupt, + all vCPUs are triggered (has_work=3D=3Dtrue) and each will grab the IO l= ock + while considering the steering logic to determine whether they're the th= read + that must handle the interrupt. diff --git a/docs/devel/index-internals.rst b/docs/devel/index-internals.rst index a8f5e310df3..763cda1e76f 100644 --- a/docs/devel/index-internals.rst +++ b/docs/devel/index-internals.rst @@ -15,6 +15,7 @@ Details about QEMU's various subsystems including how to = add features to them. clocks ebpf_rss hexagon-sys + hexagon-l2vic migration/index multi-process reset diff --git a/include/hw/intc/hex-l2vic.h b/include/hw/intc/hex-l2vic.h new file mode 100644 index 00000000000..edc278266cb --- /dev/null +++ b/include/hw/intc/hex-l2vic.h @@ -0,0 +1,61 @@ +/* + * QEMU L2VIC Interrupt Controller + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_INTC_HEX_L2VIC_H +#define HW_INTC_HEX_L2VIC_H + +#include "qom/object.h" + +#define TYPE_HEX_L2VIC "hex-l2vic" +/* + * L2VIC Interface for CPU/GlobalReg interaction + */ +#define TYPE_HEX_L2VIC_INTERFACE "hex-l2vic-if" + +typedef struct HexL2VicInterface HexL2VicInterface; + +typedef struct HexL2VicInterfaceClass { + InterfaceClass parent_class; + + uint32_t (*read_vid)(HexL2VicInterface *l2vic, uint32_t group); + + /* + * Write the VID: unpack the fields into per-group VIDs. This does + * not deliver or clear any interrupt; a pending interrupt stays + * gated until ciad. + */ + void (*update_vid)(HexL2VicInterface *l2vic, uint32_t group, + uint32_t value); + + /* Clear interrupt using CIAD instruction */ + void (*clear_interrupt)(HexL2VicInterface *l2vic); +} HexL2VicInterfaceClass; + +DECLARE_OBJ_CHECKERS(HexL2VicInterface, HexL2VicInterfaceClass, + HEX_L2VIC_INTERFACE, TYPE_HEX_L2VIC_INTERFACE); + +static inline uint32_t l2vic_read_vid(HexL2VicInterface *l2vic, + uint32_t group) +{ + HexL2VicInterfaceClass *k =3D HEX_L2VIC_INTERFACE_GET_CLASS(l2vic); + return k->read_vid(l2vic, group); +} + +static inline void l2vic_update_vid(HexL2VicInterface *l2vic, uint32_t gro= up, + uint32_t value) +{ + HexL2VicInterfaceClass *k =3D HEX_L2VIC_INTERFACE_GET_CLASS(l2vic); + k->update_vid(l2vic, group, value); +} + +static inline void l2vic_clear_interrupt(HexL2VicInterface *l2vic) +{ + HexL2VicInterfaceClass *k =3D HEX_L2VIC_INTERFACE_GET_CLASS(l2vic); + k->clear_interrupt(l2vic); +} + +#endif /* HW_INTC_HEX_L2VIC_H */ diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h index 7694fd91fa8..f6c3c639325 100644 --- a/target/hexagon/cpu.h +++ b/target/hexagon/cpu.h @@ -39,6 +39,7 @@ typedef struct HexagonGlobalRegState HexagonGlobalRegStat= e; #include "qemu/bitmap.h" =20 #include "target/hexagon/reg_fields.h" +#include "hw/intc/hex-l2vic.h" =20 #define NUM_PREGS 4 #define TOTAL_PER_THREAD_REGS 64 @@ -198,6 +199,7 @@ struct ArchCPU { uint32_t boot_addr; HexagonGlobalRegState *globalregs; uint32_t htid; + HexL2VicInterface *l2vic; #endif }; =20 diff --git a/hw/intc/hex-l2vic.c b/hw/intc/hex-l2vic.c new file mode 100644 index 00000000000..f07ec850d49 --- /dev/null +++ b/hw/intc/hex-l2vic.c @@ -0,0 +1,556 @@ +/* + * QEMU L2VIC Interrupt Controller + * + * Arm PrimeCell PL190 Vector Interrupt Controller was used as a reference. + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/core/irq.h" +#include "hw/core/sysbus.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/bitmap.h" +#include "qemu/bitops.h" +#include "hw/intc/hex-l2vic.h" +#include "trace.h" + +#define L2VIC_VID_GRP_0 0x0 /* Read */ +#define L2VIC_VID_GRP_1 0x4 /* Read */ +#define L2VIC_VID_GRP_2 0x8 /* Read */ +#define L2VIC_VID_GRP_3 0xC /* Read */ +#define L2VIC_INT_ENABLEn 0x100 /* Read/Write */ +#define L2VIC_INT_ENABLE_CLEARn 0x180 /* Write */ +#define L2VIC_INT_ENABLE_SETn 0x200 /* Write */ +#define L2VIC_INT_TYPEn 0x280 /* Read/Write */ +#define L2VIC_INT_STATUSn 0x380 /* Read */ +#define L2VIC_INT_CLEARn 0x400 /* Write */ +#define L2VIC_SOFT_INTn 0x480 /* Write */ +#define L2VIC_INT_PENDINGn 0x500 /* Read */ +#define L2VIC_INT_GRPn_0 0x600 /* Read/Write */ +#define L2VIC_INT_GRPn_1 0x680 /* Read/Write */ +#define L2VIC_INT_GRPn_2 0x700 /* Read/Write */ +#define L2VIC_INT_GRPn_3 0x780 /* Read/Write */ + +#define L2VIC_INTERRUPT_MAX 1024 +/* + * Note about l2vic groups: + * Each interrupt to L2VIC can be configured to associate with one of + * four groups. + * Group 0 interrupts go to IRQ2 via VID 0 (SSR: 0xC2, the default) + * Group 1 interrupts go to IRQ3 via VID 1 (SSR: 0xC3) + * Group 2 interrupts go to IRQ4 via VID 2 (SSR: 0xC4) + * Group 3 interrupts go to IRQ5 via VID 3 (SSR: 0xC5) + */ + +static void bitmap32_write_word(uint32_t *bitmap, int word_offset, uint32_= t val) +{ + bitmap[word_offset] =3D val; +} + +static void bitmap32_clear_word(uint32_t *bitmap, int word_offset, + uint32_t mask) +{ + bitmap[word_offset] &=3D ~mask; +} + +static void bitmap32_set_word(uint32_t *bitmap, int word_offset, uint32_t = mask) +{ + bitmap[word_offset] |=3D mask; +} + +static uint32_t bitmap32_read_word(uint32_t *bitmap, int word_offset) +{ + return bitmap[word_offset]; +} + +OBJECT_DECLARE_SIMPLE_TYPE(HexL2VICState, HEX_L2VIC) + +#define SLICE_MAX (L2VIC_INTERRUPT_MAX / 32) +#define L2VIC_REG_RANGE_SIZE 0x80 + +typedef struct HexL2VICState { + SysBusDevice parent_obj; + + MemoryRegion iomem; + MemoryRegion fast_iomem; + /* + * vid_group[i] is readable at L2VIC_VID_GRP_i (offset i*4): the irq + * last delivered through VID group i, 0-1023 so only 10 bits are used. + */ + uint32_t vid_group[4]; + /* + * Last irq delivered on any VID group; not specific to group 0. + * Used by the ciad path to clear the most-recently-delivered + * interrupt from int_status. + */ + uint32_t vid; + DECLARE_BITMAP32(int_enable, L2VIC_INTERRUPT_MAX); + /* Asserted interrupts awaiting delivery once no VID is active */ + DECLARE_BITMAP32(int_pending, L2VIC_INTERRUPT_MAX); + /* Which enabled interrupt is active */ + DECLARE_BITMAP32(int_status, L2VIC_INTERRUPT_MAX); + /* Edge or Level interrupt */ + DECLARE_BITMAP32(int_type, L2VIC_INTERRUPT_MAX); + DECLARE_BITMAP32(int_group_n[4], L2VIC_INTERRUPT_MAX); + qemu_irq irq[8]; +} HexL2VICState; + +typedef enum { + L2VIC_OP_WRITE, + L2VIC_OP_CLEAR, + L2VIC_OP_SET, + L2VIC_OP_NONE, +} L2VicWriteOp; + +typedef struct { + hwaddr base; + size_t state_offset; + L2VicWriteOp write_op; + bool write_only; +} L2VicRegRange; + +static const L2VicRegRange l2vic_reg_ranges[] =3D { + { L2VIC_INT_ENABLEn, offsetof(HexL2VICState, int_enable), + L2VIC_OP_WRITE, false }, + { L2VIC_INT_ENABLE_CLEARn, offsetof(HexL2VICState, int_enable), + L2VIC_OP_CLEAR, true }, + { L2VIC_INT_ENABLE_SETn, offsetof(HexL2VICState, int_enable), + L2VIC_OP_SET, true }, + { L2VIC_INT_TYPEn, offsetof(HexL2VICState, int_type), + L2VIC_OP_WRITE, false }, + { L2VIC_INT_STATUSn, offsetof(HexL2VICState, int_status), + L2VIC_OP_NONE, false }, + { L2VIC_INT_CLEARn, offsetof(HexL2VICState, int_status), + L2VIC_OP_CLEAR, true }, + { L2VIC_SOFT_INTn, offsetof(HexL2VICState, int_pending), + L2VIC_OP_NONE, true }, + { L2VIC_INT_PENDINGn, offsetof(HexL2VICState, int_pending), + L2VIC_OP_WRITE, false }, + { L2VIC_INT_GRPn_0, offsetof(HexL2VICState, int_group_n[0]), + L2VIC_OP_WRITE, false }, + { L2VIC_INT_GRPn_1, offsetof(HexL2VICState, int_group_n[1]), + L2VIC_OP_WRITE, false }, + { L2VIC_INT_GRPn_2, offsetof(HexL2VICState, int_group_n[2]), + L2VIC_OP_WRITE, false }, + { L2VIC_INT_GRPn_3, offsetof(HexL2VICState, int_group_n[3]), + L2VIC_OP_WRITE, false }, +}; + +static uint32_t *l2vic_state_bitmap(HexL2VICState *s, size_t state_offset) +{ + return (uint32_t *)((char *)s + state_offset); +} + +static bool l2vic_reg_read_range(HexL2VICState *s, hwaddr offset, + uint64_t *value) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(l2vic_reg_ranges); i++) { + const L2VicRegRange *r =3D &l2vic_reg_ranges[i]; + + if (offset >=3D r->base && + offset < r->base + L2VIC_REG_RANGE_SIZE) { + if (r->write_only) { + *value =3D 0; + } else { + uint32_t *bitmap =3D l2vic_state_bitmap(s, r->state_offset= ); + *value =3D bitmap32_read_word(bitmap, + (offset - r->base) >> 2); + } + return true; + } + } + return false; +} + +static bool l2vic_reg_write_range(HexL2VICState *s, hwaddr offset, + uint32_t val) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(l2vic_reg_ranges); i++) { + const L2VicRegRange *r =3D &l2vic_reg_ranges[i]; + + if (offset >=3D r->base && + offset < r->base + L2VIC_REG_RANGE_SIZE) { + uint32_t *bitmap =3D l2vic_state_bitmap(s, r->state_offset); + int word =3D (offset - r->base) >> 2; + + switch (r->write_op) { + case L2VIC_OP_WRITE: + bitmap32_write_word(bitmap, word, val); + break; + case L2VIC_OP_CLEAR: + bitmap32_clear_word(bitmap, word, val); + break; + case L2VIC_OP_SET: + bitmap32_set_word(bitmap, word, val); + break; + case L2VIC_OP_NONE: + /* Read-only or handled elsewhere; ignore the write. */ + break; + default: + g_assert_not_reached(); + } + return true; + } + } + return false; +} + +/* + * The four INT_GRPn_* register arrays are interleaved across irqs in + * blocks of 8: irq 0-7 live in group_n[0], irq 8-15 in group_n[1], irq + * 16-23 in group_n[2], irq 24-31 in group_n[3], irq 32-39 back in + * group_n[0], and so on. + */ +static uint32_t *get_int_group(HexL2VICState *s, int irq) +{ + return s->int_group_n[extract32(irq, 3, 2)]; +} + +static int find_slice(int irq) +{ + return irq / 32; +} + +static int get_vid(HexL2VICState *s, int irq) +{ + uint32_t *group =3D get_int_group(s, irq); + uint32_t slice =3D group[find_slice(irq)]; + uint32_t vid; + /* + * Each irq occupies a 4-bit field: bit 3 is the group-enable bit, + * bits 0-2 select the VID group. Shift down to this irq's field. + */ + uint32_t val =3D slice >> ((irq & 0x7) * 4); + + if (!(val & 0x8)) { + return 0; + } + vid =3D val & 0x7; + if (vid >=3D ARRAY_SIZE(s->vid_group)) { + qemu_log_mask(LOG_GUEST_ERROR, + "L2VIC: irq %d requests invalid vid group %u\n", + irq, vid); + return 0; + } + return vid; +} + +static inline bool vid_active(HexL2VICState *s) +{ + const uint32_t size =3D L2VIC_INTERRUPT_MAX; + const uint32_t active_irq =3D find_first_bit32(s->int_status, size); + return active_irq !=3D size; +} + +static bool l2vic_update(HexL2VICState *s, int irq) +{ + bool pending; + bool enable; + + if (vid_active(s)) { + return true; + } + + pending =3D test_bit32(irq, s->int_pending); + enable =3D test_bit32(irq, s->int_enable); + if (pending && enable) { + int vid =3D get_vid(s, irq); + set_bit32(irq, s->int_status); + clear_bit32(irq, s->int_pending); + /* + * Only auto-disable for edge-triggered interrupts (type=3D1). + * Level-triggered interrupts (type=3D0, the default) keep their + * enable bit set across deliveries -- the firmware enables once + * and expects the interrupt to remain enabled. + */ + if (test_bit32(irq, s->int_type)) { + clear_bit32(irq, s->int_enable); + } + s->vid =3D irq; + s->vid_group[vid] =3D irq; + + qemu_irq_pulse(s->irq[vid + 2]); + trace_hex_l2vic_delivered(irq, vid); + return true; + } + return false; +} + +static void l2vic_update_all(HexL2VICState *s) +{ + for (int i =3D 0; i < L2VIC_INTERRUPT_MAX; i++) { + if (l2vic_update(s, i)) { + /* once vid is active, no-one else can set it until ciad */ + return; + } + } +} + +static void l2vic_set_irq(void *opaque, int irq, int level) +{ + HexL2VICState *s =3D (HexL2VICState *)opaque; + + if (level) { + set_bit32(irq, s->int_pending); + } + l2vic_update(s, irq); +} + +static void l2vic_write(void *opaque, hwaddr offset, uint64_t val, + unsigned size) +{ + HexL2VICState *s =3D (HexL2VICState *)opaque; + + trace_hex_l2vic_reg_write((unsigned)offset, (uint32_t)val); + + if (!l2vic_reg_write_range(s, offset, val)) { + qemu_log_mask(LOG_UNIMP, + "%s: offset 0x%" HWADDR_PRIx " unimplemented\n", + __func__, offset); + } + + /* SOFT_INT also sets pending for edge-triggered interrupts */ + if (offset >=3D L2VIC_SOFT_INTn && + offset < L2VIC_SOFT_INTn + L2VIC_REG_RANGE_SIZE && val) { + int base_irq =3D ((offset - L2VIC_SOFT_INTn) >> 2) * 32; + uint32_t bits =3D val; + int bit; + + while ((bit =3D ctz32(bits)) < 32) { + int irq =3D base_irq + bit; + + if (test_bit32(irq, s->int_type)) { + set_bit32(irq, s->int_pending); + } + bits &=3D ~(1u << bit); + } + } + + l2vic_update_all(s); +} + +static uint64_t l2vic_read(void *opaque, hwaddr offset, unsigned size) +{ + uint64_t value; + HexL2VICState *s =3D (HexL2VICState *)opaque; + + if (offset <=3D L2VIC_VID_GRP_3) { + value =3D s->vid_group[offset >> 2]; + } else if (!l2vic_reg_read_range(s, offset, &value)) { + value =3D 0; + qemu_log_mask(LOG_GUEST_ERROR, + "L2VIC: %s: offset 0x%" HWADDR_PRIx "\n", __func__, + offset); + } + + trace_hex_l2vic_reg_read((unsigned)offset, (uint32_t)value); + return value; +} + +static const MemoryRegionOps l2vic_ops =3D { + .read =3D l2vic_read, + .write =3D l2vic_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid.min_access_size =3D 4, + .valid.max_access_size =3D 4, + .valid.unaligned =3D false, +}; + +#define FASTL2VIC_ENABLE 0x0 +#define FASTL2VIC_DISABLE 0x1 +#define FASTL2VIC_INT 0x2 + +static void fastl2vic_write(void *opaque, hwaddr offset, uint64_t val, + unsigned size) +{ + if (offset =3D=3D 0) { + uint32_t cmd =3D (val >> 16) & 0x3; + uint32_t irq =3D val & 0x3ff; + uint32_t slice =3D (irq / 32) * 4; + val =3D 1 << (irq % 32); + + if (cmd =3D=3D FASTL2VIC_ENABLE) { + l2vic_write(opaque, L2VIC_INT_ENABLE_SETn + slice, val, size); + } else if (cmd =3D=3D FASTL2VIC_DISABLE) { + l2vic_write(opaque, L2VIC_INT_ENABLE_CLEARn + slice, val, size= ); + } else if (cmd =3D=3D FASTL2VIC_INT) { + l2vic_write(opaque, L2VIC_SOFT_INTn + slice, val, size); + } else { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: invalid write cmd %" PRId32 "\n", + __func__, cmd); + } + return; + } + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid write offset 0x%08" HWADDR= _PRIx + "\n", __func__, offset); +} + +static uint64_t fastl2vic_read(void *opaque, hwaddr offset, unsigned size) +{ + return 0; +} + +static const MemoryRegionOps fastl2vic_ops =3D { + .read =3D fastl2vic_read, + .write =3D fastl2vic_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid.min_access_size =3D 4, + .valid.max_access_size =3D 4, + .valid.unaligned =3D false, +}; + +static uint32_t l2vic_interface_read_vid_impl(HexL2VicInterface *iface, + uint32_t group) +{ + HexL2VICState *s =3D HEX_L2VIC(iface); + uint32_t result =3D 0; + + if (group =3D=3D 0) { + /* VID register combines vid_group[0] (VID0) and vid_group[1] (VID= 1) */ + result =3D deposit32(result, 0, 16, s->vid_group[0]); + result =3D deposit32(result, 16, 16, s->vid_group[1]); + } else if (group =3D=3D 1) { + /* VID1 register combines vid_group[2] (VID2) and vid_group[3] (VI= D3) */ + result =3D deposit32(result, 0, 16, s->vid_group[2]); + result =3D deposit32(result, 16, 16, s->vid_group[3]); + } + return result; +} + +static void l2vic_interface_update_vid_impl(HexL2VicInterface *iface, + uint32_t group, uint32_t value) +{ + HexL2VICState *s =3D HEX_L2VIC(iface); + + if (group =3D=3D 0) { + s->vid_group[0] =3D extract32(value, 0, 16); + s->vid_group[1] =3D extract32(value, 16, 16); + } else if (group =3D=3D 1) { + s->vid_group[2] =3D extract32(value, 0, 16); + s->vid_group[3] =3D extract32(value, 16, 16); + } + + l2vic_update_all(s); +} + +static void l2vic_interface_clear_interrupt_impl(HexL2VicInterface *iface) +{ + HexL2VICState *s =3D HEX_L2VIC(iface); + + if (s->vid < L2VIC_INTERRUPT_MAX) { + clear_bit32(s->vid, s->int_status); + } + l2vic_update_all(s); +} + +static void l2vic_reset_hold(Object *obj, ResetType type G_GNUC_UNUSED) +{ + HexL2VICState *s =3D HEX_L2VIC(obj); + + memset(s->int_enable, 0, sizeof(s->int_enable)); + memset(s->int_pending, 0, sizeof(s->int_pending)); + memset(s->int_status, 0, sizeof(s->int_status)); + memset(s->int_type, 0, sizeof(s->int_type)); + memset(s->int_group_n, 0, sizeof(s->int_group_n)); + memset(s->vid_group, 0, sizeof(s->vid_group)); + s->vid =3D 0; + + l2vic_update_all(s); +} + +static void reset_irq_handler(void *opaque, int irq, int level) +{ + Object *obj =3D OBJECT(opaque); + + if (level) { + l2vic_reset_hold(obj, RESET_TYPE_COLD); + } +} + +static void l2vic_init(Object *obj) +{ + DeviceState *dev =3D DEVICE(obj); + HexL2VICState *s =3D HEX_L2VIC(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + int i; + + memory_region_init_io(&s->iomem, obj, &l2vic_ops, s, "l2vic", 0x1000); + sysbus_init_mmio(sbd, &s->iomem); + memory_region_init_io(&s->fast_iomem, obj, &fastl2vic_ops, s, "fast", + 0x10000); + sysbus_init_mmio(sbd, &s->fast_iomem); + + qdev_init_gpio_in(dev, l2vic_set_irq, L2VIC_INTERRUPT_MAX); + qdev_init_gpio_in_named(dev, reset_irq_handler, "reset", 1); + for (i =3D 0; i < 8; i++) { + sysbus_init_irq(sbd, &s->irq[i]); + } +} + +static const VMStateDescription vmstate_l2vic =3D { + .name =3D "l2vic", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D + (VMStateField[]){ + VMSTATE_UINT32_ARRAY(vid_group, HexL2VICState, 4), + VMSTATE_UINT32(vid, HexL2VICState), + VMSTATE_UINT32_ARRAY(int_enable, HexL2VICState, SLICE_MAX), + VMSTATE_UINT32_ARRAY(int_type, HexL2VICState, SLICE_MAX), + VMSTATE_UINT32_ARRAY(int_status, HexL2VICState, SLICE_MAX), + VMSTATE_UINT32_ARRAY(int_pending, HexL2VICState, SLICE_MAX), + VMSTATE_UINT32_2DARRAY(int_group_n, HexL2VICState, 4, SLICE_MA= X), + VMSTATE_END_OF_LIST() } +}; + +static void l2vic_interface_class_init(ObjectClass *klass, const void *dat= a) +{ + HexL2VicInterfaceClass *k =3D HEX_L2VIC_INTERFACE_CLASS(klass); + + k->read_vid =3D l2vic_interface_read_vid_impl; + k->update_vid =3D l2vic_interface_update_vid_impl; + k->clear_interrupt =3D l2vic_interface_clear_interrupt_impl; +} + +static void l2vic_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + dc->vmsd =3D &vmstate_l2vic; + rc->phases.hold =3D l2vic_reset_hold; +} + +static const TypeInfo l2vic_interface_info =3D { + .name =3D TYPE_HEX_L2VIC_INTERFACE, + .parent =3D TYPE_INTERFACE, + .class_size =3D sizeof(HexL2VicInterfaceClass), + .class_init =3D l2vic_interface_class_init, +}; + +static const TypeInfo l2vic_info =3D { + .name =3D TYPE_HEX_L2VIC, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(HexL2VICState), + .instance_init =3D l2vic_init, + .class_init =3D l2vic_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HEX_L2VIC_INTERFACE }, + { } + }, +}; + +static const TypeInfo l2vic_types[] =3D { + l2vic_interface_info, + l2vic_info, +}; + +DEFINE_TYPES(l2vic_types) diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 12d27ce1381..75cae450299 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -65,6 +65,8 @@ static const Property hexagon_cpu_properties[] =3D { DEFINE_PROP_LINK("tlb", HexagonCPU, tlb, TYPE_HEXAGON_TLB, HexagonTLBState *), DEFINE_PROP_UINT32("exec-start-addr", HexagonCPU, boot_addr, 0xfffffff= f), + DEFINE_PROP_LINK("l2vic", HexagonCPU, l2vic, + TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *), DEFINE_PROP_LINK("global-regs", HexagonCPU, globalregs, TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *), DEFINE_PROP_UINT32("htid", HexagonCPU, htid, 0), diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 3ce223caba3..8fb3d43c33b 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -40,6 +40,7 @@ #include "hw/hexagon/hexagon_globalreg.h" #include "hex_mmu.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/intc/hex-l2vic.h" #include "hex_interrupts.h" #include "hexswi.h" #endif @@ -1564,7 +1565,20 @@ void HELPER(raise_stack_overflow)(CPUHexagonState *e= nv, uint32_t slot, =20 void HELPER(ciad)(CPUHexagonState *env, uint32_t mask) { - g_assert_not_reached(); + uint32_t ipendad; + uint32_t iad; + HexagonCPU *cpu; + + BQL_LOCK_GUARD(); + cpu =3D env_archcpu(env); + ipendad =3D hexagon_globalreg_read(cpu->globalregs, HEX_SREG_IPENDAD, + env->threadId); + iad =3D fGET_FIELD(ipendad, IPENDAD_IAD); + fSET_FIELD(ipendad, IPENDAD_IAD, iad & ~(mask)); + hexagon_globalreg_write(cpu->globalregs, HEX_SREG_IPENDAD, + ipendad, env->threadId); + l2vic_clear_interrupt(cpu->l2vic); + hex_interrupt_update(env); } =20 void HELPER(siad)(CPUHexagonState *env, uint32_t mask) diff --git a/hw/hexagon/Kconfig b/hw/hexagon/Kconfig index 121c548bbb9..c75090c44a1 100644 --- a/hw/hexagon/Kconfig +++ b/hw/hexagon/Kconfig @@ -3,6 +3,7 @@ config HEX_DSP default y depends on HEXAGON select CPU_CLUSTER + select HEX_L2VIC =20 config HEX_VIRT bool diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index 636d00b7e88..097de4efc5d 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -8,6 +8,9 @@ config I8259 config PL190 bool =20 +config HEX_L2VIC + bool + config IOAPIC bool select I8259 diff --git a/hw/intc/meson.build b/hw/intc/meson.build index 377de78bb41..a1401cb5218 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -74,6 +74,8 @@ specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('x= ics_spapr.c', 'spapr_xi specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) + +specific_ss.add(when: 'CONFIG_HEX_L2VIC', if_true: files('hex-l2vic.c')) specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI_COMMON', if_true: files('loongs= on_ipi_common.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI', if_true: files('loongson_ipi.= c')) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index e7d6c304487..7512c6e6004 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -337,6 +337,10 @@ sh_intc_register(const char *s, int id, unsigned short= v, int c, int m) "%s %u - sh_intc_read(unsigned size, uint64_t offset, unsigned long val) "size %u 0= x%" PRIx64 " -> 0x%lx" sh_intc_write(unsigned size, uint64_t offset, unsigned long val) "size %u = 0x%" PRIx64 " <- 0x%lx" sh_intc_set(int id, int enable) "setting interrupt group %d to %d" +# hex-l2vic.c +hex_l2vic_reg_write(unsigned int addr, uint32_t value) "addr: 0x%03x value= : 0x%08"PRIx32 +hex_l2vic_reg_read(unsigned int addr, uint32_t value) "addr: 0x%03x value:= 0x%08"PRIx32 +hex_l2vic_delivered(int irq, int vid) "l2vic: delivered %d (vid %d)" =20 # loongson_ipi.c loongson_ipi_read(unsigned size, uint64_t addr, uint64_t val) "size: %u ad= dr: 0x%"PRIx64 "val: 0x%"PRIx64 --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990563; cv=none; d=zohomail.com; s=zohoarc; b=FXS5+jcOR115Sx0dPuw4Mafd7sLVa1ky6PJobULjbx8BbH7rvQv3kKTpYEiKuY8PrPKWCozjlfDDMo6uhNH4DSfvmtEdMaRvTVNcOLWaTEvzBEK+CJ8qbaiSQ1gfJGgAMllYbdJ/Tkd80+oET6/KpZVZ6Pq7H+MQkLeMb6Woin4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990563; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=12psgMGaE/AFAca7um5d5BHgu9y7A7ATuwy2bTUnMOM=; b=H45ssscNXNYch+X3cuSCt4yBocrRdteXYXCXXK/UX0wARLjUsjBzVTrhRqP0Z2oZ15xConJVbiPC8299/WEDa39gs64KfQOtaZ3038AG9VptOdJfbjxtoARkigbK2WKCyIqFBzDr2t76ughNiMMMDr/YoLeKRZEBO326SjiISnk= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990563183380.82520040222073; Wed, 5 Aug 2026 21:29:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphq-0002sa-DG; Thu, 06 Aug 2026 00:27:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphk-0002r2-Nd for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:40 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphj-0003DM-6Q for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:40 -0400 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763x2PM776166 for ; Thu, 6 Aug 2026 04:27:38 GMT Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvju8g34s-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:38 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e7ff7b375so1977677a91.1 for ; Wed, 05 Aug 2026 21:27:38 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:content-type:date:from :in-reply-to:message-id:mime-version:references:subject:to; s= qcppdkim1; bh=12psgMGaE/AFAca7um5d5BHgu9y7A7ATuwy2bTUnMOM=; b=Yo jjClVNkK4KAVW4nYmTGW9bGPmpBEgLLmOWmVTKyekI4J8bHiqtHYgoadKatIgK9J Iw3kp0Fwa0CjkaSzFjwig6tWDphMq0p8IjFyr8PlO8c5XDEfH0i4UzAbqqpzqeJs Phcs2+8I6ZgEimgljVGhINyF0mM7KPN6hIVKQ7PsZwUb9xUXe1AA05MFs0prEbUs v6XYohYW/b5mvN9ROt85gHm0637hhR8/7JclZTimfatnvcD4Ggc0MK+kgrj2MDsN a/Vjmxc0e0e12Ifp/qqmV1HnYzY1CRiNIr2jQn1lbYcGZgzFTvxJ/u6Jk39V30Kc ze8xEz97v49fNQPHbC1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990457; x=1786595257; darn=nongnu.org; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=12psgMGaE/AFAca7um5d5BHgu9y7A7ATuwy2bTUnMOM=; b=GVwEyMYwV1Rhr7JoSlNfQDXrAqaw/DnJ6lLaCqMpA/4BehF8KIr0G5zFTDpsVQvKMa 9zoGOg+XfZ08RoVbnLHFEipzrN62zoUnGn3XbrUukwJDMVUTpRBF6jwNGtcBiu24CVrv xcw6CpywS6Kn7q3SuR7uIdwZbHXkeLBQzRxAk4CI1RX3IuVqyYkxTEjD9nsK641H7X80 nBQsPKsZVnBfiHzMM+Bx7dVTr5AzigHM5rAhR0FUMiP8nfuNRj0pQfDnzb5N+MaQqkn1 qS/4WrfYYvNbZ+SVUBRRnLYPLLYfZzEF9QM2l5qLtfjgTToFnadXJvmZRsYX1drmWN3/ G23Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990457; x=1786595257; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=12psgMGaE/AFAca7um5d5BHgu9y7A7ATuwy2bTUnMOM=; b=PPeuBhMkOAp7n7knYfAVlKss+kWEVgJ6RsDYEcYSj2o/+XHYM0JQCzHVYhXxrZ9m9h l5dXYz0/IGjMln2zJFmyk39637vhxspGwfEXV8owiIiRafToM9r6czMA31dABgnMBEAP 02CmW5gYpRlC5splTJmHDQrdt+FeXOp+rNaFCyTiNpkdd4fq0ssu/MIrLgA2pAs4yfA9 XkHFZK+W3nMOY0c5tQ7Joojczky+8vye0qnrEqs2OzyFDbBNCFHQz4GLog8KBTv04UoU 96++og+k4BT2cfdO98xq9g0aRaaFmvZeu65Nonc7DmFDeBXs4IrgifPyyBmdp3E+cKnx 7/gA== X-Gm-Message-State: AOJu0Yx5GBceO037vS8QyDDt7LDoyW2pbQGHME1PY9LhROtO7A9TK241 rlbQdst9w3u+iAJOCiYQjacEqzA50+4C9cdyfaknJjmkvohFdmYTGo0qT7WE3GRfs7oUOZcV8AK PemBP20yvrGsoYsqk6sriR6rqBY8n881CK+ysSYIiLbxNDX3fR9R8T1SUJLytIWLndg== X-Gm-Gg: AR+sD11Xspkz9YWW8aQdQkyMB/S0ikwwA88VAcmx8tJIuEy3ojLywBe1kPvjm2fM/BS Wnw94WAnFbvsKbRLFI/b8qzn5fVjQOrxTnYsJy7gt7PG3EYcD6vGNYs3Au2aA9On/jRn1h0b5kK bnuQnl0bBsvCRkJG0gwDfuqHG6QAnTcBOe9AuvdKPf21vHgfpBxgalKxCYOudGs9tKIiNGCnl34 8RWVL5KzGq1rNUmmV+2TlIA6f5oawPvDEZoiUiRvF6IvoiQ15FZIbihmkw8Jm7Y+Nri/TtTxJ42 TO1lCrZCSXrUy6Ts2jOl4jda3dg/hyUpzzHvCckDJANgb4tvu88HduRfwZMHIPfC6gkB0cvdWCV IITy2GenM8pJJ0Z3YhDY7andps+BbCKaDU5tst7MKzqovmD5U X-Received: by 2002:a17:90b:5112:b0:381:28e0:6259 with SMTP id 98e67ed59e1d1-3903c592115mr12671472a91.9.1785990457360; Wed, 05 Aug 2026 21:27:37 -0700 (PDT) X-Received: by 2002:a17:90b:5112:b0:381:28e0:6259 with SMTP id 98e67ed59e1d1-3903c592115mr12671439a91.9.1785990456890; Wed, 05 Aug 2026 21:27:36 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 08/18] hw/hexagon: extract get_reg_value/set_reg_value stubs in globalreg Date: Wed, 5 Aug 2026 21:27:13 -0700 Message-Id: <20260806042723.3785369-9-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: Z7oWjMIChS101MvDp-dLKu7_kvZTuIja X-Proofpoint-ORIG-GUID: Z7oWjMIChS101MvDp-dLKu7_kvZTuIja X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX1LjNhX9bLqqu wMao6MGxwOfGxkvFTyLHyljg9GNUliG1RM/zkOA71x7cV2oOe3DkzUrS2fOCXHPLfDZLz1YDFL2 XX5ZynJldyFcuZpwGMu+Ush8x+6UHBB9W4PU43t/YORkEEqduu4usAvAq95uT3BvBTbGAKwIKc3 J/8NMQlKP61Dl62dCxxN3FXKPTWJN9LLsKDMX1QoAHIDsHwxWth22x4qA7l3CgZ8v4bM5bGKTnS Nrr1TUu3I/cvVEue3OWnAUiI+ai18PdBxxVEYsq1fr6tCo0MaFlTtiVkv9V6dPbXiKVyrrDB29U MxrNRVcxYaexLLIFM8SPTX53oeeQK+mg4LUhI1AWs4nx5PH0467DCYG2kIM5Mim3mjUW4EuStnN /D15VCmkcZLYPOQ9NSf/yEzF+AtsFkZwpsdBxblPU0NBNmFVcs4tvxmF5jbhIlXSnCE58vSnp/z gPcDz3Tu3aX+rKmAVIQ== X-Authority-Analysis: v=2.4 cv=K5cS2SWI c=1 sm=1 tr=0 ts=6a740d3a cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=Z4HElfRGeH4uGo3IGfcA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXx+StWLPNuUPN vWix/An5QNQiHFTufZcA8kFxttvwaj6+vYAqrJ2y+sxfYb1epVzu+KaHfWZ5P/gB8xP8XhG6A0b yVYnhRz1bHjRzbiVFS+TJn5Psre5rZM= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990564318158500 Content-Type: text/plain; charset="utf-8" Route the globalreg read/write accessors through new get_reg_value()/set_reg_value() helpers instead of touching s->regs[reg] directly. This will be exploited by a subsequent patch that redirects VID/VID1 accesses to the L2VIC. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Brian Cain --- hw/hexagon/hexagon_globalreg.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/hw/hexagon/hexagon_globalreg.c b/hw/hexagon/hexagon_globalreg.c index b5e5913507e..105475219ab 100644 --- a/hw/hexagon/hexagon_globalreg.c +++ b/hw/hexagon/hexagon_globalreg.c @@ -135,6 +135,17 @@ static inline uint32_t apply_write_mask(uint32_t new_v= al, uint32_t cur_val, return new_val; } =20 +static uint32_t get_reg_value(HexagonGlobalRegState *s, uint32_t reg) +{ + return s->regs[reg]; +} + +static void set_reg_value(HexagonGlobalRegState *s, uint32_t reg, + uint32_t value) +{ + s->regs[reg] =3D value; +} + uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg, uint32_t htid) { @@ -146,7 +157,7 @@ uint32_t hexagon_globalreg_read(HexagonGlobalRegState *= s, uint32_t reg, g_assert(reg < NUM_SREGS); g_assert(reg >=3D HEX_SREG_GLB_START); =20 - value =3D s->regs[reg]; + value =3D get_reg_value(s, reg); =20 trace_hexagon_globalreg_read(htid, get_sreg_name(reg), value); return value; @@ -160,7 +171,7 @@ void hexagon_globalreg_write(HexagonGlobalRegState *s, = uint32_t reg, } g_assert(reg < NUM_SREGS); g_assert(reg >=3D HEX_SREG_GLB_START); - s->regs[reg] =3D value; + set_reg_value(s, reg, value); trace_hexagon_globalreg_write(htid, get_sreg_name(reg), value); } =20 @@ -168,6 +179,7 @@ uint32_t hexagon_globalreg_masked_value(HexagonGlobalRe= gState *s, uint32_t reg, uint32_t value) { uint32_t reg_mask; + uint32_t cur_val; =20 if (!s) { return value; @@ -175,9 +187,10 @@ uint32_t hexagon_globalreg_masked_value(HexagonGlobalR= egState *s, uint32_t reg, g_assert(reg < NUM_SREGS); g_assert(reg >=3D HEX_SREG_GLB_START); reg_mask =3D global_sreg_immut_masks[reg]; + cur_val =3D get_reg_value(s, reg); return reg_mask =3D=3D IMMUTABLE ? - s->regs[reg] : - apply_write_mask(value, s->regs[reg], reg_mask); + cur_val : + apply_write_mask(value, cur_val, reg_mask); } =20 void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg, @@ -186,7 +199,7 @@ void hexagon_globalreg_write_masked(HexagonGlobalRegSta= te *s, uint32_t reg, if (!s) { return; } - s->regs[reg] =3D hexagon_globalreg_masked_value(s, reg, value); + set_reg_value(s, reg, hexagon_globalreg_masked_value(s, reg, value)); } =20 uint64_t hexagon_globalreg_get_pcycle_base(HexagonGlobalRegState *s) --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990539; cv=none; d=zohomail.com; s=zohoarc; b=ixBW+e6+7Q5P1Xq0QnPEZUB5UlaBYz+fzzp33VsYmH4ltoIVoS5LD5+t5sEaLfTyZqXKRxLxF6fOYwls8f9zh9QoUdOtWGi0ccB3kptqkYsf7SEUgfYytUWazfUPAvJp7X4zix60+2idBIskOQpyp4oRoLQOwGgZZpFgsRt+zKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990539; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BLHh55VB7GYnCYqKGWP3S3Dj4gAYp4cImisMK87+K9s=; b=O49o0OX6yqu3UjqU13p7AL79KuxGJBbozcFiyAOQfbTekLQ0UieWV4CgfyxPQuUd/TtW44WXT+HGMx/RFHMe+yemKYieawhAb9YjuhkQPeFwnzKQLS5szYC1iEbbM7cc7+Q7674CpUQbocGIrj/rvsp303S0QjsxOvcF04Gg51c= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990539699194.3428972751983; Wed, 5 Aug 2026 21:28:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphs-0002sr-EP; Thu, 06 Aug 2026 00:27:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphm-0002rS-Ko for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:42 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphk-0003DT-Mh for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:42 -0400 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763wnoc1070897 for ; Thu, 6 Aug 2026 04:27:39 GMT Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvjud02vu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:39 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38f5ac7416eso2220158a91.3 for ; Wed, 05 Aug 2026 21:27:39 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:content-type:date:from :in-reply-to:message-id:mime-version:references:subject:to; s= qcppdkim1; bh=BLHh55VB7GYnCYqKGWP3S3Dj4gAYp4cImisMK87+K9s=; b=LP ZixRsPAcinGXRONHS+W2OBSnhp7s5Y2kCusNdXMO0C0xjXKC1ZaJbKgvfYRtonPq 4yc3wD0p7SPjS1ztvFf7jiItqDBl04jZ/GxL7MTJdVcmsn6zibXL7lpsBhFvdFpS 9TC9X8xAIU5NGXrVvJTXgeUiBEHPBLuehMEUSfBjETxIoNlm6eleJG7087mo8evV UQM6yuWwpQWXbgXn5nlMJnVKBTZLn8MzVUcD5/IY0Rwk4tZHyraaRfscRw58f+MN InXboX4NzESsYC8LroJkJhu5e3fJNBehfBsQ7FpPu6TZdk0kUzrrsBxU5FeViOu0 sdJ/dtfLEOxz5m6am+zw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990459; x=1786595259; darn=nongnu.org; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=BLHh55VB7GYnCYqKGWP3S3Dj4gAYp4cImisMK87+K9s=; b=MelQMmbkqVv+Y4Brep6ADcjrsSmEzDF5X1lwvRHDz9BNjdqI9NCwe26LpU1TZfAnYh 0BNwR1sObarqd+6iBK2oTx5Go3s1KPbYHfn5slXgT3cZC26rM4vV7DdN4Fpl5jC1lj5M vQFVe4XiV+K1TmRnOsMPJX1LybTxWTktshAtc9oU6K9kDq5Ikifa6RN6HE/CBP/rsX/g JZPU6rCq/QhUrlbrsvVCtSIAQz9PWM3z5HOXBj308/iyXHiYYCRHUyEftzWPBobxhZnM sG6I/qvHxX8c4MXGs2wtoedvFXMYUP9Z5LxRe7rrhkA0lCERPwZAA2lE2JoBS69ZhHd5 Tjcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990459; x=1786595259; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BLHh55VB7GYnCYqKGWP3S3Dj4gAYp4cImisMK87+K9s=; b=EbsgvbPaiPm/E/M+HSjU2b7h13snpbnkDJ7dPKTgFL6lNPt+eORnXwyT5DRTfyE3KQ MYLgQ0Ar13rYzy6EM8tK4EIUKu8XBVZg5NLW2yu+4zsD5tweLX/y0eYF0vZcO+iyZcju 8Wu0evft23okhmwC5ldKBO/TS1EzFMbuFxP2tpKWA6FtN+kTwV9nJ6c81uspwvohca6C GcvcjWi31UGGMonfzQUyIrVII7l0EZED/wwamSZPYtzLYK2Yq27EDaf0Afz36BG0Pko4 rfzbW2i3yVeTy08m17yXSd4g4lseO+6Ftuj/qLkRFjSzYUS1tJBglNr4eUJQTf0zAvVn 9jeQ== X-Gm-Message-State: AOJu0Yw9ZE3GblunXUywHU5T+dNLEpfupmXEFr3zoPPHOAZp7wCnHu7c mPO7jYpDG1sO9watCTtSFkt6fl5tfo6tCGFaSCGaDO0g37SPojtJ2Xp2v6fbXshGj6dlzu+4/CR NbDaTS81+g9VMTPKbkW0wdH3D2qVMrfa7s2rXdLUJU3lRt3jmdsXnd3ulqAhI6h1a/g== X-Gm-Gg: AR+sD100JMX7HumWs8oGMGbDDYKyMsBgK8wmcX5dalXRNdTmqwdtVwJ4qJjEY5oruPt Q4iPsXaxvtI2QVCRwfF6kOclZgS9tai2zX2U2DvWDJVCxncLnwrmNFfciGSmn5MEjhIOdDsoyRm dC8gi8ksTyNtFFA29t+c/au9hWQXgP9ydbja29GFEikWGWilRZDSHT73tRLg5+9JxExS8U3qq5C eZX3gpeEI32aLEAsi1kUsYhKpkHBlgEXDFlbVCD0MUgybCMiDRoVy8Oruoh6tXYmvzXki6DZhYh nlEI85uX+0WgIUi5NJXEqpsVLRHSe+xdEo9gaaY9Ck+8k2QgmRYUgCJuUJGwUo8EOrbd6YsNyFT GlaI4k7bZP3anJgebjW/FPegJTo6rWp+nU96EzevgoXFuw+YO X-Received: by 2002:a17:90b:3889:b0:381:973e:fa08 with SMTP id 98e67ed59e1d1-3903c5cfba2mr10193090a91.18.1785990458552; Wed, 05 Aug 2026 21:27:38 -0700 (PDT) X-Received: by 2002:a17:90b:3889:b0:381:973e:fa08 with SMTP id 98e67ed59e1d1-3903c5cfba2mr10193053a91.18.1785990458002; Wed, 05 Aug 2026 21:27:38 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 09/18] hw/hexagon: connect l2vic device Date: Wed, 5 Aug 2026 21:27:14 -0700 Message-Id: <20260806042723.3785369-10-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXz+j8w8amgEJS Jdtwes5vzFjbuV9uEwI+b+icNRGrTqp+owGErGHWB11YGuzR66S62z9BTilevFz+IyhIp4aXTur JzWxYDF69QUDkJFFO2vg3SDQGBUIW32ZoiIiuSIF9KSGy32DR4mPG5yD6SIn4AMDgYeZq8iz9sh ZjaWIDIJvAMJh3Lu50rD/m/1HOCv7muQua/iD5qyS+HE0ag9iuTmKYYPSqVnasc5R3YMq37Ery2 LDZ3zyJytBbpbqQclh/Lc67EBNKGrq8R7ziKPM7rGwOJlTJijbzI+Kx3UCrT0Eo6k3KRjoZ4zCL gYY1HxkJl2mJPwJPWisPRK8hNpQcypLJ80kv3f18sgc8aTdL/NGZQfqLy/km6lzPdSMgpIDvrPS 0LYBm3Nf+g2JwNvoMX09WIUMLUUtccEvLAjHSwoXXLiJc+A2f1lDuVAnQpxzXxozBIp6Nv8kg/D pR8mdXh69rRL1bpUTvA== X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX1KPimleDyibl liXh28rF3g79izuG9VZMaPsyc9cWCp9ZeFlbvpOE1CWs03N5mT3kigGmC91deo741zgZsRmsbMg zIkBXw6//Nrra5lNuKc8IKpiU27feWM= X-Proofpoint-GUID: pAngieQj-xCu_7x24Ey3MIkI-MOinysY X-Proofpoint-ORIG-GUID: pAngieQj-xCu_7x24Ey3MIkI-MOinysY X-Authority-Analysis: v=2.4 cv=DeInbPtW c=1 sm=1 tr=0 ts=6a740d3b cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=dwkSCBXVzhE_Z7DFN7MA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 bulkscore=0 priorityscore=1501 adultscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990540395158500 Content-Type: text/plain; charset="utf-8" Add the l2vic to the shared hex-subsys so both machine models pick it up. Map its register banks, wire the interrupt lines to CPU[0] and link each vCPU, globalregs. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hex-subsys.h | 5 ++-- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_globalreg.h | 4 +++ hw/hexagon/hex-subsys.c | 38 +++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 2 +- hw/hexagon/hexagon_globalreg.c | 25 +++++++++++++++++ hw/hexagon/virt.c | 2 +- 7 files changed, 72 insertions(+), 5 deletions(-) diff --git a/include/hw/hexagon/hex-subsys.h b/include/hw/hexagon/hex-subsy= s.h index 6d0d5e1da86..5792f7b5af3 100644 --- a/include/hw/hexagon/hex-subsys.h +++ b/include/hw/hexagon/hex-subsys.h @@ -18,7 +18,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, /* * Parent a CPU into the subsystem's cluster and wire its links. Call for * every CPU before hex_subsys_realize_cluster(), then realize each CPU wi= th - * hex_subsys_realize_cpu(). + * hex_subsys_realize_cpu(). CPU[0] receives the L2VIC outputs. */ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu); =20 @@ -26,6 +26,7 @@ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, D= eviceState *cpu); void hex_subsys_realize_cluster(HexagonCommonMachineState *hms); =20 /* Realize a CPU previously parented via hex_subsys_add_cpu(). */ -void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu); +void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu, + bool boot_cpu); =20 #endif /* HW_HEXAGON_HEX_SUBSYS_H */ diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h index 31669a829f8..ec1578807d8 100644 --- a/include/hw/hexagon/hexagon.h +++ b/include/hw/hexagon/hexagon.h @@ -158,6 +158,7 @@ struct HexagonCommonMachineState { MemoryRegion cfgtable_rom; MemoryRegion vtcm; DeviceState *cluster; + DeviceState *l2vic; DeviceState *glob_regs; DeviceState *tlb; }; diff --git a/include/hw/hexagon/hexagon_globalreg.h b/include/hw/hexagon/he= xagon_globalreg.h index 950099808fd..397dc6854c9 100644 --- a/include/hw/hexagon/hexagon_globalreg.h +++ b/include/hw/hexagon/hexagon_globalreg.h @@ -10,6 +10,7 @@ =20 #include "hw/core/qdev.h" #include "hw/core/sysbus.h" +#include "hw/intc/hex-l2vic.h" #include "qom/object.h" #include "target/hexagon/cpu.h" =20 @@ -22,6 +23,9 @@ struct HexagonGlobalRegState { /* Array of system registers */ uint32_t regs[NUM_SREGS]; =20 + /* L2VIC interface used to back the VID/VID1 registers */ + HexL2VicInterface *l2vic; + /* Global performance cycle counter base */ uint64_t g_pcycle_base; =20 diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c index 6fad6fe0a4d..25c028f6579 100644 --- a/hw/hexagon/hex-subsys.c +++ b/hw/hexagon/hex-subsys.c @@ -10,6 +10,7 @@ #include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/intc/hex-l2vic.h" #include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" @@ -17,6 +18,31 @@ #include "hw/core/sysbus.h" #include "system/address-spaces.h" =20 +#define HEX_L2VIC_CPU_IRQS 8 + +static DeviceState *l2vic_create(HexagonCommonMachineState *hms, + const struct hexagon_machine_config *m_cf= g) +{ + DeviceState *l2vic =3D qdev_new(TYPE_HEX_L2VIC); + + object_property_add_child(OBJECT(hms), "l2vic", OBJECT(l2vic)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(l2vic), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(l2vic), 0, m_cfg->l2vic_base); + sysbus_mmio_map(SYS_BUS_DEVICE(l2vic), 1, + m_cfg->cfgtable.fastl2vic_base << 16); + + return l2vic; +} + +static void l2vic_connect_cpu(DeviceState *l2vic, DeviceState *cpu) +{ + int i; + + for (i =3D 0; i < HEX_L2VIC_CPU_IRQS; i++) { + sysbus_connect_irq(SYS_BUS_DEVICE(l2vic), i, qdev_get_gpio_in(cpu,= i)); + } +} + static DeviceState *globalreg_create(HexagonCommonMachineState *hms, const struct hexagon_machine_config *= m_cfg, Rev_t rev) @@ -26,6 +52,8 @@ static DeviceState *globalreg_create(HexagonCommonMachine= State *hms, object_property_add_child(OBJECT(hms), "global-regs", OBJECT(glob_regs= )); qdev_prop_set_uint64(glob_regs, "config-table-addr", m_cfg->cfgbase); qdev_prop_set_uint32(glob_regs, "dsp-rev", rev); + object_property_set_link(OBJECT(glob_regs), "l2vic", OBJECT(hms->l2vic= ), + &error_fatal); sysbus_realize_and_unref(SYS_BUS_DEVICE(glob_regs), &error_fatal); =20 return glob_regs; @@ -81,6 +109,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, } =20 hms->cluster =3D cluster_create(hms); + hms->l2vic =3D l2vic_create(hms, m_cfg); hms->glob_regs =3D globalreg_create(hms, m_cfg, rev); hms->tlb =3D tlb_create(hms, m_cfg); } @@ -92,6 +121,8 @@ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, = DeviceState *cpu) OBJECT(hms->glob_regs), &error_fatal); object_property_set_link(OBJECT(cpu), "tlb", OBJECT(hms->tlb), &error_fatal); + object_property_set_link(OBJECT(cpu), "l2vic", OBJECT(hms->l2vic), + &error_fatal); } =20 void hex_subsys_realize_cluster(HexagonCommonMachineState *hms) @@ -105,7 +136,12 @@ void hex_subsys_realize_cluster(HexagonCommonMachineSt= ate *hms) qdev_realize_and_unref(hms->cluster, NULL, &error_fatal); } =20 -void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu) +void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *c= pu, + bool boot_cpu) { qdev_realize_and_unref(cpu, NULL, &error_fatal); + + if (boot_cpu) { + l2vic_connect_cpu(hms->l2vic, cpu); + } } diff --git a/hw/hexagon/hexagon_dsp.c b/hw/hexagon/hexagon_dsp.c index 1db5d681665..20306c28e72 100644 --- a/hw/hexagon/hexagon_dsp.c +++ b/hw/hexagon/hexagon_dsp.c @@ -139,7 +139,7 @@ static void hexagon_common_init(MachineState *machine, = Rev_t rev, hex_subsys_realize_cluster(hms); =20 for (int i =3D 0; i < machine->smp.cpus; i++) { - hex_subsys_realize_cpu(hms, DEVICE(cpus[i])); + hex_subsys_realize_cpu(hms, DEVICE(cpus[i]), (i =3D=3D 0)); } } =20 diff --git a/hw/hexagon/hexagon_globalreg.c b/hw/hexagon/hexagon_globalreg.c index 105475219ab..285cb48c44b 100644 --- a/hw/hexagon/hexagon_globalreg.c +++ b/hw/hexagon/hexagon_globalreg.c @@ -11,6 +11,7 @@ #include "hw/core/qdev-properties.h" #include "hw/core/sysbus.h" #include "hw/core/resettable.h" +#include "hw/intc/hex-l2vic.h" #include "migration/vmstate.h" #include "qom/object.h" #include "target/hexagon/cpu.h" @@ -135,8 +136,16 @@ static inline uint32_t apply_write_mask(uint32_t new_v= al, uint32_t cur_val, return new_val; } =20 +static inline bool is_vid_reg(uint32_t reg) +{ + return reg =3D=3D HEX_SREG_VID || reg =3D=3D HEX_SREG_VID1; +} + static uint32_t get_reg_value(HexagonGlobalRegState *s, uint32_t reg) { + if (is_vid_reg(reg)) { + return l2vic_read_vid(s->l2vic, reg =3D=3D HEX_SREG_VID ? 0 : 1); + } return s->regs[reg]; } =20 @@ -144,6 +153,9 @@ static void set_reg_value(HexagonGlobalRegState *s, uin= t32_t reg, uint32_t value) { s->regs[reg] =3D value; + if (is_vid_reg(reg)) { + l2vic_update_vid(s->l2vic, reg =3D=3D HEX_SREG_VID ? 0 : 1, value); + } } =20 uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg, @@ -269,6 +281,16 @@ static void hexagon_globalreg_reset_hold(Object *obj, = ResetType type) do_hexagon_globalreg_reset(s); } =20 +static void hexagon_globalreg_realize(DeviceState *dev, Error **errp) +{ + HexagonGlobalRegState *s =3D HEXAGON_GLOBALREG(dev); + + if (!s->l2vic) { + error_setg(errp, "hexagon_globalreg: 'l2vic' link property not set= "); + return; + } +} + static const VMStateDescription vmstate_hexagon_globalreg =3D { .name =3D "hexagon_globalreg", .version_id =3D 1, @@ -288,6 +310,8 @@ static const VMStateDescription vmstate_hexagon_globalr= eg =3D { }; =20 static const Property hexagon_globalreg_properties[] =3D { + DEFINE_PROP_LINK("l2vic", HexagonGlobalRegState, l2vic, + TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *), DEFINE_PROP_UINT32("boot-evb", HexagonGlobalRegState, boot_evb, 0x0), DEFINE_PROP_UINT64("config-table-addr", HexagonGlobalRegState, config_table_addr, 0xffffffffULL), @@ -308,6 +332,7 @@ static void hexagon_globalreg_class_init(ObjectClass *k= lass, const void *data) ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 rc->phases.hold =3D hexagon_globalreg_reset_hold; + dc->realize =3D hexagon_globalreg_realize; dc->vmsd =3D &vmstate_hexagon_globalreg; dc->user_creatable =3D false; device_class_set_props(dc, hexagon_globalreg_properties); diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index dc1d5b6aa24..9a680852c3c 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -270,7 +270,7 @@ static void virt_init(MachineState *ms) hex_subsys_realize_cluster(&vms->parent_obj); =20 for (int i =3D 0; i < ms->smp.cpus; i++) { - hex_subsys_realize_cpu(&vms->parent_obj, DEVICE(cpus[i])); + hex_subsys_realize_cpu(&vms->parent_obj, DEVICE(cpus[i]), (i =3D= =3D 0)); } =20 fdt_add_cpu_nodes(vms); --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990611; cv=none; d=zohomail.com; s=zohoarc; b=Je2p73tZT/JLuYL8kHUyZlmbbGjoSvF2Su2YENnyUA82UPg0oi6AlWVnXqTjdWDWElTuo8bD8FTNC/KX3WQ9w1qkWt06jTX2F9J4Xm0UvRxk5+LVQZnU9nidc33G9DGxoSiMs/UdSguOUKoKlpx/c8v7/+1Me7mvrlJtqmkMlpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990611; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=x33rKD5AJt14CHYPvmx76d8qJqPC6RXtU8ksUlr6PXc=; b=ElmlmI+9pw6TsBv2EMumU2GEVnY1qNxXy0x5euMf3pwfz0+o7k4xVLVlPIP5SozmjvaWSYMdSg5Rzj1TuMOIAsl4M3uEf0Iy8mtG7ivvgA5tJYBLkzVW4D3gDg+K3OoBUSWpAZFNTQoH2Cd73RVIR6eC2rJrBZooKdyh/jbUc54= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990611443966.2979517961498; Wed, 5 Aug 2026 21:30:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphu-0002ta-9H; Thu, 06 Aug 2026 00:27:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrpho-0002rn-3x for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:44 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphm-0003De-Fu for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:43 -0400 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763x8xX1071632 for ; Thu, 6 Aug 2026 04:27:41 GMT Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvjucg372-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:41 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cb5bdd8450dso1147767a12.0 for ; Wed, 05 Aug 2026 21:27:41 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:content-type:date:from :in-reply-to:message-id:mime-version:references:subject:to; s= qcppdkim1; bh=x33rKD5AJt14CHYPvmx76d8qJqPC6RXtU8ksUlr6PXc=; b=ky E94WLl8Eqf2TAYZL/6dcE6ZrIxgJKDZ3DOqtcqtLyDCho/4YK+tH4WLQkFbHuqzH h7DjH3F7E5ed6tpfsp02xJostulmi+hJUPpM4+0V4Z9SBPMZZz+ybgpFXXT4/hrG BfJfdMz5SdVKVaKaueSlVYtaSm/nIx1+n628nLr77ZuW1vCEveLxAGYxPITRS/sN kXGN8fo+p1E0Qkv/MV7lp2D3KVpvtrtfdudANrHTAfLoj5dqMPWIIXeHjcN2w/bR xzODrD19g88XG4Cjs5v25Idy8jVOybdf3nTjyIdH8R33PuWPX9vWt183M9W85lZD kbcePYBKdUfgroIUM4aQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990460; x=1786595260; darn=nongnu.org; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=x33rKD5AJt14CHYPvmx76d8qJqPC6RXtU8ksUlr6PXc=; b=Q6XaFBy1qAxVhIbvaUuf6ROilX45lx/NKVrAJaNJuM5V/d7CUq6wV/uWoT50oQL5Wk mAOPYs6PrrHLp4MvhY2oXtlzsc1ZqFe2LFzaDV6b1+PV7ShhNNESClWRcEPIIyG2UBwm p3IFOd5ZQD8EAMRvnWQ9lc/m2cAEJ4/dMgQP7RaHlFEW6P+zxOMSFs4OvwJwLp2LTN3r pMhMjdnAjv7HWqA4dLBdfSkyLuF4sYuRi2cGN6/NEKcj5p1oanYHVgM6Q98jPHO1Veb6 vChlQnXIfs2dfUpylYonsMiPbV+wI49nGh32wqnmcUIjXvQMsWMMdnX9t2qlmRfgQHAt EeHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990460; x=1786595260; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=x33rKD5AJt14CHYPvmx76d8qJqPC6RXtU8ksUlr6PXc=; b=MK9N7bbnRir3u7md1Hwld5A1TQcHlldq7sC4GtMKxtQrE39vOLsUavQtFZJVY5l9mK 3Nhs4iIGu5n5ypeIDJ/jeg053/9/2CHgypo+z+qjkrZ6IQs2bMaqgNcyAofytCmNWfzV kBz8URG4jzXk4KF5ac1qh+8EbBVWmQHMIG2nD1f1TpBGCDuWMAgrtHoSOoYB0mvuL8nl Vw++0ecWcznyqRdnBZGdkg92Nxi2mJUWWXy6qw1YQ5hPmCxFYu54iBJs9fUbEMKV99qc CgjAgLQvwS1AmdG1sDfRM/eyXNsxdA4mbdUl8fiJHs7F4PQNH/+w/J3YotSRR4BFDtXF 2CGg== X-Gm-Message-State: AOJu0YxdcTFO1dKOQEuxRuLIC782FmdcpxS1GLHGKzjT2nyGq3pkCQOO bd3weoQsmJGtn/RYEVSouBc+bgDTn2byTFpEg8Yl8iikyWXXErNfML3b+G9Zi7Alp+ze+U6b3hM HfNcHOnJZGalvR4s5eHARBjD5iBn6TY+iIQwS+wVlePYzcHQ9jzcRsUSxc/EMEJ2zag== X-Gm-Gg: AR+sD13tr0ARkE2nrip9QAV02mPxGn1JAMEXQY/ETTDNnSLn8cyEGhEo2fL4WeeOyMG tUARnvmIqpKLQPh0Ia+fG0wlngZ/ZPiWMjqoNLI5b2qzEOHR/jtV8Kt4iJsKvbCWOTd1bc+9Lt1 W4AO4T90QLIwc1qLHsy7gaagk5xI5JmZyzxhn2dnoi3b1lH1xT6ucmFPHx5Z3Lk7i3gRrbexkb+ vcIXJsDI2BtaZxBpR4xL7hNY+r6QaGenXRzCoXUZspYbcUcI4tuBUCDhthta14kPhfwBF1c26yM Us2l9oL2Fxg+/o7wgt/4cBYhr5aqVJBMJ3sOwy0FP6TPtKdkL5bQFXyU65+VtTJFu7+fTootmUr zkJPvrElRQdnyg0laWwPFagfxitq4aOIZEdFbI23wyUd58+xU X-Received: by 2002:a05:6a20:4309:b0:3c3:7481:7a03 with SMTP id adf61e73a8af0-3cb86028b7dmr12701318637.34.1785990460322; Wed, 05 Aug 2026 21:27:40 -0700 (PDT) X-Received: by 2002:a05:6a20:4309:b0:3c3:7481:7a03 with SMTP id adf61e73a8af0-3cb86028b7dmr12701265637.34.1785990459923; Wed, 05 Aug 2026 21:27:39 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 10/18] hw/hexagon/virt: instantiate virtio-mmio transports Date: Wed, 5 Aug 2026 21:27:15 -0700 Message-Id: <20260806042723.3785369-11-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX0ENinrb+R2FT Jw050jzt9RBpvQ8MZtttPNEUIddrRqMqClz3Sh0EXzzY70oqJZctgkRuYQYmSOObam7Jx3dhUdc TvEoV91y/tB8YxIkgwsiU/v6fSVtCu0= X-Proofpoint-GUID: 4LXixnNLICtMvZRqrmwKM3aEBO2EzA9L X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX/MknICycPU0d NYwQcN0Afu8FrYChrG3vQ7a80uzmEJ8oKvCa0rz3re5HebgnSMt7p5pC45xtUJC9v3gh6n/K/LC 7enB8SGxgXdQge8Ak4fUUNv7+8Tyc5aXRGZVsagQr7jS/2xCgEvoCEPgEItohZATOrLVoad2Lxj EaZlf0HuEZUqccYmS37vVJF9zb+o3eemXsc1qxjOw39wfXprdZ7IbwQiTPhhB6yZBoYJx11A7vg YBDfNuRWDZSmWy2Aq64sXgHyPqmineh3azYF+HX1gaHRh5a61xlT6xelgHZK8zt+RvMtSAKpiHv ieuVz4JRmU2oHZjjQ3SANa4070e5zQyYieb/dxA1mFne+SwkPmFje8tg5/2fs3T5A92/NYkFre9 PV5yvZdBf05kaIojam+MHXkwK7rLlng3O4zUh4akAM52nIMbMAkGs2YF4XCMMoJi6cpJMoDjA9j t1vuFEV2mYGPm5Cxt2g== X-Authority-Analysis: v=2.4 cv=Mo1iLWae c=1 sm=1 tr=0 ts=6a740d3d cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=qfYuoNLC281KTBfHwCsA:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-ORIG-GUID: 4LXixnNLICtMvZRqrmwKM3aEBO2EzA9L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 adultscore=0 malwarescore=0 bulkscore=0 clxscore=1015 suspectscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990612577158500 Content-Type: text/plain; charset="utf-8" Add a VIRT_MMIO region and virtio-mmio transports, wired into l2vic. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Brian Cain --- include/hw/hexagon/virt.h | 3 +++ hw/hexagon/virt.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/hw/hexagon/virt.h b/include/hw/hexagon/virt.h index cf0cd2f8f22..4ca2f1ef859 100644 --- a/include/hw/hexagon/virt.h +++ b/include/hw/hexagon/virt.h @@ -11,6 +11,8 @@ #include "hw/hexagon/hexagon.h" #include "target/hexagon/cpu.h" =20 +#define VIRTIO_DEV_COUNT 8 + struct HexagonVirtMachineState { HexagonCommonMachineState parent_obj; =20 @@ -19,6 +21,7 @@ struct HexagonVirtMachineState { MemoryRegion tcm; MemoryRegion bios; Clock *apb_clk; + DeviceState *virtio_mmio[VIRTIO_DEV_COUNT]; }; =20 void hexagon_load_fdt(const struct HexagonVirtMachineState *vms); diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index 9a680852c3c..ff0770cfc46 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -30,11 +30,19 @@ =20 enum { VIRT_UART0, + VIRT_MMIO, VIRT_FDT, }; =20 +/* + * Virtio IRQs run from VIRTIO_IRQ_BASE to + * VIRTIO_IRQ_BASE + VIRTIO_DEV_COUNT - 1 + */ +static const int VIRTIO_IRQ_BASE =3D 16; + static const MemMapEntry base_memmap[] =3D { [VIRT_UART0] =3D { 0x10000000, 0x00000200 }, + [VIRT_MMIO] =3D { 0x11000000, 0x00001000 }, [VIRT_FDT] =3D { 0x99800000, 0x00400000 }, }; =20 @@ -167,7 +175,25 @@ static void fdt_add_cpu_nodes(const HexagonVirtMachine= State *vms) } } =20 +static void create_virtio_devices(HexagonVirtMachineState *vms) +{ + hwaddr size =3D base_memmap[VIRT_MMIO].size; =20 + for (int i =3D 0; i < VIRTIO_DEV_COUNT; i++) { + int irq =3D VIRTIO_IRQ_BASE + i; + hwaddr base =3D base_memmap[VIRT_MMIO].base + i * size; + DeviceState *dev =3D qdev_new("virtio-mmio"); + SysBusDevice *s =3D SYS_BUS_DEVICE(dev); + + object_property_add_child(OBJECT(MACHINE(vms)), "virtio-mmio[*]", + OBJECT(dev)); + sysbus_realize_and_unref(s, &error_fatal); + sysbus_mmio_map(s, 0, base); + sysbus_connect_irq(s, 0, + qdev_get_gpio_in(vms->parent_obj.l2vic, irq)); + vms->virtio_mmio[i] =3D dev; + } +} =20 void hexagon_load_fdt(const HexagonVirtMachineState *vms) { @@ -246,6 +272,8 @@ static void virt_init(MachineState *ms) =20 fdt_add_hvx(vms, m_cfg); =20 + create_virtio_devices(vms); + g_autofree HexagonCPU **cpus =3D g_new(HexagonCPU *, ms->smp.cpus); =20 for (int i =3D 0; i < ms->smp.cpus; i++) { --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990590; cv=none; d=zohomail.com; s=zohoarc; b=W7fRCQq9OaA0LGM4lkj22hRt30YkngEQPIGnwvvhAopwKccTnsZUh/Yfyskwatjl6vnFdfr6UhJM1yAiV6UiadHZtGaj7fwhJpj3aGxbWRWuKRiKWMylJI30D/xXAS0Hb1rTm9rTAguJvWHkzWlVW9SXpzZXttbPKgzAgQrgnIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990590; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vyFm6rtZZeS2n/g9pNabBjWQ5XefV0jnC61R5IL9YVU=; b=bAzEXF0SzVWTfSttcs21sllfEkOknMZvBlqPYTqUAe/QLtatKdafvHMO1tl3AdWluUS/ZoCEmHh6CehhNxC+YrcZk+DvlHUnDiElkrWXCiAlaOvqqf8P0oL5lr2ddCUaLJG5akn/plhUmWSuG+Q9BxFCLZP6GZVy1fNa3XuCRJU= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990590575679.9531762485341; Wed, 5 Aug 2026 21:29:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphs-0002sq-DF; Thu, 06 Aug 2026 00:27:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphq-0002sS-0s for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:46 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrpho-0003Dv-6n for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:45 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675NbDZv267108 for ; Thu, 6 Aug 2026 04:27:43 GMT Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv3w6c1je-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:42 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cb5bdd8450dso1147784a12.0 for ; Wed, 05 Aug 2026 21:27:42 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= vyFm6rtZZeS2n/g9pNabBjWQ5XefV0jnC61R5IL9YVU=; b=nihn8nhkJFwrvX99 u7L6T95neuTJGogmOYbsbRh0mHmhyuhaO9Z/7iDHwXOy47mb3D1MyRjMfURJd3NP JY3sFEwBQ1p03N1HpqczVXVEKph4SQWvfM7D0+0hDXsnRE8rBOJDRbfrAdKHRWOr Au4xnMkb6T6b15fe8q9swDQaDk5nEds7NFNTBjDB4obICVSJEaNZ6JwpMRUr94uC GaAbrZ0iXa9c+y7HDNHX1pVKEDdsW/6Xz1Q3s48Jvdhooq3dzrM5KiqT8yAND920 qSzsEGelbYQmQpy40wEnagRkzBuoNrDINNmT/qW4q4zcJ/vbaAEX8mryGYDUlZ2S 8AOz5Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990462; x=1786595262; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=vyFm6rtZZeS2n/g9pNabBjWQ5XefV0jnC61R5IL9YVU=; b=GE4XD+4Wfx85cNF+BGDzOz4kJTksuienrYaPTs3R0kt+AA4VbFrE55H6B+UGFAHoKm zzbI0eGK+J860vuJIGKJ2hWipMgIHOAT0lHuCsZaSPcpKdBmMYZ8SiWDXRy6+L5RimLz JIuvcdInzqk1GCgiigChCXj/mQKN+eIu3sdyO/GqOqhWi902DRdEpCfe+EF7zGm9pvPW 2kTgiFhui/LeWRJWTXUkho9VXWh4MaMR0GIkLA77X6wHzIVgHyXLV1WrOmZGmRq0L6CF B4QAw1BFetMxi8oLiTvGLK4Di+CyTSKXih69+wd4gEr3cmNEi3FB+2Mxx/EEoxbzDq4X Lopw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990462; x=1786595262; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vyFm6rtZZeS2n/g9pNabBjWQ5XefV0jnC61R5IL9YVU=; b=rhLaH0HNvRQUL6AInnRoCvluD25o7ps9Y/zmx2wr7BkK+Z5SgGROOEvZdsCL4qweoe LNooh0FqBSazIzm/otLDKutDlra+6QzYMkiRFSbeHGJYfdRiFZ7rkaCI6P8HPx7S2C/Z 3KSKFTTK67wQR29+jfJD7/GttBD7Lh1nx21b4Rf3Sr0LNcsN5aM/NbG04vnSi5LEjUIC KpQKSppSNbOwIEzGL8xTjqBfBKlFZsPYSjdDNI2n2Z4ZEZIKgGRIyIvBk25yKstbe4pu ms9KwffYRUs1e8gS5j7gYAtCRNLy3TC1m30WnjDpPOH90sTgi9v5JNoGg/3YvOcl1Smk uCoQ== X-Gm-Message-State: AOJu0YznauU8iKFxPMKujkpAf97QaGQo7uAx6Y1bzBaO9FXYyKKwhZix IR+yA+nuZUD91nd2+mIAZFr8laWIZ+0+LPnYsCdrmkn9o3YDvpGn351IZttWQeCqKnMkRBRf1bF 1gunciXC/yRuKb4tGdinG14py4olun7PXUKUGtlZnxPZ3h80DDWEb9UZiKNYctVr8vw== X-Gm-Gg: AR+sD13kIZBytAwusiDfqWGCAnQqBkD/3AsePPS0mE3VArSvBQizdyN/2Tpz887fCXF yp7wn5JhS687shCiNWECPi3dmK3BSE79fTCzTQUHK4AaaVnx5SXPpsDJJtryiz1LV74aLDdSl48 mj8JWyBmlCnTM9MuBHtBB5upUumZBRkVcfdagViOvD7yZ02eFZ6sDVwYRzBi/erJAVE+z3lMdlW Z94OIa2RrDGx6iCB5L1MKLdnrw0bVe+HoOjtOMSgrs+piTkoUXv5Cr/5QW1f+QjPaojo1x3m4uT /QhP59BkM4Dh7EagWZyeLR5GxxHte+ZC2EJl5D1OXsiG2x5lPatlPumpgzG/zjDH8st+pfeBxCM 8YuAu1qZhG+JePS2wz9UqeztlHkYDSqSdDOSgnc4lANx6Xy/0 X-Received: by 2002:a05:6a21:329e:b0:3b5:489c:7bb5 with SMTP id adf61e73a8af0-3cb85f06883mr13779902637.28.1785990462209; Wed, 05 Aug 2026 21:27:42 -0700 (PDT) X-Received: by 2002:a05:6a21:329e:b0:3b5:489c:7bb5 with SMTP id adf61e73a8af0-3cb85f06883mr13779873637.28.1785990461810; Wed, 05 Aug 2026 21:27:41 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 11/18] hw/hexagon/virt: add l2vic interrupt-controller and virtio-mmio FDT nodes Date: Wed, 5 Aug 2026 21:27:16 -0700 Message-Id: <20260806042723.3785369-12-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: C9q9GtcpxJFDW-EL5cHISBrBpP2-FEJl X-Proofpoint-ORIG-GUID: C9q9GtcpxJFDW-EL5cHISBrBpP2-FEJl X-Authority-Analysis: v=2.4 cv=a48AM0SF c=1 sm=1 tr=0 ts=6a740d3e cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=a15GVhKgg4D0RywPxTcA:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXx2xTzZ1udiZm XMwSX6jjjwkUnaNMIszDVKK0M9QoMt0hlkAP9yVW/rqWm8wMBz4V3ol7VfpP3JGtU0igUdc2a6K kaHJ7SLeUuGIMFK892ECDi+ZlEK/l1A= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX9Uj6Ehaqa3bu TEt/p9m7a4tOv80SvGVQzXbylfgF9AN7vLAhXwhW6pl5oJuOAFpKNh7EnoKKF58QqAF/yRBjYRv yzL9uKq1XSnmjcWXAkNAPOmInGXrmbSo2n1uPEs6GcMXOsB6s9wwwLNaq2UapiUrrZxkd4CGMdI nQNlw4Z6v85ALFqcKtbZK7YgNog180lr4n1EKGep72WDh+IXS+MIYlkPEdvCQpWWZSs0gkl1Yen PmzGmjDyZEjG3RhBBWlR3G5eDEnQ4ywZXoNXiqHL100LAlpbUHCgF7t5hWCLTg4GarzcCQLOeT4 lFM1T85z45QdjXTlTYuaAFIrzPSvWn3ZZOfAT4jr8JLeRmHdT+b3auzeRKYRfuaaDlpcrMdjfqo CpFLYNaR7cDj5Dvu7Z57dyXFx9Hx4udh6jbMAVpxNCL/7OIhEX/4ximEoMmLvnMr5K5ATZ/oNm5 pxxba/D6C0xmH2KGIiA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990592477158500 Expose l2vic as a device-tree interrupt-controller node and reference it via interrupt-parent, so guest kernels can discover the virtio-mmio transports. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- hw/hexagon/virt.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index ff0770cfc46..ea20ea3c50a 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -75,6 +75,30 @@ static void create_fdt(HexagonVirtMachineState *vms) qemu_fdt_setprop(fdt, "/chosen", "rng-seed", rng_seed, sizeof(rng_seed= )); } =20 +static int32_t fdt_add_l2vic(HexagonVirtMachineState *vms, + const struct hexagon_machine_config *m_cfg) +{ + MachineState *ms =3D MACHINE(vms); + int32_t l2vic_phandle =3D qemu_fdt_alloc_phandle(ms->fdt); + char *nodename =3D g_strdup_printf("/soc/interrupt-controller@%x", + m_cfg->l2vic_base); + const char compat[] =3D "qcom,h2-pic\0hvm-pic"; + + qemu_fdt_setprop_cell(ms->fdt, "/soc", "interrupt-parent", l2vic_phand= le); + + qemu_fdt_add_subnode(ms->fdt, nodename); + qemu_fdt_setprop_cell(ms->fdt, nodename, "#address-cells", 0x0); + qemu_fdt_setprop_cell(ms->fdt, nodename, "#interrupt-cells", 0x1); + qemu_fdt_setprop(ms->fdt, nodename, "compatible", compat, sizeof(compa= t)); + qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 0, + m_cfg->l2vic_base, m_cfg->l2vic_size); + qemu_fdt_setprop(ms->fdt, nodename, "interrupt-controller", NULL, 0); + qemu_fdt_setprop_cell(ms->fdt, nodename, "phandle", l2vic_phandle); + + g_free(nodename); + return l2vic_phandle; +} + static void fdt_add_hvx(HexagonVirtMachineState *vms, const struct hexagon_machine_config *m_cfg) { @@ -175,13 +199,16 @@ static void fdt_add_cpu_nodes(const HexagonVirtMachin= eState *vms) } } =20 -static void create_virtio_devices(HexagonVirtMachineState *vms) +static void create_virtio_devices(HexagonVirtMachineState *vms, + int32_t l2vic_phandle) { + MachineState *ms =3D MACHINE(vms); hwaddr size =3D base_memmap[VIRT_MMIO].size; =20 for (int i =3D 0; i < VIRTIO_DEV_COUNT; i++) { int irq =3D VIRTIO_IRQ_BASE + i; hwaddr base =3D base_memmap[VIRT_MMIO].base + i * size; + char *nodename =3D g_strdup_printf("/soc/virtio_mmio@%" PRIx64, ba= se); DeviceState *dev =3D qdev_new("virtio-mmio"); SysBusDevice *s =3D SYS_BUS_DEVICE(dev); =20 @@ -192,6 +219,16 @@ static void create_virtio_devices(HexagonVirtMachineSt= ate *vms) sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->parent_obj.l2vic, irq)); vms->virtio_mmio[i] =3D dev; + + qemu_fdt_add_subnode(ms->fdt, nodename); + qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", + "virtio,mmio"); + qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 0, base, size); + qemu_fdt_setprop_cell(ms->fdt, nodename, "interrupts", irq); + qemu_fdt_setprop_cell(ms->fdt, nodename, "interrupt-parent", + l2vic_phandle); + + g_free(nodename); } } =20 @@ -251,6 +288,7 @@ static void virt_init(MachineState *ms) HexagonVirtMachineState *vms =3D HEXAGON_VIRT_MACHINE(ms); const struct hexagon_machine_config *m_cfg =3D &v68n_1024; int32_t clk_phandle; + int32_t l2vic_phandle; =20 create_fdt(vms); qemu_fdt_setprop_string(ms->fdt, "/chosen", "bootargs", ms->kernel_cmd= line); @@ -272,7 +310,8 @@ static void virt_init(MachineState *ms) =20 fdt_add_hvx(vms, m_cfg); =20 - create_virtio_devices(vms); + l2vic_phandle =3D fdt_add_l2vic(vms, m_cfg); + create_virtio_devices(vms, l2vic_phandle); =20 g_autofree HexagonCPU **cpus =3D g_new(HexagonCPU *, ms->smp.cpus); =20 --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990486; cv=none; d=zohomail.com; s=zohoarc; b=EP3f3JzpD3RB4PWxk5VbtiPQbsDMpB2GGNnlZQZoxpKHURIgQqyllq6IfhuXDbXOGK6dmEmg66Zu7cp1cJvFC62geIbGa3kS3Tc+zozgITglZ6xUwXxM6eTddIVTQ23RPkLeBftoeLIx2O0sNzpdyWfw9VGXidT/KQStVGU/2bQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990486; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z+6qeAlJOKKWo1FncvQKP0fGn79PFWfQcGh4oQBRHxU=; b=AX9imb4Yzw4Qjpv8xXuxTkjd9TczWjTKFezQC0lz+hUM+FsCaFU4m7/caoiOwpo0phMh7EmCREOzVTTAjihpSb/5/FMNxCKgqEb9M5qO9NvK+886VhiOXORAGJQx9PWcUSZkkJERUj1sa5AxYKi3wm9wurYS8UJPUEwGkdPiqG8= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990486981963.4596654866665; Wed, 5 Aug 2026 21:28:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphx-0002vn-JF; Thu, 06 Aug 2026 00:27:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphq-0002sc-UP for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:47 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphp-0003E8-A8 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:46 -0400 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763wWwT775106 for ; Thu, 6 Aug 2026 04:27:44 GMT Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvju8g351-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:44 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-38e22137fb3so2384643a91.0 for ; Wed, 05 Aug 2026 21:27:44 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:content-type:date:from :in-reply-to:message-id:mime-version:references:subject:to; s= qcppdkim1; bh=z+6qeAlJOKKWo1FncvQKP0fGn79PFWfQcGh4oQBRHxU=; b=nJ RX+yuLbXfHKRDrji1s/0G1WA52O+NKOImNJ+zgO4aL4XFNGZBC0VjSSomjX7L0Ji Ty9HONDehor04p0JrREbUpn6LmPyg6NhkccEsgGgy14Fp+SNqKmvLjpkiJveWE5W gQthVdkAglX5wQTotROEjbvfHG6/Rhmj6SCOqYcpUouDx6L384ffmiLIOcSDx28i wQRCFwYGUqKn/KssSGC2XATgoUq+7sUU13T9OXhAP0OID+RzPQDutpXcj6YGeijK NfuxktMfPQN95JDb8VXApkQ2hogCqR4tHbdZFf5Mhk7BWR82zyWw10ZaYak2fIur 2CJ0h5bN08FPgve8l9Zg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990463; x=1786595263; darn=nongnu.org; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=z+6qeAlJOKKWo1FncvQKP0fGn79PFWfQcGh4oQBRHxU=; b=YawNxIewF4JPAAmXQojClnsdSaKW4tOOtbIs0PbLZRR3h5nrSnWDEZw6gXNjUyMQ8R Q02I0Pe87/O9kET96i2kYUor8GPH0/0KyLWJEO9s0zMxf5fen1cF/CIKMMXCzHFIlsJf HnH1H/8xovF5jZlFu/MkwIAWx2LyldOm7xCTrKg3JOJtRGa96yqLmkegNCr7shrXNk3W MwQQAABZY8TCRImFa3Xw+nIa3E5T+WV2fGZzBNeuCNm6xgFL851luMScUpQKz9LQm4pD c7fK8AIS0GzH+cvkCyLuv8D+2VvVtAk82XqERQCvfYt7D31rYoO2mHZAXzzYh6DjdWNA Oupw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990463; x=1786595263; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=z+6qeAlJOKKWo1FncvQKP0fGn79PFWfQcGh4oQBRHxU=; b=AnZIO4afpVQXU9L7IC7RhVziD0Sq3bZ/wIIXyOq/9WISL29HMv8rbzWLX65UZbtZzJ kwu/hsy/DkN+z9OMVcfFbWkokVdAhdnX1Zmyr9SAcS5Nft7ZQ3yUQUXvjUrEUBfpjZr5 x9pcl8WnEKXbAzk4+As+JuHOIGhyCJS1vHzaZhIivNycWnwex9gT0xz+gvtBn9mdQTFn pnz31vKkWhh5y69Pfce9DCycYipfr6ePSpqTUaATzJYv5NYH+fy2+nO/Kgf5DUs4m8Hv UMFDJ+PQ6heTdR6LdFiSnih6VJaAZ4RlZrnueyVBUCd8LtfWc3RPyADWn2TmFA7V78Kl iQaQ== X-Gm-Message-State: AOJu0Yzc3AQCy/Rq6CC5uWU7tEGk+klRoK+Haxzu3ly+SJrGUiWyUH4j cAoCaikQH3kE0HpjFAHr6uOvT1FHnji19R82kc/HhjHVFfF+g5V9kaZvZznEJW1/QHqtfl5/pSk 01Ig+axq4/y5n/RMceFASxD0Pqp4yH/+0pNhILKvLfueBegaFtUwAOS3ug8PmbZnikg== X-Gm-Gg: AR+sD13h0Fp4k5jHuSESigmWUshbHFOVqomryJ/VZV8+BegIvMz3SCe5fI8dTP1ht+E xz05OFrtRgaJv5MZQZHIi4JsRE35fhIdJ4hkPN4rAqY4HzIpmORoGqAe0rtmSx03b3HhnHYDerX qvdh3WUSOjAH7x9tYLmoMkNtdO1QFVZFu35zNHVIGJ/HSRMJ897ylZi69LHiIQ8RDfGaY5zgKKc Gz5qQj1976rHFMqTdT4DDcMWeNIrhRhCCheV0RcLo/dwQkFn/YWN7l+hGJmLm//vkbZTJmCN4CC 0q+buQa0mImFCMwxnieNZSyNa8X1PSE9cB/wqjd7tG7IY4n/1+k7lPb7VgdT9npaBMReMN7d4R8 zNB9UsALVx/bY5FDNSwljL+/uqcupzZ+peBq2RjKYLmoWjoww X-Received: by 2002:a17:90b:1e53:b0:38e:6d4c:14e6 with SMTP id 98e67ed59e1d1-3903c5501efmr10306231a91.3.1785990463335; Wed, 05 Aug 2026 21:27:43 -0700 (PDT) X-Received: by 2002:a17:90b:1e53:b0:38e:6d4c:14e6 with SMTP id 98e67ed59e1d1-3903c5501efmr10306201a91.3.1785990462951; Wed, 05 Aug 2026 21:27:42 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 12/18] hw/hexagon/virt: connect pl011 UART interrupt Date: Wed, 5 Aug 2026 21:27:17 -0700 Message-Id: <20260806042723.3785369-13-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: 7AivQ-CPM5FaVA62RLWOl8schOHsZANY X-Proofpoint-ORIG-GUID: 7AivQ-CPM5FaVA62RLWOl8schOHsZANY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX1DTi9jh5hnqC 37mIC+OII+ajE7VpWa7yihV1xFGa7vIx/mMhJNJfEynpjOOr+hFoiX3cnu1jpuQiXJnsM1UX4o/ 4tKzFzL9YMsus+siOalb3KeZSpKcQQtPAClf0bB8UCl8xQQxyvbuNQ/49fsY0NyGxiAViCnXVbm m+Yv3flf8FGUgzJ8NXgU1wyrUzXJL7lX98nX/1UQQVO4E88VOuOSKc+H/v1PnRj/bEE04p1V0/K 5M1wodBcKHt7gNIOVdf9/jYpLMxFhmGD/x70PDmvT3jLUhiK9XME39xDkcfy21v/J7o1PxvtBR6 hCpGnJhUL6X8hUmXbaCutOV/u+WDm9P0ARVrd5wqwYm2DdKL4/B1ql2FR6tBLcInDh2nNWfJ433 y5lwurbUBbR8eiVpxjf3bX0tl1Jfbdy9JFNV0YK4sZJUy3DtY8gnIo53QWRWi+RmehoKINDAyOb AOZeKxekxxZqbxzqwZg== X-Authority-Analysis: v=2.4 cv=K5cS2SWI c=1 sm=1 tr=0 ts=6a740d40 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=Z4HElfRGeH4uGo3IGfcA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX+AsLbXQzQvHB Tx5VZbi/COX8aU5ILeTdtiPlYTgH5KS+rVbehcx56ISNY5LhJMp7K/jVmIyzhB8YbI5/wsgx1gP cSzjPPL+YZhjEgbM8i4qQRFQ7hDjSdg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990488529158500 Content-Type: text/plain; charset="utf-8" Wire pl011's sysbus IRQ into l2vic at IRQ 15. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Brian Cain --- hw/hexagon/virt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index ea20ea3c50a..64d8366d27d 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -39,6 +39,7 @@ enum { * VIRTIO_IRQ_BASE + VIRTIO_DEV_COUNT - 1 */ static const int VIRTIO_IRQ_BASE =3D 16; +static const int VIRT_UART0_IRQ =3D 15; =20 static const MemMapEntry base_memmap[] =3D { [VIRT_UART0] =3D { 0x10000000, 0x00000200 }, @@ -143,7 +144,7 @@ static int32_t fdt_add_clocks(const HexagonVirtMachineS= tate *vms) } =20 static void fdt_add_uart(const HexagonVirtMachineState *vms, int uart, - int32_t clk_phandle) + int32_t clk_phandle, int32_t l2vic_phandle) { char *nodename; hwaddr base =3D base_memmap[uart].base; @@ -161,6 +162,8 @@ static void fdt_add_uart(const HexagonVirtMachineState = *vms, int uart, qdev_connect_clock_in(dev, "clk", vms->apb_clk); sysbus_realize_and_unref(s, &error_fatal); sysbus_mmio_map(s, 0, base); + sysbus_connect_irq(s, 0, + qdev_get_gpio_in(vms->parent_obj.l2vic, VIRT_UART0_= IRQ)); =20 nodename =3D g_strdup_printf("/pl011@%" PRIx64, base); qemu_fdt_add_subnode(ms->fdt, nodename); @@ -168,6 +171,9 @@ static void fdt_add_uart(const HexagonVirtMachineState = *vms, int uart, /* Note that we can't use setprop_string because of the embedded NUL */ qemu_fdt_setprop(ms->fdt, nodename, "compatible", compat, sizeof(compa= t)); qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 0, base, size); + qemu_fdt_setprop_cell(ms->fdt, nodename, "interrupts", VIRT_UART0_IRQ); + qemu_fdt_setprop_cell(ms->fdt, nodename, "interrupt-parent", + l2vic_phandle); qemu_fdt_setprop_cells(ms->fdt, nodename, "clocks", clk_phandle, clk_phandle); qemu_fdt_setprop(ms->fdt, nodename, "clock-names", clocknames, @@ -342,7 +348,7 @@ static void virt_init(MachineState *ms) =20 fdt_add_cpu_nodes(vms); clk_phandle =3D fdt_add_clocks(vms); - fdt_add_uart(vms, VIRT_UART0, clk_phandle); + fdt_add_uart(vms, VIRT_UART0, clk_phandle, l2vic_phandle); =20 hexagon_load_fdt(vms); } --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990512; cv=none; d=zohomail.com; s=zohoarc; b=aid4WU7JEqCI/4IMeUS1701g9UnNmh4/u3F73fCu6YrT1SIvaFZ41d/Sg5R2NnB+zAF/H2sQK8jAY95MY3WHq8x+6itVWzcLmkuNyOBxohkaXqj+xbxtmfUQcyMw/78b1Rg4vOHzm3vKKyFosKLqNwjpbjlheqixCKuWV5UC/vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990512; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=trdsKSJvYQTiKqxuiif07rmaPPA/mvXhHougvL/JRw4=; b=dxdgbKNT3Y86PtelcHBY7LM0E4hlkzhJp7JoZR/Qjcv7TnmI+9rgieMGxy9SmDTjIw2wb/8p7fuM7ZXu0hyXzSf3UivAVX2+QwCFRgRFrmdHtem5bRiza5CseHCDNbNMZ2qbALnNdBq8q+IuIm9hOD044p8mYUjflZkRBHRNtX4= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990511964314.74648142764215; Wed, 5 Aug 2026 21:28:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphu-0002tx-UG; Thu, 06 Aug 2026 00:27:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrpht-0002tA-CP for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:49 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphr-0003EN-5O for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:49 -0400 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675NbL484138244 for ; Thu, 6 Aug 2026 04:27:46 GMT Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv5x9uh6f-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:46 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-38e1118e4abso2614232a91.0 for ; Wed, 05 Aug 2026 21:27:45 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= trdsKSJvYQTiKqxuiif07rmaPPA/mvXhHougvL/JRw4=; b=RPiX4XATHEwPQOI6 ruWZrxXiu008hYYvQ9H/kLwyav7jWCvVaqHue1R3bEZjlwv95OReBcHwreMBcT9x 6+aW0jOlhXrFzzRbwFF3vuavdGQ66bAR8If74DJ0ndSMg7imNTFyZyk3LE2kGi7B R/6qm8ADIysZ3/lwpNXM64HAFGGu7YBil9MpySAavPkg5Cvy88snnIJyp6a6OOVs 5bMglH2oXWtYbLEJ3H3Sle4nXgW37Oe1u6fU09SAhIppl8cwHQk8gX4e/8Rs+OYL QyfCoHLQXqvHlqMOgfBbb5E5ZjYrzS8N5iGkrWm98CpSJQ2hntPJxyMaSwaPS+La nnXqXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990465; x=1786595265; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=trdsKSJvYQTiKqxuiif07rmaPPA/mvXhHougvL/JRw4=; b=K4bS1jRtnxErq9C8bj0R4OtIxXLUIWcUitUvXDg/hyEEyTrCtKxsmzM1ViFUuuMDxR XcyGR2V3XCQXxBtZyCzGkBwSvcveqM03wTtk3vLpZpSTPmaLi5J9ycNbtxm0cGkeBsUC 4c1H2rpC/Aiaopm+N+OGWPj8TiXENjotSPjWgC7O6Y65p/D+qkCnapBkuBd6mfvx5yd2 bGtZVch5rvJsr3TxpWXdgMNnDOrZK92MebybupKqZVNodHdIYqOQAj/qYTyIzCWCzrGQ xjPhw5DLjO2zh0rpMt+LRC4mQeOKp1NfaLO6Pi232ZNV1szW3L2PjFUloo9whC/IfLe4 hpkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990465; x=1786595265; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=trdsKSJvYQTiKqxuiif07rmaPPA/mvXhHougvL/JRw4=; b=sBh4NMYPFTYdQOqLI4oXCM/7c+/7Wsi97bBWL72hA6Rod9mEBgirHgdUw0nqtG3QUW C8PcqVNRkGnjCQmmF7hW4QJN4NiXoykncKZUAwdgxyNoVpChqKRqS51Zbn2gl61EaOMI BxBA836iTX1DoW/0Jdze+RV+YIfbHNJKjmQxkJKb+Djkr5OBlYzOocZTB05gIf1gv3rM omYGsdQ1/afpq/bBGx5htpw6UJVTYO7TZw92DQpkgHQmGJoDY9GU58PSO6J/9U1uDALv QeYBGfmO0R6EX+zmBuzifeRtzmvCVmGrZfcfaK7wiOJLb0/KiD1rtY4iTF8rwVmjArFO Sgig== X-Gm-Message-State: AOJu0YxRil8yGJQGU4/G97bYxbNPb5sxniJtcozFIcOC5Xm5/MB+BnBr ZaUU79xoh0SHkdWNZPFecU0kFFncH8q5j4CUBmO4ol5kIXBMrK6o5Lu6kgEyI0EeqxT9oNmN7CJ +cIiXcGt8i4qvOTjC1W/SktGg01INbJ7dICQg8GR+moTteHeUcSMvdLxsoAnjUSW4BQ== X-Gm-Gg: AR+sD10zT5jxkN6oPQcQ/ALPiAtsGmQWChkLvyVP1Yc7mvQNBQcHObq5m2n7iS80/eA 1jBjYXlM66cIHuMIafV7K5PGdLHswIiAAzt7I/akl5u1ey2wGFN1eTgG0SazZ7X1bsE/xEeCTEI 4nCCCbQs8lYKQIeTnRdRRXMPP9lF5mLsvouyJjomlPsPj9QUWPdQJtzvTE+4pi2xLyvD9hb8U12 I1tgut8IAkZFiTNtiKJavaPBa5D7lG/skld0nWGecIIrCxwenduWmrPlwtt7VFFgiMEL7pkg3yD lmHux01MTIzq3aEKzeC6l2+m4ac/SeyZbk29BdmiW40MQrueODzYl3lhSrVY2IfMQPLiAfggDQD kGR7wcm8dKM8SHO3mjndViwfSCLxlL/gvyPovh9+Dul6+0VT1 X-Received: by 2002:a17:90b:4d91:b0:38d:dfd1:7a8 with SMTP id 98e67ed59e1d1-3903c559592mr9123908a91.2.1785990464897; Wed, 05 Aug 2026 21:27:44 -0700 (PDT) X-Received: by 2002:a17:90b:4d91:b0:38d:dfd1:7a8 with SMTP id 98e67ed59e1d1-3903c559592mr9123883a91.2.1785990464365; Wed, 05 Aug 2026 21:27:44 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 13/18] tests/qtest: add L2VIC qtest Date: Wed, 5 Aug 2026 21:27:18 -0700 Message-Id: <20260806042723.3785369-14-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXzHlpTBHwAqq5 2Z4ks440YJbjM4/wD8QDXpH4w3E9UGXmsOmzmcDf+UafZRepsUnTYYhSmkezYF3OvcGNkH0BHhH 0HQ7vlTg25s3ZmnXdT6f8qQimslkOrdeCFay4fW2K/4BCtHHFRs3ZFzsy5YVLIkkDXp1A+pY/yB y1Si1WR1OxjQaUsZqrnBdtUtgARjC0CohVD5Gz6BHSItRppkVe6UtwU5uSJsDjaO5twXMSSJoew hRYpp+BOAgm5LG+gOYE2SapLHEKsUVUe1iciJBHU5CKlm7tLG/5TI3TPo5EV20s2zLOyeAtCVF+ KuWmT7S5ACdJaNyiz0N5GWTLu58KBix5A+9cSpCU7ZnNMFXyakj3Lzt8YD8/yKE0BS3BGIIrQBD 9onbXNLXnWyeAZ+hlCrcNG5S6AnGHvb7J8Y1yZxWgYK4poamEd8CX0xp01w7lN2hWI0/334/C/4 W4dOhwt9KwioXDNBSkA== X-Proofpoint-ORIG-GUID: TreZiOIlxccL4On75fCAGwrH91AKA01G X-Authority-Analysis: v=2.4 cv=BMqDalQG c=1 sm=1 tr=0 ts=6a740d42 cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=7KM7d0xASNUEeJCx_1UA:9 a=QEXdDO2ut3YA:10 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-GUID: TreZiOIlxccL4On75fCAGwrH91AKA01G X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX35tJdqIF3EPp L+3e+oBrMsTAWuzALE0APgvdBbYH1Fnz3EI+Ille9T9oy22rb8EoYt0+kjNP05KyPMore6KEZeI en53lbOOEYxXp9383rgduHXykyRps/g= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 suspectscore=0 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990516366158500 Add a qtest exercising L2VIC register access and interrupt enable/disable. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- MAINTAINERS | 1 + tests/qtest/l2vic-test.c | 249 +++++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 3 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/l2vic-test.c diff --git a/MAINTAINERS b/MAINTAINERS index 56b12a1af04..678b7bacd79 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -252,6 +252,7 @@ S: Supported F: target/hexagon/ F: hw/intc/hex-l2vic.c F: include/hw/intc/hex-l2vic.h +F: tests/qtest/l2vic-test.c X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/ diff --git a/tests/qtest/l2vic-test.c b/tests/qtest/l2vic-test.c new file mode 100644 index 00000000000..adb4dc7281e --- /dev/null +++ b/tests/qtest/l2vic-test.c @@ -0,0 +1,249 @@ +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + * + * QTest testcase for the L2VIC Interrupt Controller + */ + +#include "qemu/osdep.h" +#include "libqtest-single.h" +#include "hw/hexagon/hexagon.h" + +#include "hw/hexagon/machine_cfg_v66g_1024.h.inc" +#include "hw/hexagon/machine_cfg_v68n_1024.h.inc" + +/* L2VIC register offsets exercised by this test */ +#define L2VIC_INT_ENABLEn 0x100 /* Read/Write */ +#define L2VIC_INT_ENABLE_CLEARn 0x180 /* Write */ +#define L2VIC_INT_ENABLE_SETn 0x200 /* Write */ +#define L2VIC_INT_TYPEn 0x280 /* Read/Write */ +#define L2VIC_INT_STATUSn 0x380 /* Read */ +#define L2VIC_INT_CLEARn 0x400 /* Write */ +#define L2VIC_SOFT_INTn 0x480 /* Write */ +#define L2VIC_INT_PENDINGn 0x500 /* Read */ +#define L2VIC_INT_GRPn_0 0x600 /* Read/Write */ +#define L2VIC_INT_GRPn_1 0x680 /* Read/Write */ +#define L2VIC_INT_GRPn_2 0x700 /* Read/Write */ +#define L2VIC_INT_GRPn_3 0x780 /* Read/Write */ + +/* + * VID group readback: records which irq last fired through each VID + * group. Outputs themselves are momentary pulses (see l2vic_update()), + * so these registers -- not the qtest IRQ level snapshot -- are how the + * test observes VID steering. + */ +#define L2VIC_VID_GRP_0 0x0 +#define L2VIC_VID_GRP_1 0x4 +#define L2VIC_VID_GRP_2 0x8 +#define L2VIC_VID_GRP_3 0xC + +typedef struct { + const char *machine; + const struct hexagon_machine_config *cfg; +} L2VICMachineCfg; + +static const L2VICMachineCfg l2vic_machines[] =3D { + { "virt", &v68n_1024 }, + { "V66G_1024", &v66g_1024 }, +}; + +static uint32_t l2vic_read32(uint64_t base, uint32_t offset) +{ + return readl(base + offset); +} + +static void l2vic_write32(uint64_t base, uint32_t offset, uint32_t value) +{ + writel(base + offset, value); +} + +static void test_l2vic_register_access(uint64_t base) +{ + uint32_t val; + + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0x1); + val =3D l2vic_read32(base, L2VIC_INT_ENABLEn); + g_assert_cmpuint(val & 0x1, =3D=3D, 0x1); + + l2vic_write32(base, L2VIC_INT_ENABLE_CLEARn, 0x1); + val =3D l2vic_read32(base, L2VIC_INT_ENABLEn); + g_assert_cmpuint(val & 0x1, =3D=3D, 0x0); +} + +static void test_l2vic_interrupt_enable(uint64_t base) +{ + uint32_t val; + + val =3D l2vic_read32(base, L2VIC_INT_ENABLEn); + g_assert_cmpuint(val, =3D=3D, 0); + + /* Enable IRQ 0 and 2 */ + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0x5); + val =3D l2vic_read32(base, L2VIC_INT_ENABLEn); + g_assert_cmpuint(val & 0x5, =3D=3D, 0x5); + + /* Disable IRQ 0, leaving IRQ 2 enabled */ + l2vic_write32(base, L2VIC_INT_ENABLE_CLEARn, 0x1); + val =3D l2vic_read32(base, L2VIC_INT_ENABLEn); + g_assert_cmpuint(val & 0x1, =3D=3D, 0x0); + g_assert_cmpuint(val & 0x4, =3D=3D, 0x4); +} + +static void test_l2vic_basic_functionality(uint64_t base) +{ + l2vic_read32(base, L2VIC_INT_ENABLEn); + l2vic_read32(base, L2VIC_INT_PENDINGn); + l2vic_read32(base, L2VIC_INT_STATUSn); + l2vic_read32(base, L2VIC_INT_TYPEn); + + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0); + l2vic_write32(base, L2VIC_INT_ENABLE_CLEARn, 0); +} + +/* + * IRQs 0-7 pack their group-enable/VID-select nibbles into + * L2VIC_INT_GRPn_0 (int_group_n[0]), 4 bits per irq: bit 3 enables + * VID steering, bits 0-2 select the VID group (0-3), which pulses + * output line vid+2. + */ +static void l2vic_set_vid_group(uint64_t base, int irq, int vid) +{ + uint32_t val =3D l2vic_read32(base, L2VIC_INT_GRPn_0); + uint32_t nibble =3D 0x8 | (vid & 0x7); + + val &=3D ~(0xFu << (irq * 4)); + val |=3D nibble << (irq * 4); + l2vic_write32(base, L2VIC_INT_GRPn_0, val); +} + +static void test_l2vic_irq_outputs(uint64_t base) +{ + uint32_t val; + + l2vic_write32(base, L2VIC_INT_ENABLE_CLEARn, 0xFFFFFFFF); + l2vic_write32(base, L2VIC_INT_CLEARn, 0xFFFFFFFF); + l2vic_write32(base, L2VIC_INT_TYPEn, 0); + l2vic_write32(base, L2VIC_INT_GRPn_0, 0); + + /* Group 0 / IRQ2: soft interrupts require edge-triggered config */ + l2vic_write32(base, L2VIC_INT_TYPEn, 0x1); + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0x1); + l2vic_write32(base, L2VIC_SOFT_INTn, 0x1); + + val =3D l2vic_read32(base, L2VIC_INT_STATUSn); + g_assert_cmpuint(val & 0x1, =3D=3D, 0x1); + /* Default VID group (0) records the delivering irq, output line 2 */ + g_assert_cmpuint(l2vic_read32(base, L2VIC_VID_GRP_0), =3D=3D, 0); + + l2vic_write32(base, L2VIC_INT_CLEARn, 0x1); + val =3D l2vic_read32(base, L2VIC_INT_STATUSn); + g_assert_cmpuint(val & 0x1, =3D=3D, 0x0); + + /* IRQ1 steered to VID group 1 -> output line 3 */ + l2vic_write32(base, L2VIC_INT_TYPEn, 0x2); + l2vic_set_vid_group(base, 1, 1); + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0x2); + l2vic_write32(base, L2VIC_SOFT_INTn, 0x2); + + val =3D l2vic_read32(base, L2VIC_INT_STATUSn); + g_assert_cmpuint(val & 0x2, =3D=3D, 0x2); + g_assert_cmpuint(l2vic_read32(base, L2VIC_VID_GRP_1), =3D=3D, 1); + + l2vic_write32(base, L2VIC_INT_CLEARn, 0x2); + + /* IRQ4 steered to VID group 2 -> output line 4 */ + l2vic_write32(base, L2VIC_INT_TYPEn, 0x10); + l2vic_set_vid_group(base, 4, 2); + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0x10); + l2vic_write32(base, L2VIC_SOFT_INTn, 0x10); + + val =3D l2vic_read32(base, L2VIC_INT_STATUSn); + g_assert_cmpuint(val & 0x10, =3D=3D, 0x10); + g_assert_cmpuint(l2vic_read32(base, L2VIC_VID_GRP_2), =3D=3D, 4); + + l2vic_write32(base, L2VIC_INT_CLEARn, 0x10); + + /* IRQ5 steered to VID group 3 -> output line 5 */ + l2vic_write32(base, L2VIC_INT_TYPEn, 0x20); + l2vic_set_vid_group(base, 5, 3); + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0x20); + l2vic_write32(base, L2VIC_SOFT_INTn, 0x20); + + val =3D l2vic_read32(base, L2VIC_INT_STATUSn); + g_assert_cmpuint(val & 0x20, =3D=3D, 0x20); + g_assert_cmpuint(l2vic_read32(base, L2VIC_VID_GRP_3), =3D=3D, 5); + + l2vic_write32(base, L2VIC_INT_CLEARn, 0x20); + + /* Restore defaults; the block below reuses IRQ 3-5 without VID steeri= ng */ + l2vic_write32(base, L2VIC_INT_GRPn_0, 0); + l2vic_write32(base, L2VIC_INT_TYPEn, 0); + + /* Multiple pending: at most one active at a time */ + l2vic_write32(base, L2VIC_INT_TYPEn, 0xF); + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0xF); + l2vic_write32(base, L2VIC_SOFT_INTn, 0xF); + + val =3D l2vic_read32(base, L2VIC_INT_STATUSn); + g_assert_cmpuint(val & 0xF, !=3D, 0x0); + + /* + * Only one irq becomes active per delivery; each clear unblocks the + * next pending one, so drain until all four have been delivered. + */ + while ((val =3D l2vic_read32(base, L2VIC_INT_STATUSn)) & 0xF) { + l2vic_write32(base, L2VIC_INT_CLEARn, val & 0xF); + } + + /* Level-triggered sources ignore soft interrupts */ + l2vic_write32(base, L2VIC_INT_TYPEn, 0x0); + l2vic_write32(base, L2VIC_INT_ENABLE_SETn, 0x20); + l2vic_write32(base, L2VIC_SOFT_INTn, 0x20); + + val =3D l2vic_read32(base, L2VIC_INT_STATUSn); + g_assert_cmpuint(val & 0x20, =3D=3D, 0x0); + + /* Same source, now edge-triggered, does fire */ + l2vic_write32(base, L2VIC_INT_TYPEn, 0x20); + l2vic_write32(base, L2VIC_SOFT_INTn, 0x20); + val =3D l2vic_read32(base, L2VIC_INT_STATUSn); + g_assert_cmpuint(val & 0x20, =3D=3D, 0x20); + + l2vic_write32(base, L2VIC_INT_ENABLE_CLEARn, 0xFFFFFFFF); + l2vic_write32(base, L2VIC_INT_CLEARn, 0xFFFFFFFF); + l2vic_write32(base, L2VIC_INT_GRPn_0, 0); + l2vic_write32(base, L2VIC_INT_GRPn_1, 0); + l2vic_write32(base, L2VIC_INT_GRPn_2, 0); + l2vic_write32(base, L2VIC_INT_GRPn_3, 0); +} + +static void test_l2vic_on_machine(gconstpointer data) +{ + const L2VICMachineCfg *mc =3D data; + g_autofree char *args =3D g_strdup_printf("-machine %s", mc->machine); + uint64_t base =3D mc->cfg->l2vic_base; + + qtest_start(args); + + test_l2vic_register_access(base); + test_l2vic_interrupt_enable(base); + test_l2vic_basic_functionality(base); + test_l2vic_irq_outputs(base); + + qtest_end(); +} + +int main(int argc, char **argv) +{ + size_t i; + + g_test_init(&argc, &argv, NULL); + + for (i =3D 0; i < ARRAY_SIZE(l2vic_machines); i++) { + g_autofree char *path =3D g_strdup_printf("/l2vic/%s/all-tests", + l2vic_machines[i].machine); + qtest_add_data_func(path, &l2vic_machines[i], test_l2vic_on_machin= e); + } + + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 56ff860e216..a76863c7dd6 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -299,7 +299,7 @@ qtests_riscv64 =3D ['riscv-csr-test'] + \ ['iommu-riscv-test'] : []) + \ (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) =20 -qtests_hexagon =3D ['boot-serial-test'] +qtests_hexagon =3D ['boot-serial-test', 'l2vic-test'] =20 qos_test_ss =3D ss.source_set() qos_test_ss.add( --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990586; cv=none; d=zohomail.com; s=zohoarc; b=JaWYV92ViKZbxJM7Eu/FLNahsY2Xd8pL7i0lNlokuWX+gv183aZdwsoiC5+Dt4KXD1x7owPyTLxnWh6bFnkJQ1U4dZPf6vRPcgZ8aH4v8EWV+Z3kXLBLfo+g7AJf4v39QxHbYSzrdcRc5vItoklBHajbk7y+J1Zo8LRk8xfqQt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990586; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WlYwLmXhxTTRa9JsiNHuhC5FeaNc/fhNT3n5nZwsxj8=; b=GBWePEg6IPFSRUSbw2vpJimMAhxjVMS3y9bCbolzkyRl1k8ezyAQ24AHtmDacYSNpFpChv0fLTaW4pxlk40QdI+oWt7mtgUMQyb+w/MeNnhIc1ZqQmezglPqCf+x4Ib/V20FRug1/wifZs12Ec+n9v/d3xTBWQmjT6ySqLBUR80= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990586627806.2293275268759; Wed, 5 Aug 2026 21:29:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphu-0002tZ-80; Thu, 06 Aug 2026 00:27:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrpht-0002tB-HJ for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:49 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphs-0003EV-4C for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:49 -0400 Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6763x6go483313 for ; Thu, 6 Aug 2026 04:27:47 GMT Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fvjueg2ve-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:46 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-ca7c1e22995so2581692a12.3 for ; Wed, 05 Aug 2026 21:27:46 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= WlYwLmXhxTTRa9JsiNHuhC5FeaNc/fhNT3n5nZwsxj8=; b=I/p2zrG7WSYNOI3H UT5hPF1aNWxbnuNQO6WNaxLwLUbUReCM3usLAUORkDH+je+VennoKAZStituZNJM 2MTBCx3tOmuEe54toecy8n6Hnoti9+1QlwrJ8bCc28U1Csi9hxHqAdwVGtF6LRW9 uFC2py/fHcGHtGRmLHaLfIaIBAf+W/mQ7Hg9CORN+qDmCSye1fiXlWwtJ3ud5zYc VV+pnhEMZJHv8QcA5P2MxSmTlrCK9DCLv0gm8tb+1Wb9S18cGEtLUd4K0iq87cPU hNsKCewfr8reTuX6zcT1hK4QCmdE7b8S42dqgOiMiPSyWv4ATxuLB5a16AtJG93/ WZTIDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990466; x=1786595266; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=WlYwLmXhxTTRa9JsiNHuhC5FeaNc/fhNT3n5nZwsxj8=; b=DpUQJUloqtWm/wcXa54Dgiiz8PMgf23RwOMJT2DLMaYvZOpoizBys53R3GdEqq3v7d 6obcmxJHZDWrVLWENyiYKSSymzHsCjFvIz3Eztpi5UdbtUIaordgivcaQ9jlR5BOr588 0vn7AxulfOfJBDRqAcU2kEU0U7B+X2sUgpOhAWafYRmgvZ6oD/gNbrSFeSF9+IZxCHs/ zXMfPtjfof/gsw7eEi3RIeM/qnu9ogvN4GbZKL8squEiex0G1TPRYOzscoeawcAjn4Oe mZI9ouCleyOkdz8XMsmjluC0lwI15IxHzywjZDiBa2Zqj2cXxgi5hydus10DmIM3yOUL ouCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990466; x=1786595266; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=WlYwLmXhxTTRa9JsiNHuhC5FeaNc/fhNT3n5nZwsxj8=; b=Lg73m2cTJCIZb70lBODaH6NoK/MnKVUSmU6TvAPN2kcbx5oWD8ENqapcTYXaVe5dN4 8uvDNvoaAHS4CUMYi2N9sDO7u9jg24MO+aUayrlLTqRjO9pjNX1mAwWOnijPJHaVzDwn aWjT657nQ0ja7jKuLODx+mp41NamFYg5ktVV76KtsHIUGvXWBoG3joNcyXmfNVAdn0nZ pR0tltJ9xbx3lQe8L6DW/2rEswylB7arGow6yqbIFYDCVisGHoKNq5uOsH7tWCob5APh L5/HvIjCb3ZKIVNpT5S3EN57NJVKE88kgMltBue/MjyclxvxP7nHCq3xX3pybleYxnZV cKKQ== X-Gm-Message-State: AOJu0YzmDO5LHWP4qFvnbLhLJfsUZ9vv3Yb8t377Q3BA70EB9ZDg6YDA bim1dA2YnCcsnh7/OZZ3H82SjbNhPodYAybSllPC+Sd0YRMA+ljSdrNyYFr1IQj1kXaMd1tPW5o osnrI41EMl0KPylLkpFHchsYWqBWJj/rNlyKop+Nytb0MHVCBJHHG58BKqZeem2jwQA== X-Gm-Gg: AR+sD11dEgyq+b67MEfpa5hznbDYAl8U0J9Qq0wgA5/Ba9lS7ZZSND2MK+vR9lsaBmK XQRW09eV6qjwvnrcgxwR6uNWohtYNHbzr+TsoBBGxBz3n7yqTQ0YAz3RXSzzUiLiAqIMnMq44iJ jwsbfoV/8J8GLivQgcFD68ye3qtXunlUc2BMea3SqFmCnUjEpjn7H9vXZAfECLTA3cMV6sHmO+l XZOuMruHi9ulJGaCyk6A1Zm6tXkttB5hvkQ6rR/yVHjSGaHs3MIB0WhFKQm6UaPlxKLbgBoVVsI p8wt/G0iZoNY3Ioiw3+WEhNQ13GP2XEFDNh2TkBgNFmijVt+Bg8n9Bv/5Djjr8++FEdjp3wvppS vBy/CNu+97DX607NX0dh6PPtMUwQ4NibYXBrDbQjLZxbheulY X-Received: by 2002:a05:6a21:3388:b0:3bd:187e:2de with SMTP id adf61e73a8af0-3cb85eef9eemr13975835637.25.1785990466091; Wed, 05 Aug 2026 21:27:46 -0700 (PDT) X-Received: by 2002:a05:6a21:3388:b0:3bd:187e:2de with SMTP id adf61e73a8af0-3cb85eef9eemr13975788637.25.1785990465704; Wed, 05 Aug 2026 21:27:45 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 14/18] tests/functional/hexagon: add arch_tests functional test Date: Wed, 5 Aug 2026 21:27:19 -0700 Message-Id: <20260806042723.3785369-15-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=aNzAb79m c=1 sm=1 tr=0 ts=6a740d42 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=X9gmHREV3qooIQp-wBoA:9 a=QEXdDO2ut3YA:10 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-GUID: MSRcuW4IWgUXsMmm1dnOvYGmeIwYPnae X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX/Q759q4gJd9w su3utyJViYNJFBt6wRWkTePnOgviY6ql2Xs/We8H/6eHt0lEp3eqnHCMv7Nmp1GoeUCmnQ4Mm1Q Wo0uFKpmTYsxiJSfj42XjjqGPXx1bEboxFJVGbmsVflgVo5DKCYhkTCc0v0J97wO/9CVLZBlnec 1rwx07iyab6btaXrohVzjFI4KZIjSDvaccWRvVobxbZKgFec2uK2RPCp15LC+V08aWzSfP57Jiv sGTDxopoMVZ2kphP9UD6goCTLW174AXc8d3B+AqW6m+zu3UKc8smXBqJV410vZUDBYKXazutgWY SF5Y0YR+AT8rOMhdcEcuyZ5cly/Xvnfud5rbLlFtCjVPSVh5JPIdKUrFJ1YajI/il+l9sLDQZSG X8a0K/f+WfRhxDGRCA+EyXOldrTYVbGjLsAIRLPfan+dnESr9r0LDtH5TYPnO2FFuE6hm3/g42u wmce02j4kSkGKFNW1Qw== X-Proofpoint-ORIG-GUID: MSRcuW4IWgUXsMmm1dnOvYGmeIwYPnae X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX1eRoMzXitPBg tIXVH//sVLY3YYhgI6nlvyvApBw0UqysaVoyxgl9ZLPdxebl5fcbdb7DIcefHXeVy0j+z4wX1pq XDUCxDIpldsqRDDn6ERIOoiz9FCCJP0= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 suspectscore=0 adultscore=0 clxscore=1015 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990588425158500 Add the test_int_steering case from hexagon-arch-tests. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- tests/functional/hexagon/test_arch_tests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/functional/hexagon/test_arch_tests.py b/tests/functional= /hexagon/test_arch_tests.py index 54a1412c597..2bb34f9b8dc 100755 --- a/tests/functional/hexagon/test_arch_tests.py +++ b/tests/functional/hexagon/test_arch_tests.py @@ -52,6 +52,12 @@ def test_guest_mode(self) -> None: """ self.run_uart_test("test_guest_mode") =20 + def test_int_steering(self) -> None: + """Tests interrupt steering via priority-based routing to + specific threads using STID priority and iassignw. + """ + self.run_uart_test("test_int_steering") + =20 if __name__ =3D=3D "__main__": QemuSystemTest.main() --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990531; cv=none; d=zohomail.com; s=zohoarc; b=L3GwYIx8zpvOzQjKiY/+ENpL3BL66Pf8+Es953gdveQfKQ8peuTbFQo1PbG6pSPv3LoMNL0AJdgdJ7UJ+0cge+xQabkGjowHPoU+bYN7eMY5/CyCkSPbiZV93BeRDOQh+M+e7M5NyAjIu506eiqOKMqTuSHPcTWpb2qTlelRJHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990531; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=89iXHDl80CjHiyPJTAi0gvJObJTVddwUqURyu+5aomw=; b=k5sgI7rdLyUoTf7zKbcbSDcWn64mOcU2YU/9k7WsD2UQMqhdv8g46EvCw+sEMGs08edVXKff3oULFteSK5hqx3PXiDxmqwM0oBfimsuBLng50Yq7U4ti7mDhCs1sxvDBwxJhXTc8isBK1t3v4I7d0fvWwZUdUpC8xOAxZbhMj7c= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990531129652.0961943905307; Wed, 5 Aug 2026 21:28:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphz-0002wI-KZ; Thu, 06 Aug 2026 00:27:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphx-0002vo-H7 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:53 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphu-0003Ef-5v for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:53 -0400 Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675NbAmI731574 for ; Thu, 6 Aug 2026 04:27:49 GMT Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv5dk3jbv-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:48 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-ca7c1e22995so2581724a12.3 for ; Wed, 05 Aug 2026 21:27:48 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:content-type:date:from :in-reply-to:message-id:mime-version:references:subject:to; s= qcppdkim1; bh=89iXHDl80CjHiyPJTAi0gvJObJTVddwUqURyu+5aomw=; b=Ws msBifOUw+tNTL2+qO3D7bConQTrkXWE/Z9Po5RBNWe4Rd8k9x4zJqn/gPfi3xG2T UcqXvFPQ71AUVxuYm5mHSQXd8ZEkkBp7uEqvi4VKok5yYgd8u/hcp+WTbaYecLC3 8gQdzoopyEViW9WMLDJ8Wav4UI/VEZ8IHZDC8kQ67v6bIIYBOUhwyQ8q7QdiPbcz nz0rPDqIZmeKM3K99i2pzClB1VF4J3HL7BklqEPbC80Zxi/JWQ3ELSaq3SkHQrRh rsdbL0DnMzMHq9vWega7JdsFYAOj8WxHo5zTuzUaClFDBe2Pm4jlxMKZHenJSCIs wfy5OevZdsm5PxnfzC4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990468; x=1786595268; darn=nongnu.org; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=89iXHDl80CjHiyPJTAi0gvJObJTVddwUqURyu+5aomw=; b=Z4z8nuTf8YQLys9XoGCFMNCdvoaEVq0mkO1Gj3rJY8eQoMugx+t835gW3YxeNY4ByU iqf3tq4QunaROkjIj3UJKTudjIaazAi8taQ7CC1B64Sda4aetLQG5i8zAAJRcAMA3Hnh yAF8kEQk3hGKk8tdh+0MYdSNWt6JVKXnXSHgV47xW+lN4zt/hp6GYw1yiknI4T3g+OTb vVRz7CnKKBOYPhECDFUtXfi6AGfyDiBuLwZPTBeoviCC9VZ16E2ENxD8HzhX4PsCZLxr phCiqdB/aSiGf1amyS7HsL2sjx7rDbn5psfzSDxClEuHaz2ijIC9AT8dhs+jlR0jVLwU GwtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990468; x=1786595268; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=89iXHDl80CjHiyPJTAi0gvJObJTVddwUqURyu+5aomw=; b=WR0PQLAopfx6cqfCpoxDeKCmv+R4Fc8aTOmFd5dz/F82FhRYNpTtYnR54G6Yuz+LfN HqvsgqCWfEOLD/ZmvWrgqd2yaJiiRkAVCETke57HD7GDdiBLSTYwhcyfwxs4k8yOzbiS xjXi2R6ik/2cWKGZ3FfP5fPlfGqTSW9SIFXEm0YQY7OH8R7FLuOSTH80VxE3rrgtp6ls d4YmzDUyZnxvKTTJa2XFo4T5zu+1eofQCeRE8P32rzXBjrPurinEsjqLi0V12GUPhi6l fAGH8lFpgw1FIFCfDHId9vRrooexo9ktCaWEV+IobktMDP3JX5JuonrFvZdqpdr5m3m5 AYoA== X-Gm-Message-State: AOJu0YxCrKKsGkCOqDhRpmSir+D2kBMXR6q5aB3FQGgOUcYJSIhREe5R MkMXRuxc9gG1JBr5iVKXRFfxpYgw5zMOrMxQA7lEbcCy3fl670J7JeVzn7MNzCLV6HD/D2vtfH3 ZqhGup9imOW1GskJWQ9bLsvn8jifi0a9ni/YwZ4mriNXk1ob6IpTGZ+kF6F/fJT+wow== X-Gm-Gg: AR+sD11fY5eey7ET0FYFOjUcwrr1R+alLm3MHoq3RCbuo2eROYlEsCFpXNIQY89EUEp WFYaUNn1xEg4H5nI8Bg1rSptHrLICec7m32CSqlm7wD4qZ6hpYkDOQ2nMHpyi0ucBndgXXvL78y /iJjhUMddIT7PbREPWvVa3Tfapk8kHKUvQ1aFW8YCm+3PJhT28tMY1ONrs06KJ9olhjZvFXFHG6 dUjNlr8FEFzfdue9U045JRPL+8ueGXgqew1ZmkEX8JtSMFUL09ToqDAZF9HtL34JK1+NDlCkzxG oNMjCmwCH9uu1Sy/ujPXkpW/TGPm5tMkq7nEBNZOjv+k6HYonOs2xIVmUoaGdrGWjMtf5PHusbq lnNuTGbuKR+BzD7x7Jy8Rm4L3OYgFCMfdGyr1DvffVJotcOab X-Received: by 2002:a05:6a21:2293:b0:3c3:994f:b4f5 with SMTP id adf61e73a8af0-3cb85eefa11mr15938782637.28.1785990467743; Wed, 05 Aug 2026 21:27:47 -0700 (PDT) X-Received: by 2002:a05:6a21:2293:b0:3c3:994f:b4f5 with SMTP id adf61e73a8af0-3cb85eefa11mr15938707637.28.1785990467087; Wed, 05 Aug 2026 21:27:47 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Damien Hedde , =?UTF-8?q?Tobias=20R=C3=B6hmel?= , Sid Manning , Thomas Marceron , Mahmoud Kamel Subject: [PATCH v5 15/18] hw/timer: Add QCT QTimer device model Date: Wed, 5 Aug 2026 21:27:20 -0700 Message-Id: <20260806042723.3785369-16-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: IAy9Gejk51act0aUkbEbd6Cp-y4nnxMY X-Authority-Analysis: v=2.4 cv=Or9/DS/t c=1 sm=1 tr=0 ts=6a740d44 cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=1cGLs3X8AAAA:8 a=COk6AnOGAAAA:8 a=EUspDBNiAAAA:8 a=IC4WK4T7XsrJqFAnAAkA:9 a=QEXdDO2ut3YA:10 a=bFCP_H2QrGi7Okbo017w:22 a=d8ghUycwObenwynNfMyN:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX3a87CNhL7Mkm prUOUNt8AoZOblopEcVUg+CLyOR29Jv3OhydQ0niicCzPMX3T3i9WszKh1c6kJkIFWuuEzZ7SFK oANPP+E5FmGf9b/BVxCIWft8Rzgg8qNI6AA1EUow1h7chJ+y0DBePdR7Is07oRJQ1St4Rim3jJo l4GJPHF31xNA7kaEOdgItjZC7zJMu4ysEDgeU5WSvPYjvBBdDMApt3wn/mQiEf7pYpPuudTGw/z S1fTwkbgtYjFrZQWZFwOWrT3xnd/fkWX8lTMn/HxBHoXkFJus/vhDPMuVUdXhm2dW8ozlTF3+sD OMb/0RQ4mLALs//3OToKGUraPJ5imxwgfTTUDTfBLRDb0OvE6R2uYho1twI8N9alr3S70HA2EsH 1ergMKQppx3c3rgRrbW76BPEPw5wgiEu2qApX9XHEgVzNXTa22VPPo/+RrTVAXPBJfFSX43LgP5 miy1jPPdo4a1/u67XYQ== X-Proofpoint-GUID: IAy9Gejk51act0aUkbEbd6Cp-y4nnxMY X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXy3SI/kOwL1vF uIiK9NasECJLTvj/+gHXxmPwFaUxQDfheBhB+tl1XbzXLDXIrdIk6ERnJJEcjnpr0mljJIlNrNm QShdFRLCzGbbmn6XNTTm+8YOP1LWXTY= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 priorityscore=1501 spamscore=0 bulkscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990532448158500 Content-Type: text/plain; charset="utf-8" Implement the QCT QTimer generic timer device used by Hexagon DSP systems. Co-authored-by: Damien Hedde Co-authored-by: Tobias R=C3=B6hmel Co-authored-by: Sid Manning Co-authored-by: Thomas Marceron Co-authored-by: Mahmoud Kamel Signed-off-by: Brian Cain Reviewed-by: Pierrick Bouvier --- MAINTAINERS | 2 + include/hw/timer/qct-qtimer.h | 43 +++ hw/timer/qct-qtimer.c | 667 ++++++++++++++++++++++++++++++++++ hw/timer/Kconfig | 3 + hw/timer/meson.build | 2 + hw/timer/trace-events | 5 + 6 files changed, 722 insertions(+) create mode 100644 include/hw/timer/qct-qtimer.h create mode 100644 hw/timer/qct-qtimer.c diff --git a/MAINTAINERS b/MAINTAINERS index 678b7bacd79..ae623a7e924 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -253,6 +253,8 @@ F: target/hexagon/ F: hw/intc/hex-l2vic.c F: include/hw/intc/hex-l2vic.h F: tests/qtest/l2vic-test.c +F: hw/timer/qct-qtimer.c +F: include/hw/timer/qct-qtimer.h X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/ diff --git a/include/hw/timer/qct-qtimer.h b/include/hw/timer/qct-qtimer.h new file mode 100644 index 00000000000..53d8291472d --- /dev/null +++ b/include/hw/timer/qct-qtimer.h @@ -0,0 +1,43 @@ +/* + * Qualcomm QCT QTimer + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_TIMER_QCT_QTIMER_H +#define HW_TIMER_QCT_QTIMER_H + +#include "qom/object.h" + +#define TYPE_QCT_QTIMER "qct-qtimer" + +/* QTimer interface for external access from hexagon_globalreg */ +#define TYPE_QCT_QTIMER_INTERFACE "qct-qtimer-if" + +typedef struct QctQtimerInterface QctQtimerInterface; + +typedef struct QctQtimerInterfaceClass { + InterfaceClass parent_class; + + /* Read the live physical counter, backing HEX_SREG_TIMERLO/TIMERHI */ + uint32_t (*get_timer_lo)(const QctQtimerInterface *qtimer); + uint32_t (*get_timer_hi)(const QctQtimerInterface *qtimer); +} QctQtimerInterfaceClass; + +DECLARE_OBJ_CHECKERS(QctQtimerInterface, QctQtimerInterfaceClass, + QCT_QTIMER_INTERFACE, TYPE_QCT_QTIMER_INTERFACE); + +static inline uint32_t qct_qtimer_get_timer_lo(const QctQtimerInterface *q= timer) +{ + QctQtimerInterfaceClass *k =3D QCT_QTIMER_INTERFACE_GET_CLASS(qtimer); + return k->get_timer_lo(qtimer); +} + +static inline uint32_t qct_qtimer_get_timer_hi(const QctQtimerInterface *q= timer) +{ + QctQtimerInterfaceClass *k =3D QCT_QTIMER_INTERFACE_GET_CLASS(qtimer); + return k->get_timer_hi(qtimer); +} + +#endif /* HW_TIMER_QCT_QTIMER_H */ diff --git a/hw/timer/qct-qtimer.c b/hw/timer/qct-qtimer.c new file mode 100644 index 00000000000..f628e8d263a --- /dev/null +++ b/hw/timer/qct-qtimer.c @@ -0,0 +1,667 @@ +/* + * Qualcomm QCT QTimer + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/core/irq.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/sysbus.h" +#include "hw/timer/qct-qtimer.h" +#include "migration/vmstate.h" +#include "qemu/bitops.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/timer.h" +#include "qapi/error.h" +#include "trace.h" + +#define QTIMER_MEM_SIZE_BYTES 0x1000 +#define QTIMER_DEFAULT_FREQ_HZ 19200000ULL + +#define QCT_QTIMER_TIMER_FRAME_ELTS (16) +#define QCT_QTIMER_TIMER_VIEW_ELTS (2) + +#define QCT_QTIMER_AC_CNTFRQ (0x000) +#define QCT_QTIMER_AC_CNTSR (0x004) +#define QCT_QTIMER_AC_CNTTID_0 (0x08) +#define QCT_QTIMER_AC_CNTACR_START (0x40) +#define QCT_QTIMER_AC_CNTACR_END (0x5c) +#define QCT_QTIMER_AC_CNTTID_1 (0x108) +#define QCT_QTIMER_AC_CNTACR_RWPT (1 << 5) /* R/W of CNTP_* regs */ +#define QCT_QTIMER_AC_CNTACR_RWVT (1 << 4) /* R/W of CNTV_* regs */ +#define QCT_QTIMER_AC_CNTACR_RVOFF (1 << 3) /* R/W of CNTVOFF register */ +#define QCT_QTIMER_AC_CNTACR_RFRQ (1 << 2) /* R/W of CNTFRQ register */ +#define QCT_QTIMER_AC_CNTACR_RPVCT (1 << 1) /* R/W of CNTVCT register */ +#define QCT_QTIMER_AC_CNTACR_RPCT (1 << 0) /* R/W of CNTPCT register */ +#define QCT_QTIMER_VERSION (0x0fd0) + +#define QCT_QTIMER_CNTPCT_LO (0x000) +#define QCT_QTIMER_CNTPCT_HI (0x004) +#define QCT_QTIMER_CNT_FREQ (0x010) +#define QCT_QTIMER_CNTPL0ACR (0x014) +#define QCT_QTIMER_CNTPL0ACR_PL0CTEN (1 << 9) +#define QCT_QTIMER_CNTPL0ACR_PL0TVEN (1 << 8) +#define QCT_QTIMER_CNTPL0ACR_PL0VCTEN (1 << 1) +#define QCT_QTIMER_CNTPL0ACR_PL0PCTEN (1 << 0) +#define QCT_QTIMER_CNTP_CVAL_LO (0x020) +#define QCT_QTIMER_CNTP_CVAL_HI (0x024) +#define QCT_QTIMER_CNT_MASK 0x00ffffffffffffffULL +#define QCT_QTIMER_CNT_HI_BITS 24 +#define QCT_QTIMER_CNTP_TVAL (0x028) +#define QCT_QTIMER_CNTP_CTL (0x02c) +#define QCT_QTIMER_CNTP_CTL_ENABLE (1 << 0) +#define QCT_QTIMER_CNTP_CTL_INTEN (1 << 1) +#define QCT_QTIMER_CNTP_CTL_ISTAT (1 << 2) + +OBJECT_DECLARE_SIMPLE_TYPE(QCTQtimerState, QCT_QTIMER) + +typedef struct QCTHextimerState { + QCTQtimerState *qtimer; + QEMUTimer *timer; /* one-shot deadline timer */ + int64_t offset_ns; /* QEMU_CLOCK_VIRTUAL ns at which cntpct =3D= =3D 0 */ + uint64_t cntval; /* 64-bit physical timer compare value */ + uint32_t control; + uint32_t cnt_ctrl; + uint32_t cntpl0acr; + uint32_t int_level; + qemu_irq irq; +} QCTHextimerState; + +struct QCTQtimerState { + SysBusDevice parent_obj; + + MemoryRegion iomem; + MemoryRegion view_iomem; + uint32_t secure; + QCTHextimerState timer[QCT_QTIMER_TIMER_FRAME_ELTS]; + uint32_t freq_hz; + uint32_t nr_frames; + uint32_t nr_views; + uint32_t frame_stride; + uint32_t freq_scale; +}; + +/* + * QTimer version register: + * + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Major | Minor | Step | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +#define QCT_QTIMER_VERSION_VALUE 0x20020000 + +static uint32_t qct_qtimer_cnttid(QCTQtimerState *s, unsigned int half) +{ + uint32_t nibble =3D 0x1 | (s->nr_views > 1 ? 0x4 : 0x0); + uint32_t base =3D half * 8; + uint32_t cnttid =3D 0; + unsigned int i; + + for (i =3D 0; i < 8; i++) { + if (base + i < s->nr_frames) { + cnttid |=3D nibble << (i * 4); + } + } + return cnttid; +} + +/* Counter value derived on-demand from QEMU_CLOCK_VIRTUAL. */ +static uint64_t hex_timer_now(QCTHextimerState *s) +{ + int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + uint32_t scale; + uint64_t scaled_elapsed; + + if (now <=3D s->offset_ns) { + return 0; + } + scale =3D MAX(s->qtimer->freq_scale, 1u); + scaled_elapsed =3D (uint64_t)(now - s->offset_ns) / scale; + return muldiv64(scaled_elapsed, s->qtimer->freq_hz, + NANOSECONDS_PER_SECOND) & + QCT_QTIMER_CNT_MASK; +} + +/* Arm (or disarm) the one-shot deadline timer. */ +static void hex_timer_rearm(QCTHextimerState *s) +{ + uint32_t scale; + uint64_t base_ns; + int64_t deadline_ns; + + if (!(s->control & QCT_QTIMER_CNTP_CTL_ENABLE)) { + timer_del(s->timer); + return; + } + + scale =3D MAX(s->qtimer->freq_scale, 1u); + /* + * Round the ticks-to-ns conversion up so that hex_timer_now(), which + * truncates when it divides elapsed ns by scale, is guaranteed to + * report >=3D cntval once this deadline fires. A truncating conversion + * here could re-arm at the same deadline forever when scale > 1. + */ + base_ns =3D muldiv64_round_up(s->cntval, NANOSECONDS_PER_SECOND, + s->qtimer->freq_hz); + if (base_ns > + ((uint64_t)INT64_MAX - (uint64_t)s->offset_ns) / scale) { + timer_del(s->timer); + return; + } + deadline_ns =3D s->offset_ns + (int64_t)(base_ns * scale); + timer_mod(s->timer, deadline_ns); +} + +static void hex_timer_update(QCTHextimerState *s) +{ + int level =3D s->int_level && + (s->control & QCT_QTIMER_CNTP_CTL_ENABLE) && + !(s->control & QCT_QTIMER_CNTP_CTL_INTEN); + + trace_qtimer_interrupt(); + qemu_set_irq(s->irq, level); +} + +/* + * Access-control (AC) region: offsets below 0x1000, gates CNTFRQ/CNTSR/ + * CNTTID/CNTACR per frame plus the shared VERSION register. + */ +static uint64_t qct_qtimer_ac_read(void *opaque, hwaddr offset, unsigned s= ize) +{ + QCTQtimerState *s =3D opaque; + uint32_t frame; + + switch (offset) { + case QCT_QTIMER_AC_CNTFRQ: + return s->freq_hz; + case QCT_QTIMER_AC_CNTSR: + return s->secure; + case QCT_QTIMER_AC_CNTTID_0: + return qct_qtimer_cnttid(s, 0); + case QCT_QTIMER_AC_CNTTID_1: + return qct_qtimer_cnttid(s, 1); + case QCT_QTIMER_AC_CNTACR_START ... QCT_QTIMER_AC_CNTACR_END: + frame =3D (offset - QCT_QTIMER_AC_CNTACR_START) / 4; + if (frame >=3D s->nr_frames) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad CNTACR offset 0x%x\n", + __func__, (int)offset); + return 0; + } + return s->timer[frame].cnt_ctrl; + case QCT_QTIMER_VERSION: + return QCT_QTIMER_VERSION_VALUE; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad offset 0x%x\n", __func__, + (int)offset); + return 0; + } +} + +static void qct_qtimer_ac_write(void *opaque, hwaddr offset, uint64_t valu= e, + unsigned size) +{ + QCTQtimerState *s =3D opaque; + uint32_t frame; + + switch (offset) { + case QCT_QTIMER_AC_CNTFRQ: + if (value =3D=3D 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad CNTFRQ value 0\n", + __func__); + return; + } + s->freq_hz =3D value; + return; + case QCT_QTIMER_AC_CNTSR: + if (value > 0xff) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad CNTSR value 0x%x\n", + __func__, (int)value); + return; + } + s->secure =3D value; + return; + case QCT_QTIMER_AC_CNTACR_START ... QCT_QTIMER_AC_CNTACR_END: + frame =3D (offset - QCT_QTIMER_AC_CNTACR_START) / 4; + if (frame >=3D s->nr_frames) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad CNTACR offset 0x%x\n", + __func__, (int)offset); + return; + } + s->timer[frame].cnt_ctrl =3D value; + return; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad offset 0x%x\n", __func__, + (int)offset); + return; + } +} + +static const MemoryRegionOps qct_qtimer_ac_ops =3D { + .read =3D qct_qtimer_ac_read, + .write =3D qct_qtimer_ac_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + .unaligned =3D false, + }, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +/* + * View region: a flat array of (frame, view) slots, each frame_stride + * bytes wide, holding the per-frame CNTPCT/CNTP_CVAL/CNTP_TVAL/CNTP_CTL + * register set. + */ +static QCTHextimerState *qct_qtimer_demux(QCTQtimerState *s, hwaddr offset, + uint32_t *reg_offset, + uint32_t *view) +{ + uint32_t stride =3D s->frame_stride; + uint32_t stride_shift =3D ctz32(stride); + uint32_t slot_nr =3D offset >> stride_shift; + uint32_t frame =3D slot_nr / s->nr_views; + + *reg_offset =3D offset & (stride - 1); + *view =3D slot_nr % s->nr_views; + if (frame >=3D s->nr_frames) { + return NULL; + } + return &s->timer[frame]; +} + +/* Frames 8+ are described by CNTTID_1; each frame's 2nd view is a gated b= it. */ +static bool qct_qtimer_view_visible(QCTQtimerState *s, uint32_t frame, + uint32_t view) +{ + uint32_t cnttid =3D qct_qtimer_cnttid(s, frame < 8 ? 0 : 1); + uint32_t frame_idx =3D frame < 8 ? frame : frame - 8; + + return !view || (cnttid & (0x4 << (frame_idx * 4))); +} + +static bool access_ok(QCTHextimerState *s, uint32_t reg_offset, uint32_t v= iew) +{ + uint32_t acr; + uint32_t pl0acr; + + switch (reg_offset) { + case QCT_QTIMER_CNT_FREQ: + acr =3D QCT_QTIMER_AC_CNTACR_RFRQ; + pl0acr =3D QCT_QTIMER_CNTPL0ACR_PL0PCTEN | + QCT_QTIMER_CNTPL0ACR_PL0VCTEN; + break; + case QCT_QTIMER_CNTPCT_LO: + case QCT_QTIMER_CNTPCT_HI: + acr =3D QCT_QTIMER_AC_CNTACR_RPCT; + pl0acr =3D QCT_QTIMER_CNTPL0ACR_PL0PCTEN; + break; + case QCT_QTIMER_CNTP_CVAL_LO: + case QCT_QTIMER_CNTP_CVAL_HI: + case QCT_QTIMER_CNTP_TVAL: + case QCT_QTIMER_CNTP_CTL: + acr =3D QCT_QTIMER_AC_CNTACR_RWPT; + pl0acr =3D QCT_QTIMER_CNTPL0ACR_PL0CTEN; + break; + default: + /* CNTPL0ACR and VERSION are ungated. */ + return true; + } + + if (!(s->cnt_ctrl & acr)) { + return false; + } + return !view || (s->cntpl0acr & pl0acr); +} + +static MemTxResult hex_timer_read(void *opaque, hwaddr offset, uint64_t *d= ata, + unsigned size, MemTxAttrs attrs) +{ + QCTQtimerState *qs =3D opaque; + uint32_t reg_offset; + uint32_t view; + QCTHextimerState *s =3D qct_qtimer_demux(qs, offset, ®_offset, &vie= w); + uint32_t frame; + + if (!s) { + *data =3D 0; + return MEMTX_ACCESS_ERROR; + } + frame =3D s - qs->timer; + + trace_qtimer_read(offset); + + if (!qct_qtimer_view_visible(qs, frame, view)) { + *data =3D 0; + return MEMTX_OK; + } + + if (!access_ok(s, reg_offset, view)) { + return MEMTX_ACCESS_ERROR; + } + + switch (reg_offset) { + case QCT_QTIMER_CNT_FREQ: + *data =3D s->qtimer->freq_hz; + return MEMTX_OK; + case QCT_QTIMER_CNTP_CVAL_LO: + *data =3D extract64(s->cntval, 0, 32); + return MEMTX_OK; + case QCT_QTIMER_CNTP_CVAL_HI: + /* HI half is 24-bit per TRM; bits [31:24] are reserved. */ + *data =3D extract64(s->cntval, 32, QCT_QTIMER_CNT_HI_BITS); + return MEMTX_OK; + case QCT_QTIMER_CNTPCT_LO: + *data =3D extract64(hex_timer_now(s), 0, 32); + return MEMTX_OK; + case QCT_QTIMER_CNTPCT_HI: + *data =3D extract64(hex_timer_now(s), 32, QCT_QTIMER_CNT_HI_BITS); + return MEMTX_OK; + case QCT_QTIMER_CNTP_TVAL: + *data =3D (uint32_t)(int32_t)(int64_t)(s->cntval - hex_timer_now(s= )); + return MEMTX_OK; + case QCT_QTIMER_CNTP_CTL: + /* + * CNTP_CTL: bit 0 EN, bit 1 IMASK, bit 2 ISTAT (interrupt + * pending). ISTAT tracks int_level and is read-only. + */ + *data =3D s->control | ((s->int_level & 0x1) << 2); + return MEMTX_OK; + case QCT_QTIMER_CNTPL0ACR: + *data =3D view ? 0 : s->cntpl0acr; + return MEMTX_OK; + case QCT_QTIMER_VERSION: + *data =3D QCT_QTIMER_VERSION_VALUE; + return MEMTX_OK; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad offset 0x%x\n", __func__, + (int)offset); + *data =3D 0; + return MEMTX_ACCESS_ERROR; + } +} + +static MemTxResult hex_timer_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + QCTQtimerState *qs =3D opaque; + uint32_t reg_offset; + uint32_t view; + QCTHextimerState *s =3D qct_qtimer_demux(qs, offset, ®_offset, &vie= w); + uint32_t frame; + + if (!s) { + return MEMTX_ACCESS_ERROR; + } + frame =3D s - qs->timer; + + trace_qtimer_write(offset, value); + + if (!qct_qtimer_view_visible(qs, frame, view)) { + return MEMTX_OK; + } + + if (!access_ok(s, reg_offset, view)) { + return MEMTX_ACCESS_ERROR; + } + + switch (reg_offset) { + case QCT_QTIMER_CNTP_CVAL_LO: + s->int_level =3D 0; + s->cntval =3D deposit64(s->cntval, 0, 32, value); + hex_timer_rearm(s); + break; + case QCT_QTIMER_CNTP_CVAL_HI: + s->int_level =3D 0; + /* HI half is 24-bit per TRM; bits [31:24] are reserved. */ + s->cntval =3D deposit64(s->cntval, 32, QCT_QTIMER_CNT_HI_BITS, val= ue) & + QCT_QTIMER_CNT_MASK; + hex_timer_rearm(s); + break; + case QCT_QTIMER_CNTP_CTL: + /* ISTAT (bit 2) is read-only; keep SW writes from polluting it. */ + s->control =3D value & ~QCT_QTIMER_CNTP_CTL_ISTAT; + hex_timer_rearm(s); + break; + case QCT_QTIMER_CNTP_TVAL: + /* TVAL write: CVAL =3D CNTPCT + TVAL (TVAL is signed 32-bit). */ + s->int_level =3D 0; + s->cntval =3D (hex_timer_now(s) + (int64_t)(int32_t)value) & + QCT_QTIMER_CNT_MASK; + hex_timer_rearm(s); + break; + case QCT_QTIMER_CNTPL0ACR: + if (!view) { + s->cntpl0acr =3D value; + } + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad offset 0x%x\n", __func__, + (int)offset); + return MEMTX_ACCESS_ERROR; + } + hex_timer_update(s); + return MEMTX_OK; +} + +static void hex_timer_tick(void *opaque) +{ + QCTHextimerState *s =3D opaque; + uint64_t now =3D hex_timer_now(s); + uint64_t diff56 =3D (now - s->cntval) & QCT_QTIMER_CNT_MASK; + int64_t signed_diff =3D (int64_t)(diff56 << 8) >> 8; + + if (signed_diff >=3D 0) { + s->int_level =3D 1; + hex_timer_update(s); + } else { + hex_timer_rearm(s); + } +} + +static const MemoryRegionOps hex_timer_ops =3D { + .read_with_attrs =3D hex_timer_read, + .write_with_attrs =3D hex_timer_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 8, + .unaligned =3D false, + }, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +static const VMStateDescription vmstate_qct_hextimer =3D { + .name =3D "qct-hextimer", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(control, QCTHextimerState), + VMSTATE_UINT32(cnt_ctrl, QCTHextimerState), + VMSTATE_INT64(offset_ns, QCTHextimerState), + VMSTATE_UINT64(cntval, QCTHextimerState), + VMSTATE_UINT32(cntpl0acr, QCTHextimerState), + VMSTATE_UINT32(int_level, QCTHextimerState), + VMSTATE_TIMER_PTR(timer, QCTHextimerState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_qct_qtimer =3D { + .name =3D "qct-qtimer", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(freq_hz, QCTQtimerState), + VMSTATE_UINT32(secure, QCTQtimerState), + VMSTATE_STRUCT_VARRAY_UINT32(timer, QCTQtimerState, nr_frames, + 1, vmstate_qct_hextimer, QCTHextimerSt= ate), + VMSTATE_END_OF_LIST() + } +}; + +static void qct_qtimer_realize(DeviceState *dev, Error **errp) +{ + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + QCTQtimerState *s =3D QCT_QTIMER(dev); + unsigned int i; + + if (s->nr_frames > QCT_QTIMER_TIMER_FRAME_ELTS) { + error_setg(errp, "nr_frames too high"); + return; + } + if (s->nr_views > QCT_QTIMER_TIMER_VIEW_ELTS) { + error_setg(errp, "nr_views too high"); + return; + } + if (s->freq_hz =3D=3D 0) { + error_setg(errp, "freq-hz must be nonzero"); + return; + } + if (s->frame_stride =3D=3D 0 || !is_power_of_2(s->frame_stride)) { + error_setg(errp, "frame_stride must be a nonzero power of two"); + return; + } + + memory_region_init_io(&s->iomem, OBJECT(s), &qct_qtimer_ac_ops, s, + "qct-qtimer-ac", QTIMER_MEM_SIZE_BYTES); + sysbus_init_mmio(sbd, &s->iomem); + + memory_region_init_io(&s->view_iomem, OBJECT(s), &hex_timer_ops, s, + "qct-qtimer-view", + (uint64_t)s->frame_stride * s->nr_frames * + s->nr_views); + sysbus_init_mmio(sbd, &s->view_iomem); + + for (i =3D 0; i < s->nr_frames; i++) { + QCTHextimerState *t =3D &s->timer[i]; + + t->qtimer =3D s; + s->secure |=3D (1 << i); + + sysbus_init_irq(sbd, &t->irq); + t->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, hex_timer_tick, t); + } +} + +static void qct_qtimer_unrealize(DeviceState *dev) +{ + QCTQtimerState *s =3D QCT_QTIMER(dev); + unsigned int i; + + for (i =3D 0; i < s->nr_frames; i++) { + QCTHextimerState *t =3D &s->timer[i]; + + if (t->timer) { + timer_free(t->timer); + t->timer =3D NULL; + } + } +} + +static void qct_qtimer_reset_hold(Object *obj, ResetType type) +{ + QCTQtimerState *s =3D QCT_QTIMER(obj); + unsigned int i; + + for (i =3D 0; i < s->nr_frames; i++) { + QCTHextimerState *t =3D &s->timer[i]; + + /* + * Per TRM: CTL =3D 0 (EN=3D0, IMASK=3D0, ISTAT=3D0), CVAL =3D 0 s= o that + * TVAL (=3D CVAL - CNTPCT) also reads 0 at reset. The QEMUTimer is + * only armed when SW sets CTL.EN=3D1, so cntval=3D0 does not caus= e a + * spurious fire before SW programs the compare value. + */ + t->control =3D 0; + t->cnt_ctrl =3D QCT_QTIMER_AC_CNTACR_RWPT | QCT_QTIMER_AC_CNTACR_R= WVT | + QCT_QTIMER_AC_CNTACR_RVOFF | QCT_QTIMER_AC_CNTACR_RF= RQ | + QCT_QTIMER_AC_CNTACR_RPVCT | QCT_QTIMER_AC_CNTACR_RP= CT; + t->cntval =3D 0; + t->cntpl0acr =3D 0; + t->int_level =3D 0; + t->offset_ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + timer_del(t->timer); + qemu_set_irq(t->irq, 0); + } +} + +static const Property qct_qtimer_properties[] =3D { + DEFINE_PROP_UINT32("freq-hz", QCTQtimerState, freq_hz, + QTIMER_DEFAULT_FREQ_HZ), + DEFINE_PROP_UINT32("freq-scale", QCTQtimerState, freq_scale, 1), + DEFINE_PROP_UINT32("nr_frames", QCTQtimerState, nr_frames, 2), + DEFINE_PROP_UINT32("nr_views", QCTQtimerState, nr_views, 1), + DEFINE_PROP_UINT32("frame_stride", QCTQtimerState, frame_stride, 0x100= 0), +}; + +static void qct_qtimer_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + device_class_set_props(dc, qct_qtimer_properties); + dc->realize =3D qct_qtimer_realize; + dc->unrealize =3D qct_qtimer_unrealize; + dc->vmsd =3D &vmstate_qct_qtimer; + rc->phases.hold =3D qct_qtimer_reset_hold; +} + +/* QTimer interface implementation, backing HEX_SREG_TIMERLO/TIMERHI */ +static uint32_t qct_qtimer_get_timer_lo_impl(const QctQtimerInterface *obj) +{ + QCTQtimerState *s =3D QCT_QTIMER((QctQtimerInterface *)obj); + + return s->nr_frames > 0 ? extract64(hex_timer_now(&s->timer[0]), 0, 32) + : 0; +} + +static uint32_t qct_qtimer_get_timer_hi_impl(const QctQtimerInterface *obj) +{ + QCTQtimerState *s =3D QCT_QTIMER((QctQtimerInterface *)obj); + + return s->nr_frames > 0 ? extract64(hex_timer_now(&s->timer[0]), 32, 3= 2) + : 0; +} + +static void qct_qtimer_interface_class_init(ObjectClass *klass, + const void *data) +{ + QctQtimerInterfaceClass *k =3D QCT_QTIMER_INTERFACE_CLASS(klass); + + k->get_timer_lo =3D qct_qtimer_get_timer_lo_impl; + k->get_timer_hi =3D qct_qtimer_get_timer_hi_impl; +} + +static const TypeInfo qct_qtimer_types[] =3D { + { + .name =3D TYPE_QCT_QTIMER_INTERFACE, + .parent =3D TYPE_INTERFACE, + .class_size =3D sizeof(QctQtimerInterfaceClass), + .class_init =3D qct_qtimer_interface_class_init, + }, + { + .name =3D TYPE_QCT_QTIMER, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(QCTQtimerState), + .class_init =3D qct_qtimer_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_QCT_QTIMER_INTERFACE }, + { } + }, + }, +}; + +DEFINE_TYPES(qct_qtimer_types) diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig index b3d823ce2c3..e1b751a54a7 100644 --- a/hw/timer/Kconfig +++ b/hw/timer/Kconfig @@ -65,3 +65,6 @@ config STELLARIS_GPTM =20 config AVR_TIMER16 bool + +config HEX_QTIMER + bool diff --git a/hw/timer/meson.build b/hw/timer/meson.build index 201b5d8316d..8323efaf46b 100644 --- a/hw/timer/meson.build +++ b/hw/timer/meson.build @@ -34,3 +34,5 @@ specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex= _timer.c')) system_ss.add(when: 'CONFIG_SIFIVE_PWM', if_true: files('sifive_pwm.c')) =20 system_ss.add(when: 'CONFIG_AVR_TIMER16', if_true: files('avr_timer16.c')) + +system_ss.add(when: 'CONFIG_HEX_QTIMER', if_true: files('qct-qtimer.c')) diff --git a/hw/timer/trace-events b/hw/timer/trace-events index 634ba1da27a..636310f8caa 100644 --- a/hw/timer/trace-events +++ b/hw/timer/trace-events @@ -128,3 +128,8 @@ imx_epit_get_freq(uint32_t freq) "ptimer frequency is %= u" imx_epit_read(const char *name, uint32_t value) "(%s) =3D 0x%08x" imx_epit_write(const char *name, uint64_t value) "(%s, value =3D 0x%08" PR= Ix64 ")" imx_epit_cmp(uint32_t sr) "sr was %d" + +# qct-qtimer.c +qtimer_interrupt(void) "qtimer interrupt line updated" +qtimer_read(uint64_t offset) "offset 0x%" PRIx64 +qtimer_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value = 0x%" PRIx64 --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990532; cv=none; d=zohomail.com; s=zohoarc; b=A1aqfvsHGd2SSBrRZtmuoJq/WCvMItSREcoT8tnRjlRxvCQut9HWIgYySMCesMM50A4P2kkfV37Tynukh1fFUjoIK8+idc0vAqBV4/BgK/lqTzhOfKqpO9yCEOqWUJfIDCzLr4NmkCdMmGZDgsXDYnnUiERKYePXl3iHj7cVDJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990532; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=76pzn4fuh9VU/kZCqhM+K4k+XFlH6M5DsSv71CNQuow=; b=aED+6w8b33hbU4R1nykEkFzzErbpbs74i+3DQZTsHikGKc8H2t+6plAmd1LbxkyjXsTo7+jGZ9vAxikbOMr9l1PDFXOVKB7vUrczYmiwX71rjFYB7KQhXVxUQC60rrf0kiABy2/fz32s2YMuIs0PoXXsBJSy5xBn23GnM03czco= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990532836403.267578788743; Wed, 5 Aug 2026 21:28:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrphz-0002wH-5e; Thu, 06 Aug 2026 00:27:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphx-0002vf-9N for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:53 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphv-0003Eq-86 for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:53 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675NbFWd4063454 for ; Thu, 6 Aug 2026 04:27:50 GMT Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv5x5kgas-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:49 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2ce7dfd33ffso21459665ad.0 for ; Wed, 05 Aug 2026 21:27:49 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 76pzn4fuh9VU/kZCqhM+K4k+XFlH6M5DsSv71CNQuow=; b=BQFaA+k4ZMlwG0ob s8ciT2wGYut6A7obhFmZTVv+WPDTuGjd03TJYTGldZCFH2y4u9/JTntgEnvmIFhA o7M0RYIa4pUUO6FIqgeSWzomgsU07I9fnA0iFHx3y3uJlPavfcZMTwUYNH5Wi7Im rbg0+br0TBJss2OlUPtO+krDZw+RNmahkVbqV5gVZ6kszkuMp+BmVheIYoUsBOFn CShkhgelG94YK5vnddv0QtE71PsKN3K48IP6wBQEQ17FKJpK9WQz0p/gam679ayl +Fr2ktG2ipT853qA2iZUHbve1kGEuHpmvZTCE0Ikta6VDt7xhHcTscT2R+UTVonX IupkDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990469; x=1786595269; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=76pzn4fuh9VU/kZCqhM+K4k+XFlH6M5DsSv71CNQuow=; b=jgoCnTuECrg33OZdz0CKM2kJpX6qdM+LQD9vVSaXx1y8uvcXdENwrSMrXh3sHCkoTj EHs7rSqqVL4DRc85KkAo2IAO+3qcpBKhllrmIhvmcUDCtFaecDLsIroJSFHjLHfn3Pe7 4eLKnHYYfbNEuhsyUtgj3tEw/HRRNmKln4a32cxZ4zzoi7Nujr+tpeLwtpicONL2aTYJ ROKQWLZyHZ+Z3Myb37JhLv5PHljdnaE0Ds3T7htgLnIKM0/0Mu6+xw5fKfGQSsgmeown dIwgUAFYT44zaJ20/wQmMFJCELzFjmZd1tKePQLf81AkQafZc3yzF0D40oV7BcesLALk XGzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990469; x=1786595269; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=76pzn4fuh9VU/kZCqhM+K4k+XFlH6M5DsSv71CNQuow=; b=bJL6BOcvDSNya9JkoYjLs7GQQgygQyjVWOdX8VcWYAkVO2Ms3A5+rz9PQxgofxizPn I6/DHAir6ApkssnPJsKmiPCQ+VtFy3rupW0t8WRxJoukJm/Fe7FfsrGqM+QOwKIIUIHw 1bnLJL8HqpZHyLSUicL93CkCOFTjPqGYQnrUyi/ZXS9KBsnn7N7xAsEjEcuJ+15hFy3+ /fNiM/+UhCHAfEFLZBR81RmXvwuySIyB8bQrLnrZem5t07MmwiSijc83v6YML/RQ42nO Z9PxCY3kgyfDNd+ZPOvxdtxFx3DXAw+n8ysd/V9ldK1FBEqZQWTVS8NeLUd+JsUSnwTl H0dA== X-Gm-Message-State: AOJu0YyXSvFsi9+A6+2FjqThlyTid+NUs72MfzE/xTGkb6Ays1SkZYGB Px4adhrrW8MUfce+gsPS17xn0TTugEteIge4DVamvwZII8TTc39KjtecKaP6lyEPgP6AHPgR2aO qJtP2Ha7/GPLAAs07z3K8sR2aZ/BIeTCwGeFHW6li94Bs+/PEMM+XOrBQgGOoEknHuQ== X-Gm-Gg: AR+sD13Xj7ApvS4JuifiIm3CvUdam6gYuFw/mErIniUOX2oW6b8fu/nmIZMiNT0SVVM 4IcVstPqsvpdBPUBb6rcImfrZGoSVXobF7DlQvtTdwBes34LWKzh2YsW/zSd8iPIiTxvHLhgNxK NH2o2G/Zl25hbkZoxcbAULBBMvrrtIIsv6OmFRbhkwO3GHbHh5c2p/09oM3WZhGYslaIXsA8Iwx mydSep6C+2ukDThv3Xk91GB0cuQ3KeKcvvImzeKz8mQT8olnsT+Wzz66177GPCi87Jy9YEdhzlz L5B+NfrgnUWSL7d6LHvd601HdMrlbsup+5bEvvkBaQUpYJ12Xwo+wtutyiEhhdXy/kurqfJlD85 lGuEZE4PKOKBZaii+lYO49nLC+f7sXeGuqQDrayua5sOYWvhA X-Received: by 2002:a17:90b:5251:b0:38e:4cb:51f with SMTP id 98e67ed59e1d1-3903c59212bmr12425416a91.11.1785990469166; Wed, 05 Aug 2026 21:27:49 -0700 (PDT) X-Received: by 2002:a17:90b:5251:b0:38e:4cb:51f with SMTP id 98e67ed59e1d1-3903c59212bmr12425366a91.11.1785990468609; Wed, 05 Aug 2026 21:27:48 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 16/18] hw/hexagon: connect qtimer device Date: Wed, 5 Aug 2026 21:27:21 -0700 Message-Id: <20260806042723.3785369-17-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX8Skrvp16ryLl aop/P9crkb6esH36CXaEjVin4uEqvhHcoylBMAGmKDjaNNt4t7LNRsKHpxwmv1Bz85TvHXg4Xp+ I84x5CR5OSAG9LZc4tRzYN5I65z2EszE5eTJxgIWDA3Vi+Blk8wJFYRrd5hgCsdXEBJY5D7nQa6 AisC9Y3GcOa39HmuLz92yshtgaDbPUKZ4LZ/NGYddMoMauWOuFA/yvb+VA3ysfTK3kAEGWcEj+c b/YLwPGI2egxqDlCUdVAJqpWnRiIrPdTimXTEBz9UatzWmqsT0XFQQamYazUsOsDiczKm+lEp2P d65s9UrOWDNNH8XQcuEELwHlO3s0FqTvWooSgg0fWAqFC1cRv+W/FFq39/093560AvBngeVtuOQ swnQFVTuPFXIGPVmNCHLUew8W7n7d62+4AWISf57KMzJQLkLAnghym8lUy+UFZuPXiORvucGdJ+ JhARa+phXFEaDQwCx5w== X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX2IQW8QkZYSq4 RzsxfA5k9xirP3EECi/GKOZR4WGOx3V4rxrt5r6IEpDS+vquoB+sp1hssRJzO8Nqmy07zoZo26x GHE+2u5aHeJHztYSbRdPkFFGxbDJWsE= X-Proofpoint-GUID: w2LXpah0wc4fUC4fYrHLyss_j5r4xNAt X-Authority-Analysis: v=2.4 cv=cIbQdFeN c=1 sm=1 tr=0 ts=6a740d45 cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=El6rGuWiIpdnsNYezL0A:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-ORIG-GUID: w2LXpah0wc4fUC4fYrHLyss_j5r4xNAt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 clxscore=1015 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990534300158500 Add the QTimer to the shared hex-subsys so both machine models pick it up. Map its view region, wire its interrupt lines into l2vic, and link it to the globalreg device backing HEX_SREG_TIMERLO/TIMERHI. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_globalreg.h | 4 ++++ hw/hexagon/hex-subsys.c | 28 ++++++++++++++++++++++++++ hw/hexagon/hexagon_globalreg.c | 17 ++++++++++++++++ hw/hexagon/Kconfig | 1 + 5 files changed, 51 insertions(+) diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h index ec1578807d8..3d7b3cb12dc 100644 --- a/include/hw/hexagon/hexagon.h +++ b/include/hw/hexagon/hexagon.h @@ -159,6 +159,7 @@ struct HexagonCommonMachineState { MemoryRegion vtcm; DeviceState *cluster; DeviceState *l2vic; + DeviceState *qtimer; DeviceState *glob_regs; DeviceState *tlb; }; diff --git a/include/hw/hexagon/hexagon_globalreg.h b/include/hw/hexagon/he= xagon_globalreg.h index 397dc6854c9..07437dfabb1 100644 --- a/include/hw/hexagon/hexagon_globalreg.h +++ b/include/hw/hexagon/hexagon_globalreg.h @@ -11,6 +11,7 @@ #include "hw/core/qdev.h" #include "hw/core/sysbus.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "qom/object.h" #include "target/hexagon/cpu.h" =20 @@ -26,6 +27,9 @@ struct HexagonGlobalRegState { /* L2VIC interface used to back the VID/VID1 registers */ HexL2VicInterface *l2vic; =20 + /* QTimer interface used to back the TIMERLO/TIMERHI registers */ + QctQtimerInterface *qtimer; + /* Global performance cycle counter base */ uint64_t g_pcycle_base; =20 diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c index 25c028f6579..4e3a418340e 100644 --- a/hw/hexagon/hex-subsys.c +++ b/hw/hexagon/hex-subsys.c @@ -11,6 +11,7 @@ #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" @@ -20,6 +21,11 @@ =20 #define HEX_L2VIC_CPU_IRQS 8 =20 +/* Number of QTimer frames instantiated for every Hexagon machine. */ +#define HEX_QTIMER_NR_FRAMES 3 + +#define HEX_QTIMER_L2VIC_IRQ_BASE 2 + static DeviceState *l2vic_create(HexagonCommonMachineState *hms, const struct hexagon_machine_config *m_cf= g) { @@ -43,6 +49,25 @@ static void l2vic_connect_cpu(DeviceState *l2vic, Device= State *cpu) } } =20 +static DeviceState *qtimer_create(HexagonCommonMachineState *hms, + const struct hexagon_machine_config *m_c= fg) +{ + DeviceState *qtimer =3D qdev_new(TYPE_QCT_QTIMER); + + object_property_add_child(OBJECT(hms), "qtimer", OBJECT(qtimer)); + qdev_prop_set_uint32(qtimer, "nr_frames", HEX_QTIMER_NR_FRAMES); + sysbus_realize_and_unref(SYS_BUS_DEVICE(qtimer), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(qtimer), 0, m_cfg->csr_base); + sysbus_mmio_map(SYS_BUS_DEVICE(qtimer), 1, m_cfg->qtmr_region); + for (unsigned int i =3D 0; i < HEX_QTIMER_NR_FRAMES; i++) { + sysbus_connect_irq(SYS_BUS_DEVICE(qtimer), i, + qdev_get_gpio_in(hms->l2vic, + HEX_QTIMER_L2VIC_IRQ_BASE + i)= ); + } + + return qtimer; +} + static DeviceState *globalreg_create(HexagonCommonMachineState *hms, const struct hexagon_machine_config *= m_cfg, Rev_t rev) @@ -54,6 +79,8 @@ static DeviceState *globalreg_create(HexagonCommonMachine= State *hms, qdev_prop_set_uint32(glob_regs, "dsp-rev", rev); object_property_set_link(OBJECT(glob_regs), "l2vic", OBJECT(hms->l2vic= ), &error_fatal); + object_property_set_link(OBJECT(glob_regs), "qtimer", OBJECT(hms->qtim= er), + &error_fatal); sysbus_realize_and_unref(SYS_BUS_DEVICE(glob_regs), &error_fatal); =20 return glob_regs; @@ -110,6 +137,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, =20 hms->cluster =3D cluster_create(hms); hms->l2vic =3D l2vic_create(hms, m_cfg); + hms->qtimer =3D qtimer_create(hms, m_cfg); hms->glob_regs =3D globalreg_create(hms, m_cfg, rev); hms->tlb =3D tlb_create(hms, m_cfg); } diff --git a/hw/hexagon/hexagon_globalreg.c b/hw/hexagon/hexagon_globalreg.c index 285cb48c44b..61621cf2b8f 100644 --- a/hw/hexagon/hexagon_globalreg.c +++ b/hw/hexagon/hexagon_globalreg.c @@ -12,6 +12,7 @@ #include "hw/core/sysbus.h" #include "hw/core/resettable.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "migration/vmstate.h" #include "qom/object.h" #include "target/hexagon/cpu.h" @@ -141,11 +142,21 @@ static inline bool is_vid_reg(uint32_t reg) return reg =3D=3D HEX_SREG_VID || reg =3D=3D HEX_SREG_VID1; } =20 +static inline bool is_timer_reg(uint32_t reg) +{ + return reg =3D=3D HEX_SREG_TIMERLO || reg =3D=3D HEX_SREG_TIMERHI; +} + static uint32_t get_reg_value(HexagonGlobalRegState *s, uint32_t reg) { if (is_vid_reg(reg)) { return l2vic_read_vid(s->l2vic, reg =3D=3D HEX_SREG_VID ? 0 : 1); } + if (is_timer_reg(reg)) { + return reg =3D=3D HEX_SREG_TIMERLO ? + qct_qtimer_get_timer_lo(s->qtimer) : + qct_qtimer_get_timer_hi(s->qtimer); + } return s->regs[reg]; } =20 @@ -289,6 +300,10 @@ static void hexagon_globalreg_realize(DeviceState *dev= , Error **errp) error_setg(errp, "hexagon_globalreg: 'l2vic' link property not set= "); return; } + if (!s->qtimer) { + error_setg(errp, "hexagon_globalreg: 'qtimer' link property not se= t"); + return; + } } =20 static const VMStateDescription vmstate_hexagon_globalreg =3D { @@ -312,6 +327,8 @@ static const VMStateDescription vmstate_hexagon_globalr= eg =3D { static const Property hexagon_globalreg_properties[] =3D { DEFINE_PROP_LINK("l2vic", HexagonGlobalRegState, l2vic, TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *), + DEFINE_PROP_LINK("qtimer", HexagonGlobalRegState, qtimer, + TYPE_QCT_QTIMER_INTERFACE, QctQtimerInterface *), DEFINE_PROP_UINT32("boot-evb", HexagonGlobalRegState, boot_evb, 0x0), DEFINE_PROP_UINT64("config-table-addr", HexagonGlobalRegState, config_table_addr, 0xffffffffULL), diff --git a/hw/hexagon/Kconfig b/hw/hexagon/Kconfig index c75090c44a1..83b2763d1e3 100644 --- a/hw/hexagon/Kconfig +++ b/hw/hexagon/Kconfig @@ -4,6 +4,7 @@ config HEX_DSP depends on HEXAGON select CPU_CLUSTER select HEX_L2VIC + select HEX_QTIMER =20 config HEX_VIRT bool --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990557; cv=none; d=zohomail.com; s=zohoarc; b=gTVEgrAuCOLDMO5zVwgse06VumzZ00+Syq0hgqzYsbenlqaHWmQ9tAIekkZzGlB8nst9YKsz+cjEhL93SP+dRwoSS4YyOtVJkYJBoV98cMQZfscltvDSMaTaqe/O+h0ppXun8krXlY4LcYelKHc6avyRgj0zJvYHn4Vl8Sw4oCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990557; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hn12mOQJOB5mPU3wEI1erJHotJcPt5CfZ+8JVKzkIOg=; b=GptPiNfJLz1bi+fs/MV8jg/bZ3i4l5PdR91sPIqou+B+dYqOBTAJEjB5ij5Y0BPdg20vydZ9KY4EZ1wyw2PEdh3C0aSaqEwFehW1SjzorXtTPTAdyIvZO6TAvEWzUImf3yrwo3k37RnJTe1hOq0oJXByJF4KaayOHPRC9bN8QCU= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990557368324.8198379461878; Wed, 5 Aug 2026 21:29:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrpi4-0002xQ-8Q; Thu, 06 Aug 2026 00:28:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrpi0-0002wc-8z for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:56 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphx-0003Ev-GY for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:56 -0400 Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675NbA483701686 for ; Thu, 6 Aug 2026 04:27:52 GMT Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv9f5a92v-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:52 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cbe77d6864dso1584791a12.2 for ; Wed, 05 Aug 2026 21:27:52 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= hn12mOQJOB5mPU3wEI1erJHotJcPt5CfZ+8JVKzkIOg=; b=U5L/3WPMOcLS5v1b +EZhJWDkq7U561osYNsD5R3kHct8SLjhdrgMt/GUl/mvwGOEROXTb0AsC3cMDQAv gbFPUFQIgNqA9bRWabUuhP2o5KydCBTwEtfjHK+PaDcPEuwMxp5Y3cQ2Mh1w9BZS Wkd0CFSnHEUzs27m/rfk/iWwmPSs/qiN60sUfD6YbtFo1W9p+otwIHNd6MISmUA+ vbhIuOUVnMvefqBKKwkNpun72fEr9lU0GYquyq0uAobToCeVmh6GJxaUThQr6j6N y8lCCysO4BUKsbE6fwbCqAJoMOGU7Ch/dxDWGlnLTEsTxRwV6gUKiaDowQzbvsLK 3z5brQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990471; x=1786595271; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=hn12mOQJOB5mPU3wEI1erJHotJcPt5CfZ+8JVKzkIOg=; b=HN0lKHqSH5fKyzOdXSy8NNOL05XQDfp648rWHzpaqmx2BXrXyCDFPPFnv6cxJadyDK EJTqga54DEVka+VyRnffEhc2JxmWBljJ9cHgaukrc363l2HB3RzrSwtLqpZVzqWMazeU xH8uHBgGLQQn1LN0RkVyH0JtILuBJowNQ4vKMgovDNFP67qzC6z/Jb0q2H/wpx5Giusv GNdG1+X3yGrzwzygchKDVnsKy3mwn/yorfXGluu/h3T2RE/wqoXq3cQd37c5fzTYjN5f zdL5myblXXuPGeehpmtYKrldzh2z1DQFz1lOCnqZ6kYS5hKGbBHuelZyN3REjv6wEhpE 7bjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990471; x=1786595271; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hn12mOQJOB5mPU3wEI1erJHotJcPt5CfZ+8JVKzkIOg=; b=G1j1z6akMHOtbcQFul7hU0yd+7IfQqXorVakAhRpHteBJzrAk6E5CzLPlMmlGjATHn 2qPgKlUSVlwq1QrvMH1qRgXrZFjaR27aPU3vcQmLbg5TSVBfSHBPeu2eiMfYImDNNIWM OH82tG/czzhsHpC8MtpWskK7LMoiJ3Lb9qCuKJyYOdyEsL5JuSPm+N84u4Mk21SYds34 NI/SdePyKYzvGKH+H1dO0fjxQWA9DRY4eselEr9zFltopTK8reQZDpJMCpoFhq1nkAGu ndSqdnvBwSLmpDvpj/tgcw1Z53N35pngvmdwgswlmp9qA8nQ9SVFOjDVUjHehGpCY/Zv HRPg== X-Gm-Message-State: AOJu0Yxtm5KDMUCVeuyEzvz0cvFrgmJuaQQ/afrj9HvDNzbMaZ82rKGG njGOkGnc5W9c5vkYuugxYs2pRSC/mhk283hf14EOfpT/WGPUAfhdNqMh6t000bB1JKwrnG2lC5O WeEEXnNXkItR6DNAwBRyNxSHFv7rJLg53QeXCiiAP/nNeabsSDeR0G7++MemzB3z2VA== X-Gm-Gg: AR+sD11hZ261iiZM1XGcAxNg0rtXnf+JXp6ZXA7/w+XzgZkVQQFN5RhOWECSsnZpHGk FhC/RIfOba+72Equ9n1RSPnstfhVpmr3HDeJa16Jv6ekjqRzCV+f3c9P9dG0FC/BUyZa68HZC6o 5AXCNFGBjLUUAbtamBHaqSj7HS7EzD9oFU0fe0O59OtSHAKdlw8lE5sugL9EAduNCoxkfRNmbya 1aPMv8xiGO7+cvAHpSk7RMtkiGbjSwn8WLjE1OYGK8KdEXabgV1l99zmSumOAAPnkeRQEQM+8+P ehoeOQOm1UtM4J7sPMJA96/6qNlT8xGunnv3a0G1K7AybpkFZqAs8wpOfyaBUQaa5jf++kCohcx B3dj1hp5RE73FdejZo9qf0DdCtGN8aM1MZa5McTez9RhrQHTs X-Received: by 2002:a05:6a21:6112:b0:3c3:bb13:438 with SMTP id adf61e73a8af0-3cb85f50b14mr14585135637.32.1785990471338; Wed, 05 Aug 2026 21:27:51 -0700 (PDT) X-Received: by 2002:a05:6a21:6112:b0:3c3:bb13:438 with SMTP id adf61e73a8af0-3cb85f50b14mr14585102637.32.1785990470845; Wed, 05 Aug 2026 21:27:50 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 17/18] tests/qtest: add qct-qtimer qtest Date: Wed, 5 Aug 2026 21:27:22 -0700 Message-Id: <20260806042723.3785369-18-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: h1Am1oBh61ewOTG6sisP3T1WbOoaDA70 X-Proofpoint-ORIG-GUID: h1Am1oBh61ewOTG6sisP3T1WbOoaDA70 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXyihGx4lsTTly AQpqRQn2v8KX7x3yjB6TCRxQ0sx5MWZIvdv3lzBXwnu1PvsoAA9Ubfc3IPYTcUBw/+/8AXBu6UJ RghHvPPeX25c3qza+nczB7bzNBJvyEo= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX9nF0zcbma+9G iTDH3WLUJXmP6CKwf+TrdQ+xPecv+Dk1N59g5GlbWzKmVxDaCCbFp6Fno91lj+zcUdYGndnhFva wa0J7TpBjJL0OQLWW+k74yJ5qpvMjW88K/G1Xj9TW/76l5yvka6xB+0BZXeyrnt00/VcEpw8Tuq AYnjiKRqhfJfRvNFreH3QaBPGn9X9kibzPdWDK+sZkhaaqx9OREBCyRQtORnOeTH8CzRkXvg0+h m7jEQ/w/U4Q5xkrDnx7JjBtYq4aQHcyh2oMjl3JLI1mdRJCEFpbxAuO8q5rn2WPyqP0upibiNtN 4U2j7BqQtneplK9f0L3+qCaVX9QXMWKdxLuQhATkDymW5ptYrUYx8eWMDK+1iZmGP/xbgb3PH9M 2nVwtaq6TRAAvldcxiKwbV0//IeELsqGBnMoR+7bNnC3Lhz2T3cgdLA/VPdS90utlCBIEd8Os/3 TYYJMy7aF9buInUPOCQ== X-Authority-Analysis: v=2.4 cv=d4bFDxjE c=1 sm=1 tr=0 ts=6a740d48 cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=KGlPgTmvZxXK_lQfuAQA:9 a=QEXdDO2ut3YA:10 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 suspectscore=0 clxscore=1015 impostorscore=0 adultscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990558381158500 Add a qtest exercising the QCT QTimer's register access, view-region frame addressing, and one-shot timer firing behavior. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- MAINTAINERS | 1 + tests/qtest/qct-qtimer-test.c | 385 ++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 3 files changed, 387 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/qct-qtimer-test.c diff --git a/MAINTAINERS b/MAINTAINERS index ae623a7e924..c02bb2749e2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -255,6 +255,7 @@ F: include/hw/intc/hex-l2vic.h F: tests/qtest/l2vic-test.c F: hw/timer/qct-qtimer.c F: include/hw/timer/qct-qtimer.h +F: tests/qtest/qct-qtimer-test.c X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/ diff --git a/tests/qtest/qct-qtimer-test.c b/tests/qtest/qct-qtimer-test.c new file mode 100644 index 00000000000..fd8bb0af776 --- /dev/null +++ b/tests/qtest/qct-qtimer-test.c @@ -0,0 +1,385 @@ +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + * + * QTest testcase for the QCT QTimer + */ + +#include "qemu/osdep.h" +#include "libqtest-single.h" +#include "hw/hexagon/hexagon.h" +#include "qemu/bitops.h" + +#include "hw/hexagon/machine_cfg_v68n_1024.h.inc" +#include "hw/hexagon/machine_cfg_v66g_1024.h.inc" + +#define QTIMER_DEFAULT_FREQ_HZ 19200000ULL + +#define QCT_QTIMER_CNTPCT_LO (0x000) +#define QCT_QTIMER_CNTPCT_HI (0x004) +#define QCT_QTIMER_CNT_FREQ (0x010) +#define QCT_QTIMER_CNTP_CVAL_LO (0x020) +#define QCT_QTIMER_CNTP_TVAL (0x028) +#define QCT_QTIMER_CNTP_CTL (0x02c) +#define QCT_QTIMER_CNTP_CTL_ENABLE (1 << 0) + +#define QTIMER_FRAME_STRIDE 0x1000 +/* Frames instantiated by hex-subsys, and the L2VIC input frame 0 drives. = */ +#define QTIMER_NR_FRAMES 3 +#define QTIMER_L2VIC_IRQ_BASE 2 + +#define QCT_QTIMER_AC_CNTFRQ (0x000) +#define QCT_QTIMER_AC_CNTSR (0x004) +#define QCT_QTIMER_AC_CNTTID_0 (0x08) +#define QCT_QTIMER_AC_CNTACR_START (0x40) +#define QCT_QTIMER_AC_CNTACR_ALL (0x3f) +#define QCT_QTIMER_AC_CNTACR_RWPT (1 << 5) /* R/W of CNTP_* regs */ +#define QCT_QTIMER_AC_CNTACR_RFRQ (1 << 2) /* R/W of CNTFRQ register */ +#define QCT_QTIMER_AC_CNTACR_RPCT (1 << 0) /* R/W of CNTPCT register */ + +static uint64_t qtimer_view_base; +static uint64_t qtimer_ac_base; + +#define TIMER_TEST_OFFSET 1000 +/* TIMER_TEST_OFFSET ticks expressed in nanoseconds of QEMU_CLOCK_VIRTUAL = */ +#define TIMER_TEST_NS \ + ((TIMER_TEST_OFFSET * 1000000000ULL) / QTIMER_DEFAULT_FREQ_HZ) + +static uint32_t qtimer_read32(uint64_t base, uint32_t offset) +{ + return readl(base + offset); +} + +static void qtimer_write32(uint64_t base, uint32_t offset, uint32_t value) +{ + writel(base + offset, value); +} + +static uint64_t qtimer_read64(uint64_t base, uint32_t offset) +{ + uint32_t lo =3D qtimer_read32(base, offset); + uint32_t hi =3D qtimer_read32(base, offset + 4); + + return ((uint64_t)hi << 32) | lo; +} + +static void qtimer_write64(uint64_t base, uint32_t offset, uint64_t value) +{ + qtimer_write32(base, offset, extract64(value, 0, 32)); + qtimer_write32(base, offset + 4, extract64(value, 32, 32)); +} + +static void test_qtimer_basic_access(void) +{ + uint32_t val; + + val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNT_FREQ); + g_assert_cmpuint(val, =3D=3D, QTIMER_DEFAULT_FREQ_HZ); +} + +static void test_qtimer_multiple_frames(void) +{ + uint32_t val; + uint64_t frame0_base =3D qtimer_view_base; + uint64_t frame1_base =3D qtimer_view_base + 0x1000; + + val =3D qtimer_read32(frame0_base, QCT_QTIMER_CNT_FREQ); + g_assert_cmpuint(val, =3D=3D, QTIMER_DEFAULT_FREQ_HZ); + + val =3D qtimer_read32(frame1_base, QCT_QTIMER_CNT_FREQ); + g_assert_cmpuint(val, =3D=3D, QTIMER_DEFAULT_FREQ_HZ); +} + +static void test_qtimer_register_reads(void) +{ + qtimer_read32(qtimer_view_base, QCT_QTIMER_CNT_FREQ); + qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO); + qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO); + qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTP_CTL); + qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTP_TVAL); +} + +static void test_qtimer_control_registers(void) +{ + uint32_t ctl_val; + uint64_t cval_before, cval_after; + + cval_before =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO); + + qtimer_write32(qtimer_view_base, QCT_QTIMER_CNTP_TVAL, 1000); + + qtimer_write32(qtimer_view_base, QCT_QTIMER_CNTP_CTL, 1); + ctl_val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTP_CTL); + g_assert_cmpuint(ctl_val & 1, =3D=3D, 1); + + /* CVAL should be greater than before since we set TVAL */ + cval_after =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO= ); + g_assert_cmpuint(cval_after, >, cval_before); + + qtimer_write32(qtimer_view_base, QCT_QTIMER_CNTP_CTL, 0); + ctl_val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTP_CTL); + g_assert_cmpuint(ctl_val & 1, =3D=3D, 0); +} + +static void test_qtimer_cval_access(void) +{ + uint64_t current_time, test_cval, read_cval; + + current_time =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO); + test_cval =3D current_time + 10000; + + qtimer_write64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO, test_cval); + read_cval =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO); + g_assert_cmpuint(read_cval, =3D=3D, test_cval); +} + +static void test_qtimer_counter_progression(void) +{ + uint32_t freq; + uint64_t count1, count2; + + /* + * In qtest mode the virtual clock does not advance on its own, so + * reading the counter twice must give the same value. + */ + count1 =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO); + count2 =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO); + g_assert_cmpuint(count2, =3D=3D, count1); + + freq =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNT_FREQ); + g_assert_cmpuint(freq, =3D=3D, QTIMER_DEFAULT_FREQ_HZ); +} + +static void test_qtimer_timer_behavior(void) +{ + uint64_t current_count, target_count, read_cval, new_count; + uint64_t ctl_val, count_after_disable; + + current_count =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO= ); + + target_count =3D current_count + TIMER_TEST_OFFSET; + qtimer_write64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO, target_count= ); + + read_cval =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO); + g_assert_cmpuint(read_cval, =3D=3D, target_count); + + qtimer_write32(qtimer_view_base, QCT_QTIMER_CNTP_CTL, 1); + + ctl_val =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CTL); + /* EN set, IMASK clear, ISTAT not yet pending */ + g_assert_cmpuint(ctl_val, =3D=3D, 0x1); + + /* Step forward but not past the target */ + qtest_clock_step(global_qtest, TIMER_TEST_NS / 2); + new_count =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO); + g_assert_cmpuint(new_count, >=3D, current_count); + + /* Step past the target */ + qtest_clock_step(global_qtest, TIMER_TEST_NS); + new_count =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO); + g_assert_cmpuint(new_count, >=3D, target_count); + + qtimer_write32(qtimer_view_base, QCT_QTIMER_CNTP_CTL, 0); + + ctl_val =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CTL); + /* EN cleared, ISTAT set since new_count >=3D target_count */ + g_assert_cmpuint(ctl_val, =3D=3D, 0x4); + + /* + * CNTPCT runs independently of CNTP_CTL.EN: only the compare/IRQ + * logic is gated by EN, so the counter must keep advancing. + */ + qtest_clock_step(global_qtest, TIMER_TEST_NS / 2); + count_after_disable =3D qtimer_read64(qtimer_view_base, + QCT_QTIMER_CNTPCT_LO); + g_assert_cmpuint(count_after_disable, >, new_count); + + /* ISTAT remains set while CNTPCT >=3D CVAL, even with EN=3D0 */ + ctl_val =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CTL); + g_assert_cmpuint(ctl_val, =3D=3D, 0x4); +} + +/* Test the access-control region: CNTFRQ, CNTSR, CNTTID_0, CNTACR frame 0= */ +static void test_qtimer_ac_region(void) +{ + uint32_t freq, sr, tid0, acr0; + + freq =3D qtimer_read32(qtimer_ac_base, QCT_QTIMER_AC_CNTFRQ); + g_assert_cmpuint(freq, =3D=3D, QTIMER_DEFAULT_FREQ_HZ); + + /* A write of 0 to CNTFRQ must be ignored (freq-hz must stay nonzero).= */ + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTFRQ, 0); + freq =3D qtimer_read32(qtimer_ac_base, QCT_QTIMER_AC_CNTFRQ); + g_assert_cmpuint(freq, =3D=3D, QTIMER_DEFAULT_FREQ_HZ); + + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTSR, 0x3); + sr =3D qtimer_read32(qtimer_ac_base, QCT_QTIMER_AC_CNTSR); + g_assert_cmpuint(sr, =3D=3D, 0x3); + + tid0 =3D qtimer_read32(qtimer_ac_base, QCT_QTIMER_AC_CNTTID_0); + g_assert_cmpuint(tid0, =3D=3D, 0x111); + + /* CNTACR for frame 0 defaults to full read/write permissions. */ + acr0 =3D qtimer_read32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START); + g_assert_cmpuint(acr0, !=3D, 0); + + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START, 0); + acr0 =3D qtimer_read32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START); + g_assert_cmpuint(acr0, =3D=3D, 0); + + /* Restore full permissions so later view-region tests keep working. */ + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START, + QCT_QTIMER_AC_CNTACR_ALL); +} + +static void test_qtimer_access_denied(void) +{ + uint32_t acr_all =3D QCT_QTIMER_AC_CNTACR_ALL; + uint64_t cval, saved_cval; + uint32_t val; + + /* Park CVAL at a known nonzero value while access is still permitted.= */ + saved_cval =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTPCT_LO) += 10000; + qtimer_write64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO, saved_cval); + g_assert_cmpuint(qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_= LO), + =3D=3D, saved_cval); + + /* Clearing RFRQ denies CNTFRQ reads. */ + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START, + acr_all & ~QCT_QTIMER_AC_CNTACR_RFRQ); + val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNT_FREQ); + g_assert_cmpuint(val, =3D=3D, 0); + + /* Clearing RPCT denies CNTPCT reads, both halves. */ + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START, + acr_all & ~QCT_QTIMER_AC_CNTACR_RPCT); + val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTPCT_LO); + g_assert_cmpuint(val, =3D=3D, 0); + val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTPCT_HI); + g_assert_cmpuint(val, =3D=3D, 0); + + /* + * Clearing RWPT denies the whole CNTP_* set: CVAL/TVAL/CTL reads all + * read back 0 even though CVAL holds saved_cval. + */ + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START, + acr_all & ~QCT_QTIMER_AC_CNTACR_RWPT); + cval =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO); + g_assert_cmpuint(cval, =3D=3D, 0); + val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTP_TVAL); + g_assert_cmpuint(val, =3D=3D, 0); + val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTP_CTL); + g_assert_cmpuint(val, =3D=3D, 0); + + /* Denied writes must be dropped rather than applied. */ + qtimer_write64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO, 0x1234); + qtimer_write32(qtimer_view_base, QCT_QTIMER_CNTP_TVAL, 0x5678); + qtimer_write32(qtimer_view_base, QCT_QTIMER_CNTP_CTL, 1); + + /* Restoring RWPT reveals that CVAL still holds the pre-denial value. = */ + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START, acr_all); + cval =3D qtimer_read64(qtimer_view_base, QCT_QTIMER_CNTP_CVAL_LO); + g_assert_cmpuint(cval, =3D=3D, saved_cval); + val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNTP_CTL); + g_assert_cmpuint(val & 1, =3D=3D, 0); + + /* CNTFRQ and CNTPCT work again once permissions are back. */ + val =3D qtimer_read32(qtimer_view_base, QCT_QTIMER_CNT_FREQ); + g_assert_cmpuint(val, =3D=3D, QTIMER_DEFAULT_FREQ_HZ); + + /* + * An unimplemented offset in the view region is also an access error, + * and reads back as 0. + */ + val =3D qtimer_read32(qtimer_view_base, 0x100); + g_assert_cmpuint(val, =3D=3D, 0); + + /* Leave the frame with full permissions for any later test. */ + qtimer_write32(qtimer_ac_base, QCT_QTIMER_AC_CNTACR_START, acr_all); +} + +static void test_qtimer_frame_irq_routing(void) +{ + unsigned int frame, other; + uint64_t frame_base; + + qtest_irq_intercept_in(global_qtest, "/machine/l2vic"); + + for (frame =3D 0; frame < QTIMER_NR_FRAMES; frame++) { + frame_base =3D qtimer_view_base + frame * QTIMER_FRAME_STRIDE; + + qtimer_write32(frame_base, QCT_QTIMER_CNTP_TVAL, TIMER_TEST_OFFSET= ); + qtimer_write32(frame_base, QCT_QTIMER_CNTP_CTL, + QCT_QTIMER_CNTP_CTL_ENABLE); + g_assert_false(qtest_get_irq(global_qtest, + QTIMER_L2VIC_IRQ_BASE + frame)); + + /* Step past the deadline so the frame raises its interrupt. */ + qtest_clock_step(global_qtest, TIMER_TEST_NS * 2); + g_assert_true(qtest_get_irq(global_qtest, + QTIMER_L2VIC_IRQ_BASE + frame)); + + /* No other frame's line may be disturbed. */ + for (other =3D 0; other < QTIMER_NR_FRAMES; other++) { + if (other !=3D frame) { + g_assert_false(qtest_get_irq(global_qtest, + QTIMER_L2VIC_IRQ_BASE + other= )); + } + } + + /* Clearing EN drops the interrupt, leaving a clean slate. */ + qtimer_write32(frame_base, QCT_QTIMER_CNTP_CTL, 0); + g_assert_false(qtest_get_irq(global_qtest, + QTIMER_L2VIC_IRQ_BASE + frame)); + } +} + +typedef struct { + const char *machine; + const struct hexagon_machine_config *cfg; +} QtimerMachineCfg; + +static const QtimerMachineCfg qtimer_machines[] =3D { + { "virt", &v68n_1024 }, + { "V66G_1024", &v66g_1024 }, +}; + +static void test_qtimer_on_machine(gconstpointer data) +{ + const QtimerMachineCfg *mc =3D data; + g_autofree char *args =3D g_strdup_printf( + "-machine %s -global qct-qtimer.freq-scale=3D1", mc->machine); + + qtimer_view_base =3D mc->cfg->qtmr_region; + qtimer_ac_base =3D mc->cfg->csr_base; + + qtest_start(args); + + test_qtimer_basic_access(); + test_qtimer_multiple_frames(); + test_qtimer_register_reads(); + test_qtimer_control_registers(); + test_qtimer_cval_access(); + test_qtimer_counter_progression(); + test_qtimer_timer_behavior(); + test_qtimer_ac_region(); + test_qtimer_access_denied(); + test_qtimer_frame_irq_routing(); + + qtest_end(); +} + +int main(int argc, char **argv) +{ + size_t i; + + g_test_init(&argc, &argv, NULL); + + for (i =3D 0; i < ARRAY_SIZE(qtimer_machines); i++) { + g_autofree char *path =3D g_strdup_printf("/qct-qtimer/%s/all-test= s", + qtimer_machines[i].machine= ); + qtest_add_data_func(path, &qtimer_machines[i], test_qtimer_on_mach= ine); + } + + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index a76863c7dd6..651246b2ebb 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -299,7 +299,7 @@ qtests_riscv64 =3D ['riscv-csr-test'] + \ ['iommu-riscv-test'] : []) + \ (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) =20 -qtests_hexagon =3D ['boot-serial-test', 'l2vic-test'] +qtests_hexagon =3D ['boot-serial-test', 'l2vic-test', 'qct-qtimer-test'] =20 qos_test_ss =3D ss.source_set() qos_test_ss.add( --=20 2.34.1 From nobody Mon Sep 28 01:13:32 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1785990571; cv=none; d=zohomail.com; s=zohoarc; b=BKp+utjutHDYyFi+oOD+EBk/QinNRdQvSQptt9Yo5tSxG+1+TqxuwEhE5VGyCWYCwkq2PFfLHq1rS6FNW/+JKQtUKZH0dzgNNSc9Ohpmgw8w041hwvbpFmK5U+ptkqV5+EghENVTC1gvePDb+XULMF0oakGGvvL7e+roYXX8oZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785990571; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YWVviQ+H5wY7Zn6hT9cA60EmloSaszs1xldCcfSlZw0=; b=QCjC/Sb0SC/EWryxKimufeJ4LdMQhFIKPIvkbiUWrXFmHNomw74KB97kRqtd4THuW4b1VJSV2IBe3pAEdGK4Fav66aaNduFcwYIKA/9pyOubbTqvtE8ah70VbWYSbacUTGgvv50rV1CTbTTjc/+yZTO/0r6WntVB/lFe44CIJwE= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785990571824120.87393405459011; Wed, 5 Aug 2026 21:29:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrpi4-0002xS-99; Thu, 06 Aug 2026 00:28:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrpi0-0002we-AD for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:56 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrphy-0003F9-EF for qemu-devel@nongnu.org; Thu, 06 Aug 2026 00:27:56 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 675NcIHJ269752 for ; Thu, 6 Aug 2026 04:27:53 GMT Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fv3w6c1k8-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 06 Aug 2026 04:27:53 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-ca7c1e22995so2581853a12.3 for ; Wed, 05 Aug 2026 21:27:53 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fca926c0bsm19572628c88.14.2026.08.05.21.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 21:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= YWVviQ+H5wY7Zn6hT9cA60EmloSaszs1xldCcfSlZw0=; b=kTmvLUiIEvjaFcna wyFmAU1J6woFKaWZtduWmVwGYGgQvay5Uxa4ShGRJI9bnXekQsrXavHWbKzwrUTb Fky4Jhaa8CEbx8H3Ik4NSayIScRGmMaLNDGvb2lECaFd2WqcBczaPLSkDswVLkzy rPLTFcYmpugz90PCT2sZcPwrV/ZjtPTe/KPO/3IPu9z9YtS69GmBca3rZ6C5HlZ7 RJFfLA3kwyf5n8SjA1DKrcO7E7x/OaTGzOL+0UNg0mY7GCEMJW/spWPmgxqvS15P SgfCkbJTPWsmDJoeXpwXcjT73BriXUpWVGFNOYclAAptuPavYh00cN6re83HW3O4 Mf8Rxw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785990472; x=1786595272; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=YWVviQ+H5wY7Zn6hT9cA60EmloSaszs1xldCcfSlZw0=; b=dhroDQvUyB6xfVGrtPdQLFHRAlUeC5VfHCIMJaYHz3ZvTI0HHzDeKnRz4zpjkbrmX+ g+4KGip4rioynxFu/zlqHxudfWMIGtzqgZIyaEevm0h4UuT6BlMgMV4b2pfUHYhoZO3a fiG7HTJ+OtVqY5YXAcVUz6qSqNMvqBPk0lNd5xcK1FBF2i+lebHZ2kPvD/To19O2Oq/S enzHmGDxI5lPfbFjMh2rYym44Km/wcJxhpCYLKPDiEA6PtX+d4w0kcHBn7Tp9714/ApL Mde2SmraZMFZC9pi8uGeUDbUQvvVzN8/Q808tFPPBeVYxEyIu0SGQX2pS9ZmGsKNsdop bQXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785990472; x=1786595272; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YWVviQ+H5wY7Zn6hT9cA60EmloSaszs1xldCcfSlZw0=; b=M1pzT82a8uF3YS3RiwgaHku7L7IXQf1owvzkZu6Glirs/mNaqKIYnXKX1h6nFexhjW TAm3kl/alxNCUHUaLhUSGRgSxOopbGFjJhOJNMvqxV6K8nh5maAXhE4BSsx9a408Leh8 9wZ0SxZiZd3BB+yaS2RoZSacUPxtKaPwxKEEZbcS2jY22S9GUL+GrPhk9rCKpDRL4wxB J6NwOxSHJA1l9haDGHPgHEuVH6ln1ONwEd5ib345I38Appz4f338gGA3bycdu/wg/1CU Rjbt5zgwXbWEPq7+M4ZWGcnPlKwZVnFlJRyWSezhefasY+nhmCcLKndCFi6i0Bh5Pji4 llIg== X-Gm-Message-State: AOJu0YyF+lv9TerfzNGs7DNvWwoiy3u4vtvzZxOCbqJJ11yJ2w5yKRoX r68ZGyir9cAy1O2dFiyfdbH/cNoc6hnVxKS2Wlb1IkidB/LntwABHpPewpIU5ibUJChSOgOJVMR tZrl81ZyX59I0CYBggjtZa7jvZMNJeFCtyptFrCMPBqF17eMicLq4FZtEcW/dETPWgw== X-Gm-Gg: AR+sD10SoNApFW/v78JFyZ+l12EFX7uqIin4ASVBkjfiopfxSedYcCy7sz9N+Ev9zPv bUPLJoy7VLlV4VaLGChZyg1OeJG0qfy/kWg2dZ8RbUPkWW8agjmuJKRD8T4ahnoTE1+0MXabJGB ZuQ6tsMPxfKy532VMejl66Z9+dseBGT7IXEoZdjBLqWCvoxv+szlSqhL6Ze/4gOQZeKB4wR0JhC HQNlgwUprAyJb9q984eDWUtYuGqWzbEKRl9cvxvgls8FVNp4KErGcWgPiRmeRfa2N7E67aFsrF1 QvAkowcj2BXFESWpCTZTudRGFS6U0A9tuQNcc2rTHoT2HgutpB6RnyQUlvars4ta4mtjl0fryuZ UkjzhiePaUZSIG4Xg9ZYVqeL7NIoL5ToBojFBzGpC3g7URDF6 X-Received: by 2002:a05:6a21:32a6:b0:3c4:1916:9d46 with SMTP id adf61e73a8af0-3cb85eef9e1mr13352149637.27.1785990472562; Wed, 05 Aug 2026 21:27:52 -0700 (PDT) X-Received: by 2002:a05:6a21:32a6:b0:3c4:1916:9d46 with SMTP id adf61e73a8af0-3cb85eef9e1mr13352108637.27.1785990472145; Wed, 05 Aug 2026 21:27:52 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, Pierrick Bouvier , Brian Cain , matheus.bernardino@oss.qualcomm.com, Paolo Bonzini , Fabiano Rosas , Laurent Vivier Subject: [PATCH v5 18/18] tests/functional/hexagon: enable more arch_tests cases Date: Wed, 5 Aug 2026 21:27:23 -0700 Message-Id: <20260806042723.3785369-19-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> References: <20260806042723.3785369-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: gdcGfR4rr4JR7ItEsvrzzGuQ5f1cF7oF X-Proofpoint-ORIG-GUID: gdcGfR4rr4JR7ItEsvrzzGuQ5f1cF7oF X-Authority-Analysis: v=2.4 cv=a48AM0SF c=1 sm=1 tr=0 ts=6a740d49 cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=6_sklNI9eh_OQcpcNH0A:9 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfX5GaKLzoWaZ3N 0H3oU74apuJAmXgn+WgSmyV/icc7QYnG6A8yF/99J1XFA28rtFgLBvcY33q7LXUd+IbMLWVrOU9 4lc9/eKBh7DEF1LVCdGwAF0omvEMJk4= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA2MDAzMCBTYWx0ZWRfXyQKW42i97uo1 3DLxwNGrOPFLNgYQ7rdi1bF8VqH1NMSg7eRXfsfQQ7tl07qdHCShaE7XUS46LIlIHuTmYuPhVm2 TDsaI9L9ukW9GPlJqAXwQjTaEAR0u+SBChF0lR+jPDjs079YwCXtVjkFzV9GZF6QLuu94Dk7vCF SrrM8Shu1rIiiOCB1kY7DolfLhQu+u060IXfk9wYzJkOY8/6fM1rpQl1Z5YMt1IAzK3+dqp6qLQ lESGxr3B+vGAO2PvUnZ2MmLsgKi9qTM3PsqCaFz0w7dXFnxAldHgt3VSnJix68E4aN9aSMxQ83g PwurTTnrJ/Cxl/sG3g8qVraRzJAU3qVAloCsSdls4Jb4TVPBHV2w57y2m7FjNE5wSkW+lzB0Xk7 ZY6AoWfRZyEqzbsomTfhkHmQCmEjqVVvoJT6sCdjbMnCrfgJklYyti0ajOpixWPDzStUZJCYlZE 3d4+fsWdV1zxaQPeObQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-05_06,2026-08-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608060030 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1785990572425158500 Add more tests from hexagon-arch-tests, enabled by QTimer device. These exercise cache maintenance ops, l2vic, thread start/stop, tlb/mmu operations, and user-mode transitions. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- tests/functional/hexagon/test_arch_tests.py | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/functional/hexagon/test_arch_tests.py b/tests/functional= /hexagon/test_arch_tests.py index 2bb34f9b8dc..0834398c3b1 100755 --- a/tests/functional/hexagon/test_arch_tests.py +++ b/tests/functional/hexagon/test_arch_tests.py @@ -58,6 +58,38 @@ def test_int_steering(self) -> None: """ self.run_uart_test("test_int_steering") =20 + def test_cache(self) -> None: + """Tests cache operations: dckill/ickill, l2kill, dczeroa, + dccleaninva, cache disable/enable, barriers, and dcinva/dccleana. + """ + self.run_uart_test("test_cache") + + def test_l2vic(self) -> None: + """Tests the L2VIC interrupt controller: enable readback, + interrupt type readback, VID capture, and the fast interface. + """ + self.run_uart_test("test_l2vic") + + def test_threads(self) -> None: + """Tests hardware thread management: start/stop, MODECTL state, + per-thread HTID, shared memory, wait/resume, STID priority, and + SCHEDCFG/BESTWAIT readback. + """ + self.run_uart_test("test_threads") + + def test_tlb_mmu(self) -> None: + """Tests TLB/MMU operations: write/read/probe/invalidate, + global entries, multiple entries, overwrite, ASID matching, + and permission checks. + """ + self.run_uart_test("test_tlb_mmu") + + def test_user_mode(self) -> None: + """Tests user mode / privilege transitions: supervisor mode, + SSR UM/IE/XE/CE/PE bits, and the trap0 user-mode exit handler. + """ + self.run_uart_test("test_user_mode") + =20 if __name__ =3D=3D "__main__": QemuSystemTest.main() --=20 2.34.1