From nobody Sun Nov 9 21:59:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552046020454163.84532055449358; Fri, 8 Mar 2019 03:53:40 -0800 (PST) Received: from localhost ([127.0.0.1]:41658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E4H-0006bD-Ci for importer@patchew.org; Fri, 08 Mar 2019 06:53:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dw0-0000Bi-Hv for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:45:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dvx-0007lq-9U for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:45:03 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2189 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2Dvo-0006m5-IH; Fri, 08 Mar 2019 06:44:52 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6D4E06C0D5FC7E7957FB; Fri, 8 Mar 2019 19:44:48 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:39 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:18 +0000 Message-ID: <20190308114218.26692-12-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v2 11/11] hw/arm/virt: Add GED irq routing and Enable memory hotplug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Adds GED irq routing to guest and enables memory hotplug. Signed-off-by: Shameer Kolothum --- hw/arm/virt-acpi.c | 27 +++++++++++++++++++++++++-- hw/arm/virt.c | 17 +++++++++++------ include/hw/arm/virt.h | 3 ++- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/hw/arm/virt-acpi.c b/hw/arm/virt-acpi.c index 3b55c63..c5a9311 100644 --- a/hw/arm/virt-acpi.c +++ b/hw/arm/virt-acpi.c @@ -32,6 +32,7 @@ typedef struct VirtAcpiState { SysBusDevice parent_obj; MemHotplugState memhp_state; GEDState ged_state; + qemu_irq *gsi; } VirtAcpiState; =20 #define TYPE_VIRT_ACPI "virt-acpi" @@ -71,6 +72,21 @@ static void virt_device_unplug_cb(HotplugHandler *hotplu= g_dev, =20 static void virt_send_ged(AcpiDeviceIf *adev, AcpiEventStatusBits ev) { + VirtAcpiState *s =3D VIRT_ACPI(adev); + uint32_t sel =3D ACPI_GED_IRQ_SEL_INIT; + + if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { + sel =3D ACPI_GED_IRQ_SEL_MEM; + } else { + /* Unknown event. Return without generating interrupt. */ + return; + } + + /* + * We inject the hotplug interrupt. The IRQ selector will make + * the difference from the ACPI table. + */ + acpi_ged_event(&s->ged_state, s->gsi, sel); } =20 static void virt_device_realize(DeviceState *dev, Error **errp) @@ -89,9 +105,16 @@ static void virt_device_realize(DeviceState *dev, Error= **errp) } } =20 -DeviceState *virt_acpi_init(void) +DeviceState *virt_acpi_init(qemu_irq *gsi) { - return sysbus_create_simple(TYPE_VIRT_ACPI, -1, NULL); + DeviceState *dev; + VirtAcpiState *s; + + dev =3D sysbus_create_simple(TYPE_VIRT_ACPI, -1, NULL); + s =3D VIRT_ACPI(dev); + s->gsi =3D gsi; + + return dev; } =20 static Property virt_acpi_properties[] =3D { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 352dbb1..fa352c5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -577,6 +577,12 @@ static void create_v2m(VirtMachineState *vms, qemu_irq= *pic) fdt_add_v2m_gic_node(vms); } =20 +static void virt_gsi_handler(void *opaque, int n, int level) +{ + qemu_irq *gic_irq =3D opaque; + qemu_set_irq(gic_irq[n], level); +} + static void create_gic(VirtMachineState *vms, qemu_irq *pic) { /* We create a standalone GIC */ @@ -692,6 +698,8 @@ static void create_gic(VirtMachineState *vms, qemu_irq = *pic) pic[i] =3D qdev_get_gpio_in(gicdev, i); } =20 + vms->gsi =3D qemu_allocate_irqs(virt_gsi_handler, pic, NUM_IRQS); + fdt_add_gic_node(vms); =20 if (type =3D=3D 3 && vms->its) { @@ -1444,7 +1452,7 @@ static void machvirt_init(MachineState *machine) VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(machine); MachineClass *mc =3D MACHINE_GET_CLASS(machine); const CPUArchIdList *possible_cpus; - qemu_irq pic[NUM_IRQS]; + qemu_irq *pic; MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *secure_sysmem =3D NULL; int n, virt_max_cpus; @@ -1640,6 +1648,7 @@ static void machvirt_init(MachineState *machine) =20 create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); =20 + pic =3D g_new0(qemu_irq, NUM_IRQS); create_gic(vms, pic); =20 fdt_add_pmu_nodes(vms); @@ -1670,7 +1679,7 @@ static void machvirt_init(MachineState *machine) =20 create_platform_bus(vms, pic); =20 - vms->acpi =3D virt_acpi_init(); + vms->acpi =3D virt_acpi_init(vms->gsi); virt_acpi_ged_conf(vms); =20 vms->bootinfo.ram_size =3D machine->ram_size; @@ -1842,10 +1851,6 @@ static void virt_memory_pre_plug(HotplugHandler *hot= plug_dev, DeviceState *dev, { const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 - if (dev->hotplugged) { - error_setg(errp, "memory hotplug is not supported"); - } - if (is_nvdimm) { error_setg(errp, "nvdimm is not yet supported"); return; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 49fda81..30ff460 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -136,6 +136,7 @@ typedef struct { int psci_conduit; hwaddr highest_gpa; DeviceState *acpi; + qemu_irq *gsi; GedEvent *ged_events; uint32_t ged_events_size; } VirtMachineState; @@ -151,7 +152,7 @@ typedef struct { OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) =20 void virt_acpi_setup(VirtMachineState *vms); -DeviceState *virt_acpi_init(void); +DeviceState *virt_acpi_init(qemu_irq *gsi); =20 /* Return the number of used redistributor regions */ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) --=20 2.7.4