From patchwork Tue Jul 7 12:58:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 234996 Delivered-To: patches@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp889211ilg; Tue, 7 Jul 2020 05:58:29 -0700 (PDT) X-Received: by 2002:a2e:b892:: with SMTP id r18mr31952778ljp.319.1594126709777; Tue, 07 Jul 2020 05:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594126709; cv=none; d=google.com; s=arc-20160816; b=Dsa9ONnLY9euGLWZG8ozvN1VkAAlCdfpfcQ/We5lgQgrRaAGbppAjNNxHnd38gKvpK /VpjDo70aHUSG9mtzai2moM0zk8tDxxifX84i0bQclAlBmnDqPnYtm5JqHR+gDyIpyOs jo2KEsEqBjcPDjOR2yso3mYk2247H+QQo3aa2g8Xo9eg3DCLibXS6nAA3Z2rQJrVjaw2 7ZW+KSmWUfDqI4xpeoDMGgP3R1x4M0rcTNZ0h1SYNOsambWfhMmNa9QC7YTH1VlanhsF oKsCxXaaO6bFVNTn/hjSYchgD3TROacBcnrhSVTd6EilMl22ZjjarQlbuZfHjdaTuWRJ Q69g== 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=CYhuF0zVY5i8kQEARQ65YbwasNE9FCG8p/MJLf/CDkM=; b=lNzb1SOe3umipd6vq87aRghleh+9bDg0ahdF+0r79okU50ZjFm/m6TY9sCbr4gs+dQ vQoSeUK8ZZL+BK0GNeanIN+PPnk9oScw4yq+ZzEg3G8NAKyb+/e5FS6rVgmy2U/ZwFi8 ld+ShHkyXSLDUfgr/8J0EAozqpL6tuGewOefoTJXceQ6ONHtBG2IfV7EpkEwAUn0SDMe m9a0Exkahi6Z5n/oGCBcU1Zs3URNPtBPmzxKQgBUhnCgx4vUYmNnxFVfEWIcdv6AMICQ mJGLK1zSEmBEtdD874PXtj+iHQYgOqfFqslZ+zDws+NWtChOy+3gUsGJf6X3PGgVXeXX PKuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XRKE1m42; 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 j8sor12166557ljo.65.2020.07.07.05.58.29 for (Google Transport Security); Tue, 07 Jul 2020 05:58:29 -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=XRKE1m42; 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=CYhuF0zVY5i8kQEARQ65YbwasNE9FCG8p/MJLf/CDkM=; b=XRKE1m42wozCzlMVoYCRUQuqeOC9av7JxEB0gwGu6watUzk7LuG9aJ/E6jKGbRvkPf lu+/bZqn3eoofwBRRy6Kb2FRSiGWl7+BlPuBspBCydJFUTN6aXo5mOUABE8Xb62Sqc0q PElQwHWDYxvQXUUwipKFhU6k/MdymHIo4xd16Srh65KoyBXb5a3p+vvoTCH1TyzitwkI 0lhh/qL0W69CpnF8Hv7TFmkHA7lf4oDTGeErnaSb5PVXiL9KebNEjbSpZIrK76ZwSlz0 E1O4cn1fnbBkVATsvl9XuczLYbOuF/jm0yuOMyykFxBPDxn6SOQfbqxnP7aIGeF6pbFR fYoQ== 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=CYhuF0zVY5i8kQEARQ65YbwasNE9FCG8p/MJLf/CDkM=; b=uASKw4oiQ2jTV4VCPR66dD5n8yGIGLeDMkt0pir9TMATew82ly6fhUzCNPzh2FSu3J SMk/ct/tGBGAeQmSYlw6mzvwR0ANEdf9FjNiU0dLQHM03rMNPjpZ31IOsjvbFqVS96S2 NxgMPQfvs3zGe4VS6MIhZgEcRgTJdamy2sxRSwh7qYp3S+toWGUzkiohkppDyJRbqw5N N4Aqvk4pr+UCZ10DkzMo2+KJLEQd+nWKis60i4HVg94WKn8Mv5L5b10SOkB7RGEYnokA aOfEWSct1PJbzyD2MZ7DPFtIQmN+VzhTD+VU15Yt/hgkLHtNyyyu0+AB3p0YxLsK/DL+ 9ZNw== X-Gm-Message-State: AOAM533KJfNBdjNx0J92WU7RzDzBDhN2dOWy4EcN3Worv4wyDf3eUZ7e /Ny901u58A++if3MSdYVGdeoZ3A4 X-Google-Smtp-Source: ABdhPJxbyT/FghZpCKz9xb09tQjwD2xzc8YuE3qmmbt66tP8td4H3OMfxh3JHoGmbJoHRbHEExwVww== X-Received: by 2002:a05:651c:2043:: with SMTP id t3mr30863147ljo.0.1594126709210; Tue, 07 Jul 2020 05:58:29 -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 11sm9554395lfz.78.2020.07.07.05.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 05:58:28 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Saravana Kannan , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/5] cpuidle: psci: Prevent domain idlestates until consumers are ready Date: Tue, 7 Jul 2020 14:58:04 +0200 Message-Id: <20200707125804.13030-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707125804.13030-1-ulf.hansson@linaro.org> References: <20200707125804.13030-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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. Acked-by: Saravana Kannan Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.20.1 Reviewed-by: Lukasz Luba 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, }, };