From patchwork Mon Jun 15 15:20:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 187948 Delivered-To: patch@linaro.org Received: by 2002:a54:30ca:0:0:0:0:0 with SMTP id e10csp2633608ecs; Mon, 15 Jun 2020 08:21:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlInDhC+usOJSTEmzd6QspDX2hfnIzRHPd9Ahg0kHTqNDlKy1YKVkrmg/EPv5NpKc94y8F X-Received: by 2002:a50:f052:: with SMTP id u18mr23749513edl.16.1592234475200; Mon, 15 Jun 2020 08:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592234475; cv=none; d=google.com; s=arc-20160816; b=hKtV5J/d/BFhUiB3O4r2lFCsWX/uMHXBbIcXIlISj0hO4cYp9MxUNVnVCB/fBFgriz vkGzexiSJAqahGEmVJPETroz2wvsAuBVfBHtrHGMmvFZupY/kzkVs8xS0srbIL6Xs8At FyIdbvXx5yZbrsC+CWUUdrYcm1v8EmPv4J4d6u9cyGxS29Sy/u/s+xaj6DRGTUkAa557 4qKKK2mOeGAbJxXJ7TKegK3inHxLhCfo3qxzPrgxIFYmbmuGdZmmlpAkDR8cYbqEsKeD 9BJ/fYFvXJqxkQXrj8AJvjJU4o4wBk+WIFoC0OrDS3ZcY+RWQ/4kfViywdAYK/VcXzTC dbpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vhNL1X1q5NcFvN2K8EIYcmkOuXak8nPvZVNGDqJ5u0c=; b=RJTFM8VQXjbAYuvbWUUV8b9S9GftN+qHX7GQ0ym9DOqRpXiCkLhoETLa1s3PTBqBzm DrngGxY3omDHV40MYED3dX4EiGii2MGSjo5CDnXXxsDO+et0niQVxDwNbFiNE6AHCrNZ 6YPWuyHPApcuE8hbGN5rQEHbyndfGCTDlA9vpTGV5w5QAiGuCj+vZcykePrb9bj/Ye8u M4HWObhvnR//VOeLtprv5AGiBnQy067PF29hGgy1WAt1tb3z/BLsKYCiqAG1/CG4tuYH 82OuSFbxpPJ37QjAakPDxrkqZ1RnIy7ADtRylIePSFjsAfa8upZs4vYrnQzUIvVj15ep vcdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OQjdZzsx; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si8811298ejw.501.2020.06.15.08.21.15; Mon, 15 Jun 2020 08:21:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OQjdZzsx; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729825AbgFOPVL (ORCPT + 10 others); Mon, 15 Jun 2020 11:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730313AbgFOPVK (ORCPT ); Mon, 15 Jun 2020 11:21:10 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC0EBC061A0E for ; Mon, 15 Jun 2020 08:21:09 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id c21so9792171lfb.3 for ; Mon, 15 Jun 2020 08:21:09 -0700 (PDT) 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=vhNL1X1q5NcFvN2K8EIYcmkOuXak8nPvZVNGDqJ5u0c=; b=OQjdZzsxvgkgfaKvQLiV9tJflG/RmsGfS4m0I+TNrGoWmxvcK+jbLmLbY/ExTtyYIY Vg0NakP5xmuAUYG5zcgPGVkCT9VZF1veYdWFoUD5fUgHkfVGaeNHKEJN25AAgTF8V8LQ PgzfhEgTzMOyHpSDNFa2qyo9TypmPVyqxH4getv5l1aDBZQ3JkpJ8cxAiWzEzKFR4E10 49TbJjXKfSkjjPLPMQcqrsoyB/Ois6R99dzAT+FzaGoCQbXGJ1dSBUfaQ4MCqVesCMIo 7R4yEVofwZbDenbjuj6hfTqi7qeLn8Gkf0aQ0W8V+NzNUTtNWCiLwAcU9+i8nBfBxN1i aXPA== 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=vhNL1X1q5NcFvN2K8EIYcmkOuXak8nPvZVNGDqJ5u0c=; b=nWuSrnIWdL9yIAEAcmREyMu6lgstllwP3QSqrKIyrnZFMA9XdGjVbzluS4ZCz8uh0t +fdfG1rA5oHpHV16sE//swsPTJP1UrRYMd5SgItfFoOGXvkVJy73RjP8QceTvu+PgRlp rOUW3K6fic/Ur9P/SFpSaWXvIBJtXm5TibQCzxbCyAu1lpABONWvVK0JNqtb88mILHPO auoZJD8sVQIe4lmC6jJ8uTpl+dq2Q3uuHLeX0iwkAewvRSwl3J1Io4nYsNQSDMY8eVpv tb62ZIj9RNoJyZdxVGvvjs5A182kySdLtgbVaw/0xEENOGywV/NKxSTJaMQhF1c8FHtr or+A== X-Gm-Message-State: AOAM533K0s92qKAsxI5LbZvNyiXhN7qgKLz/eq1y3KncIm9KGIEYRIR8 ZyXWbEJN0Ktkv4L5XPbL4fi7SA== X-Received: by 2002:a19:a44:: with SMTP id 65mr2240250lfk.69.1592234468265; Mon, 15 Jun 2020 08:21:08 -0700 (PDT) Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id r13sm507045lfp.80.2020.06.15.08.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 08:21:07 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Saravana Kannan , 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 5/5] cpuidle: psci: Prevent domain idlestates until consumers are ready Date: Mon, 15 Jun 2020 17:20:54 +0200 Message-Id: <20200615152054.6819-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200615152054.6819-1-ulf.hansson@linaro.org> References: <20200615152054.6819-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Depending on the SoC/platform, additional devices may be part of the PSCI PM domain topology. This is the case with 'qcom,rpmh-rsc' device, for example, even if this is not yet visible in the corresponding DTS-files. Without going into too much details, a device like the 'qcom,rpmh-rsc' may have HW constraints that needs to be obeyed to, before a domain idlestate can be picked. Therefore, let's implement the ->sync_state() callback to receive a notification when all consumers of the PSCI PM domain providers have been attached/probed to it. In this way, we can make sure all constraints from all relevant devices, are taken into account before allowing a domain idlestate to be picked. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.20.1 Acked-by: Saravana Kannan diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index bf527d2bb4b6..b6e9649ab0da 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -27,6 +27,7 @@ struct psci_pd_provider { }; static LIST_HEAD(psci_pd_providers); +static bool psci_pd_allow_domain_state; static int psci_pd_power_off(struct generic_pm_domain *pd) { @@ -36,6 +37,9 @@ static int psci_pd_power_off(struct generic_pm_domain *pd) if (!state->data) return 0; + if (!psci_pd_allow_domain_state) + return -EBUSY; + /* OSI mode is enabled, set the corresponding domain state. */ pd_state = state->data; psci_set_domain_state(*pd_state); @@ -222,6 +226,15 @@ static void psci_pd_remove_topology(struct device_node *np) psci_pd_init_topology(np, false); } +static void psci_cpuidle_domain_sync_state(struct device *dev) +{ + /* + * All devices have now been attached/probed to the PM domain topology, + * hence it's fine to allow domain states to be picked. + */ + psci_pd_allow_domain_state = true; +} + static const struct of_device_id psci_of_match[] = { { .compatible = "arm,psci-1.0" }, {} @@ -289,6 +302,7 @@ static struct platform_driver psci_cpuidle_domain_driver = { .driver = { .name = "psci-cpuidle-domain", .of_match_table = psci_of_match, + .sync_state = psci_cpuidle_domain_sync_state, }, };