From patchwork Wed Dec 11 15:43:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 181267 Delivered-To: patches@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp701613ile; Wed, 11 Dec 2019 07:43:56 -0800 (PST) X-Received: by 2002:ac2:5216:: with SMTP id a22mr2667168lfl.18.1576079036288; Wed, 11 Dec 2019 07:43:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576079036; cv=none; d=google.com; s=arc-20160816; b=SfpzzYU3G5cvyKHnGaUUKRtJm2jqpxfQ5toKLWcx0nULilyru7PS2BE4z7WCQtRFpT bhk8T4YboGguXbI5MaUCHdo8t6EsWBlmfz9ML2slzNJ3RxWC/RtuEVyDYTj1SeDFlKD4 WqhuvoPaP2S4xka3b/BmP3yPrUqQwH168iwcYG76tmHRlowuH3dx5N2cuwf+4/1tcxLw aQRiQRCip/lv3co2B3bqM+tO6dH6pxG4t8/Pc6u2cXCKCjRUXb8E9+NJqhd5tRTbhwSA cprkP0E3FPCIlpXz95cHq4DlwPmZ9ApyiQZ4v9vMutyt7g0kp9wWV6a51uF+xrqj1Nl8 UueA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rTyFfehsHZ4NrOw6RaeXcNkMIHnoS8zNHPnwBdHCVW4=; b=GRAfw1Cdtws8PINSeVGGAaTzEo8C1pum1kivI4mIxdnefVG9iVPGQw5c3nYM5uZOxw o7nadSY1Ex7rl03Oi9XFFKrXyU05Ao7/8ztjKH9xlrm+Q3y0W+7Sw34K0oL8qN80gX52 LRPGqlIsS9pHKBrMVUnC09tAWca6PsCJG5FQfGHlNEP+hnBZ+AD6WCabXOqlxdyl9+uo Jy8Jbi9TD+ziz+A4nffdc9cmY7EMNHmyfowXYcO2C9UEisb/3Xxy3givKiDgo9Dbuz1o FPUwfktq9ASZvqeuHSPXxc7P0XkHR3bkImdt1xu+ol4Baec+RJC5VchijlTi8ohZ5m1T CNbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p5CrlKDt; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e11sor1681736ljk.48.2019.12.11.07.43.56 for (Google Transport Security); Wed, 11 Dec 2019 07:43:56 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p5CrlKDt; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=rTyFfehsHZ4NrOw6RaeXcNkMIHnoS8zNHPnwBdHCVW4=; b=p5CrlKDt3mkO5z+JaPTIxWFp1zu66so+e8FkAUrFkoA8GpcVCIRnRFbgMKzLoaHzlW HCv+6p5dqkThhU/6+gENScBRN2Ij182cE77XbziWSrktZRYLrulaWpBFRO4l1Fr/ITes XMrApT04irJm6q/vvKyw0CjHNrtvRz3jxX/ux2yCHAbH4j8a7VSuUN91m7v6KQevqpWh 5rwME1geedwsSxeTd32eFCIwPYPb4gns9rdDMoY7+L46ViaYCQfjBTlJ8omHwMW+vMl9 Yuel0R2OWPSUCRoJTIy9gsQF8SUuIS6aAYxo8lNs+lJ8yiQsqFiaDuKhBwv2/9lre3TK 1qUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rTyFfehsHZ4NrOw6RaeXcNkMIHnoS8zNHPnwBdHCVW4=; b=GJGCn1b58lm7OgFmxq2qWK1Th6XoHyNZdb7pBoJgDpELCMj7TZk8BYWBVqC/FdyYh0 RlwjYAmjEe9ZfiB1jg7PcfMCyDT0FT45MVMnaaNkq7jOedqD1rkGlcWmw2qljVHjg/9U BhfA0bwRLpSoU41BabTO8y5GLY4C5aFup6zgyyuHXDZzllpyW3fOe0OUpDfTLKGEAUMN hD/EluAzP0dIFnmGck2fNhAgGvQ9oQVl9aP+Kc8PjkKoNIC6J6gv5Jr+w+BiTNsGohLd dquW6KYPHJ4hrMQ0nE1C70j+Ea4PU7PBLFffv2i9LgkGhL1JvZx2QCY8p2A2EQRnTMsd Q5KA== X-Gm-Message-State: APjAAAXv6SA7D5ERmnxv3AnFceawbcqcMY9SXgHUo7YZws28GbEyn2eR jpyUV6qUBQmoTSyxJGtuP44oHK5k X-Google-Smtp-Source: APXvYqyuPt21/xnIK8FG2LgE0sYaNL0lj+qHjE9ysH3DMI2EmfAOl/ZGGEJEhFZhyeNFNpE1jzEoxQ== X-Received: by 2002:a2e:9a51:: with SMTP id k17mr2389984ljj.206.1576079035828; Wed, 11 Dec 2019 07:43:55 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id b14sm1389608lff.68.2019.12.11.07.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 07:43:55 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v4 03/14] firmware: psci: Export functions to manage the OSI mode Date: Wed, 11 Dec 2019 16:43:32 +0100 Message-Id: <20191211154343.29765-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211154343.29765-1-ulf.hansson@linaro.org> References: <20191211154343.29765-1-ulf.hansson@linaro.org> To allow subsequent changes to implement support for OSI mode through the cpuidle-psci driver, export the existing psci_has_osi_support(). Export also a new function, psci_set_osi_mode(), that allows its caller to enable the OS-initiated CPU-suspend mode in the PSCI FW. To deal with backwards compatibility for a kernel started through a kexec call, default to set the CPU-suspend mode to the Platform Coordinated mode during boot. Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v4: - None. --- drivers/firmware/psci/psci.c | 18 ++++++++++++++++-- include/linux/psci.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index b3b6c15e7b36..2937d44b5df4 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -97,7 +97,7 @@ static inline bool psci_has_ext_power_state(void) PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; } -static inline bool psci_has_osi_support(void) +bool psci_has_osi_support(void) { return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; } @@ -162,6 +162,15 @@ static u32 psci_get_version(void) return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); } +int psci_set_osi_mode(void) +{ + int err; + + err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + return psci_to_linux_errno(err); +} + static int psci_cpu_suspend(u32 state, unsigned long entry_point) { int err; @@ -544,9 +553,14 @@ static int __init psci_1_0_init(struct device_node *np) if (err) return err; - if (psci_has_osi_support()) + if (psci_has_osi_support()) { pr_info("OSI mode supported.\n"); + /* Default to PC mode. */ + invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_PC, 0, 0); + } + return 0; } diff --git a/include/linux/psci.h b/include/linux/psci.h index ebe0a881d13d..a67712b73b6c 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -18,6 +18,8 @@ bool psci_tos_resident_on(int cpu); int psci_cpu_suspend_enter(u32 state); bool psci_power_state_is_valid(u32 state); +int psci_set_osi_mode(void); +bool psci_has_osi_support(void); enum smccc_version { SMCCC_VERSION_1_0,