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: 11648549 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBC2014B7 for ; Tue, 7 Jul 2020 13:00:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B416620708 for ; Tue, 7 Jul 2020 13:00:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pzLqxvNl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XRKE1m42" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B416620708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g0i23rRtDKVhrE9jPEiJYHjKGMe/aGXWEm3fl6YVfHc=; b=pzLqxvNl3hzY/w26h4jDI8rj/ CxZ5mHEFuCF6TaQTIWYqn+9qfRyO0M+QCk0/c7A6phcu2K3w52HIoD/XMzNyHsdnA8mMaZo8u5ZL+ LDO/cQyrLYgP59awA8rnFFIIE1F+cHajhhRkus78wzjPBE0eKbtBPqPzG+k1Xnxpap/B5AUJUvdFv WWfIVHfs5QnDiC4DmoMvTe0htbFC+mE+QSmFXwZmhyWakf7GqlgpGuPVB+Xq9ZUC71Qq83RGpFaYU d7vryRiV1Q9MM8ivxQtzsn1aAEgEuh3h4YpvRA0kMwqj0055eTHzOC9IetyU6+RNuI4crP3E9FO0j TfJsx6Nsw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnBT-0006i2-1a; Tue, 07 Jul 2020 12:58:51 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsnB8-0006Z1-BN for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2020 12:58:33 +0000 Received: by mail-lj1-x244.google.com with SMTP id 9so49723534ljv.5 for ; Tue, 07 Jul 2020 05:58:30 -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=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=LzllkD3MCuiPLv3NusZKhBBbejhDfSF4NsD/eLOX6bHCCDaWtJIExkomWfOtvuLWkS IkpqWjW0/cSPwp3TgZBiw/Uhn/S8Q7rUk78HAJRksLFEWMy6Z8GTnXErIqp65cE0a4Re HWGC2MGCMZx4r++UQTooxsYCj/E8EfNQ7am9X1dG6+QoVWzeiMVDaBv7cCExfAnWTsE8 WD0S1ugNqtWpnRDttUkcXkG5/3q2FN0e5h7o8IAg7pTt9s21qe75VMkhx6w0GXSHXlVZ 8KAUKg7uTvm1XoWI1XU0+CZNhTkANNZVoLaQtfckvNhK6qmkL31XyW40Y124nEXXiFOz OVIA== X-Gm-Message-State: AOAM531kaAz40aSbg9mBCFt9rX7RspdIdb0GRUu4Ew9NJWy+qZ6lBlvc eNgDtHIANQPCC+k0sUTOSsCUVw== 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) 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200707_085830_465127_2D667617 X-CRM114-Status: GOOD ( 17.14 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Benjamin Gaignard , Saravana Kannan , Stephen Boyd , Daniel Lezcano , "Rafael J . Wysocki" , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, Lukasz Luba Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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. Acked-by: Saravana Kannan Signed-off-by: Ulf Hansson Reviewed-by: Lukasz Luba --- drivers/cpuidle/cpuidle-psci-domain.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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, }, };