From patchwork Fri Mar 8 11:42:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 159975 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8615372jad; Fri, 8 Mar 2019 03:54:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzgvyXfE34XDCmP1ctZvsMxRoEkkhgsaUCEWLUDsC1fx7FJVX4FRVFjnS6af37eU66svUmS X-Received: by 2002:a0d:e1d3:: with SMTP id k202mr14063269ywe.198.1552046072335; Fri, 08 Mar 2019 03:54:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552046072; cv=none; d=google.com; s=arc-20160816; b=0fZaegX0UNnSWbVIxBpEAqqC8GPTNkAw8EI3i73dPkh4GMu5WuA3TTcspCAgNki0m6 PdNk7XV91s9COLO3Wi86T0PIIe9zdzH3FJeUqm2uavIH/jbxMw2mbqrBmMSyK3E+3mLy iaaFJqk0zimsehs+BDLvVBkqwNWNrppKfVC4E7xj/1Yk6g/VTk1SbJEBBKtLfjGT4Q1I 8VZ2Or7o91Y7O5hgZ/Qo/iejP/XiJeIv8cQ7fABHfUf9mbDmxWhQ5VZdgBE/igAa27gq mj8E7iluj1PIz7HlVL3km7q3vsdMlUcZP18T/XZK1JqtEr6PGgqBaSTUo2oQYiFDj1T9 2CFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=8dAZh6ardznfCQ5M2tkxm3YaTQKmKl9t7SYpkC9mBe4=; b=XpegRxVLOukmB33mOR0UMwS0S4rXbWvMSgkEDVK4GQbuneGYzjG4+pHqIX75wgVC7/ Gf85dUKzJrLIAwkAmMrxFbGj9e9353gt4mTq/makkLYh+7ve9g5DGUm3G0hHZFALfNra JiFiiXAC8WoftM4OpLGnl/dj28P674DfnxNft11IzKwbZ35P1nvAFfeCHINr4r+6WoFK AOH6JPnDvz+OuN3qp3E9POzJMKtc4NcWE55Sr57/y2nKGExYRobM/bSCNFw5jHKNi2Ek /jym8iZgZrEftMC+82ht5UmUqyAtFqIZ6Wo/zC5VxV2fGyx3pz/bgl3rWTFbDmbn1/ye 7BCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=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 x15si2629036ybk.423.2019.03.08.03.54.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:54:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:41658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E57-0006bD-Ta for patch@linaro.org; Fri, 08 Mar 2019 06:54:29 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.7.4 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; #define TYPE_VIRT_ACPI "virt-acpi" @@ -71,6 +72,21 @@ static void virt_device_unplug_cb(HotplugHandler *hotplug_dev, static void virt_send_ged(AcpiDeviceIf *adev, AcpiEventStatusBits ev) { + VirtAcpiState *s = VIRT_ACPI(adev); + uint32_t sel = ACPI_GED_IRQ_SEL_INIT; + + if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { + sel = 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); } static void virt_device_realize(DeviceState *dev, Error **errp) @@ -89,9 +105,16 @@ static void virt_device_realize(DeviceState *dev, Error **errp) } } -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 = sysbus_create_simple(TYPE_VIRT_ACPI, -1, NULL); + s = VIRT_ACPI(dev); + s->gsi = gsi; + + return dev; } static Property virt_acpi_properties[] = { 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); } +static void virt_gsi_handler(void *opaque, int n, int level) +{ + qemu_irq *gic_irq = 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] = qdev_get_gpio_in(gicdev, i); } + vms->gsi = qemu_allocate_irqs(virt_gsi_handler, pic, NUM_IRQS); + fdt_add_gic_node(vms); if (type == 3 && vms->its) { @@ -1444,7 +1452,7 @@ static void machvirt_init(MachineState *machine) VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(machine); MachineClass *mc = MACHINE_GET_CLASS(machine); const CPUArchIdList *possible_cpus; - qemu_irq pic[NUM_IRQS]; + qemu_irq *pic; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *secure_sysmem = NULL; int n, virt_max_cpus; @@ -1640,6 +1648,7 @@ static void machvirt_init(MachineState *machine) create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); + pic = g_new0(qemu_irq, NUM_IRQS); create_gic(vms, pic); fdt_add_pmu_nodes(vms); @@ -1670,7 +1679,7 @@ static void machvirt_init(MachineState *machine) create_platform_bus(vms, pic); - vms->acpi = virt_acpi_init(); + vms->acpi = virt_acpi_init(vms->gsi); virt_acpi_ged_conf(vms); vms->bootinfo.ram_size = machine->ram_size; @@ -1842,10 +1851,6 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, { const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); - 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) void virt_acpi_setup(VirtMachineState *vms); -DeviceState *virt_acpi_init(void); +DeviceState *virt_acpi_init(qemu_irq *gsi); /* Return the number of used redistributor regions */ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)