From patchwork Wed Nov 27 10:29:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 180282 Delivered-To: patches@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp5914350ilf; Wed, 27 Nov 2019 02:29:23 -0800 (PST) X-Received: by 2002:ac2:5dcc:: with SMTP id x12mr28009245lfq.163.1574850562884; Wed, 27 Nov 2019 02:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574850562; cv=none; d=google.com; s=arc-20160816; b=sJ3S4zpHwQSsfcP5PJKkDUUENF2nnraO6I51nXCYgH4x+yqELbCVVzej7EvCuXnLUE TjETC8HmaamR5HOZjEXzvc2/0YcubCNZghC6g1/nH2BJ9dmMUMQBmJWMmHv2l9witJjN nab5HurWG/Oi4CDJISigtbX3CNggq+M3MoYoxyLQGyn45mrMIOUCflz/DxvwrWc1pNiQ 6wk0ribsiFwDqLyG2NQUPLFinWuQJrciX70OKSK7/3BveH8AHgqVsvNMjwmjsyrNv4Sx t4R2M+mfvdiy4C1YsUelCT9NOIPgYf15Qo1eyk2iQix3CbWiGfKD6NLggN1CYlsQKeEo tgYA== 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=HTpoNIOk6QVHLkL5hD/y3Oh3mM1LWBHn64GrXkiktTA=; b=UDqA6uRaNfO6vzt7vzcmP2UZFIeuRproz1pMguhE1giXIXiT5yIUG5raBv/HrXCk05 0XZpzYG7MArZ+OS/Pbulscc59yjPWFxzIegAPZ2JgH3xGapwuV8CRVBaj91pIkyz+NUb zboLuPaZOkcaFhDcVCzoGao/Vn8JQ6spKz+6UPk2X9pcymUmN1KlOPRm5qM+zUqA9udB Akb/MfFaBzG/XHuVWepShaBx0t/IKQ/BvpI+9XMOP91OWgjN2aQ90v9jKGYafQH6A4kL Cj8BFn58qHLGVrkG8ZB1KMPJ1JUe5IqTwXIbnt2jUQsgh2e7Z5/gD4a6XK6KjnCJoSVq OCfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AyUxtvbc; 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 s3sor3783626lfo.24.2019.11.27.02.29.22 for (Google Transport Security); Wed, 27 Nov 2019 02:29:22 -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=AyUxtvbc; 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=HTpoNIOk6QVHLkL5hD/y3Oh3mM1LWBHn64GrXkiktTA=; b=AyUxtvbcofFh17U604la4Y1G39mBOWKGJg5dHe2xNMOmUM+72q8KFL+MRj9MXbX1cg 6TGADlEWGQG3IeUrcLndrG52Pb3xsYv/O4+js502Oo4yMQF+CBIfC6qa+QnnT5sGyBP2 TBoTGuANUAcOEiHVUgGaySfBTjOTRiGHqALcwOsEdIhI2aK06Qcf6q+7cHDOX/EEt6m9 408m8uS7ul/++ymsVs+h1d0qHZ4rTaqbZH/E6Jsnx4XhbHYMMq9nKxz5tLDMlr6qXfUf JfF4LZpBdnWLuZ9iIxL9MNTFOhBS4AwUO8u59tKLkSbAMxjg+Ymn4a6pqkfGJM72On3K FllA== 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=HTpoNIOk6QVHLkL5hD/y3Oh3mM1LWBHn64GrXkiktTA=; b=DdQP2lh/18wJg7llrLERZL99AlerDfZ9v+0oky5+VE76njwI1oj+rZxTWh+9SqjPwW Ifsk9+qVZzgDTHvmZyaDK6Lwxat12UkR3zwk1RPq9DfLZu+3b5PXHkGaC3gvXF25eo/+ 61egdrMdw73x05c2tFG2WrEsuyX2+NEE8sHyPzcgljeKp0hhXvpcUd6jZj7BZZBKKbsi NRXMgkNL6Yi5ZcA1bLR44/eOg15ytzzs32/KuE/MFpV0YDHx5VUz0MLnOvsmNIh9+U1f QccFWvhpoTufoNgg0gObafcriEQeXi+s2W0m0CwcO67/cCR9VY9SRYL7C/UbCJq6FJz8 QoNg== X-Gm-Message-State: APjAAAV8P/DdYHqQfpYD39Gh8X1DtjiWi26e/3RmlgNRqvW+1p1Wb6p1 G8hXVjiQ7W+k6Lk23Ar/bt3p/1ga X-Google-Smtp-Source: APXvYqwFJjqYM7aDnhXGNf9deKSkKCg+5HFB9vXDa+I/5Qtw5VKdR0KMezOx2PnWjK5Zoh8cIB0ztg== X-Received: by 2002:ac2:55a3:: with SMTP id y3mr17405016lfg.108.1574850562474; Wed, 27 Nov 2019 02:29:22 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t9sm6868260ljj.19.2019.11.27.02.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 02:29:21 -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 v3 03/13] firmware: psci: Export functions to manage the OSI mode Date: Wed, 27 Nov 2019 11:29:04 +0100 Message-Id: <20191127102914.18729-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191127102914.18729-1-ulf.hansson@linaro.org> References: <20191127102914.18729-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 v3: - 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,