From patchwork Mon May 11 13:33:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 186449 Delivered-To: patches@linaro.org Received: by 2002:a92:8d81:0:0:0:0:0 with SMTP id w1csp2124603ill; Mon, 11 May 2020 06:33:51 -0700 (PDT) X-Received: by 2002:a2e:a169:: with SMTP id u9mr10486884ljl.144.1589204031532; Mon, 11 May 2020 06:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589204031; cv=none; d=google.com; s=arc-20160816; b=gGUNGoN0IY5MnD30PMbS4C8t7nwGZSvknD9smKCY/1RzpRXQkT6Jm04U6bWUSQ07L8 QOUJoWndeUjVEuNfoP0IMCsAOwUicono490I2mtEJPrgYBrVuaLN6QpWun/yhkyV1ns7 iTnaSPdkONLzDPB07e2zg5+YKF+oBDX0Qb41NCwrpjQnG8ads2ohP6U4ZPMDIcOAsasO yMr20cd6EUM2r4/RKC2hDoo6Ed7wGT8rIxacxKasOUMlc2bp4yMej37b6aqNbl8RGmPB KthRJZf+TXybsdHYT2W9U/CJlfegjp2hQ3Fr/lPoiR1yD5G8lAPFuG5HgGYaEGUdnyH9 +AEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=pD+rR7D06+zskc19Z/Pv5SiqhDDKHoIwqYjQ0Wayknc=; b=XQ4f7wT0z7W7GC2vrCg6TqF8MY5K/0Y/BmW7RSu+VVUHreWfxxlZVZjzn5pVrPrXec 1Sud5DUOocZshHp1bvZ6GueP6It0JvR0ygxr4sCnlLLvJBIvy3J9yb8TldcxU+AY2akn npmqtwScYVQUZ2iVtlhF6cRhVoG5MqW5OPrTl7hntNAQXZAGt4p+N48ZvdosaUiyOJl4 TofOp99QNW+VcUfDPfDBqCn1VDochDseXnaxdba8HZwj83dEWI1lg2f1Dx1oEKz84xRL rTmqUkMKddTTUxfopNLevmtY+w+Hs5HTvBfm5XfTUYrm1ohr9q/qXpuy4dNDrGL5uSLv 50hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wGeFNaCN; 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 b201sor3290390lfg.35.2020.05.11.06.33.51 for (Google Transport Security); Mon, 11 May 2020 06:33:51 -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=wGeFNaCN; 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:mime-version :content-transfer-encoding; bh=pD+rR7D06+zskc19Z/Pv5SiqhDDKHoIwqYjQ0Wayknc=; b=wGeFNaCNE319dM+/gmrxsh9u5N2NlvakeOBIH0GiNZHjeBYijjs7Fd8B8OWF55HT+L AW9YhQJa4Qz8QPC6Wi3TF6kh1feJTCQn9YzYxswaK+lft2JhtoRU52Qe6i0/K9w7n+1b s3aFK8kia0sbUDBCQEI9QJVZg4BEJ7prPmHhkP2DJPiNHsdDUqOLx2woVgzOL115FEt0 L5NDZccGHzfLOXWFA3Ws0GP7mTKvN6CBQWe1Y2bkdTHaPHvXeR6T8uUZoAzPD6omlfWu X6jfkySYRkYV3mPYcn57v+bpbAJJNeLvoQuO/SZr9JhQWowl+JAnGzI29UIcO9FTgkw6 12gg== 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:mime-version :content-transfer-encoding; bh=pD+rR7D06+zskc19Z/Pv5SiqhDDKHoIwqYjQ0Wayknc=; b=bClY8z697yHFGrBLCw1xkeUECu20iK/OV5wbZRwkjpXoyPYOlurq+8+EW5yYB0Sgaw QYVMJeX2YYM76skG54Txy3e7YhNg60TFz9gqw90iJKVbd1dhX9PpnSiukxh2prLZmvGS Bq0LCB7NlBrYnexgdpLnRG0GwPEmFGmJLnsWiZPDenint/RHEPhRig2PhkGXW7wuOg6G X6i2c9q23EBwDDst7f5S2hOZCWdD4WECqnnWizapMxzBPoXk2eQinVTaEoJiB+18zw4+ oZg9IVknjMWFSnDnT5YfXUZtSwVtWjN4Ulmx7CymwWJFDAh7fjPX+1mXrR8xfObgMugu u+JA== X-Gm-Message-State: AOAM531Tg4osx8vh0oC62za46cFN0o/z9/1gxVuKAP2H+McZ+/Wrproh Fp2GTRCj0uepirdkvcHWebs0TSts X-Google-Smtp-Source: ABdhPJziSi1YV5QdlXPx0bt8kOzmpPToYnuHC1CNLcZpxF6+CeliIUVJusEuJofyX9lU33BAJ2K3QQ== X-Received: by 2002:ac2:555b:: with SMTP id l27mr11295444lfk.170.1589204031084; Mon, 11 May 2020 06:33:51 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id q2sm5647426lfc.7.2020.05.11.06.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2020 06:33:49 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH] cpuidle: psci: Fixup execution order when entering a domain idle state Date: Mon, 11 May 2020 15:33:46 +0200 Message-Id: <20200511133346.21706-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Moving forward, platforms are going to need to execute specific "last-man" operations before a domain idle state can be entered. In one way or the other, these operations needs to be triggered while walking the hierarchical topology via runtime PM and genpd, as it's at that point the last-man becomes known. Moreover, executing last-man operations needs to be done after the CPU PM notifications are sent through cpu_pm_enter(), as otherwise it's likely that some notifications would fail. Therefore, let's re-order the sequence in psci_enter_domain_idle_state(), so cpu_pm_enter() gets called prior pm_runtime_put_sync(). Fixes: ce85aef570df ("cpuidle: psci: Manage runtime PM in the idle path") Reported-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index bae9140a65a5..d0fb585073c6 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -58,6 +58,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev, u32 state; int ret; + ret = cpu_pm_enter(); + if (ret) + return -1; + /* Do runtime PM to manage a hierarchical CPU toplogy. */ pm_runtime_put_sync_suspend(pd_dev); @@ -65,10 +69,12 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev, if (!state) state = states[idx]; - ret = psci_enter_state(idx, state); + ret = psci_cpu_suspend_enter(state) ? -1 : idx; pm_runtime_get_sync(pd_dev); + cpu_pm_exit(); + /* Clear the domain state to start fresh when back from idle. */ psci_set_domain_state(0); return ret;