Received: by 2002:a17:906:cf90:b0:9bd:85f7:2662 with SMTP id um16csp1154482ejb; Fri, 20 Oct 2023 04:43:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBbmZNyV0gqN9gdMT0//kBBkjxxwNqKKcjdaCcob7lCjPCJ8EScqVCDYcT2bdu31jjnj56 X-Received: by 2002:a05:620a:258d:b0:773:b036:d1a8 with SMTP id x13-20020a05620a258d00b00773b036d1a8mr1370295qko.66.1697802197265; Fri, 20 Oct 2023 04:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697802197; cv=none; d=google.com; s=arc-20160816; b=ShNqZwOpXQOfiQ1ThOKdxJHIb98dopUWNcW+xjVXqV2GPlxpe37cgktJalM4Yd4w4U HpLj4kCqVtCLIqmRsBX3NeQp1b1T/tCJeL49ElzX6Fie0z3i987jOWZFZhTXU9/1rAGD GZ6lnJbGWMyBLlY/3lJfRyCuyDKDxjeB+lLToEJW/sCQRg8p0sxPEIKQEN5zvRIR9biX ucZ4uh2TGQ1N26JJWPKw7kBVnmZOCUPGXxn3s+vncJiQl7YW2QJwFTach2/7yDT+vzdX UV3OPWqhCtsWcU0q/Sf8f8rnOVEQ5vHm4GZvrq6ymdQJn8hb526dw9J1d9ZpWQlbrfZ6 H7+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=vwLmZe6zJ5LPi+kXFXd3xZJJC4A4KqZ++ETaQv2zWAo=; fh=BiPEO9ks27M8Z+yWO7KETmJfWBYIhIIw/fZ9iDn9zgY=; b=TQOc247MMD69qlccXzszHBv8WopXMU0zA5eiH6aB++oamnSfzC4gX3ERDgkJ3fDSIK 0WYqYPR7m21o3qdoyeIcQcRom8xZr6SGoHDGgi0YxkQND6ktCdS/iEPeySKwIsItoKOj cFAxV63v3zfH7i9d1pJbuy0T9iiq56PoojaFsgyvUExuc5ASk071t6QFoo0NjLjmc3d6 MpSIGx1ZxFa6JOtyBRcCUeT1qNqEGNzPn1skIzV6CiCHTnI9SrBqKzrVxn4b3pXDY5bK YmnR7MtD2fssgVjlK+tzDmE1AzXVWMPH22IX2lZ39hm616BEHj85vZtKRkvmc0gnv9pf IQrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=VJp2sHZ3; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id qp17-20020a05620a389100b0077893815e89si1058516qkn.541.2023.10.20.04.43.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2023 04:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=VJp2sHZ3; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtnuI-0000TC-11; Fri, 20 Oct 2023 07:43:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtnuA-0000S3-Dk for qemu-arm@nongnu.org; Fri, 20 Oct 2023 07:43:06 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtnu7-000405-AQ for qemu-arm@nongnu.org; Fri, 20 Oct 2023 07:43:01 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6bb4abb8100so656272b3a.2 for ; Fri, 20 Oct 2023 04:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697802176; x=1698406976; darn=nongnu.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vwLmZe6zJ5LPi+kXFXd3xZJJC4A4KqZ++ETaQv2zWAo=; b=VJp2sHZ3OUmAOXQHNpCvBYrepDnmi/2+rKcEc6NqxfOXrDFLrsEZRCzVNBfzviyi0d r5Pd0ON5THG0zYcB4AIRxD+01KgtlbrqhejBQic/hdbqpuFEHJ8BqeLHiQcVxMI6zP1C RAN5bfDn0kSoFkKhaqRQKyeumHUQ/1u94Q3dIOSrYzZoGhGJ0kscbM0W7w3dihFJTwuv 9w3ncHxbjyQSHn090jOCUYEFdiHjrYDmZIfOYIOcW/t0Xtlhh2Af/1sEZEbl9E8hdnIn xCIOLuZxyKeptBwHt2E5ntm3LiDi1pxs0HaDLrPDDHhJFsrZk/wE9k1l+W08vbV8t/wt fHJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697802176; x=1698406976; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vwLmZe6zJ5LPi+kXFXd3xZJJC4A4KqZ++ETaQv2zWAo=; b=DUEzWwp5UhTS7cpviVbCrREdL6x+L8ymCkuQE6UZaIT8ffYyrALfm9V0DlP2hNIjW5 pox4KCjdT8SCcr4Hwdkw9te0GqMHAuLunhmiYwzAnQmOgWGmnP9w2pG2D/NgPceo8J7K 8hk75WfL9GLeB1AM3VCrpU+zIveqzCPeaxyMXyal5Ic+ljla5fGKegKaiMG7gBeCRm0i E4ZI58hhNCBysSfdHD+RYNbqryvegfbM6Y8OGNHZ2HO4bxwwOTQYlyWwgbBUBWIoXz3T b3rBBeuCa+Na69G/N3/+sF8St2I/6FG1QEpbLwMTkYqZrSSlBNwtS9in9rKw2+aoSErL zBDg== X-Gm-Message-State: AOJu0YwgaLMING1voW5SRUIVrawhfDucT+YsGMWk2TQBxQ3FUJoDUVKp fEUPxjST01KJoVTH5C14XjHYIA== X-Received: by 2002:a05:6a20:a89e:b0:159:b7ba:74bd with SMTP id ca30-20020a056a20a89e00b00159b7ba74bdmr1269734pzb.50.1697802176597; Fri, 20 Oct 2023 04:42:56 -0700 (PDT) Received: from ?IPV6:2804:7f0:bdcd:fb00:6501:2693:db52:c621? ([2804:7f0:bdcd:fb00:6501:2693:db52:c621]) by smtp.gmail.com with ESMTPSA id bs1-20020a632801000000b005b0b7ede830sm1280633pgb.50.2023.10.20.04.42.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Oct 2023 04:42:56 -0700 (PDT) Message-ID: <3416aeba-35d6-4d8d-8306-7250a6905431@ventanamicro.com> Date: Fri, 20 Oct 2023 08:42:49 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 02/12] hw/arm/virt-acpi-build.c: Migrate virtio creation to common location To: Sunil V L , qemu-riscv@nongnu.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Shannon Zhao , Peter Maydell , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Anup Patel , Andrew Jones , Atish Kumar Patra , Haibo Xu References: <20231019132648.23703-1-sunilvl@ventanamicro.com> <20231019132648.23703-3-sunilvl@ventanamicro.com> Content-Language: en-US From: Daniel Henrique Barboza In-Reply-To: <20231019132648.23703-3-sunilvl@ventanamicro.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@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-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: 1/it0MT6DDX3 Nit: this will give a whitespace error when applying: Applying: hw/arm/virt-acpi-build.c: Migrate virtio creation to common location .git/rebase-apply/patch:123: new blank line at EOF. + warning: 1 line adds whitespace errors. Thanks, Daniel On 10/19/23 10:26, Sunil V L wrote: > 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 > --- > hw/arm/virt-acpi-build.c | 29 ++--------------------------- > hw/virtio/meson.build | 1 + > hw/virtio/virtio-acpi.c | 28 ++++++++++++++++++++++++++++ > include/hw/virtio/virtio-acpi.h | 11 +++++++++++ > 4 files changed, 42 insertions(+), 27 deletions(-) > create mode 100644 hw/virtio/virtio-acpi.c > create mode 100644 include/hw/virtio/virtio-acpi.h > > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index b8e725d953..69733f6663 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" > > #define ARM_SPI_BASE 32 > > @@ -118,32 +119,6 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap) > aml_append(scope, dev); > } > > -static void acpi_dsdt_add_virtio(Aml *scope, > - const MemMapEntry *virtio_mmio_memmap, > - uint32_t mmio_irq, int num) > -{ > - hwaddr base = virtio_mmio_memmap->base; > - hwaddr size = virtio_mmio_memmap->size; > - int i; > - > - for (i = 0; i < num; i++) { > - uint32_t irq = mmio_irq + i; > - Aml *dev = 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 = 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 += size; > - } > -} > - > static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, > uint32_t irq, VirtMachineState *vms) > { > @@ -850,7 +825,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *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], > + virtio_acpi_dsdt_add(scope, &memmap[VIRT_MMIO], > (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS); > acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms); > if (vms->acpi_dev) { > diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build > index c0055a7832..9d62097a21 100644 > --- a/hw/virtio/meson.build > +++ b/hw/virtio/meson.build > @@ -79,3 +79,4 @@ system_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c')) > system_ss.add(files('virtio-hmp-cmds.c')) > > specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: specific_virtio_ss) > +system_ss.add(when: 'CONFIG_ACPI', if_true: files('virtio-acpi.c')) > diff --git a/hw/virtio/virtio-acpi.c b/hw/virtio/virtio-acpi.c > new file mode 100644 > index 0000000000..977499defd > --- /dev/null > +++ b/hw/virtio/virtio-acpi.c > @@ -0,0 +1,28 @@ > +#include "hw/virtio/virtio-acpi.h" > +#include "hw/acpi/aml-build.h" > + > +void virtio_acpi_dsdt_add(Aml *scope, > + const MemMapEntry *virtio_mmio_memmap, > + uint32_t mmio_irq, int num) > +{ > + hwaddr base = virtio_mmio_memmap->base; > + hwaddr size = virtio_mmio_memmap->size; > + int i; > + > + for (i = 0; i < num; i++) { > + uint32_t irq = mmio_irq + i; > + Aml *dev = 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 = 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 += size; > + } > +} > diff --git a/include/hw/virtio/virtio-acpi.h b/include/hw/virtio/virtio-acpi.h > new file mode 100644 > index 0000000000..b8687b1b42 > --- /dev/null > +++ b/include/hw/virtio/virtio-acpi.h > @@ -0,0 +1,11 @@ > +#ifndef VIRTIO_ACPI_H > +#define VIRTIO_ACPI_H > + > +#include "qemu/osdep.h" > +#include "exec/hwaddr.h" > + > +void virtio_acpi_dsdt_add(Aml *scope, const MemMapEntry *virtio_mmio_memmap, > + uint32_t mmio_irq, int num); > + > +#endif > +