From patchwork Fri Mar 8 11:42:17 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: 10844555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F01B14DE for ; Fri, 8 Mar 2019 11:57:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 091072E360 for ; Fri, 8 Mar 2019 11:57:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F19B52E365; Fri, 8 Mar 2019 11:57:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B2CA2E360 for ; Fri, 8 Mar 2019 11:57:38 +0000 (UTC) Received: from localhost ([127.0.0.1]:41825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E87-0001g2-FY for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Mar 2019 06:57:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dvv-0008WM-AK for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:45:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dvq-0007Eo-R3 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:57 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43868 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2Dvk-0006Ly-2E; Fri, 08 Mar 2019 06:44:48 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 59352DBA3A4E39A5D7AB; Fri, 8 Mar 2019 19:44:43 +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:36 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:17 +0000 Message-ID: <20190308114218.26692-11-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.35 Subject: [Qemu-devel] [PATCH v2 10/11] hw/arm/virt: Add GED device configuration and build aml 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This initializes the GED device with base memory and irq. It also configures ged memory hotplug event and builds the corresponding aml code. But ged irq routing to Guest is not enabled and thus hotplug is not yet supported. Signed-off-by: Shameer Kolothum --- default-configs/arm-softmmu.mak | 1 + hw/arm/virt-acpi-build.c | 13 +++++++++++++ hw/arm/virt-acpi.c | 4 ++++ hw/arm/virt.c | 22 ++++++++++++++++++++++ include/hw/arm/virt.h | 4 ++++ 5 files changed, 44 insertions(+) diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index b3bac25..7c442fd 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -168,3 +168,4 @@ CONFIG_MUSICPAL=y CONFIG_MEM_DEVICE=y CONFIG_DIMM=y CONFIG_ACPI_MEMORY_HOTPLUG=y +CONFIG_ACPI_HW_REDUCED=y diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 6cb7263..86f25ad 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -50,6 +50,18 @@ #define ARM_SPI_BASE 32 #define ACPI_POWER_BUTTON_DEVICE "PWRB" +static void acpi_dsdt_add_ged(Aml *scope, VirtMachineState *vms) +{ + int irq = vms->irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE; + + if (!vms->ged_events || !vms->ged_events_size) { + return; + } + + build_ged_aml(scope, "\\_SB."GED_DEVICE, irq, vms->ged_events, + vms->ged_events_size, AML_SYSTEM_MEMORY); +} + static void acpi_dsdt_add_memory_hotplug(Aml *scope, MachineState *ms) { uint32_t nr_mem = ms->ram_slots; @@ -758,6 +770,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) */ scope = aml_scope("\\_SB"); acpi_dsdt_add_memory_hotplug(scope, MACHINE(vms)); + acpi_dsdt_add_ged(scope, vms); acpi_dsdt_add_cpus(scope, vms->smp_cpus); acpi_dsdt_add_uart(scope, &memmap[VIRT_UART], (irqmap[VIRT_UART] + ARM_SPI_BASE)); diff --git a/hw/arm/virt-acpi.c b/hw/arm/virt-acpi.c index 18ebe94..3b55c63 100644 --- a/hw/arm/virt-acpi.c +++ b/hw/arm/virt-acpi.c @@ -31,6 +31,7 @@ typedef struct VirtAcpiState { SysBusDevice parent_obj; MemHotplugState memhp_state; + GEDState ged_state; } VirtAcpiState; #define TYPE_VIRT_ACPI "virt-acpi" @@ -76,12 +77,15 @@ static void virt_device_realize(DeviceState *dev, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(qdev_get_machine()); const MemMapEntry *memmap = vms->memmap; + const int *irqmap = vms->irqmap; VirtAcpiState *s = VIRT_ACPI(dev); if (s->memhp_state.is_enabled) { acpi_memory_hotplug_init(get_system_memory(), OBJECT(dev), &s->memhp_state, memmap[VIRT_PCDIMM_ACPI].base); + acpi_ged_init(get_system_memory(), OBJECT(dev), &s->ged_state, + memmap[VIRT_ACPI_GED].base, irqmap[VIRT_ACPI_GED]); } } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9427f4f..352dbb1 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -134,6 +134,7 @@ static const MemMapEntry base_memmap[] = { [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, [VIRT_SMMU] = { 0x09050000, 0x00020000 }, [VIRT_PCDIMM_ACPI] = { 0x09070000, 0x00010000 }, + [VIRT_ACPI_GED] = { 0x09080000, 0x00010000 }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, @@ -169,6 +170,7 @@ static const int a15irqmap[] = { [VIRT_PCIE] = 3, /* ... to 6 */ [VIRT_GPIO] = 7, [VIRT_SECURE_UART] = 8, + [VIRT_ACPI_GED] = 9, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] = 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ @@ -184,6 +186,25 @@ static const char *valid_cpus[] = { ARM_CPU_TYPE_NAME("max"), }; +static void virt_acpi_ged_conf(VirtMachineState *vms) +{ + uint8_t events_size; + + /* GED events */ + GedEvent events[] = { + { + .selector = ACPI_GED_IRQ_SEL_MEM, + .event = GED_MEMORY_HOTPLUG, + }, + }; + + events_size = ARRAY_SIZE(events); + + vms->ged_events = g_malloc0(events_size * sizeof(GedEvent)); + memcpy(vms->ged_events, events, events_size * sizeof(GedEvent)); + vms->ged_events_size = events_size; +} + static bool cpu_type_valid(const char *cpu) { int i; @@ -1650,6 +1671,7 @@ static void machvirt_init(MachineState *machine) create_platform_bus(vms, pic); vms->acpi = virt_acpi_init(); + virt_acpi_ged_conf(vms); vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.kernel_filename = machine->kernel_filename; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index e46a051..49fda81 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -37,6 +37,7 @@ #include "hw/arm/arm.h" #include "sysemu/kvm.h" #include "hw/intc/arm_gicv3_common.h" +#include "hw/acpi/ged.h" #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -78,6 +79,7 @@ enum { VIRT_SECURE_UART, VIRT_SECURE_MEM, VIRT_PCDIMM_ACPI, + VIRT_ACPI_GED, VIRT_LOWMEMMAP_LAST, }; @@ -134,6 +136,8 @@ typedef struct { int psci_conduit; hwaddr highest_gpa; DeviceState *acpi; + GedEvent *ged_events; + uint32_t ged_events_size; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)