From patchwork Tue Sep 1 14:28:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 248865 Delivered-To: patches@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4296041ilg; Tue, 1 Sep 2020 07:29:08 -0700 (PDT) X-Received: by 2002:a05:651c:1252:: with SMTP id h18mr763814ljh.319.1598970548704; Tue, 01 Sep 2020 07:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598970548; cv=none; d=google.com; s=arc-20160816; b=Z0MWozsb0yuxVVPLns1dxQR7RietjYgCBW+8f6RKNgW76MKM/xN2DbnbVjpKOcrR2V GxL9wVXW5/+Fm0dx8uiSAQ2ApvK2D0Tisbu8eHs52mmurY5ti5BYjpOBgeDIL2igY6n1 CnEg1LUz9vWFkuppexINL0+PeOgBHaPeQDDSvHlM1NEzC9kCA4qswhc0/qmRmHJwcyEb n/2rm+AhUM/EHvxzg3wNE3Z5KsaVJdwM9sVS9k8hD87mePvIxIm1pRRXwZKt7T5KOWz1 5/Z6jgWnghvQAnCnVzk/mIdH30wkLnfnGrewMCh8b5B7fHopM6TgIZHHKhSqkJWV+sGs rEmA== 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=LTilAKx6uhyrrDCSQGM9DUga+qKc7kxrp8ADcGsaoJo=; b=Y/YEYAHoJyC+OfOSYe+SX8Lb1gaCmhfMnnJbq8lBQdznslf8NvEUSP0LDxuxs1rkvD gNtMMR2GIZ3PhGSsVGj+A52zmy51hZjblkx3smGhsmp9RSxd16WerfddyaPbpBZJIPEV oYKRycmo4+VKdfNfOCqDHU/ixLDE+i9XKFpCRYffPRU2RZVw9uS6q/lzWKjoxsIIhbBZ +dEIqZAOAZrVArAtYLiA7hkJ0SWKgUDET7xiumYxz5eFIQwWIyaVjgG/1exymzt249uF o6d1gAxfIBXD8F5oLIstmfLsqrC+bQkxnexdTBI4AstHQJ595Y4TZ3mNCJ2VelQktQYo kwmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WDHB19AG; 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 z14sor764653ljj.4.2020.09.01.07.29.07 for (Google Transport Security); Tue, 01 Sep 2020 07:29:08 -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=WDHB19AG; 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=LTilAKx6uhyrrDCSQGM9DUga+qKc7kxrp8ADcGsaoJo=; b=WDHB19AGJeh66EVd4uru7yOjVuBjxtiQGn+tHoHz1rkFf4LoQ14AJI8XoVMOkqK1y+ tP4yxQX7bkHab4DxtpYpGgaL2Wj7b4sr7vFGIS875JY2yLLMr/+gOFObjVzJ8V5FQV0/ sqtEblQh1nYuMiWsgwjzDQOOf2C7f1lZKdda/US6QBJvCn3uCGsYuXIWdEi14gHxGdXW LOpgn9Zy3O3S3ZJTfxKNMlWHX2My2WRvMuIxhqAVheK1sA+i/kkAy3n9J+qAX4FE32Ml B4Et8qXF96r9/1hws7RdaLIcK8AL5WV3C9/OZroNUOaWitkbW4uLMmzRpSEQchNDGkPl 3ePg== 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=LTilAKx6uhyrrDCSQGM9DUga+qKc7kxrp8ADcGsaoJo=; b=RD/sVdqGxNJKtFq54WS/ZzI/swuwCxwnu/RSxYez/YyT6jFNnXeA/2PFKYdX0ooh38 e7QGY853DseKjM9+XAyIQsHR26e2vELy5Xf6iSBCbRfWmuX3i5ANL1FYRloY08SdIch1 fKpTB7AZS6X9cCTT5yBgh+Avq6/Cz3CgOUYwfVQg0MGFogmlygjqtam1fB8VPbOiOXGp YgCQidEXkVBcbEHad3gfZT6ITGUXw9jj0MnjPXxDXiMWm2G5eCd/QU3HTJUE3fDXa/4S TpRwSpth/KyQvZYlafKYWib4/lh0CBWynjyegFbEsWX6AjfHAM60ymTUWchHv0pB5nMF TXnA== X-Gm-Message-State: AOAM530vrQoXJJC1JuxQwpGHymbCtN4/LwwLeLlKnLy6SfFaOXGxbLU5 Xcl/LWZ7lt9aYDnUKrG56URrNfWpx6vTM5/gCqo= X-Google-Smtp-Source: ABdhPJyWQNEbbmEJWXfQWRgICw8JuT0MwqJbc8qwxQ+05+O9Zg1NEAZsOpYK5ll8S0N/aewyZdl5/w== X-Received: by 2002:a05:651c:505:: with SMTP id o5mr755471ljp.306.1598970547217; Tue, 01 Sep 2020 07:29:07 -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 r7sm318313lfn.84.2020.09.01.07.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 07:29:06 -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 v3 1/2] firmware: psci: Extend psci_set_osi_mode() to allow reset to PC mode Date: Tue, 1 Sep 2020 16:28:58 +0200 Message-Id: <20200901142859.224381-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200901142859.224381-1-ulf.hansson@linaro.org> References: <20200901142859.224381-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. Reviewed-by: Sudeep Holla Signed-off-by: Ulf Hansson --- Changes in v3: - Added reviewed-by tag. --- 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 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 {