From patchwork Thu Oct 10 11:39:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 175748 Delivered-To: patches@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2186119ocf; Thu, 10 Oct 2019 04:40:10 -0700 (PDT) X-Received: by 2002:a2e:7a18:: with SMTP id v24mr6235970ljc.75.1570707609939; Thu, 10 Oct 2019 04:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570707609; cv=none; d=google.com; s=arc-20160816; b=DASXXLbwZ951jO0f9Rlba+7lOOA4dS1AKIT1rbbt5Il74Co3J+dXHR3qWBwYsXuKC/ UuGy26yjYsPOTDYWlZFzZkuXBx4f+olvVJwnNSN6aU4qsGOdhSvxesuYebuO2uBmGemd 9/K95WawXOQn2jf8QgipE6nxMJH6dFxLailubjp0kCWpd+TGeeZKPGr31ah3wlmRFPGf xMi+/VKORpUDT9hc2I3WAQCc47kwJLaPxhgSmQPoC8Udrz5Q/HIErSsGyqfG5ZOTaUCZ NXHJzyXjH8OHtBElbSoIioIC3oqD4AeDOMe8Bt/TlZM7ZE3bnyuxY9Fu2lbHkVK5N61r Eoig== 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=v88JQU6vGgb8ri6uCDKoMwVq9Ia/h8wuaSmlcufCmYU=; b=VW1KofKDVbWOyirY9PH56Q/oea6qMdz43h75I8ht4nfgI4XvMVMmylhIZOzLhLgcD5 bBzF5k2TyIyyKsfBu6S/I8ZwAiRjV5dAy+2va1n+IOTBv9OKM+OyDAYkzI+rptvSykNl kVNx8aNoLt7/os4phbUC7RyYzQYvLlYU/0tAz/2ErMDjr4DBybqHwMX58g2nkw+ojGrz Hidg1inkumbacVtgRbiTNcJ1fImCl7DRDnxd2yX6abpT4KmotL1PBNIZMmp1C4pxF8Od fHINqGIT1VnUM/TdHNjjMbRwKxKFKcidniH+7n9cjh8nyBPtJBnAw5jAqD9dMIeoVEX8 TsjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jt87ZF+5; 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 b11sor3282933ljf.26.2019.10.10.04.40.09 for (Google Transport Security); Thu, 10 Oct 2019 04:40:09 -0700 (PDT) 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=jt87ZF+5; 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=v88JQU6vGgb8ri6uCDKoMwVq9Ia/h8wuaSmlcufCmYU=; b=jt87ZF+5/DHtUlBRJ5BstY8Vh6NbAEk5UF5D0u9HLT6presiea5l2x37EGTavAgCM2 H6B9YduMYxyPWcZQ4LDD0neKrxzMhr4DDLJH8oBvjt+ks9l3QnWRR5PubXNd4vzUEa3V fgBE1oE+WU63PB9MXoMoWyvRweYDa/KA+enceW5fZYXZHR2ZMUhprzxuPtzW7IdBbqZ/ kGJTTsnM0FhDhek77frZusCt3Srayy/AEUjcMSLtjZYglG2TVmus+yHd4KOQekmMb080 WIB28o60K0vFD9ulrOuL9R6XqTAkOFwHwsw7PULu7sOOm3lOtCBUtvXHBX7li4uUnl0I C04Q== 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=v88JQU6vGgb8ri6uCDKoMwVq9Ia/h8wuaSmlcufCmYU=; b=Z5JqeWiEe8cHAWBu4Nb9mL8v0Xn1kSsTUJwrxP5o193N1hGHJW8fypK5L+xBrISa6R //ucWKjnzwp8AQnenwOIrPGzTiZsrwH1LG0AMbOvRXOqLDQPsIHwv4mvnj64Ku11HyrI kZHPjH8itZ+uqOTh8Jn55bU4lxLbw33JtqYj2fgH8NIwvLWohyBoPZf09Y0v593fYB4L XpU9F7giCrCWYOIDrE3hVNyZ3Qu/IxV3E/HtVJIP/1Gqm6/dbkl6waieP52DxuRxUJcx RlK9f3EKnJJGKHU5gK6mEAqXaIp4qRDxw9dby4/E/Vm+W3td6qKIr6UE53Ubv7ad6WlG rOKQ== X-Gm-Message-State: APjAAAVcSEwuROteTWOIXqJoKEc4X4zoJ42mdNFrE+rouYY4RYHL2D4X f+rxxjhcA+UA++sH00W1EIiHus0B X-Google-Smtp-Source: APXvYqyCKks0JZZNViLz2Kmfcp+HjHLDr3UWaZTScndbtx975mvyfpGsTCg1ZMWYx/C2hWBuMccseA== X-Received: by 2002:a2e:9b8a:: with SMTP id z10mr6104674lji.80.1570707609559; Thu, 10 Oct 2019 04:40:09 -0700 (PDT) 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 p3sm1168937ljn.78.2019.10.10.04.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 04:40:08 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Daniel Lezcano , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Lina Iyer , linux-pm@vger.kernel.org Cc: Rob Herring , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 03/13] firmware: psci: Export functions to manage the OSI mode Date: Thu, 10 Oct 2019 13:39:27 +0200 Message-Id: <20191010113937.15962-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010113937.15962-1-ulf.hansson@linaro.org> References: <20191010113937.15962-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 --- 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 84f4ff351c62..76f3a991d4d7 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -89,7 +89,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; } @@ -154,6 +154,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; @@ -536,9 +545,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 e2bacc6fd2f2..f76b45341adf 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -17,6 +17,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 psci_conduit { PSCI_CONDUIT_NONE,