From patchwork Mon Apr 21 13:00:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 28706 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2223820341 for ; Mon, 21 Apr 2014 13:08:59 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id lg15sf2590126vcb.7 for ; Mon, 21 Apr 2014 06:08:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=jY2Thsl2HhTduW31neMNZdnPy2KgcsnWZpysjGe+rDU=; b=HZnXmHhmpYPsVw4MObNUaDxNPojEPseKAu3VqxwgYttD5a1ZU4A5z2iP1tB+xHC+7h z8ov69g0+f46kqJfDwB+HayT+oqZ0r6DVyLh2rLISUR/A5Ags/clRptCdb/yBwF2UeuJ tQoV33A2z/zJCh4U00kwgzosfywV39umnTC2qIAyfE76KmaS+nVsjjaMLiyZZcVYKv6h AvTXAVpNjRQ9nAuG6cgpDnei+xMGAt1FGvfVWEBoxHKyWrXtRD+/rTB7yIiEnUqHsjCN 6VM5iA0XbFgXWJjiN+3gyS6EQBIEqCWlg8UIxDa4bW3xrKRS+Lp4iLAPoA0CznKgNOBW QmRw== X-Gm-Message-State: ALoCoQm/mEDKlsWFdvMM4GwLya0gjHzLyYkocPYQ5ZdqcqOVoEncZxSkPq5ZdDaOAQuGUkWa+83B X-Received: by 10.58.198.3 with SMTP id iy3mr19201659vec.39.1398085738915; Mon, 21 Apr 2014 06:08:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.225 with SMTP id f88ls957887qgf.65.gmail; Mon, 21 Apr 2014 06:08:58 -0700 (PDT) X-Received: by 10.220.106.84 with SMTP id w20mr30328017vco.18.1398085738826; Mon, 21 Apr 2014 06:08:58 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id cx1si4893476vdb.146.2014.04.21.06.08.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 06:08:58 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id ij19so928895vcb.24 for ; Mon, 21 Apr 2014 06:08:58 -0700 (PDT) X-Received: by 10.52.108.164 with SMTP id hl4mr2785763vdb.25.1398085738725; Mon, 21 Apr 2014 06:08:58 -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.220.221.72 with SMTP id ib8csp290158vcb; Mon, 21 Apr 2014 06:08:58 -0700 (PDT) X-Received: by 10.224.163.73 with SMTP id z9mr3526983qax.90.1398085737487; Mon, 21 Apr 2014 06:08:57 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 38si7929935qgu.80.2014.04.21.06.08.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Apr 2014 06:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WcDrk-0008BK-8L; Mon, 21 Apr 2014 13:02:32 +0000 Received: from mail-pb0-f41.google.com ([209.85.160.41]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WcDrU-0007gG-8X for linux-arm-kernel@lists.infradead.org; Mon, 21 Apr 2014 13:02:17 +0000 Received: by mail-pb0-f41.google.com with SMTP id jt11so3711673pbb.14 for ; Mon, 21 Apr 2014 06:01:55 -0700 (PDT) X-Received: by 10.68.233.99 with SMTP id tv3mr1779615pbc.163.1398085315729; Mon, 21 Apr 2014 06:01:55 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id iq10sm78049235pbc.14.2014.04.21.06.01.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 06:01:54 -0700 (PDT) From: Anup Patel To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v10 11/12] ARM/ARM64: KVM: Emulate PSCI v0.2 CPU_SUSPEND Date: Mon, 21 Apr 2014 18:30:05 +0530 Message-Id: <1398085206-30555-12-git-send-email-anup.patel@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1398085206-30555-1-git-send-email-anup.patel@linaro.org> References: <1398085206-30555-1-git-send-email-anup.patel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140421_060216_399212_0AEC26D6 X-CRM114-Status: GOOD ( 15.16 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.41 listed in list.dnswl.org] Cc: Rob Herring , linaro-kernel@lists.linaro.org, Anup Patel , kvm@vger.kernel.org, Marc Zyngier , patches@apm.com, Ashwin Chaugule , linux-arm-kernel@lists.infradead.org, Christoffer Dall , Pranavkumar Sawargaonkar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: anup.patel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 This patch adds emulation of PSCI v0.2 CPU_SUSPEND function call for KVM ARM/ARM64. This is a CPU-level function call which can suspend current CPU or current CPU cluster. We don't have VCPU clusters in KVM so we only suspend the current VCPU. The CPU_SUSPEND emulation is not tested much because currently there is no CPUIDLE driver in Linux kernel that uses PSCI CPU_SUSPEND. The PSCI CPU_SUSPEND implementation in ARM64 kernel was tested using a Simple CPUIDLE driver which is not published due to unstable DT-bindings for PSCI. (For more info, http://lwn.net/Articles/574950/) For simplicity, we implement CPU_SUSPEND emulation similar to WFI (Wait-for-interrupt) emulation and we also treat power-down request to be same as stand-by request. This is consistent with section 5.4.1 and section 5.4.2 of PSCI v0.2 specification. Signed-off-by: Anup Patel Signed-off-by: Pranavkumar Sawargaonkar Acked-by: Christoffer Dall Acked-by: Marc Zyngier --- arch/arm/kvm/psci.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index b582e99..757e506 100644 --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -37,6 +37,26 @@ static unsigned long psci_affinity_mask(unsigned long affinity_level) return 0; } +static unsigned long kvm_psci_vcpu_suspend(struct kvm_vcpu *vcpu) +{ + /* + * NOTE: For simplicity, we make VCPU suspend emulation to be + * same-as WFI (Wait-for-interrupt) emulation. + * + * This means for KVM the wakeup events are interrupts and + * this is consistent with intended use of StateID as described + * in section 5.4.1 of PSCI v0.2 specification (ARM DEN 0022A). + * + * Further, we also treat power-down request to be same as + * stand-by request as-per section 5.4.2 clause 3 of PSCI v0.2 + * specification (ARM DEN 0022A). This means all suspend states + * for KVM will preserve the register state. + */ + kvm_vcpu_block(vcpu); + + return PSCI_RET_SUCCESS; +} + static void kvm_psci_vcpu_off(struct kvm_vcpu *vcpu) { vcpu->arch.pause = true; @@ -183,6 +203,10 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) */ val = 2; break; + case PSCI_0_2_FN_CPU_SUSPEND: + case PSCI_0_2_FN64_CPU_SUSPEND: + val = kvm_psci_vcpu_suspend(vcpu); + break; case PSCI_0_2_FN_CPU_OFF: kvm_psci_vcpu_off(vcpu); val = PSCI_RET_SUCCESS; @@ -221,10 +245,6 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) val = PSCI_RET_INTERNAL_FAILURE; ret = 0; break; - case PSCI_0_2_FN_CPU_SUSPEND: - case PSCI_0_2_FN64_CPU_SUSPEND: - val = PSCI_RET_NOT_SUPPORTED; - break; default: return -EINVAL; }