From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroBu-0007hw-Ot for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:28:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZroBq-0008W4-F4 for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:28:34 -0400 Received: from mail-pa0-x232.google.com ([2607:f8b0:400e:c03::232]:33369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroBq-0008Vp-7D for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:28:30 -0400 Received: by padhy1 with SMTP id hy1so36649746pad.0 for ; Thu, 29 Oct 2015 07:28:29 -0700 (PDT) From: Shannon Zhao Date: Thu, 29 Oct 2015 22:27:27 +0800 Message-Id: <1446128855-26637-1-git-send-email-shannon.zhao@linaro.org> Subject: [Qemu-devel] [PATCH v2 0/8] Add system_powerdown support on ARM for ACPI and DT List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, imammedo@redhat.com Cc: zhaoshenglong@huawei.com, peter.huangpeng@huawei.com, shannon.zhao@linaro.org ACPI SPEC 5.0 defines GPIO-signaled ACPI Events for Hardware-reduced platforms(like ARM). It uses GPIO pin to trigger an event to the guest. For QEMU, here we add PL061 GPIO controller and use PIN 3 for system_powerdown, reserving PIN 0, 1, 2 for PCI hotplug, CPU hotplug and memory hotplug. This patchset adds system_powerdown support on ARM through both ACPI and DT ways. It adds a GPIO controller(here is PL061) in machine virt and uses GPIO-singled event for ACPI while gpio-keys for DT. It can be fetched from [1] and has been tested for the guests starting by ACPI or DT while guests use systemd or acpid. a) ACPI way. Since Graeme send a patchset to make ACPI on ARM64 support amba device[2], it could use PL061 directly without modification to its kernel driver code. In addition, we should use ACPI to start VM, referring to below script. QEMU_EFI.fd can be fetched from [3]. qemu-system-aarch64 \ -smp 1 -m 1024 -M virt \ -cpu cortex-a57 -nographic \ -monitor telnet::4444,server,nowait \ -bios QEMU_EFI.fd \ -kernel Image \ -initrd guestfs.cpio.gz \ -append "rdinit=/sbin/init console=ttyAMA0 mem=512M root=/dev/ram earlycon=pl011,0x9000000 rw acpi=force" b) DT way. Start vm as usual. qemu-system-aarch64 \ -smp 1 -m 1024 -M virt \ -cpu cortex-a57 -nographic \ -monitor telnet::4444,server,nowait \ -kernel Image \ -initrd guestfs.cpio.gz \ -append "rdinit=/sbin/init console=ttyAMA0 mem=512M root=/dev/ram earlycon=pl011,0x9000000 rw" Guest internal setup: If your guest FS uses systemd, you should check file /lib/udev/rules.d/70-power-switch.rules and add the following line in it if it doesn't exist. SUBSYSTEM=="input", KERNEL=="event*", SUBSYSTEMS=="platform", ATTRS{keys}=="116", TAG+="power-switch" If your guest FS uses acpid, you should check it has /etc/acpi/powerbtn.sh and /etc/acpi/events/powerbtn. Refer to [4] for the setup of acpid. Thanks, Shannon [1] https://git.linaro.org/people/shannon.zhao/qemu.git/shortlog/refs/heads/PowerButton_v2 [2] https://lkml.org/lkml/2015/9/30/392 [3] http://people.linaro.org/~shannon.zhao/ACPI_ARM/QEMU_EFI.fd [4] https://wiki.linaro.org/LEG/Engineering/Kernel/ACPI/GPIOPowerButton Changes since v1: * rewrite GPIO Connection Descriptor (Michael) Shannon Zhao (8): hw/arm/virt: Add a GPIO controller hw/arm/virt-acpi-build: Add GPIO controller in ACPI DSDT table hw/arm/virt-acpi-build: Add power button device in ACPI DSDT table hw/acpi/aml-build: Add GPIO Connection Descriptor hw/acpi/aml-build: Add a wrapper for GPIO Interrupt Connection hw/arm/virt-acpi-build: Add _E03 for Power Button hw/arm/virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 hw/arm/virt: Add gpio-keys node for Poweroff using DT hw/acpi/aml-build.c | 79 +++++++++++++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 45 ++++++++++++++++++++++++++ hw/arm/virt.c | 60 ++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 26 +++++++++++++++ include/hw/arm/virt.h | 1 + 5 files changed, 211 insertions(+) -- 2.1.0