From patchwork Wed Oct 16 17:02:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 21078 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0F3DB25B8B for ; Wed, 16 Oct 2013 17:03:51 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf1876955vbg.7 for ; Wed, 16 Oct 2013 10:03:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=WSjCr2LXfvd9tYOdkkC2Q5a/2cI78045BPWUv3VIHRA=; b=E1HoLbLLNf9t8dj74tifZdlCJqlWm5yz0JJ+yZPgyA1zs95ORduW0TTHClY112ByrD eJIf7k7S83xrQe8FXamFTiQZuZ6ECbHs873KnjyiSFoIDL9kLTiY3JMwXRAICToVdx7s bDCKSsoIojH9R03RG8IJzXXO2U1ewIiOBrljbwwyJc4oDFZ4UlHXny1RsEKqKwHcAk5E EwyXZbab0EEVsyunhRkraVUccjIij4vHtQjyJ8H1ewyWf3B3hgCve8XTy9c0f9PTk1K4 UdlLCNZxnaWYLg+hWsckjQZ9q21N7tZpIgWSHgAC7pl8KATBF86cYwekN9i7c7c+/CxX gAfg== X-Received: by 10.58.94.162 with SMTP id dd2mr1392071veb.21.1381943030883; Wed, 16 Oct 2013 10:03:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.41 with SMTP id 9ls644616qeb.15.gmail; Wed, 16 Oct 2013 10:03:50 -0700 (PDT) X-Received: by 10.58.54.69 with SMTP id h5mr1277801vep.25.1381943030765; Wed, 16 Oct 2013 10:03:50 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id gw1si24966663vcb.62.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Oct 2013 10:03:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id c14so542036vea.5 for ; Wed, 16 Oct 2013 10:03:50 -0700 (PDT) X-Gm-Message-State: ALoCoQmabZHYZkbMbP0cCq+9W4fue2ufwgtQAR39lsb+R/zpk+hC2+38vl/OU29jQXF6kZh56lac X-Received: by 10.58.136.231 with SMTP id qd7mr3070903veb.1.1381943030685; Wed, 16 Oct 2013 10:03:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp54604vcz; Wed, 16 Oct 2013 10:03:50 -0700 (PDT) X-Received: by 10.66.65.108 with SMTP id w12mr2865374pas.183.1381943029678; Wed, 16 Oct 2013 10:03:49 -0700 (PDT) Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by mx.google.com with ESMTPS id u9si17259933pbf.83.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Oct 2013 10:03:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.180 is neither permitted nor denied by best guess record for domain of anup.patel@linaro.org) client-ip=209.85.192.180; Received: by mail-pd0-f180.google.com with SMTP id y10so1211284pdj.25 for ; Wed, 16 Oct 2013 10:03:49 -0700 (PDT) X-Received: by 10.68.185.68 with SMTP id fa4mr4033047pbc.136.1381943029232; Wed, 16 Oct 2013 10:03:49 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id hz10sm92298689pbc.36.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Oct 2013 10:03:48 -0700 (PDT) From: Anup Patel To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Pranavkumar Sawargaonkar , Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon , Mark Rutland , Russell King , Anup Patel Subject: [RFC PATCH 5/5] ARM64: psci: Add support for system reboot and poweroff Date: Wed, 16 Oct 2013 22:32:34 +0530 Message-Id: <1381942954-22388-6-git-send-email-anup.patel@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1381942954-22388-1-git-send-email-anup.patel@linaro.org> References: <1381942954-22388-1-git-send-email-anup.patel@linaro.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.128.174 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We have PSCI SYSTEM_OFF and SYSTEM_RESET function call emulation available when running as Guest using KVM ARM64. This patch implements system reboot and poweroff using PSCI SYSTEM_OFF and SYSTEM_RESET. Signed-off-by: Anup Patel Signed-off-by: Pranavkumar Sawargaonkar --- arch/arm64/kernel/psci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index 14f73c4..a157e4d 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -17,9 +17,11 @@ #include #include +#include #include #include +#include #include struct psci_operations psci_ops; @@ -31,6 +33,8 @@ enum psci_function { PSCI_FN_CPU_ON, PSCI_FN_CPU_OFF, PSCI_FN_MIGRATE, + PSCI_FN_SYSTEM_OFF, + PSCI_FN_SYSTEM_RESET, PSCI_FN_MAX, }; @@ -151,6 +155,28 @@ static int psci_migrate(unsigned long cpuid) return psci_to_linux_errno(err); } +static void psci_power_off(void) +{ + int err; + u32 fn; + + fn = psci_function_id[PSCI_FN_SYSTEM_OFF]; + err = invoke_psci_fn(fn, 0, 0, 0); + if (err) + pr_warning("%s: failed\n", __func__); +} + +static void psci_restart(enum reboot_mode reboot_mode, const char *cmd) +{ + int err; + u32 fn; + + fn = psci_function_id[PSCI_FN_SYSTEM_RESET]; + err = invoke_psci_fn(fn, 0, 0, 0); + if (err) + pr_warning("%s: failed\n", __func__); +} + static const struct of_device_id psci_of_match[] __initconst = { { .compatible = "arm,psci", }, {}, @@ -205,6 +231,16 @@ int __init psci_init(void) psci_ops.migrate = psci_migrate; } + if (!of_property_read_u32(np, "system_off", &id)) { + psci_function_id[PSCI_FN_SYSTEM_OFF] = id; + pm_power_off = psci_power_off; + } + + if (!of_property_read_u32(np, "system_reset", &id)) { + psci_function_id[PSCI_FN_SYSTEM_RESET] = id; + arm_pm_restart = psci_restart; + } + out_put_node: of_node_put(np); return err;