From patchwork Wed Jun 22 19:36:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 70690 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp75038qgy; Wed, 22 Jun 2016 12:38:15 -0700 (PDT) X-Received: by 10.98.61.90 with SMTP id k87mr36724687pfa.86.1466624274145; Wed, 22 Jun 2016 12:37:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k126si1404443pfc.180.2016.06.22.12.37.53; Wed, 22 Jun 2016 12:37:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752136AbcFVThx (ORCPT + 14 others); Wed, 22 Jun 2016 15:37:53 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:33732 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752015AbcFVThw (ORCPT ); Wed, 22 Jun 2016 15:37:52 -0400 Received: by mail-pf0-f181.google.com with SMTP id i123so20522982pfg.0 for ; Wed, 22 Jun 2016 12:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=anuWZ84nB8of07eRxaEnLi3jRI5uYVhQOGm2Ls7xRb0=; b=QhvAkD4LqK0ZcLFnNjszjkaiKVJM5r2fCRwiwhHp99Jcc0IIMUzE3YdfEWDsvWWYcc ed/pc1Kws4evm45EI/6QpEMxP1k7uAQy2ttPKlSLDt0qrs9SoE+MSBYTMzu8j/39ur/U wALJk9t3dAgS9A4T9l7s3MPX6ArVBAOo1oDvw= 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=anuWZ84nB8of07eRxaEnLi3jRI5uYVhQOGm2Ls7xRb0=; b=hVLjlWBaQQD6BYU2MNUuTv680kNlejMWw0hthqU05ShK+s6XlYl15o1jF4tbvwBSi9 gxtPtw8QbNu+ywnwaJsnytr2UCD4YFb68nmDIIfmqvdLFDEk+19SG/eaw9C7CBvi1ePt /PuVVEulE/vPATcO6CaNmNe25Q98KbuyxHYkgFCDyez2CViOxLEVOOT5rnCFRLEwFYeV kTlCqbLErxikmE97gHEMpdFrWanLOoSRGGBjE3zhUh6wyjlZSRlbIrEoZ3C1VIByHox4 OqdcymSLZZwld7QjKql9CF/HlXFPHgQ1xZGawr8B6qb2052ZsoTzTzYVq5s35ZSVndws impQ== X-Gm-Message-State: ALyK8tLOi3MCqMCRpMyvB0wbJjPuksSFCb4N9jmnpUfDvBlzmtep8PvfUVqP3xzC4BfoYOGp X-Received: by 10.98.68.84 with SMTP id r81mr36837606pfa.26.1466624271446; Wed, 22 Jun 2016 12:37:51 -0700 (PDT) Received: from ubuntu.localdomain ([172.56.9.151]) by smtp.gmail.com with ESMTPSA id t4sm1563368paw.32.2016.06.22.12.37.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Jun 2016 12:37:49 -0700 (PDT) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: geert@linux-m68k.org, k.kozlowski@samsung.com, andy.gross@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, lorenzo.pieralisi@arm.com, ahaslam@baylibre.com, mtitinger@baylibre.com, Lina Iyer , Mark Rutland Subject: [PATCH 11/14] drivers: firmware: psci: Allow OS Initiated suspend mode Date: Wed, 22 Jun 2016 13:36:46 -0600 Message-Id: <1466624209-27432-12-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466624209-27432-1-git-send-email-lina.iyer@linaro.org> References: <1466624209-27432-1-git-send-email-lina.iyer@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org PSCI firmware v1.0 onwards may support 2 different modes for CPU_SUSPEND. Platform coordinated mode is the default and every firmware should support it. OS Initiated mode is optional for the firmware to implement and allow Linux to make an better decision on the state of the CPU cluster heirarchy. With the kernel capable of deciding the state for CPU cluster and coherency domains, the OS Initiated mode may now be used by the kernel, provided the firmware supports it. SET_SUSPEND_MODE is a PSCI function available on v1.0 onwards and can be used to set the mode in the firmware. Cc: Lorenzo Pieralisi Cc: Mark Rutland Signed-off-by: Lina Iyer [Ulf: Rebased on 4.7 rc1] Signed-off-by: Ulf Hansson --- drivers/firmware/psci.c | 22 +++++++++++++++++++++- include/uapi/linux/psci.h | 5 +++++ 2 files changed, 26 insertions(+), 1 deletion(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 03e0458..3920aba 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -52,6 +52,7 @@ * require cooperation with a Trusted OS driver. */ static int resident_cpu = -1; +static bool psci_has_osi_pd; bool psci_tos_resident_on(int cpu) { @@ -563,10 +564,29 @@ out_put_node: return err; } +static int __init psci_1_0_init(struct device_node *np) +{ + int ret; + + ret = psci_0_2_init(np); + if (ret) + return ret; + + /* Check if PSCI OSI mode is available */ + ret = psci_features(psci_function_id[PSCI_FN_CPU_SUSPEND]); + if (ret & PSCI_1_0_OS_INITIATED) { + ret = psci_features(PSCI_1_0_FN_SET_SUSPEND_MODE); + if (!ret) + psci_has_osi_pd = true; + } + + return 0; +} + static const struct of_device_id psci_of_match[] __initconst = { { .compatible = "arm,psci", .data = psci_0_1_init}, { .compatible = "arm,psci-0.2", .data = psci_0_2_init}, - { .compatible = "arm,psci-1.0", .data = psci_0_2_init}, + { .compatible = "arm,psci-1.0", .data = psci_1_0_init}, {}, }; diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index 3d7a0fc..7dd778e 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -48,6 +48,7 @@ #define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10) #define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14) +#define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15) #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) @@ -93,6 +94,10 @@ #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK \ (0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT) +#define PSCI_1_0_OS_INITIATED BIT(0) +#define PSCI_1_0_SUSPEND_MODE_PC 0 +#define PSCI_1_0_SUSPEND_MODE_OSI 1 + /* PSCI return values (inclusive of all PSCI versions) */ #define PSCI_RET_SUCCESS 0 #define PSCI_RET_NOT_SUPPORTED -1