From nobody Mon Feb 9 12:31:43 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748332029; cv=none; d=zohomail.com; s=zohoarc; b=iv4chckEAO+yWBMcrip/sEaalIReHpzffmML/ZTfgqiyYfUlsehbyRlH1smBVODCmbkUQhuVXUIby2SUDbyRKdifI21r4eBfHa0hHkFdWfxf90YYQI72J3ONF3OZOGsKwvN9BSf2UlzCc6sCrr7LojvLuUz10ZBhk+ojoEmGQc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748332029; 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=zdU5cY/SULLwyXpxxEZqK8ZNb0hepj4gkwMPt3FqJ10=; b=iVnnTqvZdXMkRbIpPDbXO+Q5p0B4K+/1JjtKqREL3Vg4f3MaLqEr+PMXTXabsvypM0CHFmsFPv6Rha+uTHmdk+cPwqZW7bOl2xTGUcxGmI2H0W2gEDX6fRcxt2Lkbw8B/fDOcJ0Pd505keF9JY1QRZObepfWx2+rBCuJOnLNq0U= 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 1748332029792787.978695811117; Tue, 27 May 2025 00:47:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJp1J-0007YI-JL; Tue, 27 May 2025 03:46:45 -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 1uJozG-0002kv-3g for qemu-devel@nongnu.org; Tue, 27 May 2025 03:44:39 -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 1uJozE-0000S1-6w for qemu-devel@nongnu.org; Tue, 27 May 2025 03:44:37 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-otcXCW75Ntqxe4srdlj3OQ-1; Tue, 27 May 2025 03:44:31 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AE2BA1956094; Tue, 27 May 2025 07:44:29 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.201]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 131CE19560AA; Tue, 27 May 2025 07:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748331875; 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=zdU5cY/SULLwyXpxxEZqK8ZNb0hepj4gkwMPt3FqJ10=; b=M4Jd7/+AV928nAWxLbFaKy/AmCxUXRZ7+2FKDEpS+G4NN+nFWDIbfvDCp9Cx0GLJyiu/PF 3h9Uqszp2+56fOdtPAZr8sM4bA4ij/c1PdUGZzvZ28I4jQ3cqlgL6SIMqPLUuNGF6HaqEH 0UYvU2cjI25l6473sLlcSoteZA+SZrY= X-MC-Unique: otcXCW75Ntqxe4srdlj3OQ-1 X-Mimecast-MFC-AGG-ID: otcXCW75Ntqxe4srdlj3OQ_1748331870 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, gustavo.romero@linaro.org, anisinha@redhat.com, mst@redhat.com, shannon.zhaosl@gmail.com Cc: pbonzini@redhat.com, Jonathan.Cameron@huawei.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v2 23/25] hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks Date: Tue, 27 May 2025 09:40:25 +0200 Message-ID: <20250527074224.1197793-24-eric.auger@redhat.com> In-Reply-To: <20250527074224.1197793-1-eric.auger@redhat.com> References: <20250527074224.1197793-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.903, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1748332031174116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Eric Auger --- hw/arm/virt.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index cdcff0a984..adb9422e14 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -87,6 +87,7 @@ #include "hw/virtio/virtio-iommu.h" #include "hw/char/pl011.h" #include "qemu/guest-random.h" +#include "hw/acpi/pcihp.h" =20 static GlobalProperty arm_virt_compat[] =3D { { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "48" }, @@ -2973,6 +2974,11 @@ static void virt_machine_device_pre_plug_cb(HotplugH= andler *hotplug_dev, qlist_append_str(reserved_regions, resv_prop_str); qdev_prop_set_array(dev, "reserved-regions", reserved_regions); g_free(resv_prop_str); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + if (vms->acpi_pcihp) { + acpi_pcihp_device_pre_plug_cb(HOTPLUG_HANDLER(vms->acpi_dev), + dev, errp); + } } } =20 @@ -3002,6 +3008,14 @@ static void virt_machine_device_plug_cb(HotplugHandl= er *hotplug_dev, vms->iommu =3D VIRT_IOMMU_VIRTIO; vms->virtio_iommu_bdf =3D pci_get_bdf(pdev); create_virtio_iommu_dt_bindings(vms); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + AcpiGedState *acpi_ged_state =3D ACPI_GED(vms->acpi_dev); + AcpiPciHpState *acpi_pci_hotplug =3D &acpi_ged_state->pcihp_state; + + if (vms->acpi_pcihp) { + acpi_pcihp_device_plug_cb(HOTPLUG_HANDLER(vms->acpi_dev), + acpi_pci_hotplug, dev, errp); + } } } =20 @@ -3051,6 +3065,15 @@ static void virt_machine_device_unplug_request_cb(Ho= tplugHandler *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { virtio_md_pci_unplug_request(VIRTIO_MD_PCI(dev), MACHINE(hotplug_d= ev), errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + AcpiGedState *acpi_ged_state =3D ACPI_GED(vms->acpi_dev); + AcpiPciHpState *acpi_pci_hotplug =3D &acpi_ged_state->pcihp_state; + + if (vms->acpi_pcihp) { + acpi_pcihp_device_unplug_request_cb(HOTPLUG_HANDLER(vms->acpi_= dev), + acpi_pci_hotplug, dev, err= p); + } } else { error_setg(errp, "device unplug request for unsupported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -3064,6 +3087,15 @@ static void virt_machine_device_unplug_cb(HotplugHan= dler *hotplug_dev, virt_dimm_unplug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) { virtio_md_pci_unplug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), err= p); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + AcpiGedState *acpi_ged_state =3D ACPI_GED(vms->acpi_dev); + AcpiPciHpState *acpi_pci_hotplug =3D &acpi_ged_state->pcihp_state; + + if (vms->acpi_pcihp) { + acpi_pcihp_device_unplug_cb(HOTPLUG_HANDLER(vms->acpi_dev), + acpi_pci_hotplug, dev, errp); + } } else { error_setg(errp, "virt: device unplug for unsupported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -3074,11 +3106,14 @@ static HotplugHandler *virt_machine_get_hotplug_han= dler(MachineState *machine, DeviceState *dev) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); + VirtMachineState *vms =3D VIRT_MACHINE(machine); =20 if (device_is_dynamic_sysbus(mc, dev) || object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI) || + (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE) && + vms->acpi_pcihp)) { return HOTPLUG_HANDLER(machine); } return NULL; --=20 2.49.0