From patchwork Sat Dec 31 06:16:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Yu-B13201 X-Patchwork-Id: 133732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3B4D6B6FC9 for ; Sat, 31 Dec 2011 18:06:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750938Ab1LaHGZ (ORCPT ); Sat, 31 Dec 2011 02:06:25 -0500 Received: from am1ehsobe006.messaging.microsoft.com ([213.199.154.209]:14683 "EHLO AM1EHSOBE006.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751073Ab1LaHGZ (ORCPT ); Sat, 31 Dec 2011 02:06:25 -0500 Received: from mail24-am1-R.bigfish.com (10.3.201.247) by AM1EHSOBE006.bigfish.com (10.3.204.26) with Microsoft SMTP Server id 14.1.225.23; Sat, 31 Dec 2011 07:06:24 +0000 Received: from mail24-am1 (localhost [127.0.0.1]) by mail24-am1-R.bigfish.com (Postfix) with ESMTP id D1EFF240310; Sat, 31 Dec 2011 07:06:23 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-SS: 0,13, Received: from mail24-am1 (localhost.localdomain [127.0.0.1]) by mail24-am1 (MessageSwitch) id 1325315159605047_9778; Sat, 31 Dec 2011 07:05:59 +0000 (UTC) Received: from AM1EHSMHS019.bigfish.com (unknown [10.3.201.244]) by mail24-am1.bigfish.com (Postfix) with ESMTP id 8DCD0200042; Sat, 31 Dec 2011 07:05:59 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS019.bigfish.com (10.3.206.22) with Microsoft SMTP Server (TLS) id 14.1.225.23; Sat, 31 Dec 2011 07:05:59 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.355.3; Sat, 31 Dec 2011 01:05:57 -0600 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id pBV75tm9022461; Sat, 31 Dec 2011 01:05:56 -0600 (CST) From: Liu Yu To: CC: , , Liu Yu Subject: [PATCH 2/2] KVM: PPC: epapr: Install ev_idle hcall for paravirt guest linux Date: Sat, 31 Dec 2011 14:16:16 +0800 Message-ID: <1325312176-17697-2-git-send-email-yu.liu@freescale.com> X-Mailer: git-send-email 1.6.4 In-Reply-To: <1325312176-17697-1-git-send-email-yu.liu@freescale.com> References: <1325312176-17697-1-git-send-email-yu.liu@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org If the guest hypervisor node contains "has-idle" property. Signed-off-by: Liu Yu --- arch/powerpc/kernel/kvm.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c index b06bdae..258f129 100644 --- a/arch/powerpc/kernel/kvm.c +++ b/arch/powerpc/kernel/kvm.c @@ -28,6 +28,7 @@ #include #include #include +#include #define KVM_MAGIC_PAGE (-4096L) #define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x) @@ -571,6 +572,30 @@ static __init void kvm_free_tmp(void) } } +static void kvm_hcall_ev_idle(void) +{ + ulong in[8]; + ulong out[8]; + + current_thread_info()->local_flags |= _TLF_NAPPING; + local_irq_enable(); + kvm_hypercall(in, out, HC_VENDOR_EPAPR | HC_EV_IDLE); +} + +static int kvm_para_ev_has_idle(void) +{ + struct device_node *hyper_node; + + hyper_node = of_find_node_by_path("/hypervisor"); + if (!hyper_node) + return 0; + + if (of_get_property(hyper_node, "has-idle", NULL)) + return 1; + + return 0; +} + static int __init kvm_guest_init(void) { if (!kvm_para_available()) @@ -587,6 +612,10 @@ static int __init kvm_guest_init(void) powersave_nap = 1; #endif + /* Install hcall EV_IDLE based power_save for guest kernel */ + if (kvm_para_ev_has_idle()) + ppc_md.power_save = kvm_hcall_ev_idle; + free_tmp: kvm_free_tmp();