From patchwork Fri Jul 29 21:56:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9252909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 21F40601C0 for ; Fri, 29 Jul 2016 22:03:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10C792836F for ; Fri, 29 Jul 2016 22:03:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03CCE28416; Fri, 29 Jul 2016 22:03:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7F4022836F for ; Fri, 29 Jul 2016 22:03:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bTFqb-0006aV-Ny; Fri, 29 Jul 2016 22:01:37 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bTFmP-0001Ks-PD for linux-arm-kernel@lists.infradead.org; Fri, 29 Jul 2016 21:57:20 +0000 Received: by mail-pa0-x22f.google.com with SMTP id pp5so34538384pac.3 for ; Fri, 29 Jul 2016 14:56:57 -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=LC0fdJPvTEuC6HI+8820qytOeAcFvhWp1AyCShqU/1NGOPcc94tVNcdBTrYQhydfBu KjtdLiJ2JF4X/f2JDWBEY6qc/z08lxlxRoVnW58Pq7S3fHXyijFuaLRKD+o0JnLQFGNh QsVglC1XMGFccd9z1fq/lUOCg3MUpCH8YewRw= 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=MB8v0fVZsbb4f5tmqJqC1mMo1QPkacjxJ5BlaGKI1Xziy9H2oUlDNWn22sCFPhHB6v SPqk/qvxwKOWLyjdTGUHtNQoNkqkfWbjTQnxIIN+SY3Tp0kc2ahXcrWR1MtjC62t4OUP x1IwrgnBVBM7IZAZgYooLWBv1TmrA3krLWvRRBuWr4QAaUZPCWTLsVhil7FKHKgb/JSZ dNTWhQvZBKoykYzUQiyHwqBNklkUJGMT/NaYE+ugahvqo6TqVZBGvGLZbS6/JVheX6Qv yc84UES9YTAuNwFQOYt2aaEbd8383HILwyfojXMVtg9Rj+NdXr4BFOZXK06a9YFs9fRz fD+A== X-Gm-Message-State: AEkoousL5zxZ0Rd5QhGeXXNf0O2EksFohjBO+ph3YLrCh6rMNwTMX94h3InMSWCN7/OK8UOv X-Received: by 10.66.236.9 with SMTP id uq9mr73693755pac.145.1469829416777; Fri, 29 Jul 2016 14:56:56 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 81sm27196601pfm.90.2016.07.29.14.56.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jul 2016 14:56:55 -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 Subject: [PATCH v2 11/14] drivers: firmware: psci: Allow OS Initiated suspend mode Date: Fri, 29 Jul 2016 15:56:22 -0600 Message-Id: <1469829385-11511-12-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469829385-11511-1-git-send-email-lina.iyer@linaro.org> References: <1469829385-11511-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160729_145718_000199_6FAC82B1 X-CRM114-Status: GOOD ( 14.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, andy.gross@linaro.org, Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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