qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: shannon.zhao@linaro.org
To: qemu-devel@nongnu.org, peter.maydell@linaro.org,
	imammedo@redhat.com, mst@redhat.com, pbonzini@redhat.com,
	wei@redhat.com, arnd@arndb.de, christoffer.dall@linaro.org
Cc: hangaohuai@huawei.com, peter.huangpeng@huawei.com,
	zhaoshenglong@huawei.com
Subject: [Qemu-devel] [PATCH 0/7] Add system_powerdown support on ARM through ACPI and DT
Date: Tue, 12 May 2015 12:24:09 +0800	[thread overview]
Message-ID: <1431404656-7180-1-git-send-email-shannon.zhao@linaro.org> (raw)

From: Shannon Zhao <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. As ACPI on ARM64 doesn't support probing amba device, we
should convert the PL061 to platform device(apply patch[2]). In addition,
we should use ACPI to start VM, referring to below script. QEMU_EFI.fd
can be fetched from [3]. 
Note: The guest kernel must have the ARM64 ACPI support(the related
patches are in upstream kernel now) and uart SBSA support for ACPI [4].

    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=ttySBSA mem=512M root=/dev/ram earlycon=pl011,0x9000000 rw acpi=force"

b) DT way. Apply patch[2] as well. 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 [5] for
the setup of acpid.

Thanks,
Shannon

[1] https://git.linaro.org/people/shannon.zhao/qemu.git/shortlog/refs/heads/PowerButton
[2] http://people.linaro.org/~shannon.zhao/PowerButton/0001-PL061-convert-to-platform-device.patch
[3] http://people.linaro.org/~shannon.zhao/ACPI_ARM/QEMU_EFI.fd
[4] http://people.linaro.org/~shannon.zhao/ACPI_ARM/0001-tty-SBSA-compatible-UART.patch
[5] https://wiki.linaro.org/LEG/Engineering/Kernel/ACPI/GPIOPowerButton

Shannon Zhao (7):
  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 aml_gpio_int() term
  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         | 60 +++++++++++++++++++++++++++++++++++++++++++++
 hw/arm/virt-acpi-build.c    | 43 ++++++++++++++++++++++++++++++++
 hw/arm/virt.c               | 60 +++++++++++++++++++++++++++++++++++++++++++++
 include/hw/acpi/aml-build.h | 16 ++++++++++++
 include/hw/arm/virt.h       |  1 +
 5 files changed, 180 insertions(+)

-- 
2.1.0

             reply	other threads:[~2015-05-12  4:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12  4:24 shannon.zhao [this message]
2015-05-12  4:24 ` [Qemu-devel] [PATCH 1/7] hw/arm/virt: Add a GPIO controller shannon.zhao
2015-05-12  4:24 ` [Qemu-devel] [PATCH 2/7] hw/arm/virt-acpi-build: Add GPIO controller in ACPI DSDT table shannon.zhao
2015-05-12  4:24 ` [Qemu-devel] [PATCH 3/7] hw/arm/virt-acpi-build: Add power button device " shannon.zhao
2015-05-12  4:24 ` [Qemu-devel] [PATCH 4/7] hw/acpi/aml-build: Add aml_gpio_int() term shannon.zhao
2015-05-31 18:13   ` Michael S. Tsirkin
2015-05-31 18:21     ` Michael S. Tsirkin
2015-06-01  3:48       ` Shannon Zhao
2015-05-12  4:24 ` [Qemu-devel] [PATCH 5/7] hw/arm/virt-acpi-build: Add _E03 for Power Button shannon.zhao
2015-05-12  4:24 ` [Qemu-devel] [PATCH 6/7] hw/arm/virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 shannon.zhao
2015-05-12  4:24 ` [Qemu-devel] [PATCH 7/7] hw/arm/virt: Add gpio-keys node for Poweroff using DT shannon.zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431404656-7180-1-git-send-email-shannon.zhao@linaro.org \
    --to=shannon.zhao@linaro.org \
    --cc=arnd@arndb.de \
    --cc=christoffer.dall@linaro.org \
    --cc=hangaohuai@huawei.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wei@redhat.com \
    --cc=zhaoshenglong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).