From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD1F3C3A5A7 for ; Mon, 2 Sep 2019 07:39:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A591321881 for ; Mon, 2 Sep 2019 07:39:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A591321881 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4gvy-0005XM-OA for qemu-devel@archiver.kernel.org; Mon, 02 Sep 2019 03:39:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59685) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4guS-0004Zw-9t for qemu-devel@nongnu.org; Mon, 02 Sep 2019 03:37:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i4guQ-00049Y-Di for qemu-devel@nongnu.org; Mon, 02 Sep 2019 03:37:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59218) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i4guM-00047E-9A; Mon, 02 Sep 2019 03:37:50 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CE1C8980F6; Mon, 2 Sep 2019 07:37:49 +0000 (UTC) Received: from [10.36.116.67] (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 700AD60C18; Mon, 2 Sep 2019 07:37:41 +0000 (UTC) From: Auger Eric To: Shameer Kolothum , qemu-devel@nongnu.org, qemu-arm@nongnu.org, imammedo@redhat.com References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> <20190813210539.31164-10-shameerali.kolothum.thodi@huawei.com> Message-ID: <2c7eb5f4-3cb3-07db-5abb-b006b4854fa4@redhat.com> Date: Mon, 2 Sep 2019 09:37:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190813210539.31164-10-shameerali.kolothum.thodi@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Mon, 02 Sep 2019 07:37:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Hi Shameer, On 8/13/19 11:05 PM, Shameer Kolothum wrote: > For machines 4.2 or higher with ACPI boot use GED for system_powerdown > event instead of GPIO. Guest boot with DT still uses GPIO. > > Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger Eric > --- > v8 --> v9 > -Re-arranged patches 8 & 9 from v8 based on Igor's comments. > > v7 --> v8 > -Retained gpio based system_powerdown support for machines < 4.2. > -Reuse of virt_powerdown_req() for ACPI GED use. > -Dropped Eric's R-by for now because of above. > > --- > hw/acpi/generic_event_device.c | 8 ++++++++ > hw/arm/virt-acpi-build.c | 6 +++--- > hw/arm/virt.c | 16 +++++++++++----- > include/hw/acpi/acpi_dev_interface.h | 1 + > include/hw/acpi/generic_event_device.h | 3 +++ > 5 files changed, 26 insertions(+), 8 deletions(-) > > diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c > index f4c23470c2..d6d7b28cfd 100644 > --- a/hw/acpi/generic_event_device.c > +++ b/hw/acpi/generic_event_device.c > @@ -19,6 +19,7 @@ > > static const uint32_t ged_supported_events[] = { > ACPI_GED_MEM_HOTPLUG_EVT, > + ACPI_GED_PWR_DOWN_EVT, > }; > > /* > @@ -103,6 +104,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, > aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." > MEMORY_SLOT_SCAN_METHOD)); > break; > + case ACPI_GED_PWR_DOWN_EVT: > + aml_append(if_ctx, > + aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), > + aml_int(0x80))); > + break; > default: > /* > * Please make sure all the events in ged_supported_events[] > @@ -189,6 +195,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) > > if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { > sel = ACPI_GED_MEM_HOTPLUG_EVT; > + } else if (ev & ACPI_POWER_DOWN_STATUS) { > + sel = ACPI_GED_PWR_DOWN_EVT; > } else { > /* Unknown event. Return without generating interrupt. */ > warn_report("GED: Unsupported event %d. No irq injected", ev); > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index 6d697af2df..61b399dc58 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -49,7 +49,6 @@ > #include "kvm_arm.h" > > #define ARM_SPI_BASE 32 > -#define ACPI_POWER_BUTTON_DEVICE "PWRB" > > static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) > { > @@ -739,13 +738,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) > (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS); > acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE), > vms->highmem, vms->highmem_ecam); > - acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], > - (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); > if (vms->acpi_dev) { > build_ged_aml(scope, "\\_SB."GED_DEVICE, > HOTPLUG_HANDLER(vms->acpi_dev), > irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY, > memmap[VIRT_ACPI_GED].base); > + } else { > + acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], > + (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); > } > > if (vms->acpi_dev && ms->ram_slots) { > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 0e75213b44..d49e1a583c 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -528,7 +528,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) > { > DeviceState *dev; > int irq = vms->irqmap[VIRT_ACPI_GED]; > - uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT; > + uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT | ACPI_GED_PWR_DOWN_EVT; > > dev = qdev_create(NULL, TYPE_ACPI_GED); > qdev_prop_set_uint32(dev, "ged-event", event); > @@ -783,8 +783,14 @@ static void create_rtc(const VirtMachineState *vms, qemu_irq *pic) > static DeviceState *gpio_key_dev; > static void virt_powerdown_req(Notifier *n, void *opaque) > { > - /* use gpio Pin 3 for power button event */ > - qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); > + VirtMachineState *s = container_of(n, VirtMachineState, powerdown_notifier); > + > + if (s->acpi_dev) { > + acpi_send_event(s->acpi_dev, ACPI_POWER_DOWN_STATUS); > + } else { > + /* use gpio Pin 3 for power button event */ > + qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); > + } > } > > static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) > @@ -1712,10 +1718,10 @@ static void machvirt_init(MachineState *machine) > > create_pcie(vms, pic); > > - create_gpio(vms, pic); > - > if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { > vms->acpi_dev = create_acpi_ged(vms, pic); > + } else { > + create_gpio(vms, pic); > } > > /* connect powerdown request */ > diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h > index 43ff119179..adcb3a816c 100644 > --- a/include/hw/acpi/acpi_dev_interface.h > +++ b/include/hw/acpi/acpi_dev_interface.h > @@ -11,6 +11,7 @@ typedef enum { > ACPI_MEMORY_HOTPLUG_STATUS = 8, > ACPI_NVDIMM_HOTPLUG_STATUS = 16, > ACPI_VMGENID_CHANGE_STATUS = 32, > + ACPI_POWER_DOWN_STATUS = 64, > } AcpiEventStatusBits; > > #define TYPE_ACPI_DEVICE_IF "acpi-device-interface" > diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h > index 2049e8d873..d157eac088 100644 > --- a/include/hw/acpi/generic_event_device.h > +++ b/include/hw/acpi/generic_event_device.h > @@ -62,6 +62,8 @@ > #include "hw/sysbus.h" > #include "hw/acpi/memory_hotplug.h" > > +#define ACPI_POWER_BUTTON_DEVICE "PWRB" > + > #define TYPE_ACPI_GED "acpi-ged" > #define ACPI_GED(obj) \ > OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) > @@ -79,6 +81,7 @@ > * through GED. > */ > #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 > +#define ACPI_GED_PWR_DOWN_EVT 0x2 > > typedef struct GEDState { > MemoryRegion io; >