From nobody Sat Nov 15 22:33:51 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747242440; cv=none; d=zohomail.com; s=zohoarc; b=SgyLbavh39Dh17y/cbxgtx1cCBeatpvolNLrD+nPG6Y5mBzSFU014kdFVra5P0yOK8skXmfEQJZQVvYyTfXUM6AruXr2706gvlM+tjbTKMcUvAx5qwq7FCMuB9fVqjMxfKg2L1S8nfxxssjiW/9PcIgEs4bKaMW8gvYBikHR5wg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747242440; 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=q83CkXF8NEiBj3QV+2hl2ecjW+MQWvpfAJhE5AVyMh4=; b=bLvqc4Zu8tQ3uRdWsg5st/RhtU8jydwK64cAokKTbV+WAc0DQRv3Twqp2RRbHt5JUW+3v2KGHg6LsQm27Z4OWLG328rcWNbKnmSFGDstd+YWn59esulxxebBx6b1UB32iP3oNIYo1OHN3IgiKXqkM20fVUXGKw8+5RUMkRCulug= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747242440841806.0538741029662; Wed, 14 May 2025 10:07:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFFZ6-0003yR-2c; Wed, 14 May 2025 13:06:44 -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 1uFFYr-0003Le-4B for qemu-devel@nongnu.org; Wed, 14 May 2025 13:06:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFFYp-0007t4-4E for qemu-devel@nongnu.org; Wed, 14 May 2025 13:06:28 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-2-k9-PRzm1MjCITfZ5d5l8kA-1; Wed, 14 May 2025 13:06:22 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D2C471800876; Wed, 14 May 2025 17:06:20 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.14]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 85D1D30001B1; Wed, 14 May 2025 17:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747242386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q83CkXF8NEiBj3QV+2hl2ecjW+MQWvpfAJhE5AVyMh4=; b=Bhl6jtG0tvouPKxGwBh3vgGhsawfQaVwG9o+7Bfy6Z+PW9nG636MXxvCu4R1DrYHVIPPSM QA3J5wR2kozfUwc1EURGywDgNsYJOw8iK5AXa8u+87+C+dlLMEZ8IXlES9ebSmnLAdNZbU BGn0TGSzVqHudgGtZFEbalhLu8YzOnc= X-MC-Unique: k9-PRzm1MjCITfZ5d5l8kA-1 X-Mimecast-MFC-AGG-ID: k9-PRzm1MjCITfZ5d5l8kA_1747242380 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, imammedo@redhat.com, anisinha@redhat.com, mst@redhat.com, shannon.zhaosl@gmail.com Cc: pbonzini@redhat.com, Jonathan.Cameron@huawei.com, philmd@linaro.org Subject: [PATCH 20/22] hw/arm/virt: Let virt support pci hotplug/unplug GED event Date: Wed, 14 May 2025 19:01:07 +0200 Message-ID: <20250514170431.2786231-21-eric.auger@redhat.com> In-Reply-To: <20250514170431.2786231-1-eric.auger@redhat.com> References: <20250514170431.2786231-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 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 @redhat.com) X-ZM-MESSAGEID: 1747242442510019000 Content-Type: text/plain; charset="utf-8" Set up the IO registers used to communicate between QEMU and ACPI. Move the create_pcie() call after the creation of the acpi ged device since hotplug callbacks will soon be called on gpex realize and will require the acpi pcihp state to be initialized. The hacky thing is the root bus has not yet been created on acpi_pcihp_init() call so it is set later after the gpex realize. How to fix this chicken & egg issue? Signed-off-by: Eric Auger --- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 42 +++++++++++++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 1b2e2e1284..a4c4e3a67a 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -35,6 +35,7 @@ #include "hw/boards.h" #include "hw/arm/boot.h" #include "hw/arm/bsa.h" +#include "hw/acpi/pcihp.h" #include "hw/block/flash.h" #include "system/kvm.h" #include "hw/intc/arm_gicv3_common.h" diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 2b642e2426..05a754d368 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -44,6 +44,7 @@ #include "hw/acpi/generic_event_device.h" #include "hw/acpi/tpm.h" #include "hw/acpi/hmat.h" +#include "hw/acpi/pcihp.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4aa40c8e8b..526c4c44be 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -682,6 +682,8 @@ static inline DeviceState *create_acpi_ged(VirtMachineS= tate *vms) { DeviceState *dev; MachineState *ms =3D MACHINE(vms); + SysBusDevice *sbdev; + int irq =3D vms->irqmap[VIRT_ACPI_GED]; uint32_t event =3D ACPI_GED_PWR_DOWN_EVT; =20 @@ -693,12 +695,28 @@ static inline DeviceState *create_acpi_ged(VirtMachin= eState *vms) event |=3D ACPI_GED_NVDIMM_HOTPLUG_EVT; } =20 + if (vms->acpi_pcihp) { + event |=3D ACPI_GED_PCI_HOTPLUG_EVT; + } + dev =3D qdev_new(TYPE_ACPI_GED); qdev_prop_set_uint32(dev, "ged-event", event); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sbdev =3D SYS_BUS_DEVICE(dev); + sysbus_realize_and_unref(sbdev, &error_fatal); =20 - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].bas= e); - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].= base); + sysbus_mmio_map(sbdev, 0, vms->memmap[VIRT_ACPI_GED].base); + sysbus_mmio_map(sbdev, 1, vms->memmap[VIRT_PCDIMM_ACPI].base); + if (vms->acpi_pcihp) { + AcpiGedState *acpi_ged_state =3D ACPI_GED(dev); + int i; + + i =3D sysbus_mmio_map_name(sbdev, "pcihp container", + vms->memmap[VIRT_ACPI_PCIHP].base); + assert(i >=3D 0); + acpi_pcihp_init(OBJECT(dev), &acpi_ged_state->pcihp_state, + vms->bus, sysbus_mmio_get_region(sbdev, i), 0); + acpi_ged_state->pcihp_state.use_acpi_hotplug_bridge =3D true; + } sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(vms->gic, = irq)); =20 return dev; @@ -1758,6 +1776,13 @@ void virt_machine_done(Notifier *notifier, void *dat= a) pci_bus_add_fw_cfg_extra_pci_roots(vms->fw_cfg, vms->bus, &error_abort); =20 + + if (vms->acpi_pcihp) { + AcpiGedState *acpi_ged_state =3D ACPI_GED(vms->acpi_dev); + + acpi_pcihp_reset(&acpi_ged_state->pcihp_state); + } + virt_acpi_setup(vms); virt_build_smbios(vms); } @@ -2395,8 +2420,6 @@ static void machvirt_init(MachineState *machine) =20 create_rtc(vms); =20 - create_pcie(vms); - if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)= ) { vms->acpi_pcihp &=3D !vmc->no_acpi_pcihp; vms->acpi_dev =3D create_acpi_ged(vms); @@ -2405,6 +2428,15 @@ static void machvirt_init(MachineState *machine) create_gpio_devices(vms, VIRT_GPIO, sysmem); } =20 + create_pcie(vms); + + if (vms->acpi_dev) { + AcpiGedState *acpi_ged_state =3D ACPI_GED(vms->acpi_dev); + + acpi_ged_state =3D ACPI_GED(vms->acpi_dev); + acpi_ged_state->pcihp_state.root =3D vms->bus; + } + if (vms->secure && !vmc->no_secure_gpio) { create_gpio_devices(vms, VIRT_SECURE_GPIO, secure_sysmem); } --=20 2.49.0