From patchwork Thu Oct 29 14:27:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 55782 Delivered-To: patch@linaro.org Received: by 10.202.175.130 with SMTP id y124csp455298oie; Thu, 29 Oct 2015 07:30:40 -0700 (PDT) X-Received: by 10.140.43.70 with SMTP id d64mr2588808qga.11.1446129040253; Thu, 29 Oct 2015 07:30:40 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m6si1428509qhb.119.2015.10.29.07.30.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Oct 2015 07:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dkim=fail header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([::1]:44399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroDv-0001gr-Rc for patch@linaro.org; Thu, 29 Oct 2015 10:30:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroCr-0000Ya-Tl for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZroCo-0000UK-6F for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:33 -0400 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]:34760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroCo-0000UD-1i for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:30 -0400 Received: by padhk11 with SMTP id hk11so42642004pad.1 for ; Thu, 29 Oct 2015 07:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e7Q4UzUSvhR9Hupz/OVKkItW3GBnkdJuqjr8bHHUPws=; b=e0D30amGVpXNnPVftrMWBOkLQVFUPUy4cLlVsWZ0NpeFZs8UPfudn6fkR8ItREzhgU CbSm7auj9cYxd7rGGAv1CNTKwV7o5HvLS/Xv6998VzqL1WZy5tV9tKIrxz3w++eViye8 62k9YmzEIqECgJYip1c5VnMXdnTDo5m9w1E7Y6NQ+guaJYg0YeYJ8i0zSInXqNEb2LBN MbimnY2ht86F8pFotrclm4K/CHO3ckJOx0WIS6gmp6epkuvT/I58O1BMa2HwsyCb6I1a KExVu7XcshCJW8F1zMzfuUwgrlHc+g40M4mrspuaVP6qjRIN6xuDq/tYLlR96Ytx/tuw L2gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e7Q4UzUSvhR9Hupz/OVKkItW3GBnkdJuqjr8bHHUPws=; b=V4PUeM6ObPsmgs9BMxxfjuG2jzdwn05F1RGWem/2IsEtDNsYTXJZ+WS52T+tZ6+Fty QW6ShYUouWHRixbYNOKm7G+Y5baqkdr43xvAcdxsz0CoQ03r4Drn9kb4ZmcLBHSbEz+a TfmrxXjOkpdQBHapOecjmO/fM3Lamt82dA5vvJlMgFtjJd3P/V9toqxVyVNOFMvryEhy M3jQ2Ao+WVdoJaL9pNXUHufUh7ny5P02Qh+HBVJraGcQKAQcA4MmZ9iZY12MFccuQHh4 vyYgDsr1qEbHeMdfMXAbekoQMrNTlid/jkBY3y6fdifxcMlI9W91K4RNOBP4VnLdKuHf 3GLg== X-Gm-Message-State: ALoCoQk5CWrBSoUp9NW7vd3IUiOFPjmM+SXrpMGassfLEFEsl5HWCf3KIWo0DAuPau+y/xwvUpyY X-Received: by 10.69.16.228 with SMTP id fz4mr2241975pbd.164.1446128969611; Thu, 29 Oct 2015 07:29:29 -0700 (PDT) Received: from localhost.localdomain ([180.150.157.4]) by smtp.gmail.com with ESMTPSA id a5sm1805986pbu.55.2015.10.29.07.29.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Oct 2015 07:29:28 -0700 (PDT) From: Shannon Zhao To: qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, imammedo@redhat.com Date: Thu, 29 Oct 2015 22:27:34 +0800 Message-Id: <1446128855-26637-8-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1446128855-26637-1-git-send-email-shannon.zhao@linaro.org> References: <1446128855-26637-1-git-send-email-shannon.zhao@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::233 Cc: zhaoshenglong@huawei.com, peter.huangpeng@huawei.com, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v2 7/8] hw/arm/virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Currently mach-virt model doesn't support powerdown request. Guest VM doesn't react to system_powerdown from monitor console (or QMP) because there is no communication mechanism for such requests. This patch registers GPIO Pin 3 with powerdown notification. So guest VM can receive notification when such powerdown request is triggered. Signed-off-by: Wei Huang Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/arm/virt.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) -- 2.1.0 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 5c505a4..6f1b9d6 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -540,6 +540,18 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) g_free(nodename); } +static DeviceState *pl061_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(pl061_dev, 3), 0); + qemu_set_irq(qdev_get_gpio_in(pl061_dev, 3), 1); +} + +static Notifier virt_system_powerdown_notifier = { + .notify = virt_powerdown_req +}; + static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) { char *nodename; @@ -548,7 +560,7 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) int irq = vbi->irqmap[VIRT_GPIO]; const char compat[] = "arm,pl061\0arm,primecell"; - sysbus_create_simple("pl061", base, pic[irq]); + pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); nodename = g_strdup_printf("/pl061@%" PRIx64, base); qemu_fdt_add_subnode(vbi->fdt, nodename); @@ -563,6 +575,9 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle); qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk"); + /* connect powerdown request */ + qemu_register_powerdown_notifier(&virt_system_powerdown_notifier); + g_free(nodename); }