From patchwork Tue Sep 1 12:12:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 248848 Delivered-To: patches@linaro.org Received: by 2002:a17:906:6447:0:0:0:0 with SMTP id l7csp3532889ejn; Tue, 1 Sep 2020 05:12:38 -0700 (PDT) X-Received: by 2002:a2e:7a04:: with SMTP id v4mr478548ljc.128.1598962357989; Tue, 01 Sep 2020 05:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598962357; cv=none; d=google.com; s=arc-20160816; b=v1MczA0zgrxU6DYB0ii83tBP6et9u87yb2vYG0Ho6CESNfAf8drgSx+zijXPTgI1+x 6WQqIFI0ObvWuvLAJlosuhCJi5Hfzz2PkZMmFt/fd5RFJ6E8utxUtub8t0hZzZ+8NgXz ZQzGFplDv1v65T3g0r3KnYhDPLgvXNCbdDyf3RLn7gqb5xoem0Hj+9XJE1mblUahzdTw oMVJk/iKNIxY0cHQ0y7cQhqLfx6JJaEy5vhYjihEZVuY4Hk7Bjk/VWftL7l64ZQ9ksOD PQ2xPZ+bKwITrFmSl+0H6UXfpEvGJABMAdBxktzMUhEjS+88PCzzKK3FySJ3yndJO9OT xhqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=KcabfpNUbz/94m2beE+mIi0sXiS5hWouLrlZQW6A0Y8=; b=IggLx5gARCR+ZXrJNggt2zOmDwHLdDavwRms2dAmE4gjTNgXLDrDWdLH4l/3Lff48V jJRusPNN3M5SI9fgGcq/s87tifd4KP1/pN/Nsep1Y6XLd2HjIyGAGdrDv2+vT+nmL/1b NKyUWjGcyNF/JTcqEeNFftugQT19EWrk8IHUC7t6WWOw0g+Lz6wfTcy5BONncG9xEjdT pekecPY+PDyWP2jRwSMsoQXA/DVQnksSDAbbNrZhTjHfa8MQlmFNT5DaDI2gjPg/BwfU TzD7gDEwHPMu078ZxTzAriK98voy1KNYzJsqQe5NYM/slp7jY7aFyCZoMi3enQzNGcFf z2Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tFGpbEeR; 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 g16sor518879ljj.43.2020.09.01.05.12.37 for (Google Transport Security); Tue, 01 Sep 2020 05:12:37 -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=tFGpbEeR; 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 :mime-version:content-transfer-encoding; bh=KcabfpNUbz/94m2beE+mIi0sXiS5hWouLrlZQW6A0Y8=; b=tFGpbEeRPaD/7SAstAub6FEw+WEvnVTGkhEeyL6nCREb3OqTlxa9EvlkGGqsAuSD0I oaav8ujwDhRA3r023cxpDaTEsOiA307jLZL1B/hmJshz5Sl+0/ZSWx6W1UHRpaT4eIPb +O6tEgWgTWdUmwNsGAyCtd4sGtsCKjOoVlRfrhXEXp0MfPp0GN1FSmiQI2z+ZuyYLXPD NP7dGfwJwvLsn6pzlvFtQNHojbjzO0NR7NFOU0QcjlDtii3Xy3I7ZTg4whZBzCrEyl9V Y3z42lmtIqv9N9lny3HUry9lBuqN1V9VCzWSsQE4my9nTlfPAMi6ZjqUqKMot5jkw5EB P7zg== 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:mime-version:content-transfer-encoding; bh=KcabfpNUbz/94m2beE+mIi0sXiS5hWouLrlZQW6A0Y8=; b=pSZTyga4QlPpw3zN62NFtceFTl1F2u8RoP51dvJPgaQe/QmPBCAixPC4y/2KxPewYR 4N4bziFz9d98umcG/bzzuGs2fjtIYytBtZoXaGzQTxOukTyFC5/LkvMyxTTGE2tZnasS 28cqn8r+C6R6k9AdJWnFLvZh1JKKrSeMXohOSqNP1LJ2BV0c7Rd55HIoRjKMO8sNwM2q jw3dq1KErP9iLWlhZsUKgiNjNGMLMWXxrF+wYVutEzQpnbMDOi1Y2ILpNLjVWF/9dVT7 fgEZ8RqQJlF5HIZmeJICK5RL0aCgwDFQgelboVzLMW3b+Z1OaYdHSw+0LBWfeV4gxX+M bFWw== X-Gm-Message-State: AOAM533SS/sqv/fmRK0lZ8i4/RpRiXTFmtIGnN6o27CI3XfnTAX6YnTZ DLrtyWXG8i99Ig/Bc/IVNaLise/k X-Google-Smtp-Source: ABdhPJwSUvot8vq5xYnb2+1JuH6uVSjJsEVhPQ3s0aSQUvNrkB6VE+cTn0rhlDdWzXfSBxy7OGrMqg== X-Received: by 2002:a2e:89d9:: with SMTP id c25mr465597ljk.46.1598962357475; Tue, 01 Sep 2020 05:12:37 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-180-79.NA.cust.bahnhof.se. [98.128.180.79]) by smtp.gmail.com with ESMTPSA id u6sm241193ljg.105.2020.09.01.05.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 05:12:36 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/2] firmware: psci: Extend psci_set_osi_mode() to allow reset to PC mode Date: Tue, 1 Sep 2020 14:12:25 +0200 Message-Id: <20200901121226.217568-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200901121226.217568-1-ulf.hansson@linaro.org> References: <20200901121226.217568-1-ulf.hansson@linaro.org> MIME-Version: 1.0 The current user (cpuidle-psci) of psci_set_osi_mode() only needs to enable the PSCI OSI mode. Although, as subsequent changes shows, there is a need to be able to reset back into the PSCI PC mode. Therefore, let's extend psci_set_osi_mode() to take a bool as in-parameter, to let the user indicate whether to enable OSI or to switch back to PC mode. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 2 +- drivers/firmware/psci/psci.c | 12 +++++++----- include/linux/psci.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) -- 2.25.1 Reviewed-by: Sudeep Holla diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index b6e9649ab0da..b6ab0415f450 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -278,7 +278,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) goto remove_pd; /* Try to enable OSI mode. */ - ret = psci_set_osi_mode(); + ret = psci_set_osi_mode(true); if (ret) { pr_warn("failed to enable OSI mode: %d\n", ret); psci_pd_remove_topology(np); diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 92013ecc2d9e..00af99b6f97c 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -151,12 +151,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 psci_set_osi_mode(bool enable) { + unsigned long suspend_mode; int err; - err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, - PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + suspend_mode = enable ? PSCI_1_0_SUSPEND_MODE_OSI : + PSCI_1_0_SUSPEND_MODE_PC; + + err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, suspend_mode, 0, 0); return psci_to_linux_errno(err); } @@ -546,8 +549,7 @@ static int __init psci_1_0_init(struct device_node *np) 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); + psci_set_osi_mode(false); } return 0; diff --git a/include/linux/psci.h b/include/linux/psci.h index 14ad9b9ebcd6..2a1bfb890e58 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -18,7 +18,7 @@ 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); +int psci_set_osi_mode(bool enable); bool psci_has_osi_support(void); struct psci_operations {