From patchwork Tue May 12 04:24:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 48328 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B653921550 for ; Tue, 12 May 2015 04:27:11 +0000 (UTC) Received: by wgiv13 with SMTP id v13sf43728819wgi.3 for ; Mon, 11 May 2015 21:27:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=uq34Dqim069VmWHm+MwTAyno18SIOdYrLSju/ylRYJU=; b=k5VVVQ2c3Rp8MAYkl5vjIN8Xx9GjV+r2CGtEGKA35nQxgvT2kNobGYpYmeK7ASYoir 8IUuxqTo35vL1VicaqMtPJxziyjQnzo+rKcUSlhN6flanzSvPbT8bZAbYKrKAquG51LG Tzh39sMIykEGm0Nx1aUZp3M82a6HixMY9Netmi1H117Yiku3XQ1negDEdu+YB+3khqFn cZXl5kdCBg3nwZkqMKvJO2enoKBP/4W98RbQ0m40eKn2Ao6tYYs3B7K9gWhAcgDEykmx qr9WSFtBPfq8W25vXszoFgfWPLj9DJVsmrXSbLMCLVPFdRvvomCi6BMLQSGAO4F7txz6 oZfQ== X-Gm-Message-State: ALoCoQlFG1pQbksiylJfZf/wuovfhck0qaOX7CU6S5fE3VAJddBJKwnClAa0AyJMCu6+Z5kMMoZd X-Received: by 10.112.13.200 with SMTP id j8mr9523272lbc.14.1431404830943; Mon, 11 May 2015 21:27:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.9 with SMTP id 9ls811806laq.89.gmail; Mon, 11 May 2015 21:27:10 -0700 (PDT) X-Received: by 10.152.2.227 with SMTP id 3mr1333575lax.73.1431404830747; Mon, 11 May 2015 21:27:10 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id wu8si9535234lac.157.2015.05.11.21.27.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 21:27:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbqq2 with SMTP id qq2so108593808lbb.3 for ; Mon, 11 May 2015 21:27:10 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr10764984lad.56.1431404830611; Mon, 11 May 2015 21:27:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1855844lbb; Mon, 11 May 2015 21:27:10 -0700 (PDT) X-Received: by 10.140.102.180 with SMTP id w49mr17168185qge.82.1431404829481; Mon, 11 May 2015 21:27:09 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a79si15031377qkh.109.2015.05.11.21.27.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 21:27:09 -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; Received: from localhost ([::1]:40788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1me-0000s4-Ee for patch@linaro.org; Tue, 12 May 2015 00:27:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1kb-0005uO-DN for qemu-devel@nongnu.org; Tue, 12 May 2015 00:25:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys1kX-0006xo-CS for qemu-devel@nongnu.org; Tue, 12 May 2015 00:25:01 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:34956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1kX-0006xj-6q for qemu-devel@nongnu.org; Tue, 12 May 2015 00:24:57 -0400 Received: by pdbqd1 with SMTP id qd1so166864139pdb.2 for ; Mon, 11 May 2015 21:24:56 -0700 (PDT) X-Received: by 10.70.128.68 with SMTP id nm4mr25089410pdb.74.1431404696768; Mon, 11 May 2015 21:24:56 -0700 (PDT) Received: from localhost ([180.150.141.243]) by mx.google.com with ESMTPSA id oj10sm14623928pdb.38.2015.05.11.21.24.54 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 21:24:55 -0700 (PDT) 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 Date: Tue, 12 May 2015 12:24:15 +0800 Message-Id: <1431404656-7180-7-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1431404656-7180-1-git-send-email-shannon.zhao@linaro.org> References: <1431404656-7180-1-git-send-email-shannon.zhao@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.169 Cc: hangaohuai@huawei.com, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [PATCH 6/7] 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Shannon Zhao 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(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 3511903..354b020 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -432,6 +432,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; @@ -440,7 +452,7 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic) int irq = vbi->irqmap[VIRT_GPIO]; const char compat[] = "arm,pl061"; - 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); @@ -455,6 +467,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); }