From nobody Thu Nov 14 07:06:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1704877379; cv=none; d=zohomail.com; s=zohoarc; b=TPTx0OslBy2rjSbvvgwsROQwU8reNxEBc+q3yH1rWgViZO4l1s/2ZaHssZTTGLr6qvTXzLFDi10dTa752/D9+etq0GHvgTKDsmiHr+HFMKgE2mbE9khj5qPRoP0ezKbnkuzVFdyBUfPVikaQJqM/6hxZaFKXd6qlsXcHcHfbGFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704877379; h=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=lh94sJg/ngvqYPRH8ZJRctVdTHj1K6DW15CXMA3QDyg=; b=CbMA/V4+jOSg9NwNjJJL6DtmGRFe++ers0MVZDOoDqDK9oqbWu8dV7PVmYVTj4o5N9U9V88CtKJFM21vpYBG7emX4arzztQSnryRo9b2Dgl5JKWSEwInY3TwN3iK42oGEu2tEX64KkHClfbbRudAjnQoSeTj96G22bhMGffXMVY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704877379091331.30801064637126; Wed, 10 Jan 2024 01:02:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNUQ2-0001m1-91; Wed, 10 Jan 2024 03:58:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNUPy-0001cS-98 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 03:58:34 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNUPw-0003d1-Cz for qemu-devel@nongnu.org; Wed, 10 Jan 2024 03:58:34 -0500 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6d9ac5bd128so2416173b3a.0 for ; Wed, 10 Jan 2024 00:58:32 -0800 (PST) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id t65-20020a628144000000b006d9879ba6besm3223814pfd.170.2024.01.10.00.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 00:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704877111; x=1705481911; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lh94sJg/ngvqYPRH8ZJRctVdTHj1K6DW15CXMA3QDyg=; b=IXm6BsT/NycZn9282VDrwWAhpSP1Ef3D5/UMpSw60dBJIRfzvHp2tE4UPo3ohppPZV RNmIlbOx0mFjkzBdzQY4vOkUIgNG8a5thRQ8QBuT2ylmkN5F1qpWGreRNDAEKGZW0W79 3/Vj1rg0HuVUDhiN0hVCJEPjI3MmhDfwn/RezlhQpcXHpCscFdsr36vzcZhNbrE7OKMW ZqGuWhsKj5+cqVRHB0lvo1GNq09syA0Rltdv/C3tH5/vaMncyC7VNhwhTlBCPKlTdEj8 uSjkLoZo4pszmjX9SWTOiBLSVCyJcL56Ldwo+WLMbOUC11ll9dY70fQdUYJx7HvB/YAf IOnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704877111; x=1705481911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lh94sJg/ngvqYPRH8ZJRctVdTHj1K6DW15CXMA3QDyg=; b=g1FhewZARwPWm5uJALhlnnNvjoXvWPbrSW3mom2EEu42MiOyup3tkOkLs85Bz1MIdi 6ZKXt5M3cn2OsIlOViGX2/1c1lcQ1qr/iNw+tKYhhmp0UmxxPxIPR0SK67clno9FU+tU 9aHMD8QUEp3NQV8oMA+TfuzC7sAjTa65aBKU3Opr61/0fIGOwRwkV3/2yHG1kGDRTaZv Ka/e9efElWrsjWIIdI+FdPaSOptK7lxJA1xK23MAeTi7aPqkKgUksmgQ/dgmHOl3IXfg DCtEx5j4dHQu+vUo8S2PRcJLGdTXdSPXzWTWcsBkTWrWkzzZfBl9G1MVMtYt+CyqcRW9 gpBw== X-Gm-Message-State: AOJu0YzVKgzWLzS167GJrnifO2YPRvw8+GupKpvF35bGN2pEH3E8+Veg oXPrwh4KlFFYoL/LoZidBW+AeWqzGKp2UC7d X-Google-Smtp-Source: AGHT+IELhsn9Qkmi8OwlDOBKsBW2W1dspewEbOdeXoxKHZIu4ICHjgVUG3xwmkm02bNDBvvOZ2veRg== X-Received: by 2002:a05:6a00:17a9:b0:6db:35e7:1636 with SMTP id s41-20020a056a0017a900b006db35e71636mr72809pfg.49.1704877110731; Wed, 10 Jan 2024 00:58:30 -0800 (PST) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Sunil V L , Igor Mammedov , Alistair Francis , Andrew Jones , "Michael S . Tsirkin" Subject: [PULL 13/65] hw/arm/virt-acpi-build.c: Migrate virtio creation to common location Date: Wed, 10 Jan 2024 18:56:41 +1000 Message-ID: <20240110085733.1607526-14-alistair.francis@wdc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240110085733.1607526-1-alistair.francis@wdc.com> References: <20240110085733.1607526-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=alistair23@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1704877379559100001 Content-Type: text/plain; charset="utf-8" From: Sunil V L RISC-V also needs to create the virtio in DSDT in the same way as ARM. So, instead of duplicating the code, move this function to the device specific file which is common across architectures. Suggested-by: Igor Mammedov Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Acked-by: Michael S. Tsirkin Message-ID: <20231218150247.466427-3-sunilvl@ventanamicro.com> Signed-off-by: Alistair Francis --- include/hw/virtio/virtio-acpi.h | 16 ++++++++++++++++ hw/arm/virt-acpi-build.c | 32 ++++---------------------------- hw/virtio/virtio-acpi.c | 33 +++++++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 4 files changed, 54 insertions(+), 28 deletions(-) create mode 100644 include/hw/virtio/virtio-acpi.h create mode 100644 hw/virtio/virtio-acpi.c diff --git a/include/hw/virtio/virtio-acpi.h b/include/hw/virtio/virtio-acp= i.h new file mode 100644 index 0000000000..844e102569 --- /dev/null +++ b/include/hw/virtio/virtio-acpi.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * ACPI support for virtio + */ + +#ifndef VIRTIO_ACPI_H +#define VIRTIO_ACPI_H + +#include "qemu/osdep.h" +#include "exec/hwaddr.h" + +void virtio_acpi_dsdt_add(Aml *scope, const hwaddr virtio_mmio_base, + const hwaddr virtio_mmio_size, uint32_t mmio_irq, + long int start_index, int num); + +#endif diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index b6edf9db00..a22a2f43a5 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -58,6 +58,7 @@ #include "migration/vmstate.h" #include "hw/acpi/ghes.h" #include "hw/acpi/viot.h" +#include "hw/virtio/virtio-acpi.h" =20 #define ARM_SPI_BASE 32 =20 @@ -118,32 +119,6 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemM= apEntry *flash_memmap) aml_append(scope, dev); } =20 -static void acpi_dsdt_add_virtio(Aml *scope, - const MemMapEntry *virtio_mmio_memmap, - uint32_t mmio_irq, int num) -{ - hwaddr base =3D virtio_mmio_memmap->base; - hwaddr size =3D virtio_mmio_memmap->size; - int i; - - for (i =3D 0; i < num; i++) { - uint32_t irq =3D mmio_irq + i; - Aml *dev =3D aml_device("VR%02u", i); - aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005"))); - aml_append(dev, aml_name_decl("_UID", aml_int(i))); - aml_append(dev, aml_name_decl("_CCA", aml_int(1))); - - Aml *crs =3D aml_resource_template(); - aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE)); - aml_append(crs, - aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, - AML_EXCLUSIVE, &irq, 1)); - aml_append(dev, aml_name_decl("_CRS", crs)); - aml_append(scope, dev); - base +=3D size; - } -} - static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, uint32_t irq, VirtMachineState *vms) { @@ -850,8 +825,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]); } fw_cfg_acpi_dsdt_add(scope, &memmap[VIRT_FW_CFG]); - acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO], - (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPO= RTS); + virtio_acpi_dsdt_add(scope, memmap[VIRT_MMIO].base, memmap[VIRT_MMIO].= size, + (irqmap[VIRT_MMIO] + ARM_SPI_BASE), + 0, NUM_VIRTIO_TRANSPORTS); acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms= ); if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, diff --git a/hw/virtio/virtio-acpi.c b/hw/virtio/virtio-acpi.c new file mode 100644 index 0000000000..e18cb38bdb --- /dev/null +++ b/hw/virtio/virtio-acpi.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * virtio ACPI Support + * + */ + +#include "hw/virtio/virtio-acpi.h" +#include "hw/acpi/aml-build.h" + +void virtio_acpi_dsdt_add(Aml *scope, const hwaddr base, const hwaddr size, + uint32_t mmio_irq, long int start_index, int num) +{ + hwaddr virtio_base =3D base; + uint32_t irq =3D mmio_irq; + long int i; + + for (i =3D start_index; i < start_index + num; i++) { + Aml *dev =3D aml_device("VR%02u", (unsigned)i); + aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005"))); + aml_append(dev, aml_name_decl("_UID", aml_int(i))); + aml_append(dev, aml_name_decl("_CCA", aml_int(1))); + + Aml *crs =3D aml_resource_template(); + aml_append(crs, aml_memory32_fixed(virtio_base, size, AML_READ_WRI= TE)); + aml_append(crs, + aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, &irq, 1)); + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); + virtio_base +=3D size; + irq++; + } +} diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index c8c1001451..47baf00366 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -77,3 +77,4 @@ system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vir= tio-stub.c')) system_ss.add(files('virtio-hmp-cmds.c')) =20 specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: specific_virtio_ss) +system_ss.add(when: 'CONFIG_ACPI', if_true: files('virtio-acpi.c')) --=20 2.43.0